Selaa lähdekoodia

fix asset AspectRatio

lucky1213 4 vuotta sitten
vanhempi
commit
6cd3e7b016
3 muutettua tiedostoa jossa 13 lisäystä ja 17 poistoa
  1. 2
    4
      lib/photo.dart
  2. 2
    6
      lib/src/entity/options.dart
  3. 9
    7
      lib/src/ui/page/photo_list_page.dart

+ 2
- 4
lib/photo.dart Näytä tiedosto

@@ -137,9 +137,8 @@ class PhotoPicker {
137 137
   static Widget buildGallery({
138 138
     @required BuildContext context,
139 139
     double padding = 1,
140
-    double itemHeight,
141
-    @required double itemWidth,
142 140
     int thumbSize = 180,
141
+    double itemRadio = 1.0,
143 142
     PhotoTheme theme,
144 143
     I18nProvider provider = I18nProvider.chinese,
145 144
     SortDelegate sortDelegate,
@@ -155,8 +154,7 @@ class PhotoPicker {
155 154
 
156 155
     var options = ListOptions(
157 156
       padding: padding,
158
-      itemHeight: itemHeight,
159
-      itemWidth: itemWidth,
157
+      itemRadio: itemRadio,
160 158
       theme: theme ?? PhotoTheme.fallback(context),
161 159
       thumbSize: thumbSize,
162 160
       sortDelegate: sortDelegate,

+ 2
- 6
lib/src/entity/options.dart Näytä tiedosto

@@ -45,16 +45,11 @@ class Options {
45 45
 
46 46
 class ListOptions extends Options {
47 47
 
48
-  final double itemWidth;
49
-
50
-  final double itemHeight;
51
-
52 48
   final Axis scrollDirection;
53 49
 
54 50
   const ListOptions({
55
-    this.itemHeight = double.infinity,
56
-    this.itemWidth,
57 51
     this.scrollDirection = Axis.horizontal,
52
+    double itemRadio,
58 53
     int maxSelected,
59 54
     double padding,
60 55
     PhotoTheme theme,
@@ -67,6 +62,7 @@ class ListOptions extends Options {
67 62
   }) : super(
68 63
     maxSelected: maxSelected,
69 64
     padding: padding,
65
+    itemRadio: itemRadio,
70 66
     theme: theme,
71 67
     thumbSize: thumbSize,
72 68
     sortDelegate: sortDelegate,

+ 9
- 7
lib/src/ui/page/photo_list_page.dart Näytä tiedosto

@@ -175,7 +175,6 @@ class _PhotoListPageState extends State<PhotoListPage>
175 175
       scrollDirection: options.scrollDirection,
176 176
       physics: ClampingScrollPhysics(),
177 177
       itemCount: count,
178
-      itemExtent: options.itemWidth,
179 178
       itemBuilder: _buildItem,
180 179
     );
181 180
   }
@@ -200,12 +199,15 @@ class _PhotoListPageState extends State<PhotoListPage>
200 199
           onTap: () => _onItemClick(data, index),
201 200
           child: Stack(
202 201
             children: <Widget>[
203
-              ImageItem(
204
-                entity: data,
205
-                themeColor: options.theme.primaryColor,
206
-                size: options.thumbSize,
207
-                loadingDelegate: options.loadingDelegate,
208
-                badgeDelegate: options.badgeDelegate,
202
+              AspectRatio(
203
+                aspectRatio: options.itemRadio,
204
+                child: ImageItem(
205
+                  entity: data,
206
+                  themeColor: options.theme.primaryColor,
207
+                  size: options.thumbSize,
208
+                  loadingDelegate: options.loadingDelegate,
209
+                  badgeDelegate: options.badgeDelegate,
210
+                ),
209 211
               ),
210 212
               _buildMask(containsEntity(data)),
211 213
               _buildSelected(data),