From ee095d0fdce7f7dbcde064c4be7715f89a024336 Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Sun, 24 Mar 2024 14:59:29 +0300 Subject: [PATCH] bug_fixing 2 --- lib/features/app_layout/bloc/home_cubit.dart | 2 +- lib/features/app_layout/bloc/home_state.dart | 24 +++++++++---------- lib/features/app_layout/view/app_layout.dart | 20 ++++++---------- .../view/widgets/app_bar_home_dropdown.dart | 2 +- .../app_layout/view/widgets/app_body.dart | 4 ++-- .../view/widgets/default_nav_bar.dart | 2 +- .../view/widgets/devices_view_body.dart | 2 +- .../lights_switches/light_switches.dart | 2 +- .../devices/view/widgets/rooms_slider.dart | 2 +- 9 files changed, 27 insertions(+), 33 deletions(-) diff --git a/lib/features/app_layout/bloc/home_cubit.dart b/lib/features/app_layout/bloc/home_cubit.dart index 17cedeb..b0e1932 100644 --- a/lib/features/app_layout/bloc/home_cubit.dart +++ b/lib/features/app_layout/bloc/home_cubit.dart @@ -16,7 +16,7 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; part 'home_state.dart'; -class HomeCubit extends Cubit { +class HomeCubit extends Cubit { HomeCubit() : super(SpacesInitial()) { if (HomeCubit.spaces != null) { if (selectedSpace == null) { diff --git a/lib/features/app_layout/bloc/home_state.dart b/lib/features/app_layout/bloc/home_state.dart index 017fcf9..e5880c7 100644 --- a/lib/features/app_layout/bloc/home_state.dart +++ b/lib/features/app_layout/bloc/home_state.dart @@ -1,48 +1,48 @@ part of 'home_cubit.dart'; -abstract class SpacesState {} +abstract class HomeState {} -class SpacesInitial extends SpacesState {} +class SpacesInitial extends HomeState {} -class GetSpacesLoading extends SpacesState {} +class GetSpacesLoading extends HomeState {} -class GetSpacesLoaded extends SpacesState { +class GetSpacesLoaded extends HomeState { final List spaces; GetSpacesLoaded(this.spaces); } -class GetSpacesError extends SpacesState { +class GetSpacesError extends HomeState { final String errMessage; GetSpacesError(this.errMessage); } -class GetSpaceRoomsLoading extends SpacesState {} +class GetSpaceRoomsLoading extends HomeState {} -class GetSpaceRoomsLoaded extends SpacesState { +class GetSpaceRoomsLoaded extends HomeState { final List rooms; GetSpaceRoomsLoaded(this.rooms); } -class GetSpaceRoomsError extends SpacesState { +class GetSpaceRoomsError extends HomeState { final String errMessage; GetSpaceRoomsError(this.errMessage); } -class SpaceSelected extends SpacesState { +class SpaceSelected extends HomeState { final SpaceModel space; SpaceSelected(this.space); } -class RoomSelected extends SpacesState { +class RoomSelected extends HomeState { final RoomModel room; RoomSelected(this.room); } -class RoomUnSelected extends SpacesState {} +class RoomUnSelected extends HomeState {} -class NavChangePage extends SpacesState {} +class NavChangePage extends HomeState {} diff --git a/lib/features/app_layout/view/app_layout.dart b/lib/features/app_layout/view/app_layout.dart index 6b7d0c4..dda35a1 100644 --- a/lib/features/app_layout/view/app_layout.dart +++ b/lib/features/app_layout/view/app_layout.dart @@ -24,7 +24,7 @@ class AppLayout extends StatelessWidget { create: (context) => DevicesCubit(), ), ], - child: BlocListener( + child: BlocListener( listener: (context, state) { if (state is GetSpacesError) { ScaffoldMessenger.of(context).showSnackBar( @@ -36,7 +36,7 @@ class AppLayout extends StatelessWidget { .popUntil((route) => route.settings.name == Routes.authLogin); } }, - child: BlocBuilder( + child: BlocBuilder( builder: (context, state) { return AnnotatedRegion( value: SystemUiOverlayStyle( @@ -44,21 +44,15 @@ class AppLayout extends StatelessWidget { statusBarIconBrightness: Brightness.light, ), child: SafeArea( - child: BlocBuilder( + child: BlocBuilder( builder: (context, state) { - return Scaffold( + return const Scaffold( backgroundColor: ColorsManager.backgroundColor, extendBodyBehindAppBar: true, extendBody: true, - appBar: state is! GetSpacesLoading || - state is! GetSpaceRoomsLoading - ? const DefaultAppBar() - : null, - body: const AppBody(), - bottomNavigationBar: state is! GetSpacesLoading || - state is! GetSpaceRoomsLoading - ? const DefaultNavBar() - : null, + appBar: DefaultAppBar(), + body: AppBody(), + bottomNavigationBar: DefaultNavBar(), ); }, ), diff --git a/lib/features/app_layout/view/widgets/app_bar_home_dropdown.dart b/lib/features/app_layout/view/widgets/app_bar_home_dropdown.dart index edbb684..2b89da6 100644 --- a/lib/features/app_layout/view/widgets/app_bar_home_dropdown.dart +++ b/lib/features/app_layout/view/widgets/app_bar_home_dropdown.dart @@ -15,7 +15,7 @@ class AppBarHomeDropdown extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocBuilder( + return BlocBuilder( builder: (context, state) { return HomeCubit.selectedSpace == null ? const Center(child: BodyMedium(text: 'No Home Selected')) diff --git a/lib/features/app_layout/view/widgets/app_body.dart b/lib/features/app_layout/view/widgets/app_body.dart index e4ea499..ef2a47d 100644 --- a/lib/features/app_layout/view/widgets/app_body.dart +++ b/lib/features/app_layout/view/widgets/app_body.dart @@ -12,7 +12,7 @@ class AppBody extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocBuilder( + return BlocBuilder( builder: (context, state) { return Container( width: MediaQuery.sizeOf(context).width, @@ -26,7 +26,7 @@ class AppBody extends StatelessWidget { opacity: 0.4, ), ), - child: BlocConsumer( + child: BlocConsumer( listener: (context, state) { if (state is GetSpacesError) { ScaffoldMessenger.of(context).showSnackBar( diff --git a/lib/features/app_layout/view/widgets/default_nav_bar.dart b/lib/features/app_layout/view/widgets/default_nav_bar.dart index 21a01f4..15aef6e 100644 --- a/lib/features/app_layout/view/widgets/default_nav_bar.dart +++ b/lib/features/app_layout/view/widgets/default_nav_bar.dart @@ -13,7 +13,7 @@ class DefaultNavBar extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocBuilder( + return BlocBuilder( builder: (context, state) { var cubit = HomeCubit.get(context); return SizedBox( diff --git a/lib/features/devices/view/widgets/devices_view_body.dart b/lib/features/devices/view/widgets/devices_view_body.dart index 4345611..7837d8b 100644 --- a/lib/features/devices/view/widgets/devices_view_body.dart +++ b/lib/features/devices/view/widgets/devices_view_body.dart @@ -18,7 +18,7 @@ class DevicesViewBody extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocBuilder( + return BlocBuilder( builder: (context, state) { return BlocBuilder( builder: (context, state) { diff --git a/lib/features/devices/view/widgets/lights_switches/light_switches.dart b/lib/features/devices/view/widgets/lights_switches/light_switches.dart index 86e5f52..cadbd20 100644 --- a/lib/features/devices/view/widgets/lights_switches/light_switches.dart +++ b/lib/features/devices/view/widgets/lights_switches/light_switches.dart @@ -27,7 +27,7 @@ class LightSwitchesView extends StatelessWidget { extendBodyBehindAppBar: true, extendBody: true, appBar: const CategoryViewAppBar(), - body: BlocBuilder( + body: BlocBuilder( builder: (context, state) { return Container( width: MediaQuery.sizeOf(context).width, diff --git a/lib/features/devices/view/widgets/rooms_slider.dart b/lib/features/devices/view/widgets/rooms_slider.dart index 7c7add3..7d5795a 100644 --- a/lib/features/devices/view/widgets/rooms_slider.dart +++ b/lib/features/devices/view/widgets/rooms_slider.dart @@ -13,7 +13,7 @@ class RoomsSlider extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocBuilder( + return BlocBuilder( builder: (context, state) { return SizedBox( height: 40,