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
e7fd092f
Unverified
Commit
e7fd092f
authored
Aug 04, 2021
by
Yazeed AlKhalaf
Committed by
GitHub
Aug 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔋
Enhance cupertino button fade in and fade out (#87139)
parent
725f48fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
13 deletions
+17
-13
button.dart
packages/flutter/lib/src/cupertino/button.dart
+4
-4
button_test.dart
packages/flutter/test/cupertino/button_test.dart
+13
-9
No files found.
packages/flutter/lib/src/cupertino/button.dart
View file @
e7fd092f
...
...
@@ -148,8 +148,8 @@ class CupertinoButton extends StatefulWidget {
class
_CupertinoButtonState
extends
State
<
CupertinoButton
>
with
SingleTickerProviderStateMixin
{
// Eyeballed values. Feel free to tweak.
static
const
Duration
kFadeOutDuration
=
Duration
(
milliseconds:
10
);
static
const
Duration
kFadeInDuration
=
Duration
(
milliseconds:
1
0
0
);
static
const
Duration
kFadeOutDuration
=
Duration
(
milliseconds:
1
2
0
);
static
const
Duration
kFadeInDuration
=
Duration
(
milliseconds:
1
8
0
);
final
Tween
<
double
>
_opacityTween
=
Tween
<
double
>(
begin:
1.0
);
late
AnimationController
_animationController
;
...
...
@@ -213,8 +213,8 @@ class _CupertinoButtonState extends State<CupertinoButton> with SingleTickerProv
return
;
final
bool
wasHeldDown
=
_buttonHeldDown
;
final
TickerFuture
ticker
=
_buttonHeldDown
?
_animationController
.
animateTo
(
1.0
,
duration:
kFadeOutDuration
)
:
_animationController
.
animateTo
(
0.0
,
duration:
kFadeInDuration
);
?
_animationController
.
animateTo
(
1.0
,
duration:
kFadeOutDuration
,
curve:
Curves
.
easeInOutCubicEmphasized
)
:
_animationController
.
animateTo
(
0.0
,
duration:
kFadeInDuration
,
curve:
Curves
.
easeOutCubic
);
ticker
.
then
<
void
>((
void
value
)
{
if
(
mounted
&&
wasHeldDown
!=
_buttonHeldDown
)
_animate
();
...
...
packages/flutter/test/cupertino/button_test.dart
View file @
e7fd092f
...
...
@@ -205,23 +205,27 @@ void main() {
await
tester
.
pump
();
FadeTransition
transition
=
tester
.
firstWidget
(
find
.
byType
(
FadeTransition
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
25
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
transition
=
tester
.
firstWidget
(
find
.
byType
(
FadeTransition
));
expect
(
transition
.
opacity
.
value
,
moreOrLessEquals
(
0.4
,
epsilon:
0.001
));
expect
(
transition
.
opacity
.
value
,
moreOrLessEquals
(
0.4
03
,
epsilon:
0.001
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
25
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
transition
=
tester
.
firstWidget
(
find
.
byType
(
FadeTransition
));
expect
(
transition
.
opacity
.
value
,
moreOrLessEquals
(
0.4
37
,
epsilon:
0.001
));
expect
(
transition
.
opacity
.
value
,
moreOrLessEquals
(
0.4
00
,
epsilon:
0.001
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
25
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
transition
=
tester
.
firstWidget
(
find
.
byType
(
FadeTransition
));
expect
(
transition
.
opacity
.
value
,
moreOrLessEquals
(
0.
55
,
epsilon:
0.001
));
expect
(
transition
.
opacity
.
value
,
moreOrLessEquals
(
0.
650
,
epsilon:
0.001
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
25
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
transition
=
tester
.
firstWidget
(
find
.
byType
(
FadeTransition
));
expect
(
transition
.
opacity
.
value
,
moreOrLessEquals
(
0.
737
,
epsilon:
0.001
));
expect
(
transition
.
opacity
.
value
,
moreOrLessEquals
(
0.
894
,
epsilon:
0.001
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
25
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
transition
=
tester
.
firstWidget
(
find
.
byType
(
FadeTransition
));
expect
(
transition
.
opacity
.
value
,
moreOrLessEquals
(
0.988
,
epsilon:
0.001
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
transition
=
tester
.
firstWidget
(
find
.
byType
(
FadeTransition
));
expect
(
transition
.
opacity
.
value
,
moreOrLessEquals
(
1.0
,
epsilon:
0.001
));
});
...
...
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