11import 'package:flutter/material.dart' ;
22import 'package:piwigo_ng/api/albums.dart' ;
33import 'package:piwigo_ng/api/api_error.dart' ;
4- import 'package:piwigo_ng/components/dialogs/confirm_dialog.dart' ;
54import 'package:piwigo_ng/models/album_model.dart' ;
65import 'package:piwigo_ng/utils/localizations.dart' ;
76
@@ -19,7 +18,7 @@ class MoveOrCopyModal extends StatefulWidget {
1918 final bool isImage;
2019 final String ? title;
2120 final String ? subtitle;
22- final Function (AlbumModel )? onSelected;
21+ final Future < dynamic > Function (AlbumModel )? onSelected;
2322
2423 @override
2524 _MoveOrCopyModalState createState () => _MoveOrCopyModalState ();
@@ -46,22 +45,8 @@ class _MoveOrCopyModalState extends State<MoveOrCopyModal> {
4645 }
4746
4847 Future <void > _onTapAlbum (AlbumModel album) async {
49- if (! await showConfirmDialog (
50- context,
51- title: appStrings.moveCategory,
52- message: appStrings.moveCategory_message (
53- widget.album.name,
54- album.name,
55- ),
56- )) return ;
57- ApiResult <bool > result = await moveAlbum (
58- widget.album.id,
59- album.id,
60- );
61-
62- if (result.hasData && result.data == true ) {
63- Navigator .of (context).pop ();
64- }
48+ bool ? result = await widget.onSelected? .call (album);
49+ Navigator .of (context).pop (result ?? false );
6550 }
6651
6752 @override
@@ -77,20 +62,7 @@ class _MoveOrCopyModalState extends State<MoveOrCopyModal> {
7762 ),
7863 builder: (context) => Scaffold (
7964 backgroundColor: Colors .transparent,
80- appBar: AppBar (
81- shape: const RoundedRectangleBorder (
82- borderRadius: BorderRadius .vertical (
83- top: Radius .circular (15.0 ),
84- ),
85- ),
86- elevation: 0.0 ,
87- scrolledUnderElevation: 5.0 ,
88- leading: IconButton (
89- icon: Icon (Icons .close),
90- onPressed: () => Navigator .of (context).pop (),
91- ),
92- title: Text (widget.title ?? '' ),
93- ),
65+ appBar: _appBar,
9466 body: Theme (
9567 data: Theme .of (context).copyWith (
9668 scrollbarTheme: ScrollbarThemeData (
@@ -136,6 +108,22 @@ class _MoveOrCopyModalState extends State<MoveOrCopyModal> {
136108 );
137109 }
138110
111+ PreferredSizeWidget get _appBar => AppBar (
112+ shape: const RoundedRectangleBorder (
113+ borderRadius: BorderRadius .vertical (
114+ top: Radius .circular (15.0 ),
115+ ),
116+ ),
117+ elevation: 0.0 ,
118+ scrolledUnderElevation: 5.0 ,
119+ centerTitle: true ,
120+ leading: IconButton (
121+ icon: Icon (Icons .close),
122+ onPressed: () => Navigator .of (context).pop (),
123+ ),
124+ title: Text (widget.title ?? '' ),
125+ );
126+
139127 Widget get _albumTreeList => DecoratedBox (
140128 decoration: BoxDecoration (
141129 color: Theme .of (context).inputDecorationTheme.fillColor,
0 commit comments