mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-14 09:17:23 +00:00
80 lines
3.2 KiB
Dart
80 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
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/scene_bloc/scene_bloc.dart';
|
|
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
|
import 'package:syncrow_app/features/scene/widgets/alert_dialogs/delete_routine_dialog.dart';
|
|
import 'package:syncrow_app/navigation/navigate_to_route.dart';
|
|
import 'package:syncrow_app/navigation/routing_constants.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|
|
|
class DeleteRoutineButton extends StatelessWidget {
|
|
const DeleteRoutineButton({super.key, required this.sceneId, required this.isAutomation});
|
|
|
|
final String sceneId;
|
|
final bool isAutomation;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocConsumer<CreateSceneBloc, CreateSceneState>(
|
|
listener: (context, state) {
|
|
if (state is DeleteSceneSuccess) {
|
|
if (state.success) {
|
|
navigateToRoute(context, Routes.homeRoute);
|
|
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
|
|
HomeCubit.getInstance().selectedSpace!.id, HomeCubit.getInstance().selectedSpace!));
|
|
BlocProvider.of<SceneBloc>(context)
|
|
.add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id,HomeCubit.getInstance().selectedSpace!.community.uuid));
|
|
}
|
|
}
|
|
},
|
|
builder: (context, state) {
|
|
return InkWell(
|
|
onTap: () {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) {
|
|
return DeleteRoutineDialog(
|
|
cancelTab: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
confirmTab: () {
|
|
context.read<CreateSceneBloc>().add(DeleteSceneEvent(
|
|
sceneId: sceneId,
|
|
unitUuid: HomeCubit.getInstance().selectedSpace!.id,
|
|
));
|
|
Navigator.of(context).pop();
|
|
},
|
|
);
|
|
},
|
|
);
|
|
},
|
|
child: const Center(
|
|
child: Text(
|
|
'Remove Routine',
|
|
style: TextStyle(color: ColorsManager.red),
|
|
))
|
|
// : SceneListTile(
|
|
// onPressed: () {
|
|
|
|
// },
|
|
// padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
// titleString: isAutomation
|
|
// ? StringsManager.deleteAutomation
|
|
// : StringsManager.deleteScene,
|
|
// leadingWidget: (state is DeleteSceneLoading)
|
|
// ? const SizedBox(
|
|
// height: 24,
|
|
// width: 24,
|
|
// child: CircularProgressIndicator())
|
|
// : SvgPicture.asset(
|
|
// Assets.assetsDeleteIcon,
|
|
// color: ColorsManager.red,
|
|
// ),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|