Unverified Commit 844fc5fe authored by Davide Dessì's avatar Davide Dessì Committed by GitHub

Fix CupertinoSliverNavigationBar's alwaysShowMiddle not working properly...

Fix CupertinoSliverNavigationBar's alwaysShowMiddle not working properly during page transition (#120895)

Fix CupertinoSliverNavigationBar's alwaysShowMiddle not working properly during page transition
parent c7f8350e
...@@ -897,7 +897,7 @@ class _LargeTitleNavigationBarSliverDelegate ...@@ -897,7 +897,7 @@ class _LargeTitleNavigationBarSliverDelegate
titleTextStyle: CupertinoTheme.of(context).textTheme.navTitleTextStyle, titleTextStyle: CupertinoTheme.of(context).textTheme.navTitleTextStyle,
largeTitleTextStyle: CupertinoTheme.of(context).textTheme.navLargeTitleTextStyle, largeTitleTextStyle: CupertinoTheme.of(context).textTheme.navLargeTitleTextStyle,
border: border, border: border,
hasUserMiddle: userMiddle != null, hasUserMiddle: userMiddle != null && (alwaysShowMiddle || !showLargeTitle),
largeExpanded: showLargeTitle, largeExpanded: showLargeTitle,
child: navBar, child: navBar,
), ),
......
...@@ -625,6 +625,71 @@ void main() { ...@@ -625,6 +625,71 @@ void main() {
expect(flying(tester, find.byWidget(userMiddle)), findsOneWidget); expect(flying(tester, find.byWidget(userMiddle)), findsOneWidget);
}); });
testWidgets('Middle is not shown if alwaysShowMiddle is false and the nav bar is expanded', (WidgetTester tester) async {
const Widget userMiddle = Placeholder();
await startTransitionBetween(
tester,
from: const CupertinoSliverNavigationBar(
middle: userMiddle,
alwaysShowMiddle: false,
),
fromTitle: 'Page 1',
toTitle: 'Page 2',
);
await tester.pump(const Duration(milliseconds: 50));
expect(flying(tester, find.byWidget(userMiddle)), findsNothing);
});
testWidgets('Middle is shown if alwaysShowMiddle is false but the nav bar is collapsed', (WidgetTester tester) async {
const Widget userMiddle = Placeholder();
final ScrollController scrollController = ScrollController();
await tester.pumpWidget(
CupertinoApp(
home: CupertinoPageScaffold(
child: CustomScrollView(
controller: scrollController,
slivers: const <Widget>[
CupertinoSliverNavigationBar(
largeTitle: Text('Page 1'),
middle: userMiddle,
alwaysShowMiddle: false,
),
SliverToBoxAdapter(
child: SizedBox(
height: 1200.0,
),
),
],
),
),
),
);
scrollController.jumpTo(600.0);
await tester.pumpAndSettle();
// Middle widget is visible when nav bar is collapsed.
final RenderAnimatedOpacity userMiddleOpacity = tester
.element(find.byWidget(userMiddle))
.findAncestorRenderObjectOfType<RenderAnimatedOpacity>()!;
expect(userMiddleOpacity.opacity.value, 1.0);
tester
.state<NavigatorState>(find.byType(Navigator))
.push(CupertinoPageRoute<void>(
title: 'Page 2',
builder: (BuildContext context) => scaffoldForNavBar(null)!,
));
await tester.pump();
await tester.pump(const Duration(milliseconds: 50));
expect(flying(tester, find.byWidget(userMiddle)), findsOneWidget);
});
testWidgets('First appearance of back chevron fades in from the right', (WidgetTester tester) async { testWidgets('First appearance of back chevron fades in from the right', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
......
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