From 1407c173b0c82442dc146716fb71201916ccd07c Mon Sep 17 00:00:00 2001 From: Faris Armoush Date: Thu, 17 Apr 2025 13:28:00 +0300 Subject: [PATCH 1/8] tapping bugfix. --- lib/pages/space_tree/view/custom_expansion.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/space_tree/view/custom_expansion.dart b/lib/pages/space_tree/view/custom_expansion.dart index e4e7f423..dab0a49f 100644 --- a/lib/pages/space_tree/view/custom_expansion.dart +++ b/lib/pages/space_tree/view/custom_expansion.dart @@ -31,7 +31,7 @@ class CustomExpansionTileSpaceTree extends StatelessWidget { children: [ Checkbox( value: isSoldCheck ? null : isSelected, - onChanged: (value) => onItemSelected ?? () {}, + onChanged: (value) => onItemSelected?.call(), tristate: true, side: WidgetStateBorderSide.resolveWith( (states) => const BorderSide(color: ColorsManager.grayBorder), From 34fa426163a3224774c4011331938b35ef18f9a3 Mon Sep 17 00:00:00 2001 From: Faris Armoush Date: Thu, 17 Apr 2025 14:17:43 +0300 Subject: [PATCH 2/8] submitting password field in login logs the user in. --- lib/pages/auth/view/login_web_page.dart | 28 +++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/pages/auth/view/login_web_page.dart b/lib/pages/auth/view/login_web_page.dart index 72cad7cc..a6de87cf 100644 --- a/lib/pages/auth/view/login_web_page.dart +++ b/lib/pages/auth/view/login_web_page.dart @@ -55,12 +55,12 @@ class _LoginWebPageState extends State with HelperResponsiveLayout final isSmallScreen = isSmallScreenSize(context); final isMediumScreen = isMediumScreenSize(context); Size size = MediaQuery.of(context).size; - late ScrollController _scrollController; - _scrollController = ScrollController(); + late ScrollController scrollController; + scrollController = ScrollController(); - void _scrollToCenter() { - final double middlePosition = _scrollController.position.maxScrollExtent / 2; - _scrollController.animateTo( + void scrollToCenter() { + final double middlePosition = scrollController.position.maxScrollExtent / 2; + scrollController.animateTo( middlePosition, duration: const Duration(seconds: 1), curve: Curves.easeInOut, @@ -68,7 +68,7 @@ class _LoginWebPageState extends State with HelperResponsiveLayout } WidgetsBinding.instance.addPostFrameCallback((_) { - _scrollToCenter(); + scrollToCenter(); }); return Stack( @@ -76,7 +76,7 @@ class _LoginWebPageState extends State with HelperResponsiveLayout FirstLayer( second: Center( child: ListView( - controller: _scrollController, + controller: scrollController, shrinkWrap: true, children: [ Container( @@ -199,7 +199,7 @@ class _LoginWebPageState extends State with HelperResponsiveLayout width: size.width * 0.9, child: DropdownButtonHideUnderline( child: DropdownButton2( - style: TextStyle(color: Colors.black), + style: const TextStyle(color: Colors.black), isExpanded: true, hint: Text( 'Select your region/country', @@ -336,6 +336,16 @@ class _LoginWebPageState extends State with HelperResponsiveLayout obscureText: loginBloc.obscureText, keyboardType: TextInputType.visiblePassword, controller: loginBloc.loginPasswordController, + onFieldSubmitted: (value) { + if (loginBloc.loginFormKey.currentState!.validate()) { + loginBloc.add(LoginButtonPressed( + username: loginBloc.loginEmailController.text, + password: value, + )); + } else { + loginBloc.add(ChangeValidateEvent()); + } + }, decoration: textBoxDecoration()!.copyWith( hintText: 'At least 8 characters', hintStyle: Theme.of(context) @@ -393,7 +403,7 @@ class _LoginWebPageState extends State with HelperResponsiveLayout Transform.scale( scale: 1.2, child: Checkbox( - fillColor: MaterialStateProperty.all(Colors.white), + fillColor: WidgetStateProperty.all(Colors.white), activeColor: Colors.white, value: loginBloc.isChecked, checkColor: Colors.black, From a0dd12855766eb273c89e9e1c1b01baf3fa7c0b8 Mon Sep 17 00:00:00 2001 From: Faris Armoush Date: Thu, 17 Apr 2025 14:30:30 +0300 Subject: [PATCH 3/8] matched design of Function and action in `SaveRoutineHelper.showSaveRoutineDialog` --- .../routines/helper/save_routine_helper.dart | 103 +++++++++++------- 1 file changed, 64 insertions(+), 39 deletions(-) diff --git a/lib/pages/routines/helper/save_routine_helper.dart b/lib/pages/routines/helper/save_routine_helper.dart index 457f74dc..57081230 100644 --- a/lib/pages/routines/helper/save_routine_helper.dart +++ b/lib/pages/routines/helper/save_routine_helper.dart @@ -5,8 +5,8 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart'; import 'package:syncrow_web/pages/routines/models/device_functions.dart'; -import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart'; import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart'; +import 'package:syncrow_web/pages/routines/widgets/dialog_header.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'; @@ -31,7 +31,8 @@ class SaveRoutineHelper { children: [ DialogHeader('Create a scene: ${state.routineName ?? ""}'), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + padding: + const EdgeInsets.symmetric(horizontal: 16, vertical: 8), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -59,8 +60,9 @@ class SaveRoutineHelper { ), if (state.isAutomation) ...state.ifItems.map((item) { - final functions = - state.selectedFunctions[item['uniqueCustomId']] ?? []; + final functions = state.selectedFunctions[ + item['uniqueCustomId']] ?? + []; return functionRow(item, context, functions); }), ], @@ -68,10 +70,8 @@ class SaveRoutineHelper { ), const SizedBox(width: 16), // Right side - THEN items - Expanded( child: ListView( - // crossAxisAlignment: CrossAxisAlignment.start, shrinkWrap: true, children: [ const Text( @@ -82,8 +82,9 @@ class SaveRoutineHelper { ), const SizedBox(height: 8), ...state.thenItems.map((item) { - final functions = - state.selectedFunctions[item['uniqueCustomId']] ?? []; + final functions = state.selectedFunctions[ + item['uniqueCustomId']] ?? + []; return functionRow(item, context, functions); }), ], @@ -92,33 +93,30 @@ class SaveRoutineHelper { ], ), ), - // if (state.errorMessage != null || state.errorMessage!.isNotEmpty) - // Padding( - // padding: const EdgeInsets.all(8.0), - // child: Text( - // state.errorMessage!, - // style: const TextStyle(color: Colors.red), - // ), - // ), DialogFooter( onCancel: () => Navigator.pop(context), onConfirm: () async { if (state.isAutomation) { if (state.isUpdate ?? false) { - context.read().add(const UpdateAutomation()); + context + .read() + .add(const UpdateAutomation()); } else { - context.read().add(const CreateAutomationEvent()); + context + .read() + .add(const CreateAutomationEvent()); } } else { if (state.isUpdate ?? false) { context.read().add(const UpdateScene()); } else { - context.read().add(const CreateSceneEvent()); + context + .read() + .add(const CreateSceneEvent()); } } - // if (state.errorMessage == null || state.errorMessage!.isEmpty) { + Navigator.pop(context); - // } }, isConfirmEnabled: true, ), @@ -133,7 +131,10 @@ class SaveRoutineHelper { } static Widget functionRow( - dynamic item, BuildContext context, List functions) { + dynamic item, + BuildContext context, + List functions, + ) { return Padding( padding: const EdgeInsets.only(top: 6), child: Row( @@ -142,19 +143,36 @@ class SaveRoutineHelper { Expanded( child: Row( mainAxisAlignment: MainAxisAlignment.start, - spacing: 8, + spacing: 17, children: [ - item['type'] == 'tap_to_run' || item['type'] == 'scene' - ? Image.memory( - base64Decode(item['icon']), - width: 22, - height: 22, - ) - : SvgPicture.asset( - item['imagePath'], - width: 22, - height: 22, - ), + Container( + width: 22, + height: 22, + padding: const EdgeInsetsDirectional.all(4), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: ColorsManager.textFieldGreyColor, + border: Border.all( + color: ColorsManager.neutralGray, + width: 1.5, + ), + ), + child: Center( + child: item['type'] == 'tap_to_run' || item['type'] == 'scene' + ? Image.memory( + base64Decode(item['icon']), + width: 12, + height: 22, + fit: BoxFit.scaleDown, + ) + : SvgPicture.asset( + item['imagePath'], + width: 12, + height: 12, + fit: BoxFit.scaleDown, + ), + ), + ), Flexible( child: Column( mainAxisAlignment: MainAxisAlignment.start, @@ -166,16 +184,18 @@ class SaveRoutineHelper { maxLines: 1, overflow: TextOverflow.ellipsis, style: context.textTheme.bodySmall?.copyWith( - fontSize: 14, + fontSize: 15, color: ColorsManager.textPrimaryColor, ), ), Wrap( + runSpacing: 16, + spacing: 4, children: functions .map((f) => Text( '${f.operationName}: ${f.value}', - style: context.textTheme.bodySmall - ?.copyWith(color: ColorsManager.grayColor, fontSize: 8), + style: context.textTheme.bodySmall?.copyWith( + color: ColorsManager.grayColor, fontSize: 8), overflow: TextOverflow.ellipsis, maxLines: 3, )) @@ -197,7 +217,10 @@ class SaveRoutineHelper { child: Row( spacing: 2, children: [ - SizedBox(width: 8, height: 8, child: SvgPicture.asset(Assets.deviceTagIcon)), + SizedBox( + width: 8, + height: 8, + child: SvgPicture.asset(Assets.deviceTagIcon)), Text( item['tag'] ?? '', textAlign: TextAlign.center, @@ -218,7 +241,9 @@ class SaveRoutineHelper { spacing: 2, children: [ SizedBox( - width: 8, height: 8, child: SvgPicture.asset(Assets.spaceLocationIcon)), + width: 8, + height: 8, + child: SvgPicture.asset(Assets.spaceLocationIcon)), Text( item['subSpace'] ?? '', textAlign: TextAlign.center, From c46cfb48a83f92e8347431a9cf876a37ab3b4fba Mon Sep 17 00:00:00 2001 From: Faris Armoush Date: Thu, 17 Apr 2025 14:38:04 +0300 Subject: [PATCH 4/8] refactor: extract IF and THEN sections into separate methods for better readability --- .../routines/helper/save_routine_helper.dart | 161 +++++++++--------- 1 file changed, 81 insertions(+), 80 deletions(-) diff --git a/lib/pages/routines/helper/save_routine_helper.dart b/lib/pages/routines/helper/save_routine_helper.dart index 57081230..0750ba07 100644 --- a/lib/pages/routines/helper/save_routine_helper.dart +++ b/lib/pages/routines/helper/save_routine_helper.dart @@ -36,90 +36,13 @@ class SaveRoutineHelper { child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Left side - IF - Expanded( - child: ListView( - // crossAxisAlignment: CrossAxisAlignment.start, - shrinkWrap: true, - children: [ - const Text( - 'IF:', - style: TextStyle( - fontSize: 16, - ), - ), - const SizedBox(height: 8), - if (state.isTabToRun) - ListTile( - leading: SvgPicture.asset( - Assets.tabToRun, - width: 24, - height: 24, - ), - title: const Text('Tab to run'), - ), - if (state.isAutomation) - ...state.ifItems.map((item) { - final functions = state.selectedFunctions[ - item['uniqueCustomId']] ?? - []; - return functionRow(item, context, functions); - }), - ], - ), - ), + _buildIfConditions(state, context), const SizedBox(width: 16), - // Right side - THEN items - Expanded( - child: ListView( - shrinkWrap: true, - children: [ - const Text( - 'THEN:', - style: TextStyle( - fontSize: 16, - ), - ), - const SizedBox(height: 8), - ...state.thenItems.map((item) { - final functions = state.selectedFunctions[ - item['uniqueCustomId']] ?? - []; - return functionRow(item, context, functions); - }), - ], - ), - ), + _buildThenActions(state, context), ], ), ), - DialogFooter( - onCancel: () => Navigator.pop(context), - onConfirm: () async { - if (state.isAutomation) { - if (state.isUpdate ?? false) { - context - .read() - .add(const UpdateAutomation()); - } else { - context - .read() - .add(const CreateAutomationEvent()); - } - } else { - if (state.isUpdate ?? false) { - context.read().add(const UpdateScene()); - } else { - context - .read() - .add(const CreateSceneEvent()); - } - } - - Navigator.pop(context); - }, - isConfirmEnabled: true, - ), + _buildDialogFooter(context, state), ], ), ), @@ -130,6 +53,84 @@ class SaveRoutineHelper { ); } + static DialogFooter _buildDialogFooter(BuildContext context, RoutineState state) { + return DialogFooter( + onCancel: () => Navigator.pop(context), + onConfirm: () async { + if (state.isAutomation) { + if (state.isUpdate ?? false) { + context.read().add(const UpdateAutomation()); + } else { + context.read().add(const CreateAutomationEvent()); + } + } else { + if (state.isUpdate ?? false) { + context.read().add(const UpdateScene()); + } else { + context.read().add(const CreateSceneEvent()); + } + } + + Navigator.pop(context); + }, + isConfirmEnabled: true, + ); + } + + static Expanded _buildThenActions(RoutineState state, BuildContext context) { + return Expanded( + child: ListView( + shrinkWrap: true, + children: [ + const Text( + 'THEN:', + style: TextStyle( + fontSize: 16, + ), + ), + const SizedBox(height: 8), + ...state.thenItems.map((item) { + final functions = state.selectedFunctions[item['uniqueCustomId']] ?? []; + return functionRow(item, context, functions); + }), + ], + ), + ); + } + + static Expanded _buildIfConditions(RoutineState state, BuildContext context) { + return Expanded( + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + shrinkWrap: true, + children: [ + const Text( + 'IF:', + style: TextStyle( + fontSize: 16, + ), + ), + const SizedBox(height: 8), + if (state.isTabToRun) + ListTile( + leading: SvgPicture.asset( + Assets.tabToRun, + width: 24, + height: 24, + ), + title: const Text('Tab to run'), + ), + if (state.isAutomation) + ...state.ifItems.map((item) { + final functions = + state.selectedFunctions[item['uniqueCustomId']] ?? []; + return functionRow(item, context, functions); + }), + ], + ), + ); + } + static Widget functionRow( dynamic item, BuildContext context, From 2e4f904d3a84388a9554f768e4d21b5298192ab9 Mon Sep 17 00:00:00 2001 From: Faris Armoush Date: Thu, 17 Apr 2025 14:39:33 +0300 Subject: [PATCH 5/8] style: improve code formatting and readability in SaveRoutineHelper --- .../routines/helper/save_routine_helper.dart | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/lib/pages/routines/helper/save_routine_helper.dart b/lib/pages/routines/helper/save_routine_helper.dart index 0750ba07..e9d870d9 100644 --- a/lib/pages/routines/helper/save_routine_helper.dart +++ b/lib/pages/routines/helper/save_routine_helper.dart @@ -31,8 +31,10 @@ class SaveRoutineHelper { children: [ DialogHeader('Create a scene: ${state.routineName ?? ""}'), Padding( - padding: - const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 8, + ), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -56,7 +58,7 @@ class SaveRoutineHelper { static DialogFooter _buildDialogFooter(BuildContext context, RoutineState state) { return DialogFooter( onCancel: () => Navigator.pop(context), - onConfirm: () async { + onConfirm: () { if (state.isAutomation) { if (state.isUpdate ?? false) { context.read().add(const UpdateAutomation()); @@ -101,7 +103,6 @@ class SaveRoutineHelper { static Expanded _buildIfConditions(RoutineState state, BuildContext context) { return Expanded( child: ListView( - // crossAxisAlignment: CrossAxisAlignment.start, shrinkWrap: true, children: [ const Text( @@ -193,13 +194,17 @@ class SaveRoutineHelper { runSpacing: 16, spacing: 4, children: functions - .map((f) => Text( - '${f.operationName}: ${f.value}', - style: context.textTheme.bodySmall?.copyWith( - color: ColorsManager.grayColor, fontSize: 8), - overflow: TextOverflow.ellipsis, - maxLines: 3, - )) + .map( + (function) => Text( + '${function.operationName}: ${function.value}', + style: context.textTheme.bodySmall?.copyWith( + color: ColorsManager.grayColor, + fontSize: 8, + ), + overflow: TextOverflow.ellipsis, + maxLines: 3, + ), + ) .toList(), ), ], @@ -219,9 +224,12 @@ class SaveRoutineHelper { spacing: 2, children: [ SizedBox( - width: 8, - height: 8, - child: SvgPicture.asset(Assets.deviceTagIcon)), + width: 8, + height: 8, + child: SvgPicture.asset( + Assets.deviceTagIcon, + ), + ), Text( item['tag'] ?? '', textAlign: TextAlign.center, @@ -242,9 +250,12 @@ class SaveRoutineHelper { spacing: 2, children: [ SizedBox( - width: 8, - height: 8, - child: SvgPicture.asset(Assets.spaceLocationIcon)), + width: 8, + height: 8, + child: SvgPicture.asset( + Assets.spaceLocationIcon, + ), + ), Text( item['subSpace'] ?? '', textAlign: TextAlign.center, From 84264391d9a9bd4d20354926d981cb78a525ce89 Mon Sep 17 00:00:00 2001 From: Faris Armoush Date: Thu, 17 Apr 2025 16:14:26 +0300 Subject: [PATCH 6/8] progress towards matching the design of `save routine dialog`. --- .../routines/helper/save_routine_helper.dart | 133 +++++++++++------- lib/pages/routines/widgets/dialog_footer.dart | 32 +++-- lib/pages/routines/widgets/dialog_header.dart | 1 + 3 files changed, 105 insertions(+), 61 deletions(-) diff --git a/lib/pages/routines/helper/save_routine_helper.dart b/lib/pages/routines/helper/save_routine_helper.dart index e9d870d9..c568c6c1 100644 --- a/lib/pages/routines/helper/save_routine_helper.dart +++ b/lib/pages/routines/helper/save_routine_helper.dart @@ -6,7 +6,6 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart'; import 'package:syncrow_web/pages/routines/models/device_functions.dart'; import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart'; -import 'package:syncrow_web/pages/routines/widgets/dialog_header.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'; @@ -18,6 +17,10 @@ class SaveRoutineHelper { builder: (BuildContext context) { return BlocBuilder( builder: (context, state) { + final selectedConditionLabel = state.selectedAutomationOperator == 'and' + ? 'All Conditions are met' + : 'Any Condition is met'; + return AlertDialog( contentPadding: EdgeInsets.zero, content: Container( @@ -29,22 +32,35 @@ class SaveRoutineHelper { child: Column( mainAxisSize: MainAxisSize.min, children: [ - DialogHeader('Create a scene: ${state.routineName ?? ""}'), + const SizedBox(height: 18), + Text( + 'Create a scene: ${state.routineName ?? ""}', + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.headlineMedium!.copyWith( + color: ColorsManager.primaryColorWithOpacity, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 18), + _buildDivider(), + _buildListsLabelRow(selectedConditionLabel), Padding( - padding: const EdgeInsets.symmetric( + padding: const EdgeInsetsDirectional.symmetric( horizontal: 16, - vertical: 8, ), child: Row( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, children: [ _buildIfConditions(state, context), - const SizedBox(width: 16), _buildThenActions(state, context), ], ), ), + _buildDivider(), + const SizedBox(height: 8), _buildDialogFooter(context, state), + const SizedBox(height: 8), ], ), ), @@ -55,63 +71,82 @@ class SaveRoutineHelper { ); } - static DialogFooter _buildDialogFooter(BuildContext context, RoutineState state) { - return DialogFooter( - onCancel: () => Navigator.pop(context), - onConfirm: () { - if (state.isAutomation) { - if (state.isUpdate ?? false) { - context.read().add(const UpdateAutomation()); - } else { - context.read().add(const CreateAutomationEvent()); - } - } else { - if (state.isUpdate ?? false) { - context.read().add(const UpdateScene()); - } else { - context.read().add(const CreateSceneEvent()); - } - } - - Navigator.pop(context); - }, - isConfirmEnabled: true, + static Container _buildDivider() { + return Container( + height: 1, + width: double.infinity, + color: ColorsManager.greyColor, ); } - static Expanded _buildThenActions(RoutineState state, BuildContext context) { - return Expanded( - child: ListView( - shrinkWrap: true, + static Widget _buildListsLabelRow(String selectedConditionLabel) { + const textStyle = TextStyle( + fontSize: 16, + ); + return Container( + color: ColorsManager.backgroundColor.withValues(alpha: 0.5), + padding: const EdgeInsetsDirectional.all(20), + child: Row( + spacing: 16, children: [ - const Text( - 'THEN:', - style: TextStyle( - fontSize: 16, - ), - ), - const SizedBox(height: 8), - ...state.thenItems.map((item) { - final functions = state.selectedFunctions[item['uniqueCustomId']] ?? []; - return functionRow(item, context, functions); - }), + Expanded(child: Text('IF: $selectedConditionLabel', style: textStyle)), + const Expanded(child: Text('THEN:', style: textStyle)), ], ), ); } - static Expanded _buildIfConditions(RoutineState state, BuildContext context) { + static Widget _buildDialogFooter(BuildContext context, RoutineState state) { + return Row( + spacing: 16, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + DialogFooterButton( + text: 'Cancel', + onTap: () => Navigator.pop(context), + ), + DialogFooterButton( + text: 'Confirm', + onTap: () { + if (state.isAutomation) { + if (state.isUpdate ?? false) { + context.read().add(const UpdateAutomation()); + } else { + context.read().add(const CreateAutomationEvent()); + } + } else { + if (state.isUpdate ?? false) { + context.read().add(const UpdateScene()); + } else { + context.read().add(const CreateSceneEvent()); + } + } + + Navigator.pop(context); + }, + textColor: ColorsManager.primaryColorWithOpacity, + ), + ], + ); + } + + static Widget _buildThenActions(RoutineState state, BuildContext context) { + return Expanded( + child: ListView( + shrinkWrap: true, + children: state.thenItems.map((item) { + final functions = state.selectedFunctions[item['uniqueCustomId']] ?? []; + return functionRow(item, context, functions); + }).toList(), + ), + ); + } + + static Widget _buildIfConditions(RoutineState state, BuildContext context) { return Expanded( child: ListView( shrinkWrap: true, children: [ - const Text( - 'IF:', - style: TextStyle( - fontSize: 16, - ), - ), - const SizedBox(height: 8), if (state.isTabToRun) ListTile( leading: SvgPicture.asset( diff --git a/lib/pages/routines/widgets/dialog_footer.dart b/lib/pages/routines/widgets/dialog_footer.dart index e5a548f7..38178ee6 100644 --- a/lib/pages/routines/widgets/dialog_footer.dart +++ b/lib/pages/routines/widgets/dialog_footer.dart @@ -28,32 +28,40 @@ class DialogFooter extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - _buildFooterButton( - context: context, + DialogFooterButton( text: 'Cancel', onTap: onCancel, ), if (isConfirmEnabled) ...[ Container(width: 1, height: 50, color: ColorsManager.greyColor), - _buildFooterButton( - context: context, + DialogFooterButton( text: 'Confirm', onTap: onConfirm, - textColor: - isConfirmEnabled ? ColorsManager.primaryColorWithOpacity : Colors.red, + textColor: isConfirmEnabled + ? ColorsManager.primaryColorWithOpacity + : Colors.red, ), ], ], ), ); } +} - Widget _buildFooterButton({ - required BuildContext context, - required String text, - required VoidCallback? onTap, - Color? textColor, - }) { +class DialogFooterButton extends StatelessWidget { + const DialogFooterButton({ + required this.text, + required this.onTap, + this.textColor, + super.key, + }); + + final String text; + final VoidCallback? onTap; + final Color? textColor; + + @override + Widget build(BuildContext context) { return Expanded( child: TextButton( style: TextButton.styleFrom( diff --git a/lib/pages/routines/widgets/dialog_header.dart b/lib/pages/routines/widgets/dialog_header.dart index 4fe1f0b1..f1f5686a 100644 --- a/lib/pages/routines/widgets/dialog_header.dart +++ b/lib/pages/routines/widgets/dialog_header.dart @@ -16,6 +16,7 @@ class DialogHeader extends StatelessWidget { ), Text( title, + textAlign: TextAlign.center, style: Theme.of(context).textTheme.bodyMedium!.copyWith( color: ColorsManager.primaryColorWithOpacity, fontWeight: FontWeight.bold, From cf20bdcd4289fa28d439ba566ff39cbe5c27a507 Mon Sep 17 00:00:00 2001 From: Faris Armoush Date: Mon, 21 Apr 2025 10:57:46 +0300 Subject: [PATCH 7/8] SP-1440 --- .../routines/helper/save_routine_helper.dart | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/pages/routines/helper/save_routine_helper.dart b/lib/pages/routines/helper/save_routine_helper.dart index c568c6c1..bc4764e3 100644 --- a/lib/pages/routines/helper/save_routine_helper.dart +++ b/lib/pages/routines/helper/save_routine_helper.dart @@ -14,7 +14,7 @@ class SaveRoutineHelper { static Future showSaveRoutineDialog(BuildContext context) async { return showDialog( context: context, - builder: (BuildContext context) { + builder: (context) { return BlocBuilder( builder: (context, state) { final selectedConditionLabel = state.selectedAutomationOperator == 'and' @@ -24,7 +24,8 @@ class SaveRoutineHelper { return AlertDialog( contentPadding: EdgeInsets.zero, content: Container( - width: MediaQuery.sizeOf(context).width * 0.5, + width: context.screenWidth * 0.5, + height: 500, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(20), @@ -44,17 +45,24 @@ class SaveRoutineHelper { const SizedBox(height: 18), _buildDivider(), _buildListsLabelRow(selectedConditionLabel), - Padding( - padding: const EdgeInsetsDirectional.symmetric( - horizontal: 16, - ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - _buildIfConditions(state, context), - _buildThenActions(state, context), - ], + Expanded( + child: Padding( + padding: const EdgeInsetsDirectional.symmetric( + horizontal: 16, + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + spacing: 24, + children: [ + _buildIfConditions(state, context), + Container( + width: 1, + color: ColorsManager.greyColor, + ), + _buildThenActions(state, context), + ], + ), ), ), _buildDivider(), @@ -133,7 +141,7 @@ class SaveRoutineHelper { static Widget _buildThenActions(RoutineState state, BuildContext context) { return Expanded( child: ListView( - shrinkWrap: true, + // shrinkWrap: true, children: state.thenItems.map((item) { final functions = state.selectedFunctions[item['uniqueCustomId']] ?? []; return functionRow(item, context, functions); @@ -145,7 +153,7 @@ class SaveRoutineHelper { static Widget _buildIfConditions(RoutineState state, BuildContext context) { return Expanded( child: ListView( - shrinkWrap: true, + // shrinkWrap: true, children: [ if (state.isTabToRun) ListTile( From 67a164e6d244f06917eecfe1926ec9226b7e9988 Mon Sep 17 00:00:00 2001 From: Faris Armoush Date: Mon, 21 Apr 2025 10:59:09 +0300 Subject: [PATCH 8/8] modified divider color to match figma design. --- lib/pages/routines/helper/save_routine_helper.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/routines/helper/save_routine_helper.dart b/lib/pages/routines/helper/save_routine_helper.dart index bc4764e3..23920ba6 100644 --- a/lib/pages/routines/helper/save_routine_helper.dart +++ b/lib/pages/routines/helper/save_routine_helper.dart @@ -58,7 +58,7 @@ class SaveRoutineHelper { _buildIfConditions(state, context), Container( width: 1, - color: ColorsManager.greyColor, + color: ColorsManager.greyColor.withValues(alpha: 0.8), ), _buildThenActions(state, context), ],