diff --git a/lib/pages/routiens/bloc/routine_bloc/routine_bloc.dart b/lib/pages/routiens/bloc/routine_bloc/routine_bloc.dart index e6c45594..5f25c247 100644 --- a/lib/pages/routiens/bloc/routine_bloc/routine_bloc.dart +++ b/lib/pages/routiens/bloc/routine_bloc/routine_bloc.dart @@ -226,7 +226,7 @@ class RoutineBloc extends Bloc { return; } - emit(state.copyWith(isLoading: true)); + emit(state.copyWith(isLoading: true, errorMessage: null)); final actions = state.thenItems.expand((item) { final functions = state.selectedFunctions[item['uniqueCustomId']] ?? []; @@ -316,7 +316,7 @@ class RoutineBloc extends Bloc { )); return; } - emit(state.copyWith(isLoading: true)); + emit(state.copyWith(isLoading: true, errorMessage: null)); final conditions = state.ifItems.expand((item) { final functions = state.selectedFunctions[item['uniqueCustomId']] ?? []; @@ -920,9 +920,10 @@ class RoutineBloc extends Bloc { try { emit(state.copyWith(isLoading: true)); if (state.isTabToRun) { - SceneApi.deleteScene(unitUuid: spaceId, sceneId: event.id); + SceneApi.deleteScene(unitUuid: spaceId, sceneId: state.sceneId ?? ''); } else { - SceneApi.deleteAutomation(unitUuid: spaceId, automationId: event.id); + SceneApi.deleteAutomation( + unitUuid: spaceId, automationId: state.automationId ?? ''); } add(const LoadScenes(spaceId, communityId)); @@ -983,7 +984,7 @@ class RoutineBloc extends Bloc { return; } - emit(state.copyWith(isLoading: true)); + emit(state.copyWith(isLoading: true, errorMessage: null)); final actions = state.thenItems.expand((item) { final functions = state.selectedFunctions[item['uniqueCustomId']] ?? []; diff --git a/lib/pages/routiens/bloc/routine_bloc/routine_event.dart b/lib/pages/routiens/bloc/routine_bloc/routine_event.dart index 9c19028f..2e12bc2e 100644 --- a/lib/pages/routiens/bloc/routine_bloc/routine_event.dart +++ b/lib/pages/routiens/bloc/routine_bloc/routine_event.dart @@ -156,10 +156,9 @@ class InitializeRoutineState extends RoutineEvent { } class DeleteScene extends RoutineEvent { - final String id; - const DeleteScene({required this.id}); + const DeleteScene(); @override - List get props => [id]; + List get props => []; } // class DeleteAutomation extends RoutineEvent { diff --git a/lib/pages/routiens/helper/save_routine_helper.dart b/lib/pages/routiens/helper/save_routine_helper.dart index e7f29763..2f48eead 100644 --- a/lib/pages/routiens/helper/save_routine_helper.dart +++ b/lib/pages/routiens/helper/save_routine_helper.dart @@ -162,6 +162,10 @@ class SaveRoutineHelper { .read() .add(const CreateSceneEvent()); } + if (context.read().state.errorMessage == + null) { + Navigator.pop(context, true); + } } }, isConfirmEnabled: true, diff --git a/lib/pages/routiens/widgets/delete_scene.dart b/lib/pages/routiens/widgets/delete_scene.dart index 37895358..7e06a615 100644 --- a/lib/pages/routiens/widgets/delete_scene.dart +++ b/lib/pages/routiens/widgets/delete_scene.dart @@ -18,7 +18,7 @@ class DeleteSceneWidget extends StatelessWidget { ), GestureDetector( onTap: () async { - showCustomDialog( + await showCustomDialog( context: context, message: 'Are you sure you want to delete this scene?', actions: [ @@ -33,26 +33,31 @@ class DeleteSceneWidget extends StatelessWidget { alignment: AlignmentDirectional.center, child: Text( 'Cancel', - style: Theme.of(context).textTheme.bodyMedium!.copyWith( + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( color: ColorsManager.textGray, ), ), ), ), - Container(width: 1, height: 50, color: ColorsManager.greyColor), + Container( + width: 1, height: 50, color: ColorsManager.greyColor), InkWell( onTap: () { - context.read().add(DeleteScene( - id: context.read().state.automationId!, - )); - Navigator.of(context).pop(); + context.read().add(const DeleteScene()); Navigator.of(context).pop(); + Navigator.of(context).pop(true); }, child: Container( alignment: AlignmentDirectional.center, child: Text( 'Confirm', - style: Theme.of(context).textTheme.bodyMedium!.copyWith( + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( color: ColorsManager.primaryColorWithOpacity, ), ),