16
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
*/
18
18
19
- import 'dart:io' ;
20
-
21
19
import 'package:flutter/material.dart' ;
22
20
import 'package:flutter_gen/gen_l10n/app_localizations.dart' ;
23
21
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart' ;
24
22
import 'package:intl/intl.dart' ;
25
23
import 'package:provider/provider.dart' ;
24
+ import 'package:wger/helpers/platform.dart' ;
26
25
import 'package:wger/providers/gallery.dart' ;
27
26
import 'package:wger/screens/form_screen.dart' ;
28
27
@@ -40,76 +39,76 @@ class Gallery extends StatelessWidget {
40
39
child: RefreshIndicator (
41
40
onRefresh: () => provider.fetchAndSetGallery (),
42
41
child: MasonryGridView .count (
43
- crossAxisCount: 2 ,
44
- mainAxisSpacing: 5 ,
45
- crossAxisSpacing: 5 ,
46
- itemCount: provider.images.length,
47
- itemBuilder: (context, index) {
48
- final currentImage = provider.images[index];
42
+ crossAxisCount: 2 ,
43
+ mainAxisSpacing: 5 ,
44
+ crossAxisSpacing: 5 ,
45
+ itemCount: provider.images.length,
46
+ itemBuilder: (context, index) {
47
+ final currentImage = provider.images[index];
49
48
50
- return GestureDetector (
51
- onTap: () {
52
- showModalBottomSheet (
53
- builder: (context) => Material (
54
- child: Container (
55
- key: Key ('image-${currentImage .id }-detail' ),
56
- padding: const EdgeInsets .all (10 ),
57
- color: Colors .white,
58
- child: Column (
49
+ return GestureDetector (
50
+ onTap: () {
51
+ showModalBottomSheet (
52
+ builder: (context) => Container (
53
+ key: Key ('image-${currentImage .id }-detail' ),
54
+ padding: const EdgeInsets .all (10 ),
55
+ color: Colors .white,
56
+ child: Column (
57
+ children: [
58
+ Text (
59
+ DateFormat .yMd (Localizations .localeOf (context).languageCode)
60
+ .format (currentImage.date),
61
+ style: Theme .of (context).textTheme.headline5,
62
+ ),
63
+ Expanded (
64
+ child: Image .network (currentImage.url! ),
65
+ ),
66
+ Padding (
67
+ padding: const EdgeInsets .symmetric (vertical: 8 ),
68
+ child: Text (currentImage.description),
69
+ ),
70
+ Row (
71
+ mainAxisAlignment: MainAxisAlignment .center,
59
72
children: [
60
- Text (
61
- DateFormat .yMd (Localizations .localeOf (context).languageCode)
62
- .format (currentImage.date),
63
- style: Theme .of (context).textTheme.headline5,
64
- ),
65
- Expanded (
66
- child: Image .network (currentImage.url! ),
67
- ),
68
- Padding (
69
- padding: const EdgeInsets .symmetric (vertical: 8 ),
70
- child: Text (currentImage.description),
71
- ),
72
- Row (
73
- mainAxisAlignment: MainAxisAlignment .center,
74
- children: [
75
- IconButton (
76
- icon: const Icon (Icons .delete),
77
- onPressed: () {
78
- Provider .of <GalleryProvider >(context, listen: false )
79
- .deleteImage (currentImage);
80
- Navigator .of (context).pop ();
81
- }),
82
- if (! (Platform .isLinux || Platform .isMacOS))
83
- IconButton (
84
- icon: const Icon (Icons .edit),
85
- onPressed: () {
86
- Navigator .pushNamed (
87
- context,
88
- FormScreen .routeName,
89
- arguments: FormScreenArguments (
90
- AppLocalizations .of (context).edit,
91
- ImageForm (currentImage),
92
- hasListView: true ,
93
- ),
94
- );
95
- }),
96
- ],
97
- )
73
+ IconButton (
74
+ icon: const Icon (Icons .delete),
75
+ onPressed: () {
76
+ Provider .of <GalleryProvider >(context, listen: false )
77
+ .deleteImage (currentImage);
78
+ Navigator .of (context).pop ();
79
+ }),
80
+ if (! isDesktop)
81
+ IconButton (
82
+ icon: const Icon (Icons .edit),
83
+ onPressed: () {
84
+ Navigator .pushNamed (
85
+ context,
86
+ FormScreen .routeName,
87
+ arguments: FormScreenArguments (
88
+ AppLocalizations .of (context).edit,
89
+ ImageForm (currentImage),
90
+ hasListView: true ,
91
+ ),
92
+ );
93
+ },
94
+ ),
98
95
],
99
- ),
100
- ) ,
96
+ )
97
+ ] ,
101
98
),
102
- context: context,
103
- );
104
- },
105
- child: FadeInImage (
106
- key: Key ('image-${currentImage .id }' ),
107
- placeholder: const AssetImage ('assets/images/placeholder.png' ),
108
- image: NetworkImage (currentImage.url! ),
109
- fit: BoxFit .cover,
110
- ),
111
- );
112
- }),
99
+ ),
100
+ context: context,
101
+ );
102
+ },
103
+ child: FadeInImage (
104
+ key: Key ('image-${currentImage .id }' ),
105
+ placeholder: const AssetImage ('assets/images/placeholder.png' ),
106
+ image: NetworkImage (currentImage.url! ),
107
+ fit: BoxFit .cover,
108
+ ),
109
+ );
110
+ },
111
+ ),
113
112
),
114
113
);
115
114
}
0 commit comments