@@ -16,6 +16,7 @@ import 'package:cloudotp/Widgets/Item/item_builder.dart';
1616import 'package:context_menus/context_menus.dart' ;
1717import 'package:flutter/material.dart' ;
1818import 'package:flutter/services.dart' ;
19+ import 'package:flutter_slidable/flutter_slidable.dart' ;
1920import 'package:move_to_background/move_to_background.dart' ;
2021import 'package:provider/provider.dart' ;
2122import 'package:window_manager/window_manager.dart' ;
@@ -204,18 +205,122 @@ class TokenLayoutState extends State<TokenLayout>
204205 );
205206 }
206207
208+ _buildSlidable ({
209+ required Widget child,
210+ bool simple = false ,
211+ double startExtentRatio = 0.16 ,
212+ double endExtentRatio = 0.64 ,
213+ }) {
214+ return Slidable (
215+ groupTag: "TokenLayout" ,
216+ enabled: ! ResponsiveUtil .isWideLandscape (),
217+ startActionPane: ActionPane (
218+ extentRatio: startExtentRatio,
219+ motion: const ScrollMotion (),
220+ children: [
221+ SlidableAction (
222+ onPressed: (context) => _processPin (),
223+ backgroundColor: widget.token.pinned
224+ ? Theme .of (context).primaryColor
225+ : Theme .of (context).cardColor,
226+ borderRadius: const BorderRadius .all (Radius .circular (12 )),
227+ foregroundColor: Theme .of (context).primaryColor,
228+ icon: widget.token.pinned
229+ ? Icons .push_pin_rounded
230+ : Icons .push_pin_outlined,
231+ label: widget.token.pinned
232+ ? S .current.unPinTokenShort
233+ : S .current.pinTokenShort,
234+ simple: simple,
235+ spacing: 8 ,
236+ padding: const EdgeInsets .symmetric (horizontal: 4 ),
237+ iconAndTextColor: widget.token.pinned ? Colors .white : null ,
238+ ),
239+ const SizedBox (width: 6 ),
240+ ],
241+ ),
242+ endActionPane: ActionPane (
243+ extentRatio: endExtentRatio,
244+ motion: const ScrollMotion (),
245+ children: [
246+ const SizedBox (width: 6 ),
247+ SlidableAction (
248+ onPressed: (context) => _processViewQrCode (),
249+ backgroundColor: Theme .of (context).cardColor,
250+ borderRadius: const BorderRadius .all (Radius .circular (12 )),
251+ foregroundColor: Theme .of (context).primaryColor,
252+ icon: Icons .qr_code_rounded,
253+ label: S .current.viewTokenQrCodeShort,
254+ spacing: 8 ,
255+ simple: simple,
256+ padding: const EdgeInsets .symmetric (horizontal: 4 ),
257+ ),
258+ const SizedBox (width: 6 ),
259+ SlidableAction (
260+ onPressed: (context) => _processEdit (),
261+ backgroundColor: Theme .of (context).cardColor,
262+ borderRadius: const BorderRadius .all (Radius .circular (12 )),
263+ foregroundColor: Theme .of (context).primaryColor,
264+ icon: Icons .edit_outlined,
265+ padding: const EdgeInsets .symmetric (horizontal: 4 ),
266+ label: S .current.editTokenShort,
267+ simple: simple,
268+ spacing: 8 ,
269+ ),
270+ const SizedBox (width: 6 ),
271+ SlidableAction (
272+ onPressed: (context) => showContextMenu (),
273+ backgroundColor: Theme .of (context).cardColor,
274+ borderRadius: const BorderRadius .all (Radius .circular (12 )),
275+ foregroundColor: Theme .of (context).primaryColor,
276+ icon: Icons .more_vert_rounded,
277+ padding: const EdgeInsets .symmetric (horizontal: 4 ),
278+ label: S .current.moreOptionShort,
279+ simple: simple,
280+ spacing: 8 ,
281+ ),
282+ const SizedBox (width: 6 ),
283+ SlidableAction (
284+ onPressed: (context) => _processDelete (),
285+ backgroundColor: Colors .red,
286+ borderRadius: const BorderRadius .all (Radius .circular (12 )),
287+ foregroundColor: Theme .of (context).primaryColor,
288+ icon: Icons .delete,
289+ simple: simple,
290+ label: S .current.deleteTokenShort,
291+ padding: const EdgeInsets .symmetric (horizontal: 4 ),
292+ spacing: 8 ,
293+ iconAndTextColor: Colors .white,
294+ ),
295+ ],
296+ ),
297+ child: child,
298+ );
299+ }
300+
207301 _buildBody () {
208302 switch (widget.layoutType) {
209303 case LayoutType .Simple :
210304 return _buildSimpleLayout ();
211305 case LayoutType .Compact :
212306 return _buildCompactLayout ();
213- case LayoutType .Tile :
214- return _buildTileLayout ();
307+ // case LayoutType.Tile:
308+ // return _buildSlidable(
309+ // startExtentRatio: 0.23,
310+ // endExtentRatio: 0.9,
311+ // child: _buildTileLayout(),
312+ // );
215313 case LayoutType .List :
216- return _buildListLayout ();
314+ return _buildSlidable (
315+ simple: true ,
316+ child: _buildListLayout (),
317+ );
217318 case LayoutType .Spotlight :
218- return _buildSpotlightLayout ();
319+ return _buildSlidable (
320+ startExtentRatio: 0.21 ,
321+ endExtentRatio: 0.8 ,
322+ child: _buildSpotlightLayout (),
323+ );
219324 }
220325 }
221326
0 commit comments