100 lines
3.3 KiB
Dart
100 lines
3.3 KiB
Dart
import 'package:core_localization/core_localization.dart' as core_localization;
|
|
import 'package:design_system/design_system.dart';
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
import 'package:flutter_modular/flutter_modular.dart';
|
|
import 'package:krow_data_connect/krow_data_connect.dart';
|
|
import 'package:krowwithus_staff/firebase_options.dart';
|
|
import 'package:staff_authentication/staff_authentication.dart'
|
|
as staff_authentication;
|
|
import 'package:staff_main/staff_main.dart' as staff_main;
|
|
import 'package:krow_core/core.dart';
|
|
|
|
import 'src/widgets/session_listener.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
|
|
|
// Register global BLoC observer for centralized error logging
|
|
Bloc.observer = CoreBlocObserver(
|
|
logEvents: true,
|
|
logStateChanges: false, // Set to true for verbose debugging
|
|
);
|
|
|
|
// Initialize session listener for Firebase Auth state changes
|
|
DataConnectService.instance.initializeAuthListener(
|
|
allowedRoles: <String>['STAFF', 'BOTH'], // Only allow users with STAFF or BOTH roles
|
|
);
|
|
|
|
runApp(
|
|
ModularApp(
|
|
module: AppModule(),
|
|
child: const SessionListener(child: AppWidget()),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// The main application module.
|
|
class AppModule extends Module {
|
|
@override
|
|
List<Module> get imports =>
|
|
<Module>[
|
|
core_localization.LocalizationModule(),
|
|
staff_authentication.StaffAuthenticationModule(),
|
|
];
|
|
|
|
@override
|
|
void routes(RouteManager r) {
|
|
// Set the initial route to the authentication module
|
|
r.module(
|
|
StaffPaths.root,
|
|
module: staff_authentication.StaffAuthenticationModule(),
|
|
);
|
|
|
|
r.module(StaffPaths.main, module: staff_main.StaffMainModule());
|
|
}
|
|
}
|
|
|
|
class AppWidget extends StatelessWidget {
|
|
const AppWidget({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return WebMobileFrame(
|
|
appName: 'KROW Staff\nApplication',
|
|
logo: Image.asset('assets/logo.png'),
|
|
child: BlocProvider<core_localization.LocaleBloc>(
|
|
create: (BuildContext context) =>
|
|
Modular.get<core_localization.LocaleBloc>(),
|
|
child:
|
|
BlocBuilder<
|
|
core_localization.LocaleBloc,
|
|
core_localization.LocaleState
|
|
>(
|
|
builder:
|
|
(BuildContext context, core_localization.LocaleState state) {
|
|
return core_localization.TranslationProvider(
|
|
child: MaterialApp.router(
|
|
title: "KROW Staff",
|
|
theme: UiTheme.light,
|
|
routerConfig: Modular.routerConfig,
|
|
locale: state.locale,
|
|
supportedLocales: state.supportedLocales,
|
|
localizationsDelegates:
|
|
const <LocalizationsDelegate<dynamic>>[
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|