push changes

This commit is contained in:
ashrafzarkanisala
2024-12-01 01:07:26 +03:00
parent 02c788d03a
commit 76e44c8910
4 changed files with 25 additions and 16 deletions

View File

@ -226,7 +226,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
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<RoutineEvent, RoutineState> {
));
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<RoutineEvent, RoutineState> {
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<RoutineEvent, RoutineState> {
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']] ?? [];

View File

@ -156,10 +156,9 @@ class InitializeRoutineState extends RoutineEvent {
}
class DeleteScene extends RoutineEvent {
final String id;
const DeleteScene({required this.id});
const DeleteScene();
@override
List<Object> get props => [id];
List<Object> get props => [];
}
// class DeleteAutomation extends RoutineEvent {

View File

@ -162,6 +162,10 @@ class SaveRoutineHelper {
.read<RoutineBloc>()
.add(const CreateSceneEvent());
}
if (context.read<RoutineBloc>().state.errorMessage ==
null) {
Navigator.pop(context, true);
}
}
},
isConfirmEnabled: true,

View File

@ -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<RoutineBloc>().add(DeleteScene(
id: context.read<RoutineBloc>().state.automationId!,
));
Navigator.of(context).pop();
context.read<RoutineBloc>().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,
),
),