fetch groups

This commit is contained in:
Mohammad Salameh
2024-03-18 11:46:27 +03:00
parent 65cbf10485
commit 13e80fbad7
20 changed files with 273 additions and 164 deletions

View File

@ -21,7 +21,7 @@ class SpacesCubit extends Cubit<SpacesState> {
static List<SpaceModel> spaces = [];
SpaceModel? selectedSpace = spaces.isNotEmpty ? spaces.first : null;
static SpaceModel? selectedSpace = spaces.isNotEmpty ? spaces.first : null;
RoomModel? selectedRoom;
@ -47,8 +47,8 @@ class SpacesCubit extends Cubit<SpacesState> {
unselectRoom();
} else {
selectedRoom = selectedSpace!.rooms![index - 1];
emit(RoomSelected(selectedRoom!));
}
emit(RoomSelected(selectedRoom!));
}
devicesPageChanged(int index) {
@ -58,12 +58,12 @@ class SpacesCubit extends Cubit<SpacesState> {
curve: Curves.linear,
);
if (index == 0) {
if (index <= 0) {
unselectRoom();
} else {
selectedRoom = selectedSpace!.rooms![index - 1];
emit(RoomSelected(selectedRoom!));
}
emit(RoomSelected(selectedRoom!));
}
unselectRoom() {

View File

@ -26,4 +26,8 @@ class SpaceModel {
rooms: [],
);
}
static List<SpaceModel> fromJsonList(List<dynamic> jsonList) {
return jsonList.map((item) => SpaceModel.fromJson(item)).toList();
}
}

View File

@ -28,7 +28,7 @@ class AppBarHomeDropdown extends StatelessWidget {
underline: const SizedBox.shrink(),
padding: const EdgeInsets.all(0),
borderRadius: BorderRadius.circular(20),
value: SpacesCubit.get(context).selectedSpace!.id,
value: SpacesCubit.selectedSpace!.id,
items: SpacesCubit.spaces.map((space) {
return DropdownMenuItem(
value: space.id,