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
0b7fddae
Unverified
Commit
0b7fddae
authored
Jan 22, 2022
by
Taha Tesser
Committed by
GitHub
Jan 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to control if bottom child focus can be excluded in `AnimatedCrossFade` (#96593)
parent
ec37a4eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
animated_cross_fade.dart
packages/flutter/lib/src/widgets/animated_cross_fade.dart
+12
-0
animated_cross_fade_test.dart
packages/flutter/test/widgets/animated_cross_fade_test.dart
+25
-0
No files found.
packages/flutter/lib/src/widgets/animated_cross_fade.dart
View file @
0b7fddae
...
...
@@ -130,6 +130,7 @@ class AnimatedCrossFade extends StatefulWidget {
required
this
.
duration
,
this
.
reverseDuration
,
this
.
layoutBuilder
=
defaultLayoutBuilder
,
this
.
excludeBottomFocus
=
true
,
})
:
assert
(
firstChild
!=
null
),
assert
(
secondChild
!=
null
),
assert
(
firstCurve
!=
null
),
...
...
@@ -139,6 +140,7 @@ class AnimatedCrossFade extends StatefulWidget {
assert
(
crossFadeState
!=
null
),
assert
(
duration
!=
null
),
assert
(
layoutBuilder
!=
null
),
assert
(
excludeBottomFocus
!=
null
),
super
(
key:
key
);
/// The child that is visible when [crossFadeState] is
...
...
@@ -206,6 +208,15 @@ class AnimatedCrossFade extends StatefulWidget {
/// result in the widgets jumping about when the cross-fade state is changed.
final
AnimatedCrossFadeBuilder
layoutBuilder
;
/// When true, this is equivalent to wrapping the bottom widget with an [ExcludeFocus]
/// widget while it is at the bottom of the cross-fade stack.
///
/// Defaults to true. When it is false, the bottom widget in the cross-fade stack
/// can remain in focus until the top widget requests focus. This is useful for
/// animating between different [TextField]s so the keyboard remains open during the
/// cross-fade animation.
final
bool
excludeBottomFocus
;
/// The default layout algorithm used by [AnimatedCrossFade].
///
/// The top child is placed in a stack that sizes itself to match the top
...
...
@@ -345,6 +356,7 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
child:
IgnorePointer
(
child:
ExcludeSemantics
(
// Always exclude the semantics of the widget that's fading out.
child:
ExcludeFocus
(
excluding:
widget
.
excludeBottomFocus
,
child:
FadeTransition
(
opacity:
bottomAnimation
,
child:
bottomChild
,
...
...
packages/flutter/test/widgets/animated_cross_fade_test.dart
View file @
0b7fddae
...
...
@@ -385,6 +385,31 @@ void main() {
expect
(
hiddenNode
.
hasPrimaryFocus
,
isFalse
);
});
testWidgets
(
'AnimatedCrossFade bottom child can have focus'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
AnimatedCrossFade
(
firstChild:
TextButton
(
onPressed:
()
{},
child:
const
Text
(
'AAA'
)),
secondChild:
TextButton
(
onPressed:
()
{},
child:
const
Text
(
'BBB'
)),
crossFadeState:
CrossFadeState
.
showFirst
,
duration:
const
Duration
(
milliseconds:
50
),
excludeBottomFocus:
false
,
),
),
);
final
FocusNode
visibleNode
=
Focus
.
of
(
tester
.
element
(
find
.
text
(
'AAA'
)),
scopeOk:
true
);
visibleNode
.
requestFocus
();
await
tester
.
pump
();
expect
(
visibleNode
.
hasPrimaryFocus
,
isTrue
);
final
FocusNode
hiddenNode
=
Focus
.
of
(
tester
.
element
(
find
.
text
(
'BBB'
)),
scopeOk:
true
);
hiddenNode
.
requestFocus
();
await
tester
.
pump
();
expect
(
hiddenNode
.
hasPrimaryFocus
,
isTrue
);
});
testWidgets
(
'AnimatedCrossFade second child do not receive touch events'
,
(
WidgetTester
tester
)
async
{
int
numberOfTouchEventNoticed
=
0
;
...
...
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