mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
push delete automation
This commit is contained in:
@ -393,8 +393,12 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
emit(DeleteSceneLoading());
|
emit(DeleteSceneLoading());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final response = await SceneApi.deleteScene(
|
final response =
|
||||||
sceneId: event.sceneId, unitUuid: event.unitUuid);
|
sceneType.name == CreateSceneEnum.deviceStatusChanges.name
|
||||||
|
? await SceneApi.deleteAutomation(
|
||||||
|
automationId: event.sceneId, unitUuid: event.unitUuid)
|
||||||
|
: await SceneApi.deleteScene(
|
||||||
|
sceneId: event.sceneId, unitUuid: event.unitUuid);
|
||||||
if (response == true) {
|
if (response == true) {
|
||||||
emit(const DeleteSceneSuccess(true));
|
emit(const DeleteSceneSuccess(true));
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,6 +5,7 @@ import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
|||||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
|
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
||||||
|
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
||||||
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
||||||
import 'package:syncrow_app/features/scene/widgets/create_scene_save_button.dart';
|
import 'package:syncrow_app/features/scene/widgets/create_scene_save_button.dart';
|
||||||
import 'package:syncrow_app/features/scene/widgets/if_then_containers/if_container.dart';
|
import 'package:syncrow_app/features/scene/widgets/if_then_containers/if_container.dart';
|
||||||
@ -27,6 +28,9 @@ class SceneTasksView extends StatelessWidget {
|
|||||||
final sceneSettings = ModalRoute.of(context)!.settings.arguments
|
final sceneSettings = ModalRoute.of(context)!.settings.arguments
|
||||||
as SceneSettingsRouteArguments;
|
as SceneSettingsRouteArguments;
|
||||||
|
|
||||||
|
final isAutomation =
|
||||||
|
sceneSettings.sceneType == CreateSceneEnum.deviceStatusChanges.name;
|
||||||
|
|
||||||
return DefaultScaffold(
|
return DefaultScaffold(
|
||||||
title: sceneSettings.sceneName.isNotEmpty
|
title: sceneSettings.sceneName.isNotEmpty
|
||||||
? sceneSettings.sceneName
|
? sceneSettings.sceneName
|
||||||
@ -41,7 +45,8 @@ class SceneTasksView extends StatelessWidget {
|
|||||||
: () {
|
: () {
|
||||||
context.customBottomSheet(
|
context.customBottomSheet(
|
||||||
child: DeleteBottomSheetContent(
|
child: DeleteBottomSheetContent(
|
||||||
sceneId: sceneSettings.sceneId),
|
sceneId: sceneSettings.sceneId,
|
||||||
|
isAutomation: isAutomation),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
@ -95,9 +100,11 @@ class SceneTasksView extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class DeleteBottomSheetContent extends StatelessWidget {
|
class DeleteBottomSheetContent extends StatelessWidget {
|
||||||
const DeleteBottomSheetContent({super.key, required this.sceneId});
|
const DeleteBottomSheetContent(
|
||||||
|
{super.key, required this.sceneId, required this.isAutomation});
|
||||||
|
|
||||||
final String sceneId;
|
final String sceneId;
|
||||||
|
final bool isAutomation;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -113,6 +120,8 @@ class DeleteBottomSheetContent extends StatelessWidget {
|
|||||||
navigateToRoute(context, Routes.homeRoute);
|
navigateToRoute(context, Routes.homeRoute);
|
||||||
BlocProvider.of<SceneBloc>(context).add(
|
BlocProvider.of<SceneBloc>(context).add(
|
||||||
LoadScenes(HomeCubit.getInstance().selectedSpace!.id!));
|
LoadScenes(HomeCubit.getInstance().selectedSpace!.id!));
|
||||||
|
BlocProvider.of<SceneBloc>(context).add(LoadAutomation(
|
||||||
|
HomeCubit.getInstance().selectedSpace!.id!));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -126,7 +135,9 @@ class DeleteBottomSheetContent extends StatelessWidget {
|
|||||||
));
|
));
|
||||||
},
|
},
|
||||||
child: SceneListTile(
|
child: SceneListTile(
|
||||||
titleString: StringsManager.deleteScene,
|
titleString: isAutomation
|
||||||
|
? StringsManager.deleteAutomation
|
||||||
|
: StringsManager.deleteScene,
|
||||||
leadingWidget: (state is DeleteSceneLoading)
|
leadingWidget: (state is DeleteSceneLoading)
|
||||||
? const SizedBox(
|
? const SizedBox(
|
||||||
height: 24,
|
height: 24,
|
||||||
|
@ -28,6 +28,8 @@ class SceneView extends StatelessWidget {
|
|||||||
if (state.success) {
|
if (state.success) {
|
||||||
BlocProvider.of<SceneBloc>(context)
|
BlocProvider.of<SceneBloc>(context)
|
||||||
.add(LoadScenes(HomeCubit.getInstance().selectedSpace!.id!));
|
.add(LoadScenes(HomeCubit.getInstance().selectedSpace!.id!));
|
||||||
|
BlocProvider.of<SceneBloc>(context).add(
|
||||||
|
LoadAutomation(HomeCubit.getInstance().selectedSpace!.id!));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state is CreateSceneWithTasks) {
|
if (state is CreateSceneWithTasks) {
|
||||||
|
@ -144,18 +144,21 @@ abstract class ApiEndpoints {
|
|||||||
|
|
||||||
static const String getUnitAutomation = '$baseUrl/automation/{unitUuid}';
|
static const String getUnitAutomation = '$baseUrl/automation/{unitUuid}';
|
||||||
|
|
||||||
static const String getAutomationDetails = '$baseUrl/automation/details/{automationId}';
|
static const String getAutomationDetails =
|
||||||
|
'$baseUrl/automation/details/{automationId}';
|
||||||
|
|
||||||
/// PUT
|
/// PUT
|
||||||
static const String updateScene = '$baseUrl/scene/tap-to-run/{sceneId}';
|
static const String updateScene = '$baseUrl/scene/tap-to-run/{sceneId}';
|
||||||
|
|
||||||
static const String updateAutomation =
|
static const String updateAutomation = '$baseUrl/automation/{automationId}';
|
||||||
'$baseUrl/automation/{automationId}';
|
|
||||||
|
|
||||||
/// DELETE
|
/// DELETE
|
||||||
static const String deleteScene =
|
static const String deleteScene =
|
||||||
'$baseUrl/scene/tap-to-run/{unitUuid}/{sceneId}';
|
'$baseUrl/scene/tap-to-run/{unitUuid}/{sceneId}';
|
||||||
|
|
||||||
|
static const String deleteAutomation =
|
||||||
|
'$baseUrl/automation/{unitUuid}/{automationId}';
|
||||||
|
|
||||||
//////////////////////Door Lock //////////////////////
|
//////////////////////Door Lock //////////////////////
|
||||||
//online
|
//online
|
||||||
static const String addTemporaryPassword =
|
static const String addTemporaryPassword =
|
||||||
|
@ -183,4 +183,21 @@ class SceneApi {
|
|||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete automation
|
||||||
|
static Future<bool> deleteAutomation(
|
||||||
|
{required String unitUuid, required String automationId}) async {
|
||||||
|
try {
|
||||||
|
final response = await _httpService.delete(
|
||||||
|
path: ApiEndpoints.deleteAutomation
|
||||||
|
.replaceAll('{automationId}', automationId)
|
||||||
|
.replaceAll('{unitUuid}', unitUuid),
|
||||||
|
showServerMessage: false,
|
||||||
|
expectedResponseModel: (json) => json['statusCode'] == 200,
|
||||||
|
);
|
||||||
|
return response;
|
||||||
|
} catch (e) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,4 +40,5 @@ class StringsManager {
|
|||||||
static const String functions = "Functions";
|
static const String functions = "Functions";
|
||||||
static const String firstLaunch = "firstLaunch";
|
static const String firstLaunch = "firstLaunch";
|
||||||
static const String deleteScene = 'Delete Scene';
|
static const String deleteScene = 'Delete Scene';
|
||||||
|
static const String deleteAutomation = 'Delete Automation';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user