Unverified Commit 5bbcf6d4 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Apply T, L, R media padding in Cupertino nav bar (#13580)

Applies top, left, right media padding for iOS safe area insets. This is
a follow-up to the media padding applied to large titles in
flutter/flutter#13550.
parent c28121ee
...@@ -395,15 +395,13 @@ class _CupertinoPersistentNavigationBar extends StatelessWidget implements Prefe ...@@ -395,15 +395,13 @@ class _CupertinoPersistentNavigationBar extends StatelessWidget implements Prefe
color: actionsForegroundColor, color: actionsForegroundColor,
size: 22.0, size: 22.0,
), ),
child: new Padding( child: new SafeArea(
padding: new EdgeInsetsDirectional.only( bottom: false,
top: MediaQuery.of(context).padding.top, child: new Padding(
start: useBackButton ? _kNavBarBackButtonPadding : _kNavBarEdgePadding, padding: new EdgeInsetsDirectional.only(
end: _kNavBarEdgePadding, start: useBackButton ? _kNavBarBackButtonPadding : _kNavBarEdgePadding,
), end: _kNavBarEdgePadding,
child: new MediaQuery.removePadding( ),
context: context,
removeTop: true,
child: new NavigationToolbar( child: new NavigationToolbar(
leading: styledLeading ?? backOrCloseButton, leading: styledLeading ?? backOrCloseButton,
middle: animatedStyledMiddle, middle: animatedStyledMiddle,
......
...@@ -118,7 +118,9 @@ void main() { ...@@ -118,7 +118,9 @@ void main() {
testWidgets('Media padding is applied to CupertinoSliverNavigationBar', (WidgetTester tester) async { testWidgets('Media padding is applied to CupertinoSliverNavigationBar', (WidgetTester tester) async {
final ScrollController scrollController = new ScrollController(); final ScrollController scrollController = new ScrollController();
final Key leadingKey = new GlobalKey();
final Key middleKey = new GlobalKey(); final Key middleKey = new GlobalKey();
final Key trailingKey = new GlobalKey();
final Key titleKey = new GlobalKey(); final Key titleKey = new GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new WidgetsApp(
...@@ -141,8 +143,10 @@ void main() { ...@@ -141,8 +143,10 @@ void main() {
controller: scrollController, controller: scrollController,
slivers: <Widget>[ slivers: <Widget>[
new CupertinoSliverNavigationBar( new CupertinoSliverNavigationBar(
middle: new Text('Not-large Title', key: middleKey), leading: new Placeholder(key: leadingKey),
middle: new Placeholder(key: middleKey),
largeTitle: new Text('Large Title', key: titleKey), largeTitle: new Text('Large Title', key: titleKey),
trailing: new Placeholder(key: trailingKey),
), ),
new SliverToBoxAdapter( new SliverToBoxAdapter(
child: new Container( child: new Container(
...@@ -159,8 +163,10 @@ void main() { ...@@ -159,8 +163,10 @@ void main() {
), ),
); );
// Top padding is applied to middle. // Media padding applied to leading (T,L), middle (T), trailing (T, R).
expect(tester.getTopLeft(find.byKey(middleKey)), const Offset(277.5, 13.5 + 10.0)); expect(tester.getTopLeft(find.byKey(leadingKey)), const Offset(16.0 + 20.0, 10.0));
expect(tester.getRect(find.byKey(middleKey)).top, 10.0);
expect(tester.getTopRight(find.byKey(trailingKey)), const Offset(800.0 - 16.0 - 40.0, 10.0));
// Top and left padding is applied to large title. // Top and left padding is applied to large title.
expect(tester.getTopLeft(find.byKey(titleKey)), const Offset(16.0 + 20.0, 58.0 + 10.0)); expect(tester.getTopLeft(find.byKey(titleKey)), const Offset(16.0 + 20.0, 58.0 + 10.0));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment