mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-17 02:25:16 +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();
|
PageController devicesPageController = PageController();
|
||||||
|
|
||||||
ScrollController roomsScrollController = ScrollController();
|
PageController roomsPageController = PageController();
|
||||||
|
|
||||||
int selectedRoomIndex = 0;
|
var duration = const Duration(milliseconds: 300);
|
||||||
|
|
||||||
selectSpace(SpaceModel space) {
|
selectSpace(SpaceModel space) {
|
||||||
selectedSpace = space;
|
selectedSpace = space;
|
||||||
emit(SpacesSelected(space));
|
emit(SpacesSelected(space));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSelectedRoomIndex(int index) {
|
roomSliderPageChanged(int index) {
|
||||||
selectedRoomIndex = index;
|
devicesPageController.animateToPage(
|
||||||
emit(RoomSelected(selectedSpace.rooms.elementAt(index)));
|
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) {
|
devicesPageChanged(int index) {
|
||||||
selectedRoom = room;
|
roomsPageController.animateToPage(
|
||||||
selectedRoomIndex = selectedSpace.rooms.indexOf(room) + 1;
|
index,
|
||||||
print(selectedRoomIndex);
|
|
||||||
devicesPageController.animateToPage(
|
|
||||||
selectedRoomIndex,
|
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.linear,
|
||||||
);
|
);
|
||||||
// roomsScrollController.animateTo(
|
|
||||||
// roomsScrollController.positions.elementAt(selectedRoomIndex).pixels,
|
if (index == 0) {
|
||||||
// duration: const Duration(milliseconds: 300),
|
unselectRoom();
|
||||||
// curve: Curves.easeInOut,
|
} else {
|
||||||
// );
|
selectedRoom = selectedSpace.rooms[index - 1];
|
||||||
emit(RoomSelected(room));
|
print(selectedRoom!.name);
|
||||||
|
}
|
||||||
|
emit(RoomSelected(selectedRoom!));
|
||||||
}
|
}
|
||||||
|
|
||||||
unselectRoom() {
|
unselectRoom() {
|
||||||
selectedRoom = null;
|
selectedRoom = null;
|
||||||
selectedRoomIndex = 0;
|
|
||||||
devicesPageController.animateToPage(
|
devicesPageController.animateToPage(
|
||||||
selectedRoomIndex,
|
0,
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: duration,
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.linear,
|
||||||
|
);
|
||||||
|
|
||||||
|
roomsPageController.animateToPage(
|
||||||
|
0,
|
||||||
|
duration: duration,
|
||||||
|
curve: Curves.linear,
|
||||||
);
|
);
|
||||||
|
|
||||||
emit(RoomUnSelected());
|
emit(RoomUnSelected());
|
||||||
|
@ -26,8 +26,9 @@ class DevicesViewBody extends StatelessWidget {
|
|||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: CircularProgressIndicator())
|
||||||
: Padding(
|
: Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
top: Constants.appBarHeight,
|
top: Constants.appBarHeight,
|
||||||
bottom: Constants.bottomNavBarHeight),
|
bottom: Constants.bottomNavBarHeight,
|
||||||
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@ -40,6 +41,9 @@ class DevicesViewBody extends StatelessWidget {
|
|||||||
child: PageView(
|
child: PageView(
|
||||||
controller:
|
controller:
|
||||||
SpacesCubit.get(context).devicesPageController,
|
SpacesCubit.get(context).devicesPageController,
|
||||||
|
onPageChanged: (index) {
|
||||||
|
SpacesCubit.get(context).devicesPageChanged(index);
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
const WizardPage(),
|
const WizardPage(),
|
||||||
...SpacesCubit.get(context).selectedSpace.rooms.map(
|
...SpacesCubit.get(context).selectedSpace.rooms.map(
|
||||||
@ -57,22 +61,17 @@ class DevicesViewBody extends StatelessWidget {
|
|||||||
vertical: 7,
|
vertical: 7,
|
||||||
),
|
),
|
||||||
child: SmoothPageIndicator(
|
child: SmoothPageIndicator(
|
||||||
controller:
|
controller:
|
||||||
SpacesCubit.get(context).devicesPageController,
|
SpacesCubit.get(context).devicesPageController,
|
||||||
count: 3,
|
count: 3,
|
||||||
effect: const WormEffect(
|
effect: const WormEffect(
|
||||||
dotHeight: 8,
|
dotHeight: 8,
|
||||||
dotWidth: 8,
|
dotWidth: 8,
|
||||||
),
|
),
|
||||||
onDotClicked: (index) {
|
onDotClicked: (index) {
|
||||||
SpacesCubit.get(context)
|
SpacesCubit.get(context).unselectRoom();
|
||||||
.devicesPageController
|
},
|
||||||
.animateToPage(
|
),
|
||||||
index,
|
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
curve: Curves.ease,
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:syncrow_app/features/devices/view/widgets/devices_mode_tab.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/devices_mode_tab.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
|
||||||
import 'package:syncrow_app/utils/context_extension.dart';
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
||||||
|
|
||||||
class DevicesViewHeader extends StatelessWidget {
|
class DevicesViewHeader extends StatelessWidget {
|
||||||
@ -11,17 +12,25 @@ class DevicesViewHeader extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Padding(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
padding: const EdgeInsets.symmetric(
|
||||||
children: [
|
horizontal: Constants.defaultPadding,
|
||||||
TitleMedium(
|
),
|
||||||
text: StringsManager.devices,
|
child: Column(
|
||||||
style: context.titleMedium.copyWith(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
fontSize: 25,
|
children: [
|
||||||
|
TitleMedium(
|
||||||
|
text: StringsManager.devices,
|
||||||
|
style: context.titleMedium.copyWith(
|
||||||
|
fontSize: 25,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const DevicesModeTab(),
|
||||||
const DevicesModeTab(),
|
const SizedBox(
|
||||||
],
|
height: 20,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,13 @@ class RoomsSlider extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<SpacesCubit, SpacesState>(
|
return BlocBuilder<SpacesCubit, SpacesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return SingleChildScrollView(
|
return SizedBox(
|
||||||
controller: SpacesCubit.get(context).roomsScrollController,
|
height: 40,
|
||||||
scrollDirection: Axis.horizontal,
|
child: PageView(
|
||||||
child: Row(
|
controller: SpacesCubit.get(context).roomsPageController,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
onPageChanged: (index) {
|
||||||
|
SpacesCubit.get(context).roomSliderPageChanged(index);
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
@ -43,18 +45,17 @@ class RoomsSlider extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
SpacesCubit.get(context).selectRoom(room);
|
SpacesCubit.get(context).roomSliderPageChanged(
|
||||||
|
SpacesCubit.get(context)
|
||||||
|
.selectedSpace
|
||||||
|
.rooms
|
||||||
|
.indexOf(room));
|
||||||
},
|
},
|
||||||
child: TitleMedium(
|
child: TitleMedium(
|
||||||
text: room.name,
|
text: room.name,
|
||||||
style: context.titleMedium.copyWith(
|
style: context.titleMedium.copyWith(
|
||||||
fontSize: 25,
|
fontSize: 25,
|
||||||
color: SpacesCubit.get(context).selectedRoomIndex ==
|
color: SpacesCubit.get(context).selectedRoom == room
|
||||||
SpacesCubit.get(context)
|
|
||||||
.selectedSpace
|
|
||||||
.rooms
|
|
||||||
.indexOf(room) +
|
|
||||||
1
|
|
||||||
? ColorsManager.textPrimaryColor
|
? ColorsManager.textPrimaryColor
|
||||||
: ColorsManager.textPrimaryColor
|
: ColorsManager.textPrimaryColor
|
||||||
.withOpacity(.2),
|
.withOpacity(.2),
|
||||||
@ -66,6 +67,58 @@ class RoomsSlider extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// SingleChildScrollView(
|
||||||
|
// controller: SpacesCubit.get(context).roomsScrollController,
|
||||||
|
// scrollDirection: Axis.horizontal,
|
||||||
|
// child: Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// Padding(
|
||||||
|
// padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
|
// child: InkWell(
|
||||||
|
// onTap: () {
|
||||||
|
// SpacesCubit.get(context).unselectRoom();
|
||||||
|
// },
|
||||||
|
// child: TitleMedium(
|
||||||
|
// text: StringsManager.wizard,
|
||||||
|
// style: context.titleMedium.copyWith(
|
||||||
|
// fontSize: 25,
|
||||||
|
// color: SpacesCubit.get(context).selectedRoom == null
|
||||||
|
// ? ColorsManager.textPrimaryColor
|
||||||
|
// : ColorsManager.textPrimaryColor.withOpacity(.2),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ...SpacesCubit.get(context).selectedSpace.rooms.map(
|
||||||
|
// (room) => Padding(
|
||||||
|
// padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
|
// child: InkWell(
|
||||||
|
// onTap: () {
|
||||||
|
// SpacesCubit.get(context).selectRoom(room);
|
||||||
|
// },
|
||||||
|
// child: TitleMedium(
|
||||||
|
// text: room.name,
|
||||||
|
// style: context.titleMedium.copyWith(
|
||||||
|
// fontSize: 25,
|
||||||
|
// color: SpacesCubit.get(context).selectedRoomIndex ==
|
||||||
|
// SpacesCubit.get(context)
|
||||||
|
// .selectedSpace
|
||||||
|
// .rooms
|
||||||
|
// .indexOf(room) +
|
||||||
|
// 1
|
||||||
|
// ? ColorsManager.textPrimaryColor
|
||||||
|
// : ColorsManager.textPrimaryColor
|
||||||
|
// .withOpacity(.2),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:syncrow_app/features/app_layout/view/app_layout.dart';
|
||||||
import 'package:syncrow_app/features/auth/view/auth_view.dart';
|
import 'package:syncrow_app/features/auth/view/auth_view.dart';
|
||||||
import 'package:syncrow_app/features/dashboard/view/dashboard_view.dart';
|
import 'package:syncrow_app/features/dashboard/view/dashboard_view.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/devices_view.dart';
|
import 'package:syncrow_app/features/devices/view/devices_view.dart';
|
||||||
import 'package:syncrow_app/features/layout/view/layout_view.dart';
|
import 'package:syncrow_app/features/layout/view/layout_view.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/view/app_layout.dart';
|
import 'package:syncrow_app/features/menu/view/menu_view.dart';
|
||||||
import 'package:syncrow_app/features/profile/view/profile_view.dart';
|
import 'package:syncrow_app/features/profile/view/profile_view.dart';
|
||||||
import 'package:syncrow_app/features/scene/view/scene_view.dart';
|
import 'package:syncrow_app/features/scene/view/scene_view.dart';
|
||||||
import 'package:syncrow_app/features/splash/view/splash_view.dart';
|
import 'package:syncrow_app/features/splash/view/splash_view.dart';
|
||||||
@ -45,6 +46,10 @@ class Router {
|
|||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (_) => const AppLayout(), settings: settings);
|
builder: (_) => const AppLayout(), settings: settings);
|
||||||
|
|
||||||
|
case Routes.menuRoute:
|
||||||
|
return MaterialPageRoute(
|
||||||
|
builder: (_) => const MenuView(), settings: settings);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (_) => Scaffold(
|
builder: (_) => Scaffold(
|
||||||
|
@ -6,5 +6,6 @@ class Routes {
|
|||||||
static const String sceneRoute = '/scene';
|
static const String sceneRoute = '/scene';
|
||||||
static const String layoutRoute = '/layout';
|
static const String layoutRoute = '/layout';
|
||||||
static const String profileRoute = '/profile';
|
static const String profileRoute = '/profile';
|
||||||
|
static const String menuRoute = '/menu';
|
||||||
static const String authRoute = '/auth';
|
static const String authRoute = '/auth';
|
||||||
}
|
}
|
||||||
|
48
pubspec.lock
48
pubspec.lock
@ -389,6 +389,30 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.7"
|
version: "0.6.7"
|
||||||
|
leak_tracker:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: leak_tracker
|
||||||
|
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "10.0.0"
|
||||||
|
leak_tracker_flutter_testing:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: leak_tracker_flutter_testing
|
||||||
|
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.1"
|
||||||
|
leak_tracker_testing:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: leak_tracker_testing
|
||||||
|
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.1"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -401,26 +425,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.16"
|
version: "0.12.16+1"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.0"
|
version: "0.8.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
|
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.0"
|
version: "1.11.0"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -441,10 +465,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path
|
name: path
|
||||||
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
|
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.3"
|
version: "1.9.0"
|
||||||
path_parsing:
|
path_parsing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -810,6 +834,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.4"
|
||||||
|
vm_service:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: vm_service
|
||||||
|
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "13.0.0"
|
||||||
web:
|
web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
Reference in New Issue
Block a user