mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 03:04:54 +00:00
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:
@ -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());
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user