@@ -197,83 +197,95 @@ class _AlbumPageState extends State<AlbumPage> {
197197 }).then ((value) => _refreshController.requestRefresh ());
198198 }
199199
200+ void _onWillPop (bool pop) {
201+ if (_selectedList.isNotEmpty) {
202+ setState (() {
203+ _selectedList.clear ();
204+ });
205+ }
206+ }
207+
200208 @override
201209 Widget build (BuildContext context) {
202- return Scaffold (
203- body: SafeArea (
204- child: SmartRefresher (
205- controller: _refreshController,
206- scrollController: _scrollController,
207- enablePullUp: _enableLoad,
208- onLoading: _loadMoreImages,
209- onRefresh: _onRefresh,
210- header: MaterialClassicHeader (
211- backgroundColor: Theme .of (context).cardColor,
212- color: Theme .of (context).colorScheme.secondary,
213- ),
214- footer: ClassicFooter (
215- loadingText: appStrings.loadingHUD_label,
216- noDataText: appStrings.categoryImageList_noDataError,
217- failedText: appStrings.errorHUD_label,
218- idleText: '' ,
219- canLoadingText: appStrings.loadMoreHUD_label,
220- ),
221- child: CustomScrollView (
222- controller: _scrollController,
223- slivers: [
224- _appBar,
225- SliverToBoxAdapter (
226- child: FutureBuilder <List <ApiResponse >>(
227- future: _data,
228- builder: (context, snapshot) {
229- if (snapshot.hasData) {
230- if (snapshot.data! .first.hasError && snapshot.data! .last.hasError) {
231- return Padding (
232- padding: const EdgeInsets .symmetric (horizontal: 16.0 , vertical: 8.0 ),
233- child: Text (
234- appStrings.categoryImageList_noDataError,
235- textAlign: TextAlign .center,
236- ),
237- );
238- }
239- return Column (
240- crossAxisAlignment: CrossAxisAlignment .center,
241- children: [
242- _albumGrid (snapshot),
243- _imageGrid (snapshot),
244- SizedBox (
245- height: 72.0 ,
246- child: Padding (
247- padding: const EdgeInsets .all (8.0 ),
248- child: Text (
249- appStrings.imageCount (_currentAlbum.nbTotalImages),
250- style: Theme .of (context).textTheme.titleSmall,
210+ return PopScope (
211+ canPop: _selectedList.isEmpty,
212+ onPopInvoked: _onWillPop,
213+ child: Scaffold (
214+ body: SafeArea (
215+ child: SmartRefresher (
216+ controller: _refreshController,
217+ scrollController: _scrollController,
218+ enablePullUp: _enableLoad,
219+ onLoading: _loadMoreImages,
220+ onRefresh: _onRefresh,
221+ header: MaterialClassicHeader (
222+ backgroundColor: Theme .of (context).cardColor,
223+ color: Theme .of (context).colorScheme.secondary,
224+ ),
225+ footer: ClassicFooter (
226+ loadingText: appStrings.loadingHUD_label,
227+ noDataText: appStrings.categoryImageList_noDataError,
228+ failedText: appStrings.errorHUD_label,
229+ idleText: '' ,
230+ canLoadingText: appStrings.loadMoreHUD_label,
231+ ),
232+ child: CustomScrollView (
233+ controller: _scrollController,
234+ slivers: [
235+ _appBar,
236+ SliverToBoxAdapter (
237+ child: FutureBuilder <List <ApiResponse >>(
238+ future: _data,
239+ builder: (context, snapshot) {
240+ if (snapshot.hasData) {
241+ if (snapshot.data! .first.hasError && snapshot.data! .last.hasError) {
242+ return Padding (
243+ padding: const EdgeInsets .symmetric (horizontal: 16.0 , vertical: 8.0 ),
244+ child: Text (
245+ appStrings.categoryImageList_noDataError,
246+ textAlign: TextAlign .center,
247+ ),
248+ );
249+ }
250+ return Column (
251+ crossAxisAlignment: CrossAxisAlignment .center,
252+ children: [
253+ _albumGrid (snapshot),
254+ _imageGrid (snapshot),
255+ SizedBox (
256+ height: 72.0 ,
257+ child: Padding (
258+ padding: const EdgeInsets .all (8.0 ),
259+ child: Text (
260+ appStrings.imageCount (_currentAlbum.nbTotalImages),
261+ style: Theme .of (context).textTheme.titleSmall,
262+ ),
251263 ),
252264 ),
253- ),
254- ],
265+ ],
266+ );
267+ }
268+ return const Center (
269+ child: Padding (
270+ padding: EdgeInsets .all (8.0 ),
271+ child: CircularProgressIndicator (),
272+ ),
255273 );
256- }
257- return const Center (
258- child: Padding (
259- padding: EdgeInsets .all (8.0 ),
260- child: CircularProgressIndicator (),
261- ),
262- );
263- },
274+ },
275+ ),
264276 ),
265- ) ,
266- ] ,
277+ ] ,
278+ ) ,
267279 ),
268280 ),
281+ bottomNavigationBar: AnimatedSlide (
282+ duration: const Duration (milliseconds: 300 ),
283+ curve: Curves .easeInOut,
284+ offset: _selectedList.isEmpty ? Offset (0 , 1 ) : Offset .zero,
285+ child: _bottomBar,
286+ ),
287+ floatingActionButton: _adminActionsSpeedDial,
269288 ),
270- bottomNavigationBar: AnimatedSlide (
271- duration: const Duration (milliseconds: 300 ),
272- curve: Curves .easeInOut,
273- offset: _selectedList.isEmpty ? Offset (0 , 1 ) : Offset .zero,
274- child: _bottomBar,
275- ),
276- floatingActionButton: _adminActionsSpeedDial,
277289 );
278290 }
279291
0 commit comments