mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00

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
73 lines
2.6 KiB
Dart
73 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.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/default_app_bar.dart';
|
|
import 'package:syncrow_app/features/app_layout/view/widgets/default_nav_bar.dart';
|
|
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
|
import 'package:syncrow_app/navigation/routing_constants.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|
|
|
class AppLayout extends StatelessWidget {
|
|
const AppLayout({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MultiBlocProvider(
|
|
providers: [
|
|
BlocProvider(
|
|
create: (context) => HomeCubit(),
|
|
),
|
|
BlocProvider(
|
|
create: (context) => DevicesCubit(),
|
|
),
|
|
],
|
|
child: BlocListener<HomeCubit, SpacesState>(
|
|
listener: (context, state) {
|
|
if (state is GetSpacesError) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(state.errMessage),
|
|
),
|
|
);
|
|
Navigator.of(context)
|
|
.popUntil((route) => route.settings.name == Routes.authLogin);
|
|
}
|
|
},
|
|
child: BlocBuilder<HomeCubit, SpacesState>(
|
|
builder: (context, state) {
|
|
return AnnotatedRegion(
|
|
value: SystemUiOverlayStyle(
|
|
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
|
|
statusBarIconBrightness: Brightness.light,
|
|
),
|
|
child: SafeArea(
|
|
child: BlocBuilder<HomeCubit, SpacesState>(
|
|
builder: (context, state) {
|
|
return 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,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|