@@ -20,6 +20,7 @@ import 'package:piwigo_ng/services/theme_provider.dart';
2020import 'package:piwigo_ng/utils/image_actions.dart' ;
2121import 'package:piwigo_ng/utils/localizations.dart' ;
2222import 'package:piwigo_ng/utils/resources.dart' ;
23+ import 'package:piwigo_ng/utils/settings.dart' ;
2324import 'package:piwigo_ng/views/image/video_player_page.dart' ;
2425import 'package:provider/provider.dart' ;
2526
@@ -79,6 +80,9 @@ class _ImageViewPageState extends State<ImageViewPage> {
7980 void initState () {
8081 _imageList = widget.images.sublist (0 );
8182 _album = widget.album;
83+ _imagePage =
84+ ((_imageList.length - 1 ) / Settings .defaultElementPerPage).floor ();
85+
8286 final ImageModel ? startImage =
8387 _imageList.firstWhere ((image) => image.id == widget.startId);
8488 if (startImage != null ) {
@@ -87,12 +91,15 @@ class _ImageViewPageState extends State<ImageViewPage> {
8791 _loadMoreImages ();
8892 }
8993 }
94+
9095 _pageController = PageController (initialPage: _page);
96+
97+ _loadCookies ();
98+
9199 SystemChrome .setSystemUIOverlayStyle (SystemUiOverlayStyle .light.copyWith (
92100 systemNavigationBarColor: Colors .black.withOpacity (0.1 ),
93101 statusBarColor: Colors .black.withOpacity (0.1 ),
94102 ));
95- _loadCookies ();
96103 WidgetsBinding .instance.addPostFrameCallback ((timeStamp) {
97104 _getImagesInfo (_imageList);
98105 });
@@ -166,7 +173,8 @@ class _ImageViewPageState extends State<ImageViewPage> {
166173 });
167174 return false ;
168175 }
169- return true ;
176+ Navigator .of (context).pop (_imageList);
177+ return false ;
170178 }
171179
172180 /// Toggle overlay action (orientation was necessary, *see comments*).
@@ -190,7 +198,7 @@ class _ImageViewPageState extends State<ImageViewPage> {
190198 /// Handle when
191199 Future <void > _onRemoveImage (ImageModel image) async {
192200 if (_imageList.length == 1 ) {
193- Navigator .of (context).pop ();
201+ Navigator .of (context).pop ([] );
194202 }
195203 if (_imageList.length - 1 == _page) {
196204 await _pageController.previousPage (
@@ -291,7 +299,7 @@ class _ImageViewPageState extends State<ImageViewPage> {
291299 child: Row (
292300 children: [
293301 IconButton (
294- onPressed: () => Navigator .of (context).pop (),
302+ onPressed: () => Navigator .of (context).pop (_imageList ),
295303 icon: Icon (Icons .arrow_back),
296304 ),
297305 Expanded (
0 commit comments