mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 21:14:55 +00:00
password_changes&_routine_changes
This commit is contained in:
81
lib/features/scene/widgets/delete_routine_b.dart
Normal file
81
lib/features/scene/widgets/delete_routine_b.dart
Normal file
@ -0,0 +1,81 @@
|
||||
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!));
|
||||
BlocProvider.of<SceneBloc>(context).add(
|
||||
LoadAutomation(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
}
|
||||
}
|
||||
},
|
||||
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,
|
||||
// ),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user