@@ -25,14 +25,22 @@ class GridList<T> extends StatelessWidget {
2525 required this .provider,
2626 this .viewLongList,
2727 required this .onSelect,
28- this .visibleRowCount,
28+ required this .createListItem,
29+ this .heightOverride,
30+ this .longBottomSheetHeightOverride,
31+ this .longBottomSheetAspectRatio = 0.73 ,
32+ this .itemAspectRatio = 0.85 ,
2933 });
3034
3135 final GridListState state;
3236 final GridListProvider <T > provider;
3337 final void Function ()? viewLongList;
3438 final void Function (T ) onSelect;
35- final int ? visibleRowCount;
39+ final Widget Function (GridListItemModel <T >, double ) createListItem;
40+ final double ? heightOverride;
41+ final double ? longBottomSheetHeightOverride;
42+ final double longBottomSheetAspectRatio;
43+ final double itemAspectRatio;
3644
3745 @override
3846 Widget build (BuildContext context) {
@@ -91,8 +99,10 @@ class GridList<T> extends StatelessWidget {
9199 break ;
92100 }
93101
94- if (visibleRowCount != null ) {
95- height = 120.0 * visibleRowCount! ;
102+ if (longBottomSheet && longBottomSheetHeightOverride != null ) {
103+ height = longBottomSheetHeightOverride! ;
104+ } else if (! longBottomSheet && heightOverride != null ) {
105+ height = heightOverride! ;
96106 }
97107
98108 if (value.isEmpty) {
@@ -122,14 +132,16 @@ class GridList<T> extends StatelessWidget {
122132 }
123133
124134 return Container (
125- padding: const EdgeInsets .all ( 8.0 ),
135+ padding: const EdgeInsets .symmetric (horizontal : 8.0 ),
126136 height: height,
127137 child: GridView .builder (
128138 key: Key ('${value .length }' ),
129139 itemCount: itemCount,
130140 gridDelegate: SliverGridDelegateWithFixedCrossAxisCount (
131141 crossAxisCount: longBottomSheet ? 8 : 4 ,
132- childAspectRatio: longBottomSheet ? 0.73 : 0.85 ,
142+ childAspectRatio: longBottomSheet
143+ ? longBottomSheetAspectRatio
144+ : itemAspectRatio,
133145 ),
134146 itemBuilder: (context, index) {
135147 if (index == itemCount - 1 &&
@@ -143,15 +155,12 @@ class GridList<T> extends StatelessWidget {
143155 } else {
144156 return GridListItem (
145157 key: Key (value[index].title),
146- title: value[index].title,
147- description: value[index].description,
148158 onSelect: () => onSelect (value[index].data),
149- child: WalletImage (
150- imageUrl: value[index].image,
151- imageSize: size.height < 700.0
152- ? GridList .smallTileSize
153- : GridList .tileSize,
154- ),
159+ child: createListItem (
160+ value[index],
161+ size.height < 700.0
162+ ? GridList .smallTileSize
163+ : GridList .tileSize),
155164 );
156165 }
157166 },
@@ -168,7 +177,9 @@ class GridList<T> extends StatelessWidget {
168177 ) {
169178 final WalletConnectModalThemeData themeData =
170179 WalletConnectModalTheme .getData (context);
171- final size = MediaQuery .of (context).size;
180+ final Size size = MediaQuery .of (context).size;
181+ final tileSize =
182+ size.height < 700.0 ? GridList .smallTileSize : GridList .tileSize;
172183
173184 List <Widget > images = [];
174185
@@ -180,37 +191,50 @@ class GridList<T> extends StatelessWidget {
180191 images.add (
181192 WalletImage (
182193 imageUrl: items[startIndex + i].image,
183- imageSize: GridList . tileSize / 3.0 ,
194+ imageSize: tileSize / 3.0 ,
184195 ),
185196 );
186197 }
187198
188199 return GridListItem (
189200 key: WalletConnectModalConstants .gridListViewAllButtonKey,
190- title: 'View All' ,
191201 onSelect: viewLongList ?? () {},
192- child: Container (
193- width: GridList .tileSize,
194- height:
195- size.height < 700.0 ? GridList .smallTileSize : GridList .tileSize,
196- padding: const EdgeInsets .all (2.0 ),
197- decoration: BoxDecoration (
198- color: themeData.background200,
199- border: Border .all (
200- color: themeData.overlay010,
201- strokeAlign: BorderSide .strokeAlignOutside,
202- ),
203- borderRadius: BorderRadius .circular (
204- GridList .getTileBorderRadius (GridList .tileSize),
202+ child: Column (
203+ children: [
204+ Container (
205+ width: tileSize,
206+ height: tileSize,
207+ padding: const EdgeInsets .all (2.0 ),
208+ decoration: BoxDecoration (
209+ color: themeData.background200,
210+ border: Border .all (
211+ color: themeData.overlay010,
212+ strokeAlign: BorderSide .strokeAlignOutside,
213+ ),
214+ borderRadius: BorderRadius .circular (
215+ GridList .getTileBorderRadius (GridList .tileSize),
216+ ),
217+ ),
218+ child: Center (
219+ child: Wrap (
220+ spacing: 4.0 ,
221+ runSpacing: 4.0 ,
222+ children: images,
223+ ),
224+ ),
205225 ),
206- ),
207- child: Center (
208- child: Wrap (
209- spacing: 4.0 ,
210- runSpacing: 4.0 ,
211- children: images,
226+ const SizedBox (height: 4.0 ),
227+ Text (
228+ 'View All' ,
229+ textAlign: TextAlign .center,
230+ maxLines: 1 ,
231+ overflow: TextOverflow .clip,
232+ style: TextStyle (
233+ fontSize: 12.0 ,
234+ color: themeData.foreground100,
235+ ),
212236 ),
213- ) ,
237+ ] ,
214238 ),
215239 );
216240 }
0 commit comments