Unverified Commit c2e91ad4 authored by Jason C.H's avatar Jason C.H Committed by GitHub

Remove deprecated activity indicator (#66020)

parent e0afee5b
...@@ -18,19 +18,6 @@ const Color _kActiveTickColor = CupertinoDynamicColor.withBrightness( ...@@ -18,19 +18,6 @@ const Color _kActiveTickColor = CupertinoDynamicColor.withBrightness(
darkColor: Color(0xFFEBEBF5), darkColor: Color(0xFFEBEBF5),
); );
/// Define the iOS version style of [CupertinoActivityIndicator].
enum CupertinoActivityIndicatorIOSVersionStyle {
/// The style that is used in iOS13 and earlier (12 points).
@Deprecated(
'Use iOS14 instead. '
'This feature was deprecated after v1.21.0-1.0.pre.'
)
iOS13,
/// The style that was introduced in iOS14 (8 points).
iOS14,
}
/// An iOS-style activity indicator that spins clockwise. /// An iOS-style activity indicator that spins clockwise.
/// ///
/// {@youtube 560 315 https://www.youtube.com/watch?v=AENVH-ZqKDQ} /// {@youtube 560 315 https://www.youtube.com/watch?v=AENVH-ZqKDQ}
...@@ -44,11 +31,6 @@ class CupertinoActivityIndicator extends StatefulWidget { ...@@ -44,11 +31,6 @@ class CupertinoActivityIndicator extends StatefulWidget {
Key key, Key key,
this.animating = true, this.animating = true,
this.radius = _kDefaultIndicatorRadius, this.radius = _kDefaultIndicatorRadius,
@Deprecated(
'Leave this field default to use latest style. '
'This feature was deprecated after v1.21.0-1.0.pre.'
)
this.iOSVersionStyle = CupertinoActivityIndicatorIOSVersionStyle.iOS14,
}) : assert(animating != null), }) : assert(animating != null),
assert(radius != null), assert(radius != null),
assert(radius > 0.0), assert(radius > 0.0),
...@@ -65,11 +47,6 @@ class CupertinoActivityIndicator extends StatefulWidget { ...@@ -65,11 +47,6 @@ class CupertinoActivityIndicator extends StatefulWidget {
Key key, Key key,
this.radius = _kDefaultIndicatorRadius, this.radius = _kDefaultIndicatorRadius,
this.progress = 1.0, this.progress = 1.0,
@Deprecated(
'Leave this field default to use latest style. '
'This feature was deprecated after v1.21.0-1.0.pre.'
)
this.iOSVersionStyle = CupertinoActivityIndicatorIOSVersionStyle.iOS14,
}) : assert(radius != null), }) : assert(radius != null),
assert(radius > 0.0), assert(radius > 0.0),
assert(progress != null), assert(progress != null),
...@@ -96,12 +73,6 @@ class CupertinoActivityIndicator extends StatefulWidget { ...@@ -96,12 +73,6 @@ class CupertinoActivityIndicator extends StatefulWidget {
/// Defaults to 1.0. Must be between 0.0 and 1.0 inclusive, and cannot be null. /// Defaults to 1.0. Must be between 0.0 and 1.0 inclusive, and cannot be null.
final double progress; final double progress;
/// The iOS version style of activity indicator.
///
/// Defaults to [CupertinoActivityIndicatorIOSVersionStyle.iOS14].
// TODO(ctrysbita): Deprecate after official release, https://github.com/flutter/flutter/issues/62521
final CupertinoActivityIndicatorIOSVersionStyle iOSVersionStyle;
@override @override
_CupertinoActivityIndicatorState createState() => _CupertinoActivityIndicatorState createState() =>
_CupertinoActivityIndicatorState(); _CupertinoActivityIndicatorState();
...@@ -153,7 +124,6 @@ class _CupertinoActivityIndicatorState extends State<CupertinoActivityIndicator> ...@@ -153,7 +124,6 @@ class _CupertinoActivityIndicatorState extends State<CupertinoActivityIndicator>
CupertinoDynamicColor.resolve(_kActiveTickColor, context), CupertinoDynamicColor.resolve(_kActiveTickColor, context),
radius: widget.radius, radius: widget.radius,
progress: widget.progress, progress: widget.progress,
iOSVersionStyle: widget.iOSVersionStyle,
), ),
), ),
); );
...@@ -164,37 +134,16 @@ const double _kTwoPI = math.pi * 2.0; ...@@ -164,37 +134,16 @@ const double _kTwoPI = math.pi * 2.0;
/// Alpha values extracted from the native component (for both dark and light mode) to /// Alpha values extracted from the native component (for both dark and light mode) to
/// draw the spinning ticks. /// draw the spinning ticks.
const Map<CupertinoActivityIndicatorIOSVersionStyle, List<int>> const List<int> _kAlphaValues = <int>[
_kAlphaValuesMap = <CupertinoActivityIndicatorIOSVersionStyle, List<int>>{ 47,
/// The order of these values is designed to match the first frame of the iOS activity indicator which 47,
/// has the most prominent tick at 9 o'clock. 47,
CupertinoActivityIndicatorIOSVersionStyle.iOS13: <int>[ 47,
47, 72,
47, 97,
47, 122,
47, 147,
64, ];
81,
97,
114,
131,
147,
47,
47
],
/// Alpha values for new style that introduced in iOS14.
CupertinoActivityIndicatorIOSVersionStyle.iOS14: <int>[
47,
47,
47,
47,
72,
97,
122,
147,
],
};
/// The alpha value that is used to draw the partially revealed ticks. /// The alpha value that is used to draw the partially revealed ticks.
const int _partiallyRevealedAlpha = 147; const int _partiallyRevealedAlpha = 147;
...@@ -205,16 +154,9 @@ class _CupertinoActivityIndicatorPainter extends CustomPainter { ...@@ -205,16 +154,9 @@ class _CupertinoActivityIndicatorPainter extends CustomPainter {
@required this.activeColor, @required this.activeColor,
@required this.radius, @required this.radius,
@required this.progress, @required this.progress,
CupertinoActivityIndicatorIOSVersionStyle iOSVersionStyle = }) : tickFundamentalRRect = RRect.fromLTRBXY(
CupertinoActivityIndicatorIOSVersionStyle.iOS13,
}) : alphaValues = _kAlphaValuesMap[iOSVersionStyle],
tickFundamentalRRect = RRect.fromLTRBXY(
-radius / _kDefaultIndicatorRadius, -radius / _kDefaultIndicatorRadius,
-radius / -radius / 3.0,
(iOSVersionStyle ==
CupertinoActivityIndicatorIOSVersionStyle.iOS14
? 3.0
: 2.0),
radius / _kDefaultIndicatorRadius, radius / _kDefaultIndicatorRadius,
-radius, -radius,
radius / _kDefaultIndicatorRadius, radius / _kDefaultIndicatorRadius,
...@@ -227,13 +169,12 @@ class _CupertinoActivityIndicatorPainter extends CustomPainter { ...@@ -227,13 +169,12 @@ class _CupertinoActivityIndicatorPainter extends CustomPainter {
final double radius; final double radius;
final double progress; final double progress;
final List<int> alphaValues;
final RRect tickFundamentalRRect; final RRect tickFundamentalRRect;
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
final Paint paint = Paint(); final Paint paint = Paint();
final int tickCount = alphaValues.length; final int tickCount = _kAlphaValues.length;
canvas.save(); canvas.save();
canvas.translate(size.width / 2.0, size.height / 2.0); canvas.translate(size.width / 2.0, size.height / 2.0);
...@@ -243,7 +184,7 @@ class _CupertinoActivityIndicatorPainter extends CustomPainter { ...@@ -243,7 +184,7 @@ class _CupertinoActivityIndicatorPainter extends CustomPainter {
for (int i = 0; i < tickCount * progress; ++i) { for (int i = 0; i < tickCount * progress; ++i) {
final int t = (i - activeTick) % tickCount; final int t = (i - activeTick) % tickCount;
paint.color = activeColor paint.color = activeColor
.withAlpha(progress < 1 ? _partiallyRevealedAlpha : alphaValues[t]); .withAlpha(progress < 1 ? _partiallyRevealedAlpha : _kAlphaValues[t]);
canvas.drawRRect(tickFundamentalRRect, paint); canvas.drawRRect(tickFundamentalRRect, paint);
canvas.rotate(_kTwoPI / tickCount); canvas.rotate(_kTwoPI / tickCount);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment