Advertisement
harmonyV

Habit tile

Jun 17th, 2024
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 4.17 KB | None | 0 0
  1. return Padding(
  2.       padding: const EdgeInsets.symmetric(
  3.         vertical: 4.0,
  4.       ),
  5.       child: Slidable(
  6.         startActionPane: ActionPane(
  7.           motion: const StretchMotion(),
  8.           children: <SlidableAction>[
  9.             // edit HabitTile
  10.             SlidableAction(
  11.               backgroundColor: Theme.of(context).colorScheme.inversePrimary,
  12.               borderRadius: BorderRadius.circular(16),
  13.               onPressed: (context) {
  14.                 editHabitDialogBox();
  15.               },
  16.               icon: Icons.edit,
  17.               label: "Edit",
  18.             ),
  19.  
  20.             // delete HabitTile
  21.             SlidableAction(
  22.               backgroundColor: Colors.red,
  23.               borderRadius: BorderRadius.circular(16),
  24.               onPressed: (context) {
  25.                 deleteHabitDialogBox();
  26.               },
  27.               icon: Icons.delete,
  28.               label: "Delete",
  29.             )
  30.           ],
  31.         ),
  32.         child: GestureDetector(
  33.           onTap: () {
  34.             checkHabitOnAndOff(habit, !isCompleted);
  35.           },
  36.           child: Container(
  37.             decoration: BoxDecoration(
  38.                 color: Theme.of(context).colorScheme.primaryContainer,
  39.                 border: Border.all(
  40.                   color: Theme.of(context).colorScheme.outline,
  41.                 ),
  42.                 borderRadius: BorderRadius.circular(16)),
  43.             padding: const EdgeInsets.all(8),
  44.             child: Row(
  45.               mainAxisAlignment: MainAxisAlignment.spaceBetween,
  46.               mainAxisSize: MainAxisSize.max,
  47.               children: [
  48.                 Row(
  49.                   mainAxisSize: MainAxisSize.min,
  50.                   children: [
  51.                     Row(
  52.                       mainAxisAlignment: MainAxisAlignment.start,
  53.                       mainAxisSize: MainAxisSize.min,
  54.                       children: [
  55.                         Container(
  56.                           height: 67,
  57.                           width: 67,
  58.                           decoration: BoxDecoration(
  59.                               borderRadius: BorderRadius.circular(12),
  60.                               border: Border.all(color: Colors.blue)),
  61.                           child: const Icon(Icons.account_circle_outlined),
  62.                         ),
  63.                         const SizedBox(
  64.                           width: 8,
  65.                         ),
  66.                         const Column(
  67.                           crossAxisAlignment: CrossAxisAlignment.start,
  68.                           mainAxisSize: MainAxisSize.min,
  69.                           children: [
  70.                             MyLabel(labelText: "Label1", myIcon: Icons.person),
  71.                             SizedBox(
  72.                               height: 8,
  73.                             ),
  74.                             MyLabel(labelText: "Label2", myIcon: null)
  75.                           ],
  76.                         )
  77.                       ],
  78.                     ),
  79.                     const SizedBox(
  80.                       width: 8,
  81.                     ),
  82.                     // Text that isn't wraping to the second line
  83.                     Text(
  84.                       habit.name,
  85.                       style: Theme.of(context).textTheme.bodyMedium!.copyWith(
  86.                             color: Theme.of(context)
  87.                                 .colorScheme
  88.                                 .onSecondaryContainer,
  89.                           ),
  90.                       softWrap: true,
  91.                       maxLines: 2,
  92.                       overflow: TextOverflow.fade,
  93.                     ),
  94.                   ],
  95.                 ),
  96.                 Checkbox(
  97.                     activeColor: Colors.green,
  98.                     checkColor: Colors.white,
  99.                     shape: RoundedRectangleBorder(
  100.                       borderRadius: BorderRadius.circular(6),
  101.                     ),
  102.                     side: BorderSide(
  103.                         color: Theme.of(context).colorScheme.outline),
  104.                     value: isCompleted,
  105.                     onChanged: (value) => checkHabitOnAndOff(habit, value)),
  106.               ],
  107.             ),
  108.           ),
  109.         ),
  110.       ),
  111.     );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement