Refactor device-related views and add error handling

Refactor device-related views to improve code structure and readability.
Add error handling for authentication token in the splash view.
Remove unnecessary NavCubit from the app initialization.
This commit is contained in:
Mohammad Salameh
2024-03-21 13:58:20 +03:00
parent 96d5f53d38
commit c0bfd24751
20 changed files with 607 additions and 625 deletions

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/nav_cubit.dart';
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
import '../../../../generated/assets.dart';
@ -12,7 +12,7 @@ class AppBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<NavCubit, NavState>(
return BlocBuilder<SpacesCubit, SpacesState>(
builder: (context, state) {
return Container(
width: MediaQuery.sizeOf(context).width,
@ -28,7 +28,7 @@ class AppBody extends StatelessWidget {
),
child: BlocConsumer<SpacesCubit, SpacesState>(
listener: (context, state) {
if (state is SpacesError) {
if (state is GetSpacesError) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(state.errMessage),
@ -37,8 +37,9 @@ class AppBody extends StatelessWidget {
}
},
builder: (context, state) {
return state is! SpacesLoading || state is! SpaceRoomsLoading
? NavCubit.of(context).pages[NavCubit.pageIndex]
return state is! GetSpacesLoading ||
state is! GetSpaceRoomsLoading
? SpacesCubit.get(context).pages[SpacesCubit.pageIndex]
: const Center(child: CircularProgressIndicator());
},
),