bug_fixing 2

This commit is contained in:
Mohammad Salameh
2024-03-24 14:59:29 +03:00
parent 58bf70ea1a
commit ee095d0fdc
9 changed files with 27 additions and 33 deletions

View File

@ -16,7 +16,7 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
part 'home_state.dart';
class HomeCubit extends Cubit<SpacesState> {
class HomeCubit extends Cubit<HomeState> {
HomeCubit() : super(SpacesInitial()) {
if (HomeCubit.spaces != null) {
if (selectedSpace == null) {

View File

@ -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<SpaceModel> 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<RoomModel> 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 {}

View File

@ -24,7 +24,7 @@ class AppLayout extends StatelessWidget {
create: (context) => DevicesCubit(),
),
],
child: BlocListener<HomeCubit, SpacesState>(
child: BlocListener<HomeCubit, HomeState>(
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<HomeCubit, SpacesState>(
child: BlocBuilder<HomeCubit, HomeState>(
builder: (context, state) {
return AnnotatedRegion(
value: SystemUiOverlayStyle(
@ -44,21 +44,15 @@ class AppLayout extends StatelessWidget {
statusBarIconBrightness: Brightness.light,
),
child: SafeArea(
child: BlocBuilder<HomeCubit, SpacesState>(
child: BlocBuilder<HomeCubit, HomeState>(
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(),
);
},
),

View File

@ -15,7 +15,7 @@ class AppBarHomeDropdown extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<HomeCubit, SpacesState>(
return BlocBuilder<HomeCubit, HomeState>(
builder: (context, state) {
return HomeCubit.selectedSpace == null
? const Center(child: BodyMedium(text: 'No Home Selected'))

View File

@ -12,7 +12,7 @@ class AppBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<HomeCubit, SpacesState>(
return BlocBuilder<HomeCubit, HomeState>(
builder: (context, state) {
return Container(
width: MediaQuery.sizeOf(context).width,
@ -26,7 +26,7 @@ class AppBody extends StatelessWidget {
opacity: 0.4,
),
),
child: BlocConsumer<HomeCubit, SpacesState>(
child: BlocConsumer<HomeCubit, HomeState>(
listener: (context, state) {
if (state is GetSpacesError) {
ScaffoldMessenger.of(context).showSnackBar(

View File

@ -13,7 +13,7 @@ class DefaultNavBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<HomeCubit, SpacesState>(
return BlocBuilder<HomeCubit, HomeState>(
builder: (context, state) {
var cubit = HomeCubit.get(context);
return SizedBox(