Refactor scrolling code to prepare for nested scrolling (#9575)

This patch reworks some of the guts of scrolling to make it easier to
implement nested scrolling effects. The actually nested scrolling effect
will be included in a later patch.
This commit is contained in:
Adam Barth
2017-04-24 23:32:55 -07:00
committed by GitHub
parent 57648ba0e4
commit c288c7064f
28 changed files with 1410 additions and 1042 deletions

View File

@@ -411,7 +411,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
if (notification.depth == 0 && notification is ScrollUpdateNotification) {
selectedIndex.value = leader.page;
if (follower.page != leader.page)
follower.position.jumpTo(leader.position.pixels, settle: false);
follower.position.jumpToWithoutSettling(leader.position.pixels); // ignore: deprecated_member_use
}
return false;
}

View File

@@ -87,7 +87,7 @@ class ContactsDemo extends StatefulWidget {
ContactsDemoState createState() => new ContactsDemoState();
}
enum AppBarBehavior { normal, pinned, floating }
enum AppBarBehavior { normal, pinned, floating, snapping }
class ContactsDemoState extends State<ContactsDemo> {
static final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
@@ -110,7 +110,8 @@ class ContactsDemoState extends State<ContactsDemo> {
new SliverAppBar(
expandedHeight: _appBarHeight,
pinned: _appBarBehavior == AppBarBehavior.pinned,
floating: _appBarBehavior == AppBarBehavior.floating,
floating: _appBarBehavior == AppBarBehavior.floating || _appBarBehavior == AppBarBehavior.snapping,
snap: _appBarBehavior == AppBarBehavior.snapping,
actions: <Widget>[
new IconButton(
icon: const Icon(Icons.create),
@@ -140,6 +141,10 @@ class ContactsDemoState extends State<ContactsDemo> {
value: AppBarBehavior.floating,
child: const Text('App bar floats')
),
const PopupMenuItem<AppBarBehavior>(
value: AppBarBehavior.snapping,
child: const Text('App bar snaps')
),
],
),
],