mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
fetch groups
This commit is contained in:
@ -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() {
|
||||
|
@ -26,4 +26,8 @@ class SpaceModel {
|
||||
rooms: [],
|
||||
);
|
||||
}
|
||||
|
||||
static List<SpaceModel> fromJsonList(List<dynamic> jsonList) {
|
||||
return jsonList.map((item) => SpaceModel.fromJson(item)).toList();
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user