mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
default CupertinoSliverNavigationBar's stretch to false (#74669)
This commit is contained in:
parent
d1538320d2
commit
00143388a2
@ -541,7 +541,7 @@ class _CupertinoNavigationBarState extends State<CupertinoNavigationBar> {
|
|||||||
/// The [stretch] parameter determines whether the nav bar should stretch to
|
/// The [stretch] parameter determines whether the nav bar should stretch to
|
||||||
/// fill the over-scroll area. The nav bar can still expand and contract as the
|
/// fill the over-scroll area. The nav bar can still expand and contract as the
|
||||||
/// user scrolls, but it will also stretch when the user over-scrolls if the
|
/// user scrolls, but it will also stretch when the user over-scrolls if the
|
||||||
/// [stretch] value is `true`. Defaults to `true`.
|
/// [stretch] value is `true`. Defaults to `false`.
|
||||||
///
|
///
|
||||||
/// See also:
|
/// See also:
|
||||||
///
|
///
|
||||||
@ -566,7 +566,7 @@ class CupertinoSliverNavigationBar extends StatefulWidget {
|
|||||||
this.padding,
|
this.padding,
|
||||||
this.transitionBetweenRoutes = true,
|
this.transitionBetweenRoutes = true,
|
||||||
this.heroTag = _defaultHeroTag,
|
this.heroTag = _defaultHeroTag,
|
||||||
this.stretch = true,
|
this.stretch = false,
|
||||||
}) : assert(automaticallyImplyLeading != null),
|
}) : assert(automaticallyImplyLeading != null),
|
||||||
assert(automaticallyImplyTitle != null),
|
assert(automaticallyImplyTitle != null),
|
||||||
assert(
|
assert(
|
||||||
@ -658,7 +658,12 @@ class CupertinoSliverNavigationBar extends StatefulWidget {
|
|||||||
///
|
///
|
||||||
/// The nav bar can still expand and contract as the user scrolls, but it will
|
/// The nav bar can still expand and contract as the user scrolls, but it will
|
||||||
/// also stretch when the user over-scrolls if the [stretch] value is `true`.
|
/// also stretch when the user over-scrolls if the [stretch] value is `true`.
|
||||||
/// Defaults to `true`.
|
///
|
||||||
|
/// When set to `true`, the nav bar will prevent subsequent slivers from
|
||||||
|
/// accessing overscrolls. This may be undesirable for using overscroll-based
|
||||||
|
/// widgets like the [CupertinoSliverRefreshControl].
|
||||||
|
///
|
||||||
|
/// Defaults to `false`.
|
||||||
final bool stretch;
|
final bool stretch;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -1230,6 +1230,7 @@ void main() {
|
|||||||
const CupertinoSliverNavigationBar(
|
const CupertinoSliverNavigationBar(
|
||||||
trailing: trailingText,
|
trailing: trailingText,
|
||||||
largeTitle: titleText,
|
largeTitle: titleText,
|
||||||
|
stretch: true,
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Container(
|
child: Container(
|
||||||
|
@ -918,6 +918,47 @@ void main() {
|
|||||||
|
|
||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||||
|
|
||||||
|
// Test to make sure the refresh sliver's overscroll isn't eaten by the
|
||||||
|
// nav bar sliver https://github.com/flutter/flutter/issues/74516.
|
||||||
|
testWidgets(
|
||||||
|
'properly displays when the refresh sliver is behind the large title nav bar sliver',
|
||||||
|
(WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
CupertinoApp(
|
||||||
|
home: CustomScrollView(
|
||||||
|
slivers: <Widget>[
|
||||||
|
const CupertinoSliverNavigationBar(
|
||||||
|
largeTitle: Text('Title'),
|
||||||
|
),
|
||||||
|
CupertinoSliverRefreshControl(
|
||||||
|
builder: mockHelper.builder,
|
||||||
|
),
|
||||||
|
buildAListOfStuff(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final double initialFirstCellY = tester.getTopLeft(find.widgetWithText(Container, '0')).dy;
|
||||||
|
|
||||||
|
// Drag down but not enough to trigger the refresh.
|
||||||
|
await tester.drag(find.text('0'), const Offset(0.0, 50.0), touchSlopY: 0);
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
expect(mockHelper.invocations.first, matchesBuilder(
|
||||||
|
refreshState: RefreshIndicatorMode.drag,
|
||||||
|
pulledExtent: 50,
|
||||||
|
refreshTriggerPullDistance: 100, // default value.
|
||||||
|
refreshIndicatorExtent: 60, // default value.
|
||||||
|
));
|
||||||
|
expect(mockHelper.invocations, hasLength(1));
|
||||||
|
|
||||||
|
expect(
|
||||||
|
tester.getTopLeft(find.widgetWithText(Container, '0')).dy,
|
||||||
|
initialFirstCellY + 50
|
||||||
|
);
|
||||||
|
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||||
};
|
};
|
||||||
|
|
||||||
final VoidCallback stateMachineTestGroup = () {
|
final VoidCallback stateMachineTestGroup = () {
|
||||||
|
Loading…
Reference in New Issue
Block a user