From 2b5249e985b8944be6f63029ba28f58c6be521d1 Mon Sep 17 00:00:00 2001 From: ashrafzarkanisala Date: Mon, 7 Oct 2024 10:06:28 +0300 Subject: [PATCH] push firmware update --- .../one_gang_glass_batch_control_view.dart | 2 +- .../shared/batch_control/firmware_update.dart | 135 ++++++++++++++---- 2 files changed, 110 insertions(+), 27 deletions(-) diff --git a/lib/pages/device_managment/one_g_glass_switch/view/one_gang_glass_batch_control_view.dart b/lib/pages/device_managment/one_g_glass_switch/view/one_gang_glass_batch_control_view.dart index 7c0064c3..4239b08e 100644 --- a/lib/pages/device_managment/one_g_glass_switch/view/one_gang_glass_batch_control_view.dart +++ b/lib/pages/device_managment/one_g_glass_switch/view/one_gang_glass_batch_control_view.dart @@ -73,7 +73,7 @@ class OneGangGlassSwitchBatchControlView extends StatelessWidget ), FirmwareUpdateWidget( deviceId: deviceIds.first, - version: 12, // adjust the version according to your requirement + version: 12, ), FactoryResetWidget( callFactoryReset: () { diff --git a/lib/pages/device_managment/shared/batch_control/firmware_update.dart b/lib/pages/device_managment/shared/batch_control/firmware_update.dart index bb7c7516..095d3efc 100644 --- a/lib/pages/device_managment/shared/batch_control/firmware_update.dart +++ b/lib/pages/device_managment/shared/batch_control/firmware_update.dart @@ -1,43 +1,126 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:syncrow_web/pages/common/buttons/default_button.dart'; import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart'; import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/constants/assets.dart'; import 'package:syncrow_web/utils/extension/build_context_x.dart'; -class FirmwareUpdateWidget extends StatelessWidget { +class FirmwareUpdateWidget extends StatefulWidget { const FirmwareUpdateWidget( - {super.key, required String deviceId, required int version}); + {super.key, required this.deviceId, required this.version}); + + final String deviceId; + final int version; + + @override + State createState() => _FirmwareUpdateWidgetState(); +} + +class _FirmwareUpdateWidgetState extends State { + bool _showConfirmation = false; + + void _toggleConfirmation() { + setState(() { + _showConfirmation = !_showConfirmation; + }); + } @override Widget build(BuildContext context) { return DeviceControlsContainer( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - ClipOval( - child: Container( - color: ColorsManager.whiteColors, - height: 60, - width: 60, - child: Padding( - padding: const EdgeInsets.all(12.0), - child: SvgPicture.asset( - Assets.firmware, - fit: BoxFit.cover, + child: _showConfirmation + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Firmware Update', + style: context.textTheme.titleMedium!.copyWith( + fontWeight: FontWeight.bold, + color: ColorsManager.blackColor, + ), + ), + Text( + 'Are you sure?', + style: context.textTheme.bodySmall!.copyWith( + color: ColorsManager.grayColor, + ), + ), + const SizedBox(height: 16), + Row( + children: [ + Flexible( + child: DefaultButton( + height: 20, + elevation: 0, + padding: 0, + onPressed: _toggleConfirmation, + backgroundColor: ColorsManager.greyColor, + child: Text( + 'Cancel', + style: context.textTheme.bodyMedium!.copyWith( + color: ColorsManager.blackColor, + fontWeight: FontWeight.w400, + fontSize: 12, + ), + ), + ), + ), + const SizedBox(width: 8), + Flexible( + child: DefaultButton( + height: 20, + elevation: 0, + padding: 0, + onPressed: () { + _toggleConfirmation(); + }, + backgroundColor: ColorsManager.primaryColor, + child: Text( + 'Update', + style: context.textTheme.bodyMedium!.copyWith( + color: ColorsManager.whiteColors, + fontWeight: FontWeight.w400, + fontSize: 12, + ), + ), + ), + ), + ], + ), + ], + ) + : GestureDetector( + onTap: _toggleConfirmation, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + ClipOval( + child: Container( + color: ColorsManager.whiteColors, + height: 60, + width: 60, + child: Padding( + padding: const EdgeInsets.all(12.0), + child: SvgPicture.asset( + Assets.firmware, + fit: BoxFit.cover, + ), + ), + ), + ), + Text( + 'Firmware Update', + style: context.textTheme.titleMedium!.copyWith( + fontWeight: FontWeight.w400, + color: ColorsManager.blackColor, + ), + ), + ], ), ), - )), - Text( - 'Firmware Update', - style: context.textTheme.titleMedium!.copyWith( - fontWeight: FontWeight.w400, - color: ColorsManager.blackColor, - ), - ), - ], - ), ); } }