mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 14:27:55 +00:00
Implemented the page view functionality
-synced page controllers
This commit is contained in:
@@ -209,44 +209,59 @@ class SpacesCubit extends Cubit<SpacesState> {
|
||||
|
||||
PageController devicesPageController = PageController();
|
||||
|
||||
ScrollController roomsScrollController = ScrollController();
|
||||
PageController roomsPageController = PageController();
|
||||
|
||||
int selectedRoomIndex = 0;
|
||||
var duration = const Duration(milliseconds: 300);
|
||||
|
||||
selectSpace(SpaceModel space) {
|
||||
selectedSpace = space;
|
||||
emit(SpacesSelected(space));
|
||||
}
|
||||
|
||||
updateSelectedRoomIndex(int index) {
|
||||
selectedRoomIndex = index;
|
||||
emit(RoomSelected(selectedSpace.rooms.elementAt(index)));
|
||||
roomSliderPageChanged(int index) {
|
||||
devicesPageController.animateToPage(
|
||||
index,
|
||||
duration: duration,
|
||||
curve: Curves.linear,
|
||||
);
|
||||
|
||||
if (index == 0) {
|
||||
unselectRoom();
|
||||
} else {
|
||||
selectedRoom = selectedSpace.rooms[index - 1];
|
||||
print(selectedRoom!.name);
|
||||
}
|
||||
emit(RoomSelected(selectedRoom!));
|
||||
}
|
||||
|
||||
selectRoom(RoomModel room) {
|
||||
selectedRoom = room;
|
||||
selectedRoomIndex = selectedSpace.rooms.indexOf(room) + 1;
|
||||
print(selectedRoomIndex);
|
||||
devicesPageController.animateToPage(
|
||||
selectedRoomIndex,
|
||||
devicesPageChanged(int index) {
|
||||
roomsPageController.animateToPage(
|
||||
index,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
curve: Curves.linear,
|
||||
);
|
||||
// roomsScrollController.animateTo(
|
||||
// roomsScrollController.positions.elementAt(selectedRoomIndex).pixels,
|
||||
// duration: const Duration(milliseconds: 300),
|
||||
// curve: Curves.easeInOut,
|
||||
// );
|
||||
emit(RoomSelected(room));
|
||||
|
||||
if (index == 0) {
|
||||
unselectRoom();
|
||||
} else {
|
||||
selectedRoom = selectedSpace.rooms[index - 1];
|
||||
print(selectedRoom!.name);
|
||||
}
|
||||
emit(RoomSelected(selectedRoom!));
|
||||
}
|
||||
|
||||
unselectRoom() {
|
||||
selectedRoom = null;
|
||||
selectedRoomIndex = 0;
|
||||
devicesPageController.animateToPage(
|
||||
selectedRoomIndex,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
0,
|
||||
duration: duration,
|
||||
curve: Curves.linear,
|
||||
);
|
||||
|
||||
roomsPageController.animateToPage(
|
||||
0,
|
||||
duration: duration,
|
||||
curve: Curves.linear,
|
||||
);
|
||||
|
||||
emit(RoomUnSelected());
|
||||
|
||||
Reference in New Issue
Block a user