<commit_before>// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import '../animation/animated_value.dart';
import '../animation/curves.dart';
import '../animation/generators.dart';
import '../fn.dart';
import '../theme/view-configuration.dart' as config;
import 'dart:async';
import 'dart:math' as math;
import 'dart:sky' as sky;

const double _kSplashConfirmedDuration = 350.0;
const double _kSplashUnconfirmedDuration = config.kDefaultLongPressTimeout;
const double _kSplashAbortDuration = 100.0;
const double _kSplashInitialDelay = 0.0; // we could delay initially in case the user scrolls

double _getSplashTargetSize(sky.ClientRect rect, double x, double y) {
  return 2.0 * math.max(math.max(x - rect.left, rect.right - x),
                        math.max(y - rect.top, rect.bottom - y));
}

class SplashController {
  final int pointer;
  Stream<String> get onStyleChanged => _styleStream;

  final AnimatedValue _size = new AnimatedValue(0.0);
  double _offsetX;
  double _offsetY;
  double _lastSize = 0.0;
  bool _growing = true;
  double _targetSize;
  Stream<String> _styleStream;

  void start() {
    _size.animateTo(_targetSize, _kSplashUnconfirmedDuration, curve: easeOut, initialDelay: _kSplashInitialDelay);
  }

  void confirm() {
    double fractionRemaining = (_targetSize - _size.value) / _targetSize;
    double duration = fractionRemaining * _kSplashConfirmedDuration;
    if (duration <= 0.0)
      return;
    _size.animateTo(_targetSize, duration, curve: easeOut);
  }

  void abort() {
    _growing = false;
    double durationRemaining = _size.remainingTime;
    if (durationRemaining <= _kSplashAbortDuration)
      return;
    _size.animateTo(_targetSize, _kSplashAbortDuration, curve: easeOut);
  }

  void cancel() {
    _size.stop();
  }

  SplashController(sky.ClientRect rect, double x, double y,
                   { this.pointer, Function onDone })
      : _offsetX = x - rect.left,
        _offsetY = y - rect.top,
        _targetSize = _getSplashTargetSize(rect, x, y) {

    _styleStream = _size.onValueChanged.map((p) {
      if (p == _targetSize) {
        onDone();
      }
      double size;
      if (_growing) {
        sise = p;
        _lastSize = p;
      } else {
        size = _lastSize;<commit_msg>[Effen] Typo in splash code: s/sise/size/ TBR=eseidel<commit_after>// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import '../animation/animated_value.dart';
import '../animation/curves.dart';
import '../animation/generators.dart';
import '../fn.dart';
import '../theme/view-configuration.dart' as config;
import 'dart:async';
import 'dart:math' as math;
import 'dart:sky' as sky;

const double _kSplashConfirmedDuration = 350.0;
const double _kSplashUnconfirmedDuration = config.kDefaultLongPressTimeout;
const double _kSplashAbortDuration = 100.0;
const double _kSplashInitialDelay = 0.0; // we could delay initially in case the user scrolls

double _getSplashTargetSize(sky.ClientRect rect, double x, double y) {
  return 2.0 * math.max(math.max(x - rect.left, rect.right - x),
                        math.max(y - rect.top, rect.bottom - y));
}

class SplashController {
  final int pointer;
  Stream<String> get onStyleChanged => _styleStream;

  final AnimatedValue _size = new AnimatedValue(0.0);
  double _offsetX;
  double _offsetY;
  double _lastSize = 0.0;
  bool _growing = true;
  double _targetSize;
  Stream<String> _styleStream;

  void start() {
    _size.animateTo(_targetSize, _kSplashUnconfirmedDuration, curve: easeOut, initialDelay: _kSplashInitialDelay);
  }

  void confirm() {
    double fractionRemaining = (_targetSize - _size.value) / _targetSize;
    double duration = fractionRemaining * _kSplashConfirmedDuration;
    if (duration <= 0.0)
      return;
    _size.animateTo(_targetSize, duration, curve: easeOut);
  }

  void abort() {
    _growing = false;
    double durationRemaining = _size.remainingTime;
    if (durationRemaining <= _kSplashAbortDuration)
      return;
    _size.animateTo(_targetSize, _kSplashAbortDuration, curve: easeOut);
  }

  void cancel() {
    _size.stop();
  }

  SplashController(sky.ClientRect rect, double x, double y,
                   { this.pointer, Function onDone })
      : _offsetX = x - rect.left,
        _offsetY = y - rect.top,
        _targetSize = _getSplashTargetSize(rect, x, y) {

    _styleStream = _size.onValueChanged.map((p) {
      if (p == _targetSize) {
        onDone();
      }
      double size;
      if (_growing) {
        size = p;
        _lastSize = p;
      } else {
        size = _lastSize;
{'fraction_non_alphanumeric': 0.10774058577405858, 'fraction_numerical': 0.009205020920502092, 'mean_word_length': 3.2234982332155475, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3420177', 'n_tokens_mistral': 1590, 'n_tokens_neox': 1496, 'n_words': 407}