diff --git a/lib/pages/routiens/widgets/routine_search_and_buttons.dart b/lib/pages/routiens/widgets/routine_search_and_buttons.dart index fb982a70..73bc403d 100644 --- a/lib/pages/routiens/widgets/routine_search_and_buttons.dart +++ b/lib/pages/routiens/widgets/routine_search_and_buttons.dart @@ -16,50 +16,148 @@ class RoutineSearchAndButtons extends StatelessWidget { @override Widget build(BuildContext context) { - return LayoutBuilder( - builder: (BuildContext context, BoxConstraints constraints) { - return Wrap( - runSpacing: 16, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.end, + return BlocBuilder( + builder: (context, state) { + return LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + return Wrap( + runSpacing: 16, children: [ - Expanded( - child: Wrap( - spacing: 12, - runSpacing: 12, - crossAxisAlignment: WrapCrossAlignment.end, - children: [ - ConstrainedBox( - constraints: BoxConstraints( - maxWidth: constraints.maxWidth > 700 - ? 450 - : constraints.maxWidth - 32), - child: StatefulTextField( - title: 'Routine Name', - height: 40, - controller: TextEditingController(), - hintText: 'Please enter the name', - boxDecoration: containerWhiteDecoration, - elevation: 0, - borderRadius: 15, - isRequired: true, - width: 450, - onChanged: (value) { - context - .read() - .add(SetRoutineName(value)); - }, - ), - ), - (constraints.maxWidth <= 1000) - ? const SizedBox() - : SizedBox( + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: Wrap( + spacing: 12, + runSpacing: 12, + crossAxisAlignment: WrapCrossAlignment.end, + children: [ + ConstrainedBox( + constraints: BoxConstraints( + maxWidth: constraints.maxWidth > 700 + ? 450 + : constraints.maxWidth - 32), + child: StatefulTextField( + title: 'Routine Name', height: 40, - width: 200, - child: Center( - child: DefaultButton( - onPressed: () async { + controller: TextEditingController(), + hintText: 'Please enter the name', + boxDecoration: containerWhiteDecoration, + elevation: 0, + borderRadius: 15, + isRequired: true, + width: 450, + onChanged: (value) { + context + .read() + .add(SetRoutineName(value)); + }, + ), + ), + (constraints.maxWidth <= 1000) + ? const SizedBox() + : SizedBox( + height: 40, + width: 200, + child: Center( + child: DefaultButton( + onPressed: state.isAutomation || + state.isTabToRun + ? () async { + final result = await SettingHelper + .showSettingDialog( + context: context, + ); + if (result != null) { + context.read().add( + AddSelectedIcon(result)); + } + } + : null, + borderRadius: 15, + elevation: 0, + borderColor: ColorsManager.greyColor, + backgroundColor: ColorsManager.boxColor, + child: const Text( + 'Settings', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12, + color: ColorsManager.primaryColor, + ), + ), + ), + ), + ), + ], + ), + ), + if (constraints.maxWidth > 1000) + Row( + mainAxisSize: MainAxisSize.min, + children: [ + SizedBox( + height: 40, + width: 200, + child: Center( + child: DefaultButton( + onPressed: () { + DiscardDialog.show(context); + }, + borderRadius: 15, + elevation: 0, + borderColor: ColorsManager.greyColor, + backgroundColor: ColorsManager.boxColor, + child: const Text( + 'Cancel', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12, + color: ColorsManager.blackColor, + ), + ), + ), + ), + ), + const SizedBox(width: 12), + SizedBox( + height: 40, + width: 200, + child: Center( + child: DefaultButton( + onPressed: () { + SaveRoutineHelper.showSaveRoutineDialog( + context); + }, + borderRadius: 15, + elevation: 0, + backgroundColor: ColorsManager.primaryColor, + child: const Text( + 'Save', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12, + color: ColorsManager.whiteColors, + ), + ), + ), + ), + ), + ], + ), + ], + ), + if (constraints.maxWidth <= 1000) + Wrap( + runSpacing: 12, + children: [ + SizedBox( + height: 40, + width: 200, + child: Center( + child: DefaultButton( + onPressed: state.isAutomation || state.isTabToRun + ? () async { final result = await SettingHelper.showSettingDialog( context: context, @@ -69,29 +167,24 @@ class RoutineSearchAndButtons extends StatelessWidget { .read() .add(AddSelectedIcon(result)); } - }, - borderRadius: 15, - elevation: 0, - borderColor: ColorsManager.greyColor, - backgroundColor: ColorsManager.boxColor, - child: const Text( - 'Settings', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12, - color: ColorsManager.primaryColor, - ), - ), - ), + } + : null, + borderRadius: 15, + elevation: 0, + borderColor: ColorsManager.greyColor, + backgroundColor: ColorsManager.boxColor, + child: const Text( + 'Settings', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12, + color: ColorsManager.primaryColor, ), ), - ], - ), - ), - if (constraints.maxWidth > 1000) - Row( - mainAxisSize: MainAxisSize.min, - children: [ + ), + ), + ), + const SizedBox(width: 12), SizedBox( height: 40, width: 200, @@ -141,91 +234,8 @@ class RoutineSearchAndButtons extends StatelessWidget { ], ), ], - ), - if (constraints.maxWidth <= 1000) - Wrap( - runSpacing: 12, - children: [ - SizedBox( - height: 40, - width: 200, - child: Center( - child: DefaultButton( - onPressed: () async { - final result = await SettingHelper.showSettingDialog( - context: context, - ); - if (result != null) { - context - .read() - .add(AddSelectedIcon(result)); - } - }, - borderRadius: 15, - elevation: 0, - borderColor: ColorsManager.greyColor, - backgroundColor: ColorsManager.boxColor, - child: const Text( - 'Settings', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12, - color: ColorsManager.primaryColor, - ), - ), - ), - ), - ), - const SizedBox(width: 12), - SizedBox( - height: 40, - width: 200, - child: Center( - child: DefaultButton( - onPressed: () { - DiscardDialog.show(context); - }, - borderRadius: 15, - elevation: 0, - borderColor: ColorsManager.greyColor, - backgroundColor: ColorsManager.boxColor, - child: const Text( - 'Cancel', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12, - color: ColorsManager.blackColor, - ), - ), - ), - ), - ), - const SizedBox(width: 12), - SizedBox( - height: 40, - width: 200, - child: Center( - child: DefaultButton( - onPressed: () { - SaveRoutineHelper.showSaveRoutineDialog(context); - }, - borderRadius: 15, - elevation: 0, - backgroundColor: ColorsManager.primaryColor, - child: const Text( - 'Save', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12, - color: ColorsManager.whiteColors, - ), - ), - ), - ), - ), - ], - ), - ], + ); + }, ); }, );