From 40bc9e65dab533c648985c0c93ab9ecaf5c9d94f Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Fri, 4 Dec 2015 20:20:01 -0800 Subject: [PATCH] Remove outdated radial_reaction.dart We now draw radial reactions using Material. --- packages/flutter/lib/material.dart | 1 - .../lib/src/material/radial_reaction.dart | 91 ------------------- 2 files changed, 92 deletions(-) delete mode 100644 packages/flutter/lib/src/material/radial_reaction.dart diff --git a/packages/flutter/lib/material.dart b/packages/flutter/lib/material.dart index cba0219fa4..4300bdc8ca 100644 --- a/packages/flutter/lib/material.dart +++ b/packages/flutter/lib/material.dart @@ -39,7 +39,6 @@ export 'src/material/page.dart'; export 'src/material/popup_menu.dart'; export 'src/material/popup_menu_item.dart'; export 'src/material/progress_indicator.dart'; -export 'src/material/radial_reaction.dart'; export 'src/material/radio.dart'; export 'src/material/raised_button.dart'; export 'src/material/scaffold.dart'; diff --git a/packages/flutter/lib/src/material/radial_reaction.dart b/packages/flutter/lib/src/material/radial_reaction.dart deleted file mode 100644 index 7d550b6885..0000000000 --- a/packages/flutter/lib/src/material/radial_reaction.dart +++ /dev/null @@ -1,91 +0,0 @@ -// 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 'dart:async'; - -import 'package:flutter/animation.dart'; -import 'package:flutter/painting.dart'; - -const Duration _kShowDuration = const Duration(milliseconds: 300); -const Duration _kHideDuration = const Duration(milliseconds: 200); -const Color _kOuterColor = const Color(0xFFFFFFFF); -const Color _kInnerColor = const Color(0xFFFFFFFF); -const double _kMaxOpacity = 0.2; - -int _roundOpacity(double opacity) { - return (255 * opacity).round(); -} - -/// A material design radial ink reaction -/// -/// See [https://www.google.com/design/spec/animation/responsive-interaction.html#responsive-interaction-radial-action] -class RadialReaction { - RadialReaction({ - this.center, - this.radius, - Point startPosition - }) { - _outerOpacity = new AnimatedValue(0.0, end: _kMaxOpacity, curve: Curves.easeOut); - _innerCenter = new AnimatedValue(startPosition, end: center, curve: Curves.easeOut); - _innerRadius = new AnimatedValue(0.0, end: radius, curve: Curves.easeOut); - _showPerformance = new Performance(duration: _kShowDuration) - ..addListener(() { - _showPerformance.updateVariable(_outerOpacity); - _showPerformance.updateVariable(_innerCenter); - _showPerformance.updateVariable(_innerRadius); - }); - _fade = new ValuePerformance( - variable: new AnimatedValue(1.0, end: 0.0, curve: Curves.easeIn), - duration: _kHideDuration - ); - } - - /// The center of the circle in which the reaction occurs - final Point center; - - /// The radius of the circle in which the reaction occurs - final double radius; - - Performance _showPerformance; - AnimatedValue _outerOpacity; - AnimatedValue _innerCenter; - AnimatedValue _innerRadius; - - Future _showComplete; - - ValuePerformance _fade; - - /// Show the reaction - /// - /// Returns a future that resolves when the reaction is completely revealed. - Future show() { - return _showComplete = _showPerformance.forward(); - } - - /// Hide the reaction - /// - /// Returns a future that resolves when the reaction is completely hidden. - Future hide() async { - await _showComplete; - await _fade.forward(); - } - - /// Call listener whenever the visual appearance of the reaction changes - void addListener(Function listener) { - _showPerformance.addListener(listener); - _fade.addListener(listener); - } - - final Paint _outerPaint = new Paint(); - final Paint _innerPaint = new Paint(); - - /// Paint the reaction onto the given canvas at the given offset - void paint(Canvas canvas, Offset offset) { - _outerPaint.color = _kOuterColor.withAlpha(_roundOpacity(_outerOpacity.value * _fade.value)); - canvas.drawCircle(center + offset, radius, _outerPaint); - - _innerPaint.color = _kInnerColor.withAlpha(_roundOpacity(_kMaxOpacity * _fade.value)); - canvas.drawCircle(_innerCenter.value + offset, _innerRadius.value, _innerPaint); - } -}