Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e5bd2b3d
Unverified
Commit
e5bd2b3d
authored
May 16, 2020
by
Coin
Committed by
GitHub
May 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make CircularProgressIndicator's animation match native (#50412)
parent
32547dcc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
33 deletions
+57
-33
progress_indicator.dart
packages/flutter/lib/src/material/progress_indicator.dart
+33
-33
progress_indicator_test.dart
packages/flutter/test/material/progress_indicator_test.dart
+24
-0
No files found.
packages/flutter/lib/src/material/progress_indicator.dart
View file @
e5bd2b3d
...
...
@@ -12,6 +12,7 @@ import 'theme.dart';
const
double
_kMinCircularProgressIndicatorSize
=
36.0
;
const
int
_kIndeterminateLinearDuration
=
1800
;
const
int
_kIndeterminateCircularDuration
=
1333
*
2222
;
/// A base class for material design progress indicators.
///
...
...
@@ -331,12 +332,12 @@ class _CircularProgressIndicatorPainter extends CustomPainter {
this
.
value
,
this
.
headValue
,
this
.
tailValue
,
this
.
step
Value
,
this
.
offset
Value
,
this
.
rotationValue
,
this
.
strokeWidth
,
})
:
arcStart
=
value
!=
null
?
_startAngle
:
_startAngle
+
tailValue
*
3
/
2
*
math
.
pi
+
rotationValue
*
math
.
pi
*
1.7
-
stepValue
*
0.8
*
math
.
pi
,
:
_startAngle
+
tailValue
*
3
/
2
*
math
.
pi
+
rotationValue
*
math
.
pi
*
2.0
+
offsetValue
*
0.5
*
math
.
pi
,
arcSweep
=
value
!=
null
?
(
value
.
clamp
(
0.0
,
1.0
)
as
double
)
*
_sweep
:
math
.
max
(
headValue
*
3
/
2
*
math
.
pi
-
tailValue
*
3
/
2
*
math
.
pi
,
_epsilon
);
...
...
@@ -346,7 +347,7 @@ class _CircularProgressIndicatorPainter extends CustomPainter {
final
double
value
;
final
double
headValue
;
final
double
tailValue
;
final
int
step
Value
;
final
double
offset
Value
;
final
double
rotationValue
;
final
double
strokeWidth
;
final
double
arcStart
;
...
...
@@ -385,7 +386,7 @@ class _CircularProgressIndicatorPainter extends CustomPainter {
||
oldPainter
.
value
!=
value
||
oldPainter
.
headValue
!=
headValue
||
oldPainter
.
tailValue
!=
tailValue
||
oldPainter
.
stepValue
!=
step
Value
||
oldPainter
.
offsetValue
!=
offset
Value
||
oldPainter
.
rotationValue
!=
rotationValue
||
oldPainter
.
strokeWidth
!=
strokeWidth
;
}
...
...
@@ -443,31 +444,30 @@ class CircularProgressIndicator extends ProgressIndicator {
_CircularProgressIndicatorState
createState
()
=>
_CircularProgressIndicatorState
();
}
// Tweens used by circular progress indicator
final
Animatable
<
double
>
_kStrokeHeadTween
=
CurveTween
(
curve:
const
Interval
(
0.0
,
0.5
,
curve:
Curves
.
fastOutSlowIn
),
).
chain
(
CurveTween
(
curve:
const
SawTooth
(
5
),
));
final
Animatable
<
double
>
_kStrokeTailTween
=
CurveTween
(
curve:
const
Interval
(
0.5
,
1.0
,
curve:
Curves
.
fastOutSlowIn
),
).
chain
(
CurveTween
(
curve:
const
SawTooth
(
5
),
));
final
Animatable
<
int
>
_kStepTween
=
StepTween
(
begin:
0
,
end:
5
);
final
Animatable
<
double
>
_kRotationTween
=
CurveTween
(
curve:
const
SawTooth
(
5
));
class
_CircularProgressIndicatorState
extends
State
<
CircularProgressIndicator
>
with
SingleTickerProviderStateMixin
{
static
const
int
_pathCount
=
_kIndeterminateCircularDuration
~/
1333
;
static
const
int
_rotationCount
=
_kIndeterminateCircularDuration
~/
2222
;
static
final
Animatable
<
double
>
_strokeHeadTween
=
CurveTween
(
curve:
const
Interval
(
0.0
,
0.5
,
curve:
Curves
.
fastOutSlowIn
),
).
chain
(
CurveTween
(
curve:
const
SawTooth
(
_pathCount
),
));
static
final
Animatable
<
double
>
_strokeTailTween
=
CurveTween
(
curve:
const
Interval
(
0.5
,
1.0
,
curve:
Curves
.
fastOutSlowIn
),
).
chain
(
CurveTween
(
curve:
const
SawTooth
(
_pathCount
),
));
static
final
Animatable
<
double
>
_offsetTween
=
CurveTween
(
curve:
const
SawTooth
(
_pathCount
));
static
final
Animatable
<
double
>
_rotationTween
=
CurveTween
(
curve:
const
SawTooth
(
_rotationCount
));
AnimationController
_controller
;
@override
void
initState
()
{
super
.
initState
();
_controller
=
AnimationController
(
duration:
const
Duration
(
seconds:
5
),
duration:
const
Duration
(
milliseconds:
_kIndeterminateCircularDuration
),
vsync:
this
,
);
if
(
widget
.
value
==
null
)
...
...
@@ -489,7 +489,7 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
super
.
dispose
();
}
Widget
_buildIndicator
(
BuildContext
context
,
double
headValue
,
double
tailValue
,
int
step
Value
,
double
rotationValue
)
{
Widget
_buildIndicator
(
BuildContext
context
,
double
headValue
,
double
tailValue
,
double
offset
Value
,
double
rotationValue
)
{
return
widget
.
_buildSemanticsWrapper
(
context:
context
,
child:
Container
(
...
...
@@ -504,7 +504,7 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
value:
widget
.
value
,
// may be null
headValue:
headValue
,
// remaining arguments are ignored if widget.value is not null
tailValue:
tailValue
,
stepValue:
step
Value
,
offsetValue:
offset
Value
,
rotationValue:
rotationValue
,
strokeWidth:
widget
.
strokeWidth
,
),
...
...
@@ -519,10 +519,10 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
builder:
(
BuildContext
context
,
Widget
child
)
{
return
_buildIndicator
(
context
,
_
kS
trokeHeadTween
.
evaluate
(
_controller
),
_
kS
trokeTailTween
.
evaluate
(
_controller
),
_
kStep
Tween
.
evaluate
(
_controller
),
_
kR
otationTween
.
evaluate
(
_controller
),
_
s
trokeHeadTween
.
evaluate
(
_controller
),
_
s
trokeTailTween
.
evaluate
(
_controller
),
_
offset
Tween
.
evaluate
(
_controller
),
_
r
otationTween
.
evaluate
(
_controller
),
);
},
);
...
...
@@ -542,7 +542,7 @@ class _RefreshProgressIndicatorPainter extends _CircularProgressIndicatorPainter
double
value
,
double
headValue
,
double
tailValue
,
int
step
Value
,
double
offset
Value
,
double
rotationValue
,
double
strokeWidth
,
this
.
arrowheadScale
,
...
...
@@ -551,7 +551,7 @@ class _RefreshProgressIndicatorPainter extends _CircularProgressIndicatorPainter
value:
value
,
headValue:
headValue
,
tailValue:
tailValue
,
stepValue:
step
Value
,
offsetValue:
offset
Value
,
rotationValue:
rotationValue
,
strokeWidth:
strokeWidth
,
);
...
...
@@ -645,14 +645,14 @@ class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState {
@override
Widget
build
(
BuildContext
context
)
{
if
(
widget
.
value
!=
null
)
_controller
.
value
=
widget
.
value
/
10.0
;
_controller
.
value
=
widget
.
value
*
(
1333
/
2
/
_kIndeterminateCircularDuration
)
;
else
if
(!
_controller
.
isAnimating
)
_controller
.
repeat
();
return
_buildAnimation
();
}
@override
Widget
_buildIndicator
(
BuildContext
context
,
double
headValue
,
double
tailValue
,
int
step
Value
,
double
rotationValue
)
{
Widget
_buildIndicator
(
BuildContext
context
,
double
headValue
,
double
tailValue
,
double
offset
Value
,
double
rotationValue
)
{
final
double
arrowheadScale
=
widget
.
value
==
null
?
0.0
:
((
widget
.
value
*
2.0
).
clamp
(
0.0
,
1.0
)
as
double
);
return
widget
.
_buildSemanticsWrapper
(
context:
context
,
...
...
@@ -672,7 +672,7 @@ class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState {
value:
null
,
// Draw the indeterminate progress indicator.
headValue:
headValue
,
tailValue:
tailValue
,
stepValue:
step
Value
,
offsetValue:
offset
Value
,
rotationValue:
rotationValue
,
strokeWidth:
widget
.
strokeWidth
,
arrowheadScale:
arrowheadScale
,
...
...
packages/flutter/test/material/progress_indicator_test.dart
View file @
e5bd2b3d
...
...
@@ -530,4 +530,28 @@ void main() {
handle
.
dispose
();
});
testWidgets
(
'Indeterminate CircularProgressIndicator uses expected animation'
,
(
WidgetTester
tester
)
async
{
final
AnimationSheetBuilder
animationSheet
=
AnimationSheetBuilder
(
frameSize:
const
Size
(
40
,
40
));
await
tester
.
pumpFrames
(
animationSheet
.
record
(
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Padding
(
padding:
EdgeInsets
.
all
(
4
),
child:
CircularProgressIndicator
(),
),
),
),
const
Duration
(
seconds:
2
));
tester
.
binding
.
setSurfaceSize
(
animationSheet
.
sheetSize
());
final
Widget
display
=
await
animationSheet
.
display
();
await
tester
.
pumpWidget
(
display
);
await
expectLater
(
find
.
byWidget
(
display
),
matchesGoldenFile
(
'material.circular_progress_indicator.indeterminate.png'
),
);
},
skip:
isBrowser
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment