|
| 1 | +import 'package:flutter/cupertino.dart'; |
| 2 | +import 'package:flutter/material.dart'; |
| 3 | + |
| 4 | +class AppListItem extends StatelessWidget { |
| 5 | + final IconData? icon; |
| 6 | + final dynamic image; |
| 7 | + final String text; |
| 8 | + final bool isSwitch; |
| 9 | + final bool isActive; |
| 10 | + final bool isEnabled; |
| 11 | + final VoidCallback onTap; |
| 12 | + |
| 13 | + const AppListItem({ |
| 14 | + super.key, |
| 15 | + this.icon, |
| 16 | + this.image, |
| 17 | + required this.text, |
| 18 | + required this.isSwitch, |
| 19 | + required this.isActive, |
| 20 | + required this.isEnabled, |
| 21 | + required this.onTap, |
| 22 | + }); |
| 23 | + |
| 24 | + @override |
| 25 | + Widget build(BuildContext context) { |
| 26 | + Color getColor(Set<WidgetState> states) { |
| 27 | + return Theme.of(context).colorScheme.primary; |
| 28 | + } |
| 29 | + |
| 30 | + return GestureDetector( |
| 31 | + onTap: isEnabled ? onTap : null, |
| 32 | + child: Container( |
| 33 | + height: 52, |
| 34 | + margin: const EdgeInsets.symmetric(vertical: 8), |
| 35 | + decoration: BoxDecoration( |
| 36 | + color: Colors.white, |
| 37 | + borderRadius: BorderRadius.circular(10), |
| 38 | + boxShadow: [ |
| 39 | + BoxShadow( |
| 40 | +<<<<<<< HEAD |
| 41 | + color: Colors.grey.withValues(alpha: 0.2), |
| 42 | +||||||| parent of f5f79a8 (fix quality check) |
| 43 | + color: Colors.grey.withAlpha((255 * 0.2).toInt()), |
| 44 | +======= |
| 45 | + color: Colors.grey.withAlpha((255 * 0.2).toInt()), |
| 46 | +>>>>>>> f5f79a8 (fix quality check) |
| 47 | + blurRadius: 10, |
| 48 | + offset: const Offset(0, 1), |
| 49 | + ), |
| 50 | + ], |
| 51 | + ), |
| 52 | + child: Stack( |
| 53 | + children: [ |
| 54 | + Padding( |
| 55 | + padding: const EdgeInsets.all(0), |
| 56 | + child: Row( |
| 57 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 58 | + children: [ |
| 59 | + Row( |
| 60 | + children: [ |
| 61 | + if (icon != null) |
| 62 | + Icon( |
| 63 | + icon, |
| 64 | + size: 52, |
| 65 | + color: Theme.of(context).colorScheme.primary, |
| 66 | + ), |
| 67 | + if (image != null) |
| 68 | + image is String |
| 69 | + ? Image.asset(image!, width: 52, height: 52) |
| 70 | + : Image.memory(image!, width: 52, height: 52), |
| 71 | + if (icon == null && image == null) |
| 72 | + const SizedBox(width: 16), |
| 73 | + Container( |
| 74 | + alignment: Alignment.center, |
| 75 | + height: 52, |
| 76 | + child: Text( |
| 77 | + text, |
| 78 | + style: const TextStyle( |
| 79 | + fontSize: 16, |
| 80 | + color: Colors.black, |
| 81 | + ), |
| 82 | + ), |
| 83 | + ), |
| 84 | + ], |
| 85 | + ), |
| 86 | + isSwitch |
| 87 | + ? Transform.scale( |
| 88 | + scale: 0.7, |
| 89 | + child: CupertinoSwitch( |
| 90 | + value: isActive, |
| 91 | + onChanged: null, |
| 92 | + inactiveTrackColor: |
| 93 | + Theme.of(context).colorScheme.onSecondary, |
| 94 | + ), |
| 95 | + ) |
| 96 | + : Checkbox( |
| 97 | + value: isActive, |
| 98 | + onChanged: null, |
| 99 | + checkColor: Colors.white, |
| 100 | + fillColor: WidgetStateProperty.resolveWith((states) { |
| 101 | + if (!isActive) { |
| 102 | + return Theme.of(context).colorScheme.onSecondary; |
| 103 | + } |
| 104 | + return getColor(states); |
| 105 | + }), |
| 106 | + shape: RoundedRectangleBorder( |
| 107 | + borderRadius: BorderRadius.circular(4), |
| 108 | + ), |
| 109 | + side: WidgetStateBorderSide.resolveWith((states) { |
| 110 | + return BorderSide( |
| 111 | + color: Theme.of(context).colorScheme.onSecondary, |
| 112 | + width: 0.0, |
| 113 | + ); |
| 114 | + }), |
| 115 | + ), |
| 116 | + ], |
| 117 | + ), |
| 118 | + ), |
| 119 | + if (!isEnabled) |
| 120 | + Container( |
| 121 | + decoration: BoxDecoration( |
| 122 | +<<<<<<< HEAD |
| 123 | + color: Colors.grey.withValues(alpha: 0.4), |
| 124 | +||||||| parent of f5f79a8 (fix quality check) |
| 125 | + color: Colors.grey.withAlpha((255 * 0.2).toInt()), |
| 126 | +======= |
| 127 | + color: Colors.grey.withAlpha((255 * 0.2).toInt()), |
| 128 | +>>>>>>> f5f79a8 (fix quality check) |
| 129 | + borderRadius: BorderRadius.circular(10), |
| 130 | + ), |
| 131 | + ), |
| 132 | + ], |
| 133 | + ), |
| 134 | + ), |
| 135 | + ); |
| 136 | + } |
| 137 | +} |
0 commit comments