summaryrefslogtreecommitdiffstats
path: root/lib/presentation/common_widget/fan_bar.dart
diff options
context:
space:
mode:
authorLisandro Pérez Meyer <lpmeyer@ics.com>2023-11-14 17:20:58 -0300
committerLisandro Pérez Meyer <lpmeyer@ics.com>2023-11-14 17:31:12 -0300
commit70ec8a79a121471a004e7e4c23157d10157e136f (patch)
treea4f9c0a4fac4e4274ec4324a289b6ef62e1c5653 /lib/presentation/common_widget/fan_bar.dart
Initial cleanup push.
Based on agldemo2024 on commit 2a5dc04d801134338150c3f6afc67eaa65599763 Disable device preview. Disable Lottie animation. The original commit was b3c493c340fcb4bb0a937692838fc830bec3e9ea but I am just keeping this change, because the json did not really needed to change. I think. Signed-off-by: Lisandro Pérez Meyer <lpmeyer@ics.com>
Diffstat (limited to 'lib/presentation/common_widget/fan_bar.dart')
-rw-r--r--lib/presentation/common_widget/fan_bar.dart188
1 files changed, 188 insertions, 0 deletions
diff --git a/lib/presentation/common_widget/fan_bar.dart b/lib/presentation/common_widget/fan_bar.dart
new file mode 100644
index 0000000..e119089
--- /dev/null
+++ b/lib/presentation/common_widget/fan_bar.dart
@@ -0,0 +1,188 @@
+import '../../export.dart';
+import 'package:flutter_ics_homescreen/presentation/custom_icons/custom_icons.dart';
+
+enum FanMode { off, min, medium, max }
+
+class FanBar extends ConsumerStatefulWidget {
+ const FanBar({super.key});
+
+ @override
+ FanBarState createState() => FanBarState();
+}
+
+class FanBarState extends ConsumerState<FanBar> {
+ int selectedFanSpeed = 0;
+
+ @override
+ Widget build(BuildContext context) {
+ final vehicle = ref.watch(vehicleProvider.select((vehicle) => vehicle));
+ selectedFanSpeed = vehicle.fanSpeed;
+
+ return Column(children: [
+ Container(
+ padding: EdgeInsets.zero,
+ //width: 80,
+ height: 256,
+ decoration: const ShapeDecoration(
+ // gradient: RadialGradient(
+ // colors: [Color.fromARGB(255, 19, 24, 75), Colors.black],
+ // stops: [0, 0.9],
+ // radius: 1,
+ // ),
+ color: AGLDemoColors.buttonFillEnabledColor,
+ shape: StadiumBorder(
+ side: BorderSide(
+ color: Color(0xFF5477D4),
+ width: 1,
+ )),
+ ),
+ //alignment: Alignment.topLeft,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ mainAxisAlignment: MainAxisAlignment.spaceEvenly,
+ children: [
+ Material(
+ color: Colors.transparent,
+ child: SizedBox(
+ width: 80,
+ height: 64,
+ child: IconButton(
+ isSelected: selectedFanSpeed == 3,
+ padding: EdgeInsets.zero,
+ color: AGLDemoColors.periwinkleColor,
+ onPressed: () {
+ ref.read(vehicleProvider.notifier).updateFanSpeed(3);
+ },
+ icon: selectedFanSpeed == 3
+ ? Stack(
+ alignment: Alignment.center,
+ children: [
+ SvgPicture.asset('assets/fanButtonBg.svg'),
+ const Icon(
+ CustomIcons.fan_on_enabled,
+ color: Colors.white,
+ size: 40,
+ ),
+ ],
+ )
+ : const Icon(
+ CustomIcons.fan_on_enabled,
+ size: 40,
+ ),
+ ),
+ ),
+ ),
+ Material(
+ color: Colors.transparent,
+ child: SizedBox(
+ width: 64,
+ height: 64,
+ child: IconButton(
+ isSelected: selectedFanSpeed == 2,
+ padding: EdgeInsets.zero,
+ color: AGLDemoColors.periwinkleColor,
+ onPressed: () {
+ ref.read(vehicleProvider.notifier).updateFanSpeed(2);
+ },
+ icon: selectedFanSpeed == 2
+ ? Stack(
+ alignment: Alignment.center,
+ children: [
+ SvgPicture.asset('assets/fanButtonBg.svg'),
+ const Icon(
+ CustomIcons.fan_on_enabled,
+ color: Colors.white,
+ size: 28,
+ ),
+ ],
+ )
+ : const Icon(
+ CustomIcons.fan_on_enabled,
+ size: 28,
+ ),
+ ),
+ ),
+ ),
+ Material(
+ color: Colors.transparent,
+ child: SizedBox(
+ width: 64,
+ height: 64,
+ child: IconButton(
+ isSelected: selectedFanSpeed == 1,
+ iconSize: 20,
+ padding: EdgeInsets.zero,
+ color: AGLDemoColors.periwinkleColor,
+ onPressed: () {
+ ref.read(vehicleProvider.notifier).updateFanSpeed(1);
+ },
+ icon: selectedFanSpeed == 1
+ ? Stack(
+ alignment: Alignment.center,
+ children: [
+ SvgPicture.asset('assets/fanButtonBg.svg'),
+ const Icon(
+ CustomIcons.fan_on_enabled,
+ color: Colors.white,
+ size: 20,
+ ),
+ ],
+ )
+ : const Icon(
+ CustomIcons.fan_on_enabled,
+ size: 20,
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(height: 10),
+ Container(
+ width: 80,
+ height: 80,
+ decoration: const ShapeDecoration(
+ // gradient: RadialGradient(
+ // colors: [Color.fromARGB(255, 19, 24, 75), Colors.black],
+ // stops: [0, 0.9],
+ // radius: 1,
+ // ),
+ color: AGLDemoColors.buttonFillEnabledColor,
+ shape: StadiumBorder(
+ side: BorderSide(
+ color: Color(0xFF5477D4),
+ width: 1,
+ )),
+ ),
+ //alignment: Alignment.topLeft,
+ child: Material(
+ color: Colors.transparent,
+ child: IconButton(
+ isSelected: selectedFanSpeed == 0,
+ padding: EdgeInsets.zero,
+ color: AGLDemoColors.periwinkleColor,
+ onPressed: () {
+ ref.read(vehicleProvider.notifier).updateFanSpeed(0);
+ },
+ icon: selectedFanSpeed == 0
+ ? Stack(
+ alignment: Alignment.center,
+ children: [
+ SvgPicture.asset('assets/fanButtonBg.svg'),
+ const Icon(
+ Icons.mode_fan_off,
+ color: Colors.white,
+ size: 28.4,
+ ),
+ ],
+ )
+ : const Icon(
+ Icons.mode_fan_off,
+ size: 28.4,
+ ),
+ ),
+ )),
+ ]);
+ }
+}