mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 10:06:16 +00:00
Fixed the overflow in the login screen, the page is scrollable.
- Fixed Scrolling wasent working in login screen - Changed Home page to indexed based view instead of PageView
This commit is contained in:
@ -17,10 +17,8 @@ class NavCubit extends Cubit<NavState> {
|
|||||||
|
|
||||||
static NavCubit of(context) => BlocProvider.of<NavCubit>(context);
|
static NavCubit of(context) => BlocProvider.of<NavCubit>(context);
|
||||||
|
|
||||||
//functoin to do the important work when the user logs out
|
|
||||||
static clear() {
|
static clear() {
|
||||||
pageIndex = 0;
|
pageIndex = 0;
|
||||||
pageController.jumpToPage(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pageIndex = 0;
|
static int pageIndex = 0;
|
||||||
@ -146,12 +144,9 @@ class NavCubit extends Cubit<NavState> {
|
|||||||
const MenuView(),
|
const MenuView(),
|
||||||
];
|
];
|
||||||
|
|
||||||
static final PageController pageController = PageController();
|
|
||||||
|
|
||||||
void updatePageIndex(int index) {
|
void updatePageIndex(int index) {
|
||||||
pageIndex = index;
|
pageIndex = index;
|
||||||
pageController.animateToPage(index,
|
|
||||||
duration: const Duration(milliseconds: 150), curve: Curves.easeIn);
|
|
||||||
emit(NavChangePage());
|
emit(NavChangePage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
|||||||
import 'package:syncrow_app/features/app_layout/view/widgets/app_body.dart';
|
import 'package:syncrow_app/features/app_layout/view/widgets/app_body.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/view/widgets/default_app_bar.dart';
|
import 'package:syncrow_app/features/app_layout/view/widgets/default_app_bar.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/view/widgets/default_nav_bar.dart';
|
import 'package:syncrow_app/features/app_layout/view/widgets/default_nav_bar.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
||||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
@ -14,8 +15,15 @@ class AppLayout extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return MultiBlocProvider(
|
||||||
create: (context) => SpacesCubit(),
|
providers: [
|
||||||
|
BlocProvider(
|
||||||
|
create: (context) => SpacesCubit(),
|
||||||
|
),
|
||||||
|
BlocProvider(
|
||||||
|
create: (context) => DevicesCubit(),
|
||||||
|
),
|
||||||
|
],
|
||||||
child: BlocListener<SpacesCubit, SpacesState>(
|
child: BlocListener<SpacesCubit, SpacesState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is SpacesError) {
|
if (state is SpacesError) {
|
||||||
|
@ -38,11 +38,7 @@ class AppBody extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return state is! SpacesLoading || state is! SpaceRoomsLoading
|
return state is! SpacesLoading || state is! SpaceRoomsLoading
|
||||||
? PageView(
|
? NavCubit.of(context).pages[NavCubit.pageIndex]
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
controller: NavCubit.pageController,
|
|
||||||
children: NavCubit.of(context).pages,
|
|
||||||
)
|
|
||||||
: const Center(child: CircularProgressIndicator());
|
: const Center(child: CircularProgressIndicator());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -33,40 +33,40 @@ class LoginView extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Scaffold(
|
return SafeArea(
|
||||||
body: Stack(
|
child: Scaffold(
|
||||||
children: [
|
body: Stack(
|
||||||
Container(
|
children: [
|
||||||
width: MediaQuery.sizeOf(context).width,
|
Container(
|
||||||
height: MediaQuery.sizeOf(context).height,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
decoration: const BoxDecoration(
|
height: MediaQuery.sizeOf(context).height,
|
||||||
image: DecorationImage(
|
decoration: const BoxDecoration(
|
||||||
image: AssetImage(
|
image: DecorationImage(
|
||||||
Assets.imagesBackground,
|
image: AssetImage(
|
||||||
|
Assets.imagesBackground,
|
||||||
|
),
|
||||||
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Container(
|
||||||
Container(
|
width: MediaQuery.sizeOf(context).width,
|
||||||
width: MediaQuery.sizeOf(context).width,
|
height: MediaQuery.sizeOf(context).height,
|
||||||
height: MediaQuery.sizeOf(context).height,
|
decoration: const BoxDecoration(
|
||||||
decoration: const BoxDecoration(
|
image: DecorationImage(
|
||||||
image: DecorationImage(
|
image: AssetImage(Assets.imagesVector),
|
||||||
image: AssetImage(Assets.imagesVector),
|
fit: BoxFit.cover,
|
||||||
fit: BoxFit.cover,
|
opacity: 0.9,
|
||||||
opacity: 0.9,
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.only(
|
||||||
padding: const EdgeInsets.symmetric(
|
right: Constants.defaultPadding,
|
||||||
horizontal: Constants.defaultPadding,
|
left: Constants.defaultPadding,
|
||||||
),
|
top: Constants.defaultPadding,
|
||||||
child: SingleChildScrollView(
|
),
|
||||||
child: SizedBox(
|
child: SingleChildScrollView(
|
||||||
width: MediaQuery.sizeOf(context).width,
|
|
||||||
height: MediaQuery.sizeOf(context).height,
|
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@ -99,9 +99,9 @@ class LoginView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
)
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// ignore_for_file: constant_identifier_names
|
// ignore_for_file: constant_identifier_names, unused_import
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -22,273 +22,51 @@ part 'devices_state.dart';
|
|||||||
|
|
||||||
class DevicesCubit extends Cubit<DevicesState> {
|
class DevicesCubit extends Cubit<DevicesState> {
|
||||||
DevicesCubit() : super(DevicesInitial()) {
|
DevicesCubit() : super(DevicesInitial()) {
|
||||||
fetchGroups(SpacesCubit.selectedSpace!);
|
fetchGroups(SpacesCubit.selectedSpace!.id!);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DevicesCubit get(context) => BlocProvider.of(context);
|
static DevicesCubit get(context) => BlocProvider.of(context);
|
||||||
|
|
||||||
static List<DevicesCategoryModel> allCategories = [
|
static List<DevicesCategoryModel>? allCategories;
|
||||||
// DevicesCategoryModel(
|
|
||||||
// devices: [
|
|
||||||
// DeviceModel(
|
|
||||||
// name: "Living Room AC",
|
|
||||||
// id: 0,
|
|
||||||
// functions: [],
|
|
||||||
// status: false,
|
|
||||||
// temperature: 20,
|
|
||||||
// fanSpeed: 0,
|
|
||||||
// tempMode: 0,
|
|
||||||
// coolTo: 20,
|
|
||||||
// type: DeviceType.AC,
|
|
||||||
// image: '',
|
|
||||||
// timer: null,
|
|
||||||
// bounds: Bounds(
|
|
||||||
// min: 20,
|
|
||||||
// max: 30,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// DeviceModel(
|
|
||||||
// name: "Master Bedroom AC",
|
|
||||||
// id: 1,
|
|
||||||
// functions: [],
|
|
||||||
// status: false,
|
|
||||||
// temperature: 20,
|
|
||||||
// fanSpeed: 0,
|
|
||||||
// tempMode: 0,
|
|
||||||
// coolTo: 20,
|
|
||||||
// type: DeviceType.AC,
|
|
||||||
// image: '',
|
|
||||||
// timer: null,
|
|
||||||
// bounds: Bounds(
|
|
||||||
// min: 20,
|
|
||||||
// max: 30,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// DeviceModel(
|
|
||||||
// name: "Kitchen AC",
|
|
||||||
// id: 2,
|
|
||||||
// functions: [],
|
|
||||||
// status: false,
|
|
||||||
// temperature: 20,
|
|
||||||
// fanSpeed: 0,
|
|
||||||
// tempMode: 0,
|
|
||||||
// coolTo: 20,
|
|
||||||
// type: DeviceType.AC,
|
|
||||||
// image: '',
|
|
||||||
// timer: null,
|
|
||||||
// bounds: Bounds(
|
|
||||||
// min: 20,
|
|
||||||
// max: 30,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// DeviceModel(
|
|
||||||
// name: "Bathroom AC",
|
|
||||||
// id: 3,
|
|
||||||
// functions: [],
|
|
||||||
// status: false,
|
|
||||||
// temperature: 20,
|
|
||||||
// fanSpeed: 0,
|
|
||||||
// tempMode: 0,
|
|
||||||
// coolTo: 20,
|
|
||||||
// type: DeviceType.AC,
|
|
||||||
// image: '',
|
|
||||||
// timer: null,
|
|
||||||
// bounds: Bounds(
|
|
||||||
// min: 20,
|
|
||||||
// max: 30,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// icon: Assets.iconsAC,
|
|
||||||
// name: 'ACs',
|
|
||||||
// type: DeviceType.AC,
|
|
||||||
// page: const ACsView(),
|
|
||||||
// ),
|
|
||||||
// DevicesCategoryModel(
|
|
||||||
// devices: [
|
|
||||||
// DeviceModel(
|
|
||||||
// name: "Living Room Light",
|
|
||||||
// id: 0,
|
|
||||||
// functions: [],
|
|
||||||
// status: false,
|
|
||||||
// color: 0,
|
|
||||||
// brightness: 20,
|
|
||||||
// lightingMode: 1,
|
|
||||||
// timer: null,
|
|
||||||
// type: DeviceType.Lights,
|
|
||||||
// image: '',
|
|
||||||
// recentColors: [
|
|
||||||
// 0xFF83D9FF,
|
|
||||||
// 0xFFFC3E81,
|
|
||||||
// 0xFFC0FF66,
|
|
||||||
// 0xFFFDC242,
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// DeviceModel(
|
|
||||||
// name: "Master Bedroom Light",
|
|
||||||
// id: 1,
|
|
||||||
// functions: [],
|
|
||||||
// status: false,
|
|
||||||
// color: 2,
|
|
||||||
// brightness: 40,
|
|
||||||
// lightingMode: 1,
|
|
||||||
// timer: null,
|
|
||||||
// type: DeviceType.Lights,
|
|
||||||
// image: '',
|
|
||||||
// recentColors: [
|
|
||||||
// 0xFF83D9FF,
|
|
||||||
// 0xFFFC3E81,
|
|
||||||
// 0xFFC0FF66,
|
|
||||||
// 0xFFFDC242,
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// DeviceModel(
|
|
||||||
// name: "Kitchen Light",
|
|
||||||
// id: 2,
|
|
||||||
// functions: [],
|
|
||||||
// status: false,
|
|
||||||
// color: 1,
|
|
||||||
// brightness: 60,
|
|
||||||
// lightingMode: 1,
|
|
||||||
// timer: null,
|
|
||||||
// type: DeviceType.Lights,
|
|
||||||
// image: '',
|
|
||||||
// recentColors: [
|
|
||||||
// 0xFF83D9FF,
|
|
||||||
// 0xFFFC3E81,
|
|
||||||
// 0xFFC0FF66,
|
|
||||||
// 0xFFFDC242,
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// DeviceModel(
|
|
||||||
// name: "Bathroom Light",
|
|
||||||
// id: 3,
|
|
||||||
// functions: [],
|
|
||||||
// status: false,
|
|
||||||
// color: 3,
|
|
||||||
// brightness: 80,
|
|
||||||
// lightingMode: 1,
|
|
||||||
// timer: null,
|
|
||||||
// type: DeviceType.Lights,
|
|
||||||
// image: '',
|
|
||||||
// recentColors: [
|
|
||||||
// 0xFF83D9FF,
|
|
||||||
// 0xFFFC3E81,
|
|
||||||
// 0xFFC0FF66,
|
|
||||||
// 0xFFFDC242,
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// DeviceModel(
|
|
||||||
// name: "Balcony Light",
|
|
||||||
// id: 4,
|
|
||||||
// functions: [],
|
|
||||||
// status: false,
|
|
||||||
// color: 4,
|
|
||||||
// brightness: 100,
|
|
||||||
// lightingMode: 1,
|
|
||||||
// timer: null,
|
|
||||||
// type: DeviceType.Lights,
|
|
||||||
// image: '',
|
|
||||||
// recentColors: [
|
|
||||||
// 0xFF83D9FF,
|
|
||||||
// 0xFFFC3E81,
|
|
||||||
// 0xFFC0FF66,
|
|
||||||
// 0xFFFDC242,
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// icon: Assets.iconsLight,
|
|
||||||
// name: 'Lights',
|
|
||||||
// type: DeviceType.Lights,
|
|
||||||
// page: const LightsView(),
|
|
||||||
// ),
|
|
||||||
// DevicesCategoryModel(
|
|
||||||
// devices: [],
|
|
||||||
// icon: Assets.iconsDoorLock,
|
|
||||||
// name: 'Doors',
|
|
||||||
// type: DeviceType.DoorLock,
|
|
||||||
// page: const DoorView(),
|
|
||||||
// ),
|
|
||||||
// DevicesCategoryModel(
|
|
||||||
// devices: [
|
|
||||||
// DeviceModel(
|
|
||||||
// openPercentage: 10,
|
|
||||||
// id: 1,
|
|
||||||
// functions: [],
|
|
||||||
// name: "Living Room Curtain",
|
|
||||||
// status: false,
|
|
||||||
// type: DeviceType.Curtain,
|
|
||||||
// image: '',
|
|
||||||
// timer: null,
|
|
||||||
// ),
|
|
||||||
// DeviceModel(
|
|
||||||
// openPercentage: 20,
|
|
||||||
// id: 2,
|
|
||||||
// functions: [],
|
|
||||||
// name: "Master Bedroom Curtain",
|
|
||||||
// status: false,
|
|
||||||
// type: DeviceType.Curtain,
|
|
||||||
// image: '',
|
|
||||||
// timer: null,
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// icon: Assets.iconsCurtain,
|
|
||||||
// name: 'Curtains',
|
|
||||||
// type: DeviceType.Curtain,
|
|
||||||
// page: const CurtainView(),
|
|
||||||
// ),
|
|
||||||
// DevicesCategoryModel(
|
|
||||||
// devices: [],
|
|
||||||
// icon: Assets.icons3GangSwitch,
|
|
||||||
// name: 'Bedroom Lights',
|
|
||||||
// type: DeviceType.ThreeGang,
|
|
||||||
// page: const LightSwitchesView(),
|
|
||||||
// ),
|
|
||||||
// DevicesCategoryModel(
|
|
||||||
// devices: [],
|
|
||||||
// icon: Assets.iconsGateway,
|
|
||||||
// name: 'Gateway',
|
|
||||||
// type: DeviceType.Gateway,
|
|
||||||
// page: const GateWayView(),
|
|
||||||
// ),
|
|
||||||
];
|
|
||||||
|
|
||||||
selectCategory(int index) {
|
selectCategory(int index) {
|
||||||
for (var i = 0; i < allCategories.length; i++) {
|
for (var i = 0; i < allCategories!.length; i++) {
|
||||||
if (i == index) {
|
if (i == index) {
|
||||||
allCategories[i].isSelected = true;
|
allCategories![i].isSelected = true;
|
||||||
} else {
|
} else {
|
||||||
allCategories[i].isSelected = false;
|
allCategories![i].isSelected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit(DevicesCategoryChanged());
|
emit(DevicesCategoryChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
unselectAllCategories() {
|
unselectAllCategories() {
|
||||||
for (var category in allCategories) {
|
for (var category in allCategories!) {
|
||||||
category.isSelected = false;
|
category.isSelected = false;
|
||||||
}
|
}
|
||||||
emit(DevicesCategoryChanged());
|
emit(DevicesCategoryChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget? get chosenCategoryView {
|
Widget? get chosenCategoryView {
|
||||||
for (var category in allCategories) {
|
if (allCategories != null) {
|
||||||
if (category.isSelected) {
|
for (var category in allCategories!) {
|
||||||
switch (category.type) {
|
if (category.isSelected) {
|
||||||
case DeviceType.AC:
|
switch (category.type) {
|
||||||
return const ACsView();
|
case DeviceType.AC:
|
||||||
case DeviceType.Lights:
|
return const ACsView();
|
||||||
return const LightsView();
|
case DeviceType.Lights:
|
||||||
case DeviceType.DoorLock:
|
return const LightsView();
|
||||||
return const DoorView();
|
case DeviceType.DoorLock:
|
||||||
case DeviceType.Curtain:
|
return const DoorView();
|
||||||
return const CurtainView();
|
case DeviceType.Curtain:
|
||||||
case DeviceType.ThreeGang:
|
return const CurtainView();
|
||||||
return const LightSwitchesView();
|
case DeviceType.ThreeGang:
|
||||||
case DeviceType.Gateway:
|
return const LightSwitchesView();
|
||||||
return const GateWayView();
|
case DeviceType.Gateway:
|
||||||
default:
|
return const GateWayView();
|
||||||
return null;
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -296,7 +74,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DevicesCategoryModel? get chosenCategory {
|
DevicesCategoryModel? get chosenCategory {
|
||||||
for (var category in allCategories) {
|
for (var category in allCategories!) {
|
||||||
if (category.isSelected) {
|
if (category.isSelected) {
|
||||||
return category;
|
return category;
|
||||||
}
|
}
|
||||||
@ -305,7 +83,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectDevice(DeviceModel device) {
|
selectDevice(DeviceModel device) {
|
||||||
for (var category in allCategories) {
|
for (var category in allCategories!) {
|
||||||
if (category.devices != null) {
|
if (category.devices != null) {
|
||||||
for (var device in category.devices!) {
|
for (var device in category.devices!) {
|
||||||
if (device.isSelected) {
|
if (device.isSelected) {
|
||||||
@ -321,7 +99,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeviceModel? getSelectedDevice() {
|
DeviceModel? getSelectedDevice() {
|
||||||
for (var category in allCategories) {
|
for (var category in allCategories!) {
|
||||||
if (category.devices != null) {
|
if (category.devices != null) {
|
||||||
for (var device in category.devices!) {
|
for (var device in category.devices!) {
|
||||||
if (device.isSelected) {
|
if (device.isSelected) {
|
||||||
@ -356,7 +134,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
|
|
||||||
turnOnOffDevice(DeviceModel device) {
|
turnOnOffDevice(DeviceModel device) {
|
||||||
device.status = !device.status!;
|
device.status = !device.status!;
|
||||||
DevicesCategoryModel category = allCategories.firstWhere((category) {
|
DevicesCategoryModel category = allCategories!.firstWhere((category) {
|
||||||
if (category.devices != null) {
|
if (category.devices != null) {
|
||||||
return category.devices!.contains(device);
|
return category.devices!.contains(device);
|
||||||
} else {
|
} else {
|
||||||
@ -427,7 +205,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clearCategoriesSelection(BuildContext context) {
|
clearCategoriesSelection(BuildContext context) {
|
||||||
for (var category in allCategories) {
|
for (var category in allCategories!) {
|
||||||
category.isSelected = false;
|
category.isSelected = false;
|
||||||
if (category.devices != null) {
|
if (category.devices != null) {
|
||||||
for (var device in category.devices!) {
|
for (var device in category.devices!) {
|
||||||
@ -450,16 +228,10 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchGroups(
|
fetchGroups(int spaceId) async {
|
||||||
SpaceModel space,
|
|
||||||
) async {
|
|
||||||
try {
|
try {
|
||||||
if (state is! DevicesCategoriesLoading) {
|
emit(DevicesCategoriesLoading());
|
||||||
emit(DevicesCategoriesLoading());
|
allCategories = await DevicesAPI.fetchGroups(spaceId);
|
||||||
allCategories = await DevicesAPI.fetchGroups(space.id!);
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit(DevicesCategoriesSuccess());
|
emit(DevicesCategoriesSuccess());
|
||||||
} on DioException catch (error) {
|
} on DioException catch (error) {
|
||||||
emit(
|
emit(
|
||||||
|
@ -27,8 +27,8 @@ class LightsView extends StatelessWidget {
|
|||||||
as DeviceModel;
|
as DeviceModel;
|
||||||
}
|
}
|
||||||
List<DeviceModel> lights = [];
|
List<DeviceModel> lights = [];
|
||||||
if (DevicesCubit.allCategories[1].devices != null) {
|
if (DevicesCubit.allCategories![1].devices != null) {
|
||||||
for (var device in DevicesCubit.allCategories[1].devices!) {
|
for (var device in DevicesCubit.allCategories![1].devices!) {
|
||||||
lights.add(device);
|
lights.add(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class LightsViewList extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
const BodySmall(text: "All Lights"),
|
const BodySmall(text: "All Lights"),
|
||||||
UniversalSwitch(
|
UniversalSwitch(
|
||||||
category: DevicesCubit.allCategories[1],
|
category: DevicesCubit.allCategories![1],
|
||||||
),
|
),
|
||||||
LightsList(lights: lights),
|
LightsList(lights: lights),
|
||||||
],
|
],
|
||||||
|
@ -18,71 +18,80 @@ class WizartSwitches extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<DevicesCubit, DevicesState>(
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return state is DevicesLoading
|
return state is! DevicesLoading
|
||||||
? const Center(child: CircularProgressIndicator())
|
? DevicesCubit.allCategories != null
|
||||||
: GridView.builder(
|
? GridView.builder(
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate:
|
||||||
crossAxisCount: 2,
|
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisSpacing: 10,
|
crossAxisCount: 2,
|
||||||
mainAxisSpacing: 10,
|
crossAxisSpacing: 10,
|
||||||
childAspectRatio: 1.5,
|
mainAxisSpacing: 10,
|
||||||
),
|
childAspectRatio: 1.5,
|
||||||
padding: const EdgeInsets.only(top: 10),
|
),
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
padding: const EdgeInsets.only(top: 10),
|
||||||
shrinkWrap: true,
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
itemCount: DevicesCubit.allCategories.length,
|
shrinkWrap: true,
|
||||||
itemBuilder: (_, index) {
|
itemCount: DevicesCubit.allCategories!.length,
|
||||||
return InkWell(
|
itemBuilder: (_, index) {
|
||||||
onTap: () {
|
return InkWell(
|
||||||
DevicesCubit.get(context).selectCategory(index);
|
onTap: () {
|
||||||
//Navigate to the chosen category view without animation
|
DevicesCubit.get(context).selectCategory(index);
|
||||||
|
//Navigate to the chosen category view without animation
|
||||||
|
|
||||||
Navigator.push(context,
|
Navigator.push(context,
|
||||||
CustomPageRoute(builder: (context) {
|
CustomPageRoute(builder: (context) {
|
||||||
return DevicesCubit.get(context).chosenCategoryView!;
|
return DevicesCubit.get(context)
|
||||||
}));
|
.chosenCategoryView!;
|
||||||
},
|
}));
|
||||||
child: DefaultContainer(
|
},
|
||||||
child: Padding(
|
child: DefaultContainer(
|
||||||
padding:
|
child: Padding(
|
||||||
const EdgeInsets.only(top: 10, right: 10, left: 10),
|
padding: const EdgeInsets.only(
|
||||||
child: Column(
|
top: 10, right: 10, left: 10),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
Row(
|
||||||
DevicesCubit.allCategories[index].icon!,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
fit: BoxFit.contain,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
SvgPicture.asset(
|
||||||
|
DevicesCubit.allCategories![index].icon!,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
CustomSwitch(
|
||||||
|
category:
|
||||||
|
DevicesCubit.allCategories![index],
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
CustomSwitch(
|
Expanded(
|
||||||
category: DevicesCubit.allCategories[index],
|
child: FittedBox(
|
||||||
|
fit: BoxFit.scaleDown,
|
||||||
|
child: BodyLarge(
|
||||||
|
text: DevicesCubit
|
||||||
|
.allCategories![index].name!,
|
||||||
|
style: context.bodyLarge.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
height: 0,
|
||||||
|
fontSize: 24,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Expanded(
|
),
|
||||||
child: FittedBox(
|
|
||||||
fit: BoxFit.scaleDown,
|
|
||||||
child: BodyLarge(
|
|
||||||
text: DevicesCubit.allCategories[index].name!,
|
|
||||||
style: context.bodyLarge.copyWith(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
height: 0,
|
|
||||||
fontSize: 24,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
);
|
)
|
||||||
},
|
: const SizedBox.shrink()
|
||||||
|
: const Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -5,8 +5,6 @@ import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
|||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/theme_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/theme_manager.dart';
|
||||||
|
|
||||||
import 'features/devices/bloc/devices_cubit.dart';
|
|
||||||
import 'navigation/router.dart' as router;
|
import 'navigation/router.dart' as router;
|
||||||
import 'navigation/routing_constants.dart';
|
import 'navigation/routing_constants.dart';
|
||||||
|
|
||||||
@ -30,9 +28,6 @@ class MyApp extends StatelessWidget {
|
|||||||
lazy: false,
|
lazy: false,
|
||||||
create: (context) => NavCubit(),
|
create: (context) => NavCubit(),
|
||||||
),
|
),
|
||||||
BlocProvider(
|
|
||||||
create: (context) => DevicesCubit(),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
child: MaterialApp(
|
child: MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
|
@ -38,8 +38,8 @@ class HTTPService {
|
|||||||
queryParameters: queryParameters,
|
queryParameters: queryParameters,
|
||||||
);
|
);
|
||||||
|
|
||||||
debugPrint("status code is ${response.statusCode}");
|
// debugPrint("status code is ${response.statusCode}");
|
||||||
debugPrint("response data is ${response.data}");
|
// debugPrint("response data is ${response.data}");
|
||||||
return expectedResponseModel(response.data);
|
return expectedResponseModel(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
debugPrint("******* Error");
|
debugPrint("******* Error");
|
||||||
|
Reference in New Issue
Block a user