mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 04:34:54 +00:00
Add HomeCubit and HomeState classes
This commit adds the HomeCubit class along with its corresponding HomeState class. It also includes necessary imports and updates references to the previously used SpacesCubit to the new HomeCubit in various files. handled the multible onCreate -- HomeCubit
This commit is contained in:
@ -14,11 +14,11 @@ import 'package:syncrow_app/services/api/network_exception.dart';
|
|||||||
import 'package:syncrow_app/services/api/spaces_api.dart';
|
import 'package:syncrow_app/services/api/spaces_api.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
part 'spaces_state.dart';
|
part 'home_state.dart';
|
||||||
|
|
||||||
class SpacesCubit extends Cubit<SpacesState> {
|
class HomeCubit extends Cubit<SpacesState> {
|
||||||
SpacesCubit() : super(SpacesInitial()) {
|
HomeCubit() : super(SpacesInitial()) {
|
||||||
if (SpacesCubit.spaces != null) {
|
if (HomeCubit.spaces != null) {
|
||||||
if (selectedSpace == null) {
|
if (selectedSpace == null) {
|
||||||
fetchSpaces().then((value) {
|
fetchSpaces().then((value) {
|
||||||
if (selectedSpace != null) {
|
if (selectedSpace != null) {
|
||||||
@ -32,7 +32,7 @@ class SpacesCubit extends Cubit<SpacesState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpacesCubit get(context) => BlocProvider.of(context);
|
static HomeCubit get(context) => BlocProvider.of(context);
|
||||||
|
|
||||||
static List<SpaceModel>? spaces;
|
static List<SpaceModel>? spaces;
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ class SpacesCubit extends Cubit<SpacesState> {
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
var bottomNavItems = [
|
static var bottomNavItems = [
|
||||||
defaultBottomNavBarItem(icon: Assets.iconsDashboard, label: 'Dashboard'),
|
defaultBottomNavBarItem(icon: Assets.iconsDashboard, label: 'Dashboard'),
|
||||||
// defaultBottomNavBarItem(icon: Assets.iconslayout, label: 'Layout'),
|
// defaultBottomNavBarItem(icon: Assets.iconslayout, label: 'Layout'),
|
||||||
defaultBottomNavBarItem(icon: Assets.iconsDevices, label: 'Devices'),
|
defaultBottomNavBarItem(icon: Assets.iconsDevices, label: 'Devices'),
|
||||||
@ -1,4 +1,4 @@
|
|||||||
part of 'spaces_cubit.dart';
|
part of 'home_cubit.dart';
|
||||||
|
|
||||||
abstract class SpacesState {}
|
abstract class SpacesState {}
|
||||||
|
|
||||||
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_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';
|
||||||
@ -18,13 +18,13 @@ class AppLayout extends StatelessWidget {
|
|||||||
return MultiBlocProvider(
|
return MultiBlocProvider(
|
||||||
providers: [
|
providers: [
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => SpacesCubit(),
|
create: (context) => HomeCubit(),
|
||||||
),
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => DevicesCubit(),
|
create: (context) => DevicesCubit(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
child: BlocListener<SpacesCubit, SpacesState>(
|
child: BlocListener<HomeCubit, SpacesState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is GetSpacesError) {
|
if (state is GetSpacesError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
@ -36,7 +36,7 @@ class AppLayout extends StatelessWidget {
|
|||||||
.popUntil((route) => route.settings.name == Routes.authLogin);
|
.popUntil((route) => route.settings.name == Routes.authLogin);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: BlocBuilder<SpacesCubit, SpacesState>(
|
child: BlocBuilder<HomeCubit, SpacesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return AnnotatedRegion(
|
return AnnotatedRegion(
|
||||||
value: SystemUiOverlayStyle(
|
value: SystemUiOverlayStyle(
|
||||||
@ -44,7 +44,7 @@ class AppLayout extends StatelessWidget {
|
|||||||
statusBarIconBrightness: Brightness.light,
|
statusBarIconBrightness: Brightness.light,
|
||||||
),
|
),
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: BlocBuilder<SpacesCubit, SpacesState>(
|
child: BlocBuilder<HomeCubit, SpacesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: ColorsManager.backgroundColor,
|
backgroundColor: ColorsManager.backgroundColor,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_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/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
@ -15,9 +15,9 @@ class AppBarHomeDropdown extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<SpacesCubit, SpacesState>(
|
return BlocBuilder<HomeCubit, SpacesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return SpacesCubit.selectedSpace == null
|
return HomeCubit.selectedSpace == null
|
||||||
? const Center(child: BodyMedium(text: 'No Home Selected'))
|
? const Center(child: BodyMedium(text: 'No Home Selected'))
|
||||||
: Padding(
|
: Padding(
|
||||||
padding: const EdgeInsets.only(left: 10, right: 10),
|
padding: const EdgeInsets.only(left: 10, right: 10),
|
||||||
@ -30,8 +30,8 @@ class AppBarHomeDropdown extends StatelessWidget {
|
|||||||
underline: const SizedBox.shrink(),
|
underline: const SizedBox.shrink(),
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
value: SpacesCubit.selectedSpace!.id,
|
value: HomeCubit.selectedSpace!.id,
|
||||||
items: SpacesCubit.spaces!.map((space) {
|
items: HomeCubit.spaces!.map((space) {
|
||||||
return DropdownMenuItem(
|
return DropdownMenuItem(
|
||||||
value: space.id,
|
value: space.id,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -67,7 +67,7 @@ class AppBarHomeDropdown extends StatelessWidget {
|
|||||||
}).toList(),
|
}).toList(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
SpacesCubit.get(context).selectSpace(SpacesCubit.spaces!
|
HomeCubit.get(context).selectSpace(HomeCubit.spaces!
|
||||||
.firstWhere((element) => element.id == value));
|
.firstWhere((element) => element.id == value));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
|
|
||||||
import '../../../../generated/assets.dart';
|
import '../../../../generated/assets.dart';
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ class AppBody extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<SpacesCubit, SpacesState>(
|
return BlocBuilder<HomeCubit, SpacesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Container(
|
return Container(
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
@ -26,7 +26,7 @@ class AppBody extends StatelessWidget {
|
|||||||
opacity: 0.4,
|
opacity: 0.4,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: BlocConsumer<SpacesCubit, SpacesState>(
|
child: BlocConsumer<HomeCubit, SpacesState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is GetSpacesError) {
|
if (state is GetSpacesError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
@ -39,7 +39,7 @@ class AppBody extends StatelessWidget {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return state is! GetSpacesLoading ||
|
return state is! GetSpacesLoading ||
|
||||||
state is! GetSpaceRoomsLoading
|
state is! GetSpaceRoomsLoading
|
||||||
? SpacesCubit.get(context).pages[SpacesCubit.pageIndex]
|
? HomeCubit.get(context).pages[HomeCubit.pageIndex]
|
||||||
: const Center(child: CircularProgressIndicator());
|
: const Center(child: CircularProgressIndicator());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
|
|
||||||
class DefaultAppBar extends StatelessWidget implements PreferredSizeWidget {
|
class DefaultAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
@ -9,7 +9,7 @@ class DefaultAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<SpacesCubit, SpacesState>(
|
return BlocBuilder<HomeCubit, SpacesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
@ -19,15 +19,14 @@ class DefaultAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
leadingWidth: 150,
|
leadingWidth: 150,
|
||||||
toolbarHeight: Constants.appBarHeight,
|
toolbarHeight: Constants.appBarHeight,
|
||||||
leading: SpacesCubit.spaces != null
|
leading: HomeCubit.spaces != null
|
||||||
? SpacesCubit.spaces!.isNotEmpty
|
? HomeCubit.spaces!.isNotEmpty
|
||||||
? SpacesCubit.appBarLeading[SpacesCubit()
|
? HomeCubit.appBarLeading[
|
||||||
.bottomNavItems[SpacesCubit.pageIndex]
|
HomeCubit.bottomNavItems[HomeCubit.pageIndex].label]
|
||||||
.label]
|
|
||||||
: null
|
: null
|
||||||
: null,
|
: null,
|
||||||
actions: SpacesCubit.appBarActions[
|
actions: HomeCubit.appBarActions[
|
||||||
SpacesCubit().bottomNavItems[SpacesCubit.pageIndex].label],
|
HomeCubit.bottomNavItems[HomeCubit.pageIndex].label],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
import 'package:syncrow_app/features/devices/bloc/devices_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';
|
||||||
@ -13,9 +13,9 @@ class DefaultNavBar extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<SpacesCubit, SpacesState>(
|
return BlocBuilder<HomeCubit, SpacesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
var cubit = SpacesCubit.get(context);
|
var cubit = HomeCubit.get(context);
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: Constants.bottomNavBarHeight,
|
height: Constants.bottomNavBarHeight,
|
||||||
child: BottomNavigationBar(
|
child: BottomNavigationBar(
|
||||||
@ -25,11 +25,11 @@ class DefaultNavBar extends StatelessWidget {
|
|||||||
if (DevicesCubit.get(context).chosenCategoryView != null) {
|
if (DevicesCubit.get(context).chosenCategoryView != null) {
|
||||||
DevicesCubit().clearCategoriesSelection(context);
|
DevicesCubit().clearCategoriesSelection(context);
|
||||||
}
|
}
|
||||||
if (SpacesCubit.get(context).selectedRoom != null) {
|
if (HomeCubit.get(context).selectedRoom != null) {
|
||||||
SpacesCubit.get(context).unselectRoom();
|
HomeCubit.get(context).unselectRoom();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
currentIndex: SpacesCubit.pageIndex,
|
currentIndex: HomeCubit.pageIndex,
|
||||||
selectedItemColor: ColorsManager.primaryColor,
|
selectedItemColor: ColorsManager.primaryColor,
|
||||||
selectedLabelStyle: const TextStyle(
|
selectedLabelStyle: const TextStyle(
|
||||||
color: ColorsManager.primaryColor,
|
color: ColorsManager.primaryColor,
|
||||||
@ -39,7 +39,7 @@ class DefaultNavBar extends StatelessWidget {
|
|||||||
unselectedItemColor: Colors.grey,
|
unselectedItemColor: Colors.grey,
|
||||||
type: BottomNavigationBarType.fixed,
|
type: BottomNavigationBarType.fixed,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
items: cubit.bottomNavItems,
|
items: HomeCubit.bottomNavItems,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
|
|
||||||
import 'package:syncrow_app/features/auth/model/login_with_email_model.dart';
|
import 'package:syncrow_app/features/auth/model/login_with_email_model.dart';
|
||||||
import 'package:syncrow_app/features/auth/model/token.dart';
|
import 'package:syncrow_app/features/auth/model/token.dart';
|
||||||
@ -42,8 +42,6 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
|
|
||||||
static Token token = Token.emptyConstructor();
|
static Token token = Token.emptyConstructor();
|
||||||
|
|
||||||
// (FlutterSecureStorage().read(key :'token'));
|
|
||||||
|
|
||||||
login() async {
|
login() async {
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
try {
|
try {
|
||||||
@ -76,7 +74,7 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
try {
|
try {
|
||||||
FlutterSecureStorage storage = const FlutterSecureStorage();
|
FlutterSecureStorage storage = const FlutterSecureStorage();
|
||||||
await storage.delete(key: Token.loginAccessTokenKey);
|
await storage.delete(key: Token.loginAccessTokenKey);
|
||||||
SpacesCubit.clear();
|
HomeCubit.clear();
|
||||||
emit(AuthLoggedOut());
|
emit(AuthLoggedOut());
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
emit(AuthError(ServerFailure.fromDioError(e).errMessage));
|
emit(AuthError(ServerFailure.fromDioError(e).errMessage));
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
|
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||||
@ -22,8 +22,8 @@ part 'devices_state.dart';
|
|||||||
|
|
||||||
class DevicesCubit extends Cubit<DevicesState> {
|
class DevicesCubit extends Cubit<DevicesState> {
|
||||||
DevicesCubit() : super(DevicesInitial()) {
|
DevicesCubit() : super(DevicesInitial()) {
|
||||||
if (SpacesCubit.selectedSpace != null) {
|
if (HomeCubit.selectedSpace != null) {
|
||||||
fetchGroups(SpacesCubit.selectedSpace!.id!);
|
fetchGroups(HomeCubit.selectedSpace!.id!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool _isClosed = false;
|
bool _isClosed = false;
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class ACsList extends StatelessWidget {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
DeviceModel ac = DevicesCubit.get(context)
|
DeviceModel ac = DevicesCubit.get(context)
|
||||||
.chosenCategory!
|
.chosenCategory!
|
||||||
.devices![index] as DeviceModel;
|
.devices![index];
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
|
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/devices_view_header.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/devices_view_header.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/room_page.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/room_page.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/rooms_slider.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/rooms_slider.dart';
|
||||||
@ -18,7 +18,7 @@ class DevicesViewBody extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<SpacesCubit, SpacesState>(
|
return BlocBuilder<HomeCubit, SpacesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return BlocBuilder<DevicesCubit, DevicesState>(
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
@ -42,15 +42,15 @@ class DevicesViewBody extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: PageView(
|
child: PageView(
|
||||||
controller:
|
controller:
|
||||||
SpacesCubit.get(context).devicesPageController,
|
HomeCubit.get(context).devicesPageController,
|
||||||
onPageChanged: (index) {
|
onPageChanged: (index) {
|
||||||
SpacesCubit.get(context).devicesPageChanged(index);
|
HomeCubit.get(context).devicesPageChanged(index);
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
const WizardPage(),
|
const WizardPage(),
|
||||||
if (SpacesCubit.selectedSpace != null)
|
if (HomeCubit.selectedSpace != null)
|
||||||
if (SpacesCubit.selectedSpace!.rooms != null)
|
if (HomeCubit.selectedSpace!.rooms != null)
|
||||||
...SpacesCubit.selectedSpace!.rooms!.map(
|
...HomeCubit.selectedSpace!.rooms!.map(
|
||||||
(room) {
|
(room) {
|
||||||
return RoomPage(
|
return RoomPage(
|
||||||
room: room,
|
room: room,
|
||||||
@ -60,16 +60,15 @@ class DevicesViewBody extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SpacesCubit.selectedSpace != null
|
HomeCubit.selectedSpace != null
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 7,
|
vertical: 7,
|
||||||
),
|
),
|
||||||
child: SmoothPageIndicator(
|
child: SmoothPageIndicator(
|
||||||
controller: SpacesCubit.get(context)
|
controller:
|
||||||
.devicesPageController,
|
HomeCubit.get(context).devicesPageController,
|
||||||
count:
|
count: HomeCubit.selectedSpace!.rooms!.length + 1,
|
||||||
SpacesCubit.selectedSpace!.rooms!.length + 1,
|
|
||||||
effect: const WormEffect(
|
effect: const WormEffect(
|
||||||
paintStyle: PaintingStyle.stroke,
|
paintStyle: PaintingStyle.stroke,
|
||||||
dotHeight: 8,
|
dotHeight: 8,
|
||||||
|
|||||||
@ -41,8 +41,8 @@ class LightInterfaceRecentColor extends StatelessWidget {
|
|||||||
margin: const EdgeInsets.only(right: 10),
|
margin: const EdgeInsets.only(right: 10),
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
decoration: ShapeDecoration(
|
decoration: const ShapeDecoration(
|
||||||
shape: const CircleBorder(),
|
shape: CircleBorder(),
|
||||||
// color: Color(light.recentColors[index]),
|
// color: Color(light.recentColors[index]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
|
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
||||||
@ -27,7 +27,7 @@ class LightSwitchesView extends StatelessWidget {
|
|||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
appBar: const CategoryViewAppBar(),
|
appBar: const CategoryViewAppBar(),
|
||||||
body: BlocBuilder<SpacesCubit, SpacesState>(
|
body: BlocBuilder<HomeCubit, SpacesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Container(
|
return Container(
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.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/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
@ -13,48 +13,48 @@ class RoomsSlider extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<SpacesCubit, SpacesState>(
|
return BlocBuilder<HomeCubit, SpacesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
child: PageView(
|
child: PageView(
|
||||||
controller: SpacesCubit.get(context).roomsPageController,
|
controller: HomeCubit.get(context).roomsPageController,
|
||||||
onPageChanged: (index) {
|
onPageChanged: (index) {
|
||||||
SpacesCubit.get(context).roomSliderPageChanged(index);
|
HomeCubit.get(context).roomSliderPageChanged(index);
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
SpacesCubit.get(context).unselectRoom();
|
HomeCubit.get(context).unselectRoom();
|
||||||
},
|
},
|
||||||
child: TitleMedium(
|
child: TitleMedium(
|
||||||
text: StringsManager.wizard,
|
text: StringsManager.wizard,
|
||||||
style: context.titleMedium.copyWith(
|
style: context.titleMedium.copyWith(
|
||||||
fontSize: 25,
|
fontSize: 25,
|
||||||
color: SpacesCubit.get(context).selectedRoom == null
|
color: HomeCubit.get(context).selectedRoom == null
|
||||||
? ColorsManager.textPrimaryColor
|
? ColorsManager.textPrimaryColor
|
||||||
: ColorsManager.textPrimaryColor.withOpacity(.2),
|
: ColorsManager.textPrimaryColor.withOpacity(.2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (SpacesCubit.selectedSpace != null)
|
if (HomeCubit.selectedSpace != null)
|
||||||
if (SpacesCubit.selectedSpace!.rooms != null)
|
if (HomeCubit.selectedSpace!.rooms != null)
|
||||||
...SpacesCubit.selectedSpace!.rooms!.map(
|
...HomeCubit.selectedSpace!.rooms!.map(
|
||||||
(room) => Padding(
|
(room) => Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
SpacesCubit.get(context).roomSliderPageChanged(
|
HomeCubit.get(context).roomSliderPageChanged(
|
||||||
SpacesCubit.selectedSpace!.rooms!.indexOf(room));
|
HomeCubit.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).selectedRoom == room
|
color: HomeCubit.get(context).selectedRoom == room
|
||||||
? ColorsManager.textPrimaryColor
|
? ColorsManager.textPrimaryColor
|
||||||
: ColorsManager.textPrimaryColor
|
: ColorsManager.textPrimaryColor
|
||||||
.withOpacity(.2),
|
.withOpacity(.2),
|
||||||
|
|||||||
@ -15,9 +15,8 @@ class SplashView extends StatelessWidget {
|
|||||||
return BlocConsumer<AuthCubit, AuthState>(
|
return BlocConsumer<AuthCubit, AuthState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is AuthTokenSuccess) {
|
if (state is AuthTokenSuccess) {
|
||||||
Future.delayed(const Duration(seconds: 1), () {
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
Navigator.pushReplacementNamed(context, Routes.homeRoute);
|
context, Routes.homeRoute, (route) => false);
|
||||||
});
|
|
||||||
} else if (state is AuthTokenError) {
|
} else if (state is AuthTokenError) {
|
||||||
Future.delayed(const Duration(seconds: 1), () {
|
Future.delayed(const Duration(seconds: 1), () {
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
|
|||||||
Reference in New Issue
Block a user