@@ -78,6 +78,18 @@ class _ShrineAppState extends State<ShrineApp> with TickerProviderStateMixin {
7878 );
7979 }
8080
81+ // Closes the bottom sheet if it is open.
82+ Future <bool > _onWillPop () async {
83+ final status = _expandingController.status;
84+ if (status == AnimationStatus .completed ||
85+ status == AnimationStatus .forward) {
86+ _expandingController.reverse ();
87+ return false ;
88+ }
89+
90+ return true ;
91+ }
92+
8193 @override
8294 Widget build (BuildContext context) {
8395 final bool isDesktop = isDisplayDesktop (context);
@@ -86,34 +98,37 @@ class _ShrineAppState extends State<ShrineApp> with TickerProviderStateMixin {
8698
8799 return ScopedModel <AppStateModel >(
88100 model: _model,
89- child: MaterialApp (
90- navigatorKey: widget.navigatorKey,
91- title: 'Shrine' ,
92- debugShowCheckedModeBanner: false ,
93- home: LayoutCache (
94- layouts: _layouts,
95- child: PageStatus (
96- menuController: _controller,
97- cartController: _expandingController,
98- child: HomePage (
99- backdrop: backdrop,
100- scrim: Scrim (controller: _expandingController),
101- expandingBottomSheet: ExpandingBottomSheet (
102- hideController: _controller,
103- expandingController: _expandingController,
101+ child: WillPopScope (
102+ onWillPop: _onWillPop,
103+ child: MaterialApp (
104+ navigatorKey: widget.navigatorKey,
105+ title: 'Shrine' ,
106+ debugShowCheckedModeBanner: false ,
107+ home: LayoutCache (
108+ layouts: _layouts,
109+ child: PageStatus (
110+ menuController: _controller,
111+ cartController: _expandingController,
112+ child: HomePage (
113+ backdrop: backdrop,
114+ scrim: Scrim (controller: _expandingController),
115+ expandingBottomSheet: ExpandingBottomSheet (
116+ hideController: _controller,
117+ expandingController: _expandingController,
118+ ),
104119 ),
105120 ),
106121 ),
122+ initialRoute: '/login' ,
123+ onGenerateRoute: _getRoute,
124+ theme: shrineTheme.copyWith (
125+ platform: GalleryOptions .of (context).platform,
126+ ),
127+ // L10n settings.
128+ localizationsDelegates: GalleryLocalizations .localizationsDelegates,
129+ supportedLocales: GalleryLocalizations .supportedLocales,
130+ locale: GalleryOptions .of (context).locale,
107131 ),
108- initialRoute: '/login' ,
109- onGenerateRoute: _getRoute,
110- theme: shrineTheme.copyWith (
111- platform: GalleryOptions .of (context).platform,
112- ),
113- // L10n settings.
114- localizationsDelegates: GalleryLocalizations .localizationsDelegates,
115- supportedLocales: GalleryLocalizations .supportedLocales,
116- locale: GalleryOptions .of (context).locale,
117132 ),
118133 );
119134 }
0 commit comments