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
d8ca42e2
Unverified
Commit
d8ca42e2
authored
Sep 25, 2019
by
LongCatIsLooong
Committed by
GitHub
Sep 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CupertinoPageScaffold dark mode (#40690)
parent
04cf581d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
5 deletions
+58
-5
nav_bar.dart
packages/flutter/lib/src/cupertino/nav_bar.dart
+5
-1
page_scaffold.dart
packages/flutter/lib/src/cupertino/page_scaffold.dart
+5
-4
scaffold_test.dart
packages/flutter/test/cupertino/scaffold_test.dart
+48
-0
No files found.
packages/flutter/lib/src/cupertino/nav_bar.dart
View file @
d8ca42e2
...
...
@@ -372,7 +372,11 @@ class CupertinoNavigationBar extends StatefulWidget implements ObstructingPrefer
/// True if the navigation bar's background color has no transparency.
@override
bool
get
fullObstruction
=>
backgroundColor
==
null
?
null
:
backgroundColor
.
alpha
==
0xFF
;
bool
shouldFullyObstruct
(
BuildContext
context
)
{
final
Color
backgroundColor
=
CupertinoDynamicColor
.
resolve
(
this
.
backgroundColor
,
context
)
??
CupertinoTheme
.
of
(
context
).
barBackgroundColor
;
return
backgroundColor
.
alpha
==
0xFF
;
}
@override
Size
get
preferredSize
{
...
...
packages/flutter/lib/src/cupertino/page_scaffold.dart
View file @
d8ca42e2
...
...
@@ -4,6 +4,7 @@
import
'package:flutter/widgets.dart'
;
import
'colors.dart'
;
import
'theme.dart'
;
/// Implements a single iOS application page's layout.
...
...
@@ -110,8 +111,7 @@ class _CupertinoPageScaffoldState extends State<CupertinoPageScaffold> {
?
existingMediaQuery
.
viewInsets
.
copyWith
(
bottom:
0.0
)
:
existingMediaQuery
.
viewInsets
;
final
bool
fullObstruction
=
widget
.
navigationBar
.
fullObstruction
??
CupertinoTheme
.
of
(
context
).
barBackgroundColor
.
alpha
==
0xFF
;
final
bool
fullObstruction
=
widget
.
navigationBar
.
shouldFullyObstruct
(
context
);
// If navigation bar is opaquely obstructing, directly shift the main content
// down. If translucent, let main content draw behind navigation bar but hint the
...
...
@@ -157,7 +157,8 @@ class _CupertinoPageScaffoldState extends State<CupertinoPageScaffold> {
return
DecoratedBox
(
decoration:
BoxDecoration
(
color:
widget
.
backgroundColor
??
CupertinoTheme
.
of
(
context
).
scaffoldBackgroundColor
,
color:
CupertinoDynamicColor
.
resolve
(
widget
.
backgroundColor
,
context
)
??
CupertinoTheme
.
of
(
context
).
scaffoldBackgroundColor
,
),
child:
Stack
(
children:
<
Widget
>[
...
...
@@ -204,5 +205,5 @@ abstract class ObstructingPreferredSizeWidget extends PreferredSizeWidget {
/// size.
///
/// If false, this widget partially obstructs.
bool
get
fullObstruction
;
bool
shouldFullyObstruct
(
BuildContext
context
)
;
}
packages/flutter/test/cupertino/scaffold_test.dart
View file @
d8ca42e2
...
...
@@ -6,6 +6,7 @@ import 'package:flutter/cupertino.dart';
import
'package:flutter_test/flutter_test.dart'
;
import
'../painting/mocks_for_image_cache.dart'
;
import
'../rendering/mock_canvas.dart'
;
/// Integration tests testing both [CupertinoPageScaffold] and [CupertinoTabScaffold].
void
main
(
)
{
...
...
@@ -53,6 +54,53 @@ void main() {
expect
(
tester
.
getRect
(
find
.
byType
(
Container
)),
const
Rect
.
fromLTRB
(
0
,
44
,
800
,
600
));
});
testWidgets
(
'dark mode and obstruction work'
,
(
WidgetTester
tester
)
async
{
const
Color
dynamicColor
=
CupertinoDynamicColor
.
withBrightness
(
color:
Color
(
0xFFF8F8F8
),
darkColor:
Color
(
0xEE333333
),
);
const
CupertinoDynamicColor
backgroundColor
=
CupertinoDynamicColor
.
withBrightness
(
color:
Color
(
0xFFFFFFFF
),
darkColor:
Color
(
0xFF000000
),
);
BuildContext
childContext
;
Widget
scaffoldWithBrightness
(
Brightness
brightness
)
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
MediaQueryData
(
platformBrightness:
brightness
,
viewInsets:
const
EdgeInsets
.
only
(
top:
20
),
),
child:
CupertinoPageScaffold
(
backgroundColor:
backgroundColor
,
navigationBar:
const
CupertinoNavigationBar
(
middle:
Text
(
'Title'
),
backgroundColor:
dynamicColor
,
),
child:
Builder
(
builder:
(
BuildContext
context
)
{
childContext
=
context
;
return
Container
();
},
),
),
),
);
}
await
tester
.
pumpWidget
(
scaffoldWithBrightness
(
Brightness
.
light
));
expect
(
MediaQuery
.
of
(
childContext
).
padding
.
top
,
0
);
expect
(
find
.
byType
(
CupertinoPageScaffold
),
paints
..
rect
(
color:
backgroundColor
.
color
));
await
tester
.
pumpWidget
(
scaffoldWithBrightness
(
Brightness
.
dark
));
expect
(
MediaQuery
.
of
(
childContext
).
padding
.
top
,
greaterThan
(
0
));
expect
(
find
.
byType
(
CupertinoPageScaffold
),
paints
..
rect
(
color:
backgroundColor
.
darkColor
));
});
testWidgets
(
'Contents padding from viewInsets'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
...
...
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