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
6501f1b5
Unverified
Commit
6501f1b5
authored
Sep 29, 2020
by
Daniel Edrisian
Committed by
GitHub
Sep 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow modifying barrier color and barrier dismissible for Cupertino Modal Popup (#66692)
parent
3c321ac8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
148 additions
and
2 deletions
+148
-2
route.dart
packages/flutter/lib/src/cupertino/route.dart
+17
-2
route_test.dart
packages/flutter/test/cupertino/route_test.dart
+131
-0
No files found.
packages/flutter/lib/src/cupertino/route.dart
View file @
6501f1b5
...
...
@@ -933,6 +933,7 @@ class _CupertinoModalPopupRoute<T> extends PopupRoute<T> {
required
this
.
barrierColor
,
required
this
.
barrierLabel
,
required
this
.
builder
,
bool
?
barrierDismissible
,
bool
?
semanticsDismissible
,
required
ImageFilter
?
filter
,
RouteSettings
?
settings
,
...
...
@@ -940,10 +941,14 @@ class _CupertinoModalPopupRoute<T> extends PopupRoute<T> {
filter:
filter
,
settings:
settings
,
)
{
_barrierDismissible
=
barrierDismissible
;
_semanticsDismissible
=
semanticsDismissible
;
}
final
WidgetBuilder
builder
;
bool
?
_barrierDismissible
;
bool
?
_semanticsDismissible
;
@override
...
...
@@ -953,7 +958,7 @@ class _CupertinoModalPopupRoute<T> extends PopupRoute<T> {
final
Color
?
barrierColor
;
@override
bool
get
barrierDismissible
=>
true
;
bool
get
barrierDismissible
=>
_barrierDismissible
??
true
;
@override
bool
get
semanticsDismissible
=>
_semanticsDismissible
??
false
;
...
...
@@ -1012,6 +1017,13 @@ class _CupertinoModalPopupRoute<T> extends PopupRoute<T> {
/// It is only used when the method is called. Its corresponding widget can be
/// safely removed from the tree before the popup is closed.
///
/// The `barrierColor` argument determines the [Color] of the barrier underneath
/// the popup. When unspecified, the barrier color defaults to a light opacity
/// black scrim based on iOS's dialog screens.
///
/// The `barrierDismissible` argument determines whether clicking outside the
/// popup results in dismissal. It is `true` by default.
///
/// The `useRootNavigator` argument is used to determine whether to push the
/// popup to the [Navigator] furthest from or nearest to the given `context`. It
/// is `false` by default.
...
...
@@ -1038,13 +1050,16 @@ Future<T> showCupertinoModalPopup<T>({
required
BuildContext
context
,
required
WidgetBuilder
builder
,
ImageFilter
?
filter
,
Color
barrierColor
=
_kModalBarrierColor
,
bool
barrierDismissible
=
true
,
bool
useRootNavigator
=
true
,
bool
?
semanticsDismissible
,
})
{
assert
(
useRootNavigator
!=
null
);
return
Navigator
.
of
(
context
,
rootNavigator:
useRootNavigator
)!.
push
(
_CupertinoModalPopupRoute
<
T
>(
barrierColor:
CupertinoDynamicColor
.
resolve
(
_kModalBarrierColor
,
context
),
barrierColor:
CupertinoDynamicColor
.
resolve
(
barrierColor
,
context
),
barrierDismissible:
barrierDismissible
,
barrierLabel:
'Dismiss'
,
builder:
builder
,
filter:
filter
,
...
...
packages/flutter/test/cupertino/route_test.dart
View file @
6501f1b5
...
...
@@ -1375,6 +1375,137 @@ void main() {
debugDefaultTargetPlatformOverride
=
null
;
});
testWidgets
(
'showCupertinoModalPopup transparent barrier color is transparent'
,
(
WidgetTester
tester
)
async
{
const
Color
_kTransparentColor
=
Color
(
0x00000000
);
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
CupertinoPageScaffold
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
GestureDetector
(
onTap:
()
async
{
await
showCupertinoModalPopup
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
=>
const
SizedBox
(),
barrierColor:
_kTransparentColor
,
);
},
child:
const
Text
(
'tap'
),
);
}),
),
));
await
tester
.
tap
(
find
.
text
(
'tap'
));
await
tester
.
pumpAndSettle
();
expect
(
tester
.
widget
<
ModalBarrier
>(
find
.
byType
(
ModalBarrier
).
last
).
color
,
null
);
});
testWidgets
(
'showCupertinoModalPopup null barrier color must be default gray barrier color'
,
(
WidgetTester
tester
)
async
{
// Barrier color for a Cupertino modal barrier.
// Extracted from https://developer.apple.com/design/resources/.
const
Color
kModalBarrierColor
=
CupertinoDynamicColor
.
withBrightness
(
color:
Color
(
0x33000000
),
darkColor:
Color
(
0x7A000000
),
);
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
CupertinoPageScaffold
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
GestureDetector
(
onTap:
()
async
{
await
showCupertinoModalPopup
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
=>
const
SizedBox
(),
);
},
child:
const
Text
(
'tap'
),
);
}),
),
));
await
tester
.
tap
(
find
.
text
(
'tap'
));
await
tester
.
pumpAndSettle
();
expect
(
tester
.
widget
<
ModalBarrier
>(
find
.
byType
(
ModalBarrier
).
last
).
color
,
kModalBarrierColor
);
});
testWidgets
(
'showCupertinoModalPopup custom barrier color'
,
(
WidgetTester
tester
)
async
{
const
Color
customColor
=
Color
(
0x11223344
);
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
CupertinoPageScaffold
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
GestureDetector
(
onTap:
()
async
{
await
showCupertinoModalPopup
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
=>
const
SizedBox
(),
barrierColor:
customColor
);
},
child:
const
Text
(
'tap'
),
);
}),
),
));
await
tester
.
tap
(
find
.
text
(
'tap'
));
await
tester
.
pumpAndSettle
();
expect
(
tester
.
widget
<
ModalBarrier
>(
find
.
byType
(
ModalBarrier
).
last
).
color
,
customColor
);
});
testWidgets
(
'showCupertinoModalPopup barrier dismissible'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
CupertinoPageScaffold
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
GestureDetector
(
onTap:
()
async
{
await
showCupertinoModalPopup
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
=>
const
Text
(
'Visible'
),
barrierDismissible:
true
);
},
child:
const
Text
(
'tap'
),
);
}),
),
));
await
tester
.
tap
(
find
.
text
(
'tap'
));
await
tester
.
pumpAndSettle
();
await
tester
.
tapAt
(
tester
.
getTopLeft
(
find
.
ancestor
(
of:
find
.
text
(
'tap'
),
matching:
find
.
byType
(
CupertinoPageScaffold
))));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Visible'
),
findsNothing
);
});
testWidgets
(
'showCupertinoModalPopup barrier not dismissible'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
CupertinoPageScaffold
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
GestureDetector
(
onTap:
()
async
{
await
showCupertinoModalPopup
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
=>
const
Text
(
'Visible'
),
barrierDismissible:
false
);
},
child:
const
Text
(
'tap'
),
);
}),
),
));
await
tester
.
tap
(
find
.
text
(
'tap'
));
await
tester
.
pumpAndSettle
();
await
tester
.
tapAt
(
tester
.
getTopLeft
(
find
.
ancestor
(
of:
find
.
text
(
'tap'
),
matching:
find
.
byType
(
CupertinoPageScaffold
))));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Visible'
),
findsOneWidget
);
});
testWidgets
(
'CupertinoPage works'
,
(
WidgetTester
tester
)
async
{
final
LocalKey
pageKey
=
UniqueKey
();
final
TransitionDetector
detector
=
TransitionDetector
();
...
...
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