Selaa lähdekoodia

fix asset AspectRatio

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

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

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

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

175
       scrollDirection: options.scrollDirection,
175
       scrollDirection: options.scrollDirection,
176
       physics: ClampingScrollPhysics(),
176
       physics: ClampingScrollPhysics(),
177
       itemCount: count,
177
       itemCount: count,
178
-      itemExtent: options.itemWidth,
179
       itemBuilder: _buildItem,
178
       itemBuilder: _buildItem,
180
     );
179
     );
181
   }
180
   }
200
           onTap: () => _onItemClick(data, index),
199
           onTap: () => _onItemClick(data, index),
201
           child: Stack(
200
           child: Stack(
202
             children: <Widget>[
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
               _buildMask(containsEntity(data)),
212
               _buildMask(containsEntity(data)),
211
               _buildSelected(data),
213
               _buildSelected(data),