diff --git a/lib/features/scene/view/scene_auto_settings.dart b/lib/features/scene/view/scene_auto_settings.dart index fe39b09..d73d268 100644 --- a/lib/features/scene/view/scene_auto_settings.dart +++ b/lib/features/scene/view/scene_auto_settings.dart @@ -5,109 +5,84 @@ import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart'; import 'package:syncrow_app/features/scene/view/scene_tasks_view.dart'; import 'package:syncrow_app/features/scene/widgets/effective_period_setting/effective_period_bottom_sheet.dart'; import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart'; -import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart'; -import 'package:syncrow_app/generated/assets.dart'; +import 'package:syncrow_app/features/shared_widgets/default_container.dart'; +import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart'; import 'package:syncrow_app/utils/context_extension.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; -import 'package:syncrow_app/utils/resource_manager/font_manager.dart'; class SceneAutoSettings extends StatelessWidget { const SceneAutoSettings({super.key}); @override Widget build(BuildContext context) { - final sceneSettings = - ModalRoute.of(context)!.settings.arguments as Map? ?? - {}; + final sceneSettings = ModalRoute.of(context)!.settings.arguments as Map? ?? {}; final sceneId = sceneSettings['sceneId'] as String? ?? ''; - final isAutomation = context.read().sceneType == - CreateSceneEnum.deviceStatusChanges; + final isAutomation = + context.read().sceneType == CreateSceneEnum.deviceStatusChanges; final sceneName = sceneSettings['sceneName'] as String? ?? ''; - return Scaffold( - backgroundColor: ColorsManager.backgroundColor, - appBar: AppBar( - centerTitle: true, - backgroundColor: ColorsManager.backgroundColor, - title: const BodyLarge( - text: "Settings", - fontColor: ColorsManager.secondaryColor, - fontWeight: FontsManager.bold, - ), - ), - body: Stack( - children: [ - Container( - width: double.infinity, - height: context.height, - decoration: const BoxDecoration( - color: ColorsManager.backgroundColor, - image: DecorationImage( - image: AssetImage( - Assets.assetsImagesBackground, - ), - fit: BoxFit.cover, - opacity: 0.4, - ), - ), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 16), - child: Container( - decoration: const BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all(Radius.circular(16)), - ), - constraints: const BoxConstraints( - maxWidth: 600, - maxHeight: 300, - ), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - const SizedBox( - height: 8, - ), - Visibility( - visible: isAutomation == true, - child: SceneListTile( - padding: const EdgeInsets.symmetric( - horizontal: 16, vertical: 8), - titleString: "Effective Period", - trailingWidget: - const Icon(Icons.arrow_forward_ios_rounded), - onPressed: () { - context.customBottomSheet( - child: const EffectPeriodBottomSheetContent(), - ); - }, + return DefaultScaffold( + title: 'Settings', + padding: EdgeInsets.zero, + leading: IconButton( + onPressed: () { + Navigator.of(context).pop(); + }, + icon: const Icon( + Icons.arrow_back_ios, + )), + child: SizedBox( + height: MediaQuery.sizeOf(context).height, + child: Column( + children: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 16), + child: DefaultContainer( + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const SizedBox( + height: 8, ), - ), - Visibility( - visible: sceneName.isNotEmpty, - child: SizedBox( - width: context.width * 0.9, - child: const Divider( - color: ColorsManager.greyColor, + Visibility( + visible: isAutomation, + child: SceneListTile( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + titleString: "Effective Period", + trailingWidget: const Icon(Icons.arrow_forward_ios_rounded), + onPressed: () { + context.customBottomSheet( + child: const EffectPeriodBottomSheetContent(), + ); + }, ), ), - ), - Visibility( - visible: sceneName.isNotEmpty, - child: DeleteBottomSheetContent( - isAutomation: isAutomation, - sceneId: sceneId, + Visibility( + visible: sceneName.isNotEmpty && isAutomation, + child: SizedBox( + width: context.width * 0.9, + child: const Divider( + color: ColorsManager.greyColor, + ), + ), ), - ), - const SizedBox( - height: 16, - ), - ], + Visibility( + visible: sceneName.isNotEmpty, + child: DeleteBottomSheetContent( + isAutomation: isAutomation, + sceneId: sceneId, + ), + ), + const SizedBox( + height: 16, + ), + ], + ), ), ), - ), - ], + ], + ), ), ); } diff --git a/lib/features/scene/view/smart_automation_select_route.dart b/lib/features/scene/view/smart_automation_select_route.dart index 76efd84..5126a0d 100644 --- a/lib/features/scene/view/smart_automation_select_route.dart +++ b/lib/features/scene/view/smart_automation_select_route.dart @@ -29,55 +29,58 @@ class SmartAutomationSelectView extends StatelessWidget { icon: const Icon( Icons.arrow_back_ios, )), - height: sceneType.name == CreateSceneEnum.deviceStatusChanges.name - ? 260 - : 200, - child: DefaultContainer( - width: double.infinity, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Visibility( - visible: - sceneType.name == CreateSceneEnum.deviceStatusChanges.name, - child: SceneListTile( - assetPath: Assets.handClickIcon, - titleString: "Tap To Run", - subtitleString: '', - trailingWidget: const Icon( - Icons.arrow_forward_ios_rounded, - color: ColorsManager.greyColor, + // height: sceneType.name == CreateSceneEnum.deviceStatusChanges.name + // ? 260 + // : 200, + height: MediaQuery.sizeOf(context).height, + child: Column( + children: [ + DefaultContainer( + width: double.infinity, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Visibility( + visible: sceneType.name == CreateSceneEnum.deviceStatusChanges.name, + child: SceneListTile( + assetPath: Assets.handClickIcon, + titleString: "Tap To Run", + subtitleString: '', + trailingWidget: const Icon( + Icons.arrow_forward_ios_rounded, + color: ColorsManager.greyColor, + ), + onPressed: () { + context.customBottomSheet( + child: const SmartEnableTabRun(), + ); + }, + ), ), - onPressed: () { - context.customBottomSheet( - child: const SmartEnableTabRun(), - ); - }, - ), + Visibility( + visible: sceneType.name == CreateSceneEnum.deviceStatusChanges.name, + child: const Divider( + color: ColorsManager.dividerColor, + ), + ), + SceneListTile( + assetPath: Assets.refreshIcon, + titleString: "Automation", + subtitleString: '', + trailingWidget: const Icon( + Icons.arrow_forward_ios_rounded, + color: ColorsManager.greyColor, + ), + onPressed: () { + context.customBottomSheet( + child: const SmartEnableAutomation(), + ); + }, + ), + ], ), - Visibility( - visible: - sceneType.name == CreateSceneEnum.deviceStatusChanges.name, - child: const Divider( - color: ColorsManager.dividerColor, - ), - ), - SceneListTile( - assetPath: Assets.refreshIcon, - titleString: "Automation", - subtitleString: '', - trailingWidget: const Icon( - Icons.arrow_forward_ios_rounded, - color: ColorsManager.greyColor, - ), - onPressed: () { - context.customBottomSheet( - child: const SmartEnableAutomation(), - ); - }, - ), - ], - ), + ), + ], ), ); } diff --git a/lib/features/scene/widgets/effective_period_setting/effective_period_bottom_sheet.dart b/lib/features/scene/widgets/effective_period_setting/effective_period_bottom_sheet.dart index 659f163..68f829e 100644 --- a/lib/features/scene/widgets/effective_period_setting/effective_period_bottom_sheet.dart +++ b/lib/features/scene/widgets/effective_period_setting/effective_period_bottom_sheet.dart @@ -1,14 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:syncrow_app/features/scene/helper/effect_period_helper.dart'; import 'package:syncrow_app/features/scene/widgets/effective_period_setting/period_options.dart'; import 'package:syncrow_app/features/scene/widgets/effective_period_setting/repeat_days.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart'; -import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart'; -import 'package:syncrow_app/utils/context_extension.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; import 'package:syncrow_app/utils/resource_manager/font_manager.dart'; -import '../../helper/effect_period_helper.dart'; - class EffectPeriodBottomSheetContent extends StatelessWidget { const EffectPeriodBottomSheetContent({super.key}); @@ -22,17 +19,18 @@ class EffectPeriodBottomSheetContent extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + // Expanded( + // child: TextButton( + // onPressed: () => Navigator.pop(context), + // child: BodySmall( + // text: 'Save', + // style: + // context.bodySmall.copyWith(color: ColorsManager.primaryColorWithOpacity), + // )), + // ), + const Spacer(), Expanded( - child: TextButton( - onPressed: () => Navigator.pop(context), - child: BodySmall( - text: 'Save', - style: context.bodySmall.copyWith( - color: ColorsManager.primaryColorWithOpacity), - )), - ), - Expanded( - flex: 2, + // flex: 2, child: BodyMedium( text: 'Effective Period', fontColor: ColorsManager.primaryColorWithOpacity, diff --git a/lib/features/scene/widgets/select_smart_scene/smart_automation_list.dart b/lib/features/scene/widgets/select_smart_scene/smart_automation_list.dart index 8ea2aaa..fad1025 100644 --- a/lib/features/scene/widgets/select_smart_scene/smart_automation_list.dart +++ b/lib/features/scene/widgets/select_smart_scene/smart_automation_list.dart @@ -7,7 +7,6 @@ import 'package:syncrow_app/features/scene/model/scenes_model.dart'; import 'package:syncrow_app/features/scene/model/smart_scene_enable.dart'; import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart'; -import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart'; import 'package:syncrow_app/generated/assets.dart'; import 'package:syncrow_app/utils/context_extension.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; @@ -21,12 +20,10 @@ class SmartSceneSelectAutomationList extends StatefulWidget { final List automationList; @override - State createState() => - _SmartSceneSelectAutomationListState(); + State createState() => _SmartSceneSelectAutomationListState(); } -class _SmartSceneSelectAutomationListState - extends State { +class _SmartSceneSelectAutomationListState extends State { final List colorList = _generateDarkColors(100); static List _generateDarkColors(int count) { @@ -34,8 +31,7 @@ class _SmartSceneSelectAutomationListState final colors = []; while (colors.length < count) { - final color = - Color((random.nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0); + final color = Color((random.nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0); if (_isDark(color)) { colors.add(color); } @@ -44,8 +40,7 @@ class _SmartSceneSelectAutomationListState } static bool _isDark(Color color) { - final brightness = - ((color.red * 299) + (color.green * 587) + (color.blue * 114)) / 1000; + final brightness = ((color.red * 299) + (color.green * 587) + (color.blue * 114)) / 1000; return brightness < 128; } @@ -57,15 +52,16 @@ class _SmartSceneSelectAutomationListState Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded( - child: TextButton( - onPressed: () => Navigator.pop(context), - child: BodySmall( - text: 'Save', - style: context.bodySmall - .copyWith(color: ColorsManager.primaryColorWithOpacity), - )), - ), + // Expanded( + // child: TextButton( + // onPressed: () => Navigator.pop(context), + // child: BodySmall( + // text: 'Save', + // style: context.bodySmall + // .copyWith(color: ColorsManager.primaryColorWithOpacity), + // )), + // ), + const Spacer(), Expanded( flex: 2, child: Padding( @@ -74,8 +70,7 @@ class _SmartSceneSelectAutomationListState text: 'Automation', textAlign: TextAlign.center, style: context.bodyMedium.copyWith( - color: ColorsManager.primaryColorWithOpacity, - fontWeight: FontWeight.bold), + color: ColorsManager.primaryColorWithOpacity, fontWeight: FontWeight.bold), ), ), ), @@ -97,12 +92,9 @@ class _SmartSceneSelectAutomationListState itemCount: widget.automationList.length, itemBuilder: (context, index) { final automation = widget.automationList[index]; - final isSelected = - smartSceneEnable?.entityId == automation.id; + final isSelected = smartSceneEnable?.entityId == automation.id; final descriptionSelected = isSelected - ? (smartSceneEnable?.actionExecutor == 'rule_enable' - ? 'Enable' - : 'Disable') + ? (smartSceneEnable?.actionExecutor == 'rule_enable' ? 'Enable' : 'Disable') : automation.status == 'enable' ? 'Enable' : 'Disable'; @@ -136,17 +128,14 @@ class _SmartSceneSelectAutomationListState Navigator.pop(context); }, onDismiss: () { - context - .read() - .add(const SmartSceneClearEvent()); + context.read().add(const SmartSceneClearEvent()); Navigator.pop(context); }, ); }, label: BodyMedium( text: _capitalizeFirst(descriptionSelected), - style: context.bodyMedium - .copyWith(color: ColorsManager.greyColor), + style: context.bodyMedium.copyWith(color: ColorsManager.greyColor), ), icon: const Icon( Icons.arrow_forward_ios_rounded, @@ -173,9 +162,7 @@ class _SmartSceneSelectAutomationListState Navigator.pop(context); }, onDismiss: () { - context - .read() - .add(const SmartSceneClearEvent()); + context.read().add(const SmartSceneClearEvent()); Navigator.pop(context); }, ); @@ -211,12 +198,10 @@ class EnableDisableAutomationDialog extends StatefulWidget { final String type; @override - State createState() => - _EnableDisableAutomationDialogState(); + State createState() => _EnableDisableAutomationDialogState(); } -class _EnableDisableAutomationDialogState - extends State { +class _EnableDisableAutomationDialogState extends State { String? groupValue; final List values = [ SceneOperationalValue( @@ -234,16 +219,14 @@ class _EnableDisableAutomationDialogState @override void initState() { super.initState(); - groupValue = - widget.descriptionSelected == 'Enable' ? 'rule_enable' : 'rule_disable'; + groupValue = widget.descriptionSelected == 'Enable' ? 'rule_enable' : 'rule_disable'; - context.read().add(SmartSceneEnableEvent( - SmartSceneEnable( - entityId: widget.automationId, - actionExecutor: groupValue!, - sceneORAutomationName: widget.sceneORAutomationName, - type: widget.type, - isAutomation: true))); + context.read().add(SmartSceneEnableEvent(SmartSceneEnable( + entityId: widget.automationId, + actionExecutor: groupValue!, + sceneORAutomationName: widget.sceneORAutomationName, + type: widget.type, + isAutomation: true))); } @override @@ -269,14 +252,11 @@ class _EnableDisableAutomationDialogState setState(() { groupValue = value; }); - context - .read() - .add(SmartSceneEnableEvent( + context.read().add(SmartSceneEnableEvent( SmartSceneEnable( entityId: widget.automationId, actionExecutor: value!, - sceneORAutomationName: - widget.sceneORAutomationName, + sceneORAutomationName: widget.sceneORAutomationName, type: widget.type, isAutomation: true), )); @@ -286,9 +266,7 @@ class _EnableDisableAutomationDialogState setState(() { groupValue = operation.value; }); - context - .read() - .add(SmartSceneEnableEvent( + context.read().add(SmartSceneEnableEvent( SmartSceneEnable( entityId: widget.automationId, actionExecutor: operation.value, diff --git a/lib/features/scene/widgets/select_smart_scene/smart_tab_run_list.dart b/lib/features/scene/widgets/select_smart_scene/smart_tab_run_list.dart index 6d6b65d..502d69d 100644 --- a/lib/features/scene/widgets/select_smart_scene/smart_tab_run_list.dart +++ b/lib/features/scene/widgets/select_smart_scene/smart_tab_run_list.dart @@ -5,7 +5,6 @@ import 'package:syncrow_app/features/scene/model/scenes_model.dart'; import 'package:syncrow_app/features/scene/model/smart_scene_enable.dart'; import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart'; -import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart'; import 'package:syncrow_app/generated/assets.dart'; import 'package:syncrow_app/utils/context_extension.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; @@ -18,12 +17,10 @@ class SmartSceneSelectTabToRunList extends StatefulWidget { final List scenes; @override - State createState() => - _SmartSceneSelectTabToRunListState(); + State createState() => _SmartSceneSelectTabToRunListState(); } -class _SmartSceneSelectTabToRunListState - extends State { +class _SmartSceneSelectTabToRunListState extends State { String groupValue = ''; @override @@ -34,15 +31,16 @@ class _SmartSceneSelectTabToRunListState Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded( - child: TextButton( - onPressed: () => Navigator.pop(context), - child: BodySmall( - text: 'Save', - style: context.bodySmall - .copyWith(color: ColorsManager.primaryColorWithOpacity), - )), - ), + // Expanded( + // child: TextButton( + // onPressed: () => Navigator.pop(context), + // child: BodySmall( + // text: 'Save', + // style: context.bodySmall + // .copyWith(color: ColorsManager.primaryColorWithOpacity), + // )), + // ), + const Spacer(), Expanded( flex: 2, child: Padding( @@ -51,8 +49,7 @@ class _SmartSceneSelectTabToRunListState text: 'Tab To Run', textAlign: TextAlign.center, style: context.bodyMedium.copyWith( - color: ColorsManager.primaryColorWithOpacity, - fontWeight: FontWeight.bold), + color: ColorsManager.primaryColorWithOpacity, fontWeight: FontWeight.bold), ), ), ), @@ -68,8 +65,7 @@ class _SmartSceneSelectTabToRunListState itemCount: widget.scenes.length, itemBuilder: (context, index) { final scene = widget.scenes[index]; - final selectedScene = - context.read().smartSceneEnable; + final selectedScene = context.read().smartSceneEnable; if (selectedScene != null) { if (scene.id == selectedScene.entityId) { groupValue = scene.id; @@ -111,9 +107,7 @@ class _SmartSceneSelectTabToRunListState setState(() { groupValue = scene.id; }); - context - .read() - .add(SmartSceneEnableEvent(SmartSceneEnable( + context.read().add(SmartSceneEnableEvent(SmartSceneEnable( entityId: scene.id, actionExecutor: 'rule_enable', sceneORAutomationName: scene.name,