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(
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.
///
/// {@youtube 560 315 https://www.youtube.com/watch?v=AENVH-ZqKDQ}
......@@ -44,11 +31,6 @@ class CupertinoActivityIndicator extends StatefulWidget {
Key key,
this.animating = true,
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(radius != null),
assert(radius > 0.0),
......@@ -65,11 +47,6 @@ class CupertinoActivityIndicator extends StatefulWidget {
Key key,
this.radius = _kDefaultIndicatorRadius,
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 > 0.0),
assert(progress != null),
......@@ -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.
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
_CupertinoActivityIndicatorState createState() =>
_CupertinoActivityIndicatorState();
......@@ -153,7 +124,6 @@ class _CupertinoActivityIndicatorState extends State<CupertinoActivityIndicator>
CupertinoDynamicColor.resolve(_kActiveTickColor, context),
radius: widget.radius,
progress: widget.progress,
iOSVersionStyle: widget.iOSVersionStyle,
),
),
);
......@@ -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
/// draw the spinning ticks.
const Map<CupertinoActivityIndicatorIOSVersionStyle, List<int>>
_kAlphaValuesMap = <CupertinoActivityIndicatorIOSVersionStyle, List<int>>{
/// The order of these values is designed to match the first frame of the iOS activity indicator which
/// has the most prominent tick at 9 o'clock.
CupertinoActivityIndicatorIOSVersionStyle.iOS13: <int>[
47,
47,
47,
47,
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,
],
};
const List<int> _kAlphaValues = <int>[
47,
47,
47,
47,
72,
97,
122,
147,
];
/// The alpha value that is used to draw the partially revealed ticks.
const int _partiallyRevealedAlpha = 147;
......@@ -205,16 +154,9 @@ class _CupertinoActivityIndicatorPainter extends CustomPainter {
@required this.activeColor,
@required this.radius,
@required this.progress,
CupertinoActivityIndicatorIOSVersionStyle iOSVersionStyle =
CupertinoActivityIndicatorIOSVersionStyle.iOS13,
}) : alphaValues = _kAlphaValuesMap[iOSVersionStyle],
tickFundamentalRRect = RRect.fromLTRBXY(
}) : tickFundamentalRRect = RRect.fromLTRBXY(
-radius / _kDefaultIndicatorRadius,
-radius /
(iOSVersionStyle ==
CupertinoActivityIndicatorIOSVersionStyle.iOS14
? 3.0
: 2.0),
-radius / 3.0,
radius / _kDefaultIndicatorRadius,
-radius,
radius / _kDefaultIndicatorRadius,
......@@ -227,13 +169,12 @@ class _CupertinoActivityIndicatorPainter extends CustomPainter {
final double radius;
final double progress;
final List<int> alphaValues;
final RRect tickFundamentalRRect;
@override
void paint(Canvas canvas, Size size) {
final Paint paint = Paint();
final int tickCount = alphaValues.length;
final int tickCount = _kAlphaValues.length;
canvas.save();
canvas.translate(size.width / 2.0, size.height / 2.0);
......@@ -243,7 +184,7 @@ class _CupertinoActivityIndicatorPainter extends CustomPainter {
for (int i = 0; i < tickCount * progress; ++i) {
final int t = (i - activeTick) % tickCount;
paint.color = activeColor
.withAlpha(progress < 1 ? _partiallyRevealedAlpha : alphaValues[t]);
.withAlpha(progress < 1 ? _partiallyRevealedAlpha : _kAlphaValues[t]);
canvas.drawRRect(tickFundamentalRRect, paint);
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