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
bf5e4b45
Unverified
Commit
bf5e4b45
authored
Aug 29, 2018
by
Jonah Williams
Committed by
GitHub
Aug 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure modal BottomSheets routes are identified as dialog routes (#21075)
parent
373243bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
9 deletions
+82
-9
bottom_sheet.dart
packages/flutter/lib/src/material/bottom_sheet.dart
+34
-9
modal_bottom_sheet_test.dart
packages/flutter/test/material/modal_bottom_sheet_test.dart
+48
-0
No files found.
packages/flutter/lib/src/material/bottom_sheet.dart
View file @
bf5e4b45
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'colors.dart'
;
import
'colors.dart'
;
...
@@ -141,6 +142,7 @@ class _BottomSheetState extends State<BottomSheet> {
...
@@ -141,6 +142,7 @@ class _BottomSheetState extends State<BottomSheet> {
onVerticalDragUpdate:
_handleDragUpdate
,
onVerticalDragUpdate:
_handleDragUpdate
,
onVerticalDragEnd:
_handleDragEnd
,
onVerticalDragEnd:
_handleDragEnd
,
child:
bottomSheet
,
child:
bottomSheet
,
excludeFromSemantics:
true
,
);
);
}
}
}
}
...
@@ -190,20 +192,43 @@ class _ModalBottomSheet<T> extends StatefulWidget {
...
@@ -190,20 +192,43 @@ class _ModalBottomSheet<T> extends StatefulWidget {
class
_ModalBottomSheetState
<
T
>
extends
State
<
_ModalBottomSheet
<
T
>>
{
class
_ModalBottomSheetState
<
T
>
extends
State
<
_ModalBottomSheet
<
T
>>
{
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
final
MediaQueryData
mediaQuery
=
MediaQuery
.
of
(
context
);
final
MaterialLocalizations
localizations
=
MaterialLocalizations
.
of
(
context
);
String
routeLabel
;
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
iOS
:
routeLabel
=
''
;
break
;
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
routeLabel
=
localizations
.
dialogLabel
;
break
;
}
return
new
GestureDetector
(
return
new
GestureDetector
(
excludeFromSemantics:
true
,
onTap:
()
=>
Navigator
.
pop
(
context
),
onTap:
()
=>
Navigator
.
pop
(
context
),
child:
new
AnimatedBuilder
(
child:
new
AnimatedBuilder
(
animation:
widget
.
route
.
animation
,
animation:
widget
.
route
.
animation
,
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
child
)
{
return
new
ClipRect
(
// Disable the initial animation when accessible navigation is on so
child:
new
CustomSingleChildLayout
(
// that the semantics are added to the tree at the correct time.
delegate:
new
_ModalBottomSheetLayout
(
widget
.
route
.
animation
.
value
),
final
double
animationValue
=
mediaQuery
.
accessibleNavigation
?
1.0
:
widget
.
route
.
animation
.
value
;
child:
new
BottomSheet
(
return
new
Semantics
(
animationController:
widget
.
route
.
_animationController
,
scopesRoute:
true
,
onClosing:
()
=>
Navigator
.
pop
(
context
),
namesRoute:
true
,
builder:
widget
.
route
.
builder
label:
routeLabel
,
)
explicitChildNodes:
true
,
)
child:
new
ClipRect
(
child:
new
CustomSingleChildLayout
(
delegate:
new
_ModalBottomSheetLayout
(
animationValue
),
child:
new
BottomSheet
(
animationController:
widget
.
route
.
_animationController
,
onClosing:
()
=>
Navigator
.
pop
(
context
),
builder:
widget
.
route
.
builder
,
),
),
),
);
);
}
}
)
)
...
...
packages/flutter/test/material/modal_bottom_sheet_test.dart
View file @
bf5e4b45
...
@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
...
@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/gestures.dart'
;
import
'../widgets/semantics_tester.dart'
;
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'Verify that a tap dismisses a modal BottomSheet'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Verify that a tap dismisses a modal BottomSheet'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
BuildContext
savedContext
;
...
@@ -203,4 +205,50 @@ void main() {
...
@@ -203,4 +205,50 @@ void main() {
const
EdgeInsets
.
only
(
left:
50.0
,
right:
50.0
,
bottom:
50.0
),
const
EdgeInsets
.
only
(
left:
50.0
,
right:
50.0
,
bottom:
50.0
),
);
);
});
});
testWidgets
(
'modal BottomSheet has semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
new
GlobalKey
<
ScaffoldState
>();
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
new
Scaffold
(
key:
scaffoldKey
,
body:
const
Center
(
child:
Text
(
'body'
))
)
));
showModalBottomSheet
<
void
>(
context:
scaffoldKey
.
currentContext
,
builder:
(
BuildContext
context
)
{
return
new
Container
(
child:
const
Text
(
'BottomSheet'
)
);
});
await
tester
.
pump
();
// bottom sheet show animation starts
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// animation done
expect
(
semantics
,
hasSemantics
(
new
TestSemantics
.
root
(
children:
<
TestSemantics
>[
new
TestSemantics
.
rootChild
(
children:
<
TestSemantics
>[
new
TestSemantics
(
label:
'Dialog'
,
textDirection:
TextDirection
.
ltr
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
scopesRoute
,
SemanticsFlag
.
namesRoute
,
],
children:
<
TestSemantics
>[
new
TestSemantics
(
label:
'BottomSheet'
,
textDirection:
TextDirection
.
ltr
,
),
],
),
],
),
],
),
ignoreTransform:
true
,
ignoreRect:
true
,
ignoreId:
true
));
semantics
.
dispose
();
});
}
}
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