Removed static space id and community id in the routine

This commit is contained in:
Abdullah Alassaf
2025-02-17 03:32:40 +03:00
parent dec3a25639
commit 0aa029a2fc
13 changed files with 248 additions and 255 deletions

View File

@ -20,7 +20,7 @@ class _RoutinesViewState extends State<RoutinesView> {
@override
void initState() {
super.initState();
context.read<RoutineBloc>().add(FetchDevicesInRoutine());
// context.read<RoutineBloc>().add(FetchDevicesInRoutine());
}
@override
@ -32,9 +32,12 @@ class _RoutinesViewState extends State<RoutinesView> {
}
return Row(
children: [
Expanded(
child: SpaceTreeView(
onSelect: () {},
Expanded(child: SpaceTreeView(
onSelect: () {
context.read<RoutineBloc>()
..add(const LoadScenes())
..add(const LoadAutomation());
},
)),
Expanded(
flex: 4,
@ -59,8 +62,8 @@ class _RoutinesViewState extends State<RoutinesView> {
),
RoutineViewCard(
onTap: () {
if (context.read<SpaceTreeBloc>().selectedCommunityId.isNotEmpty &&
context.read<SpaceTreeBloc>().selectedSpaceId.isNotEmpty) {
if (context.read<SpaceTreeBloc>().state.selectedCommunities.length == 1 &&
context.read<SpaceTreeBloc>().state.selectedSpaces.length == 1) {
context.read<RoutineBloc>().add(
(ResetRoutineState()),
);
@ -68,7 +71,18 @@ class _RoutinesViewState extends State<RoutinesView> {
const CreateNewRoutineViewEvent(createRoutineView: true),
);
} else {
CustomSnackBar.redSnackBar('Please select a space');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
context.read<SpaceTreeBloc>().state.selectedSpaces.isEmpty
? 'Please select a space'
: 'Please select only one space to proceed'),
),
);
// CustomSnackBar.redSnackBar(
// context.read<SpaceTreeBloc>().state.selectedSpaces.isEmpty
// ? 'Please select a space'
// : 'Please select only one space to proceed');
}
},
icon: Icons.add,