Update Saqel Platform: 2026-08-31 01:52:23
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'core/config/app_config.dart';
|
||||
import 'core/localization/app_strings.dart';
|
||||
import 'core/theme/app_theme.dart';
|
||||
import 'logic/cubits/auth_cubit.dart';
|
||||
import 'logic/cubits/dashboard_cubits.dart';
|
||||
import 'presentation/screens/auth/auth_screen.dart';
|
||||
import 'presentation/screens/home/unified_home_screen.dart';
|
||||
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
runApp(const SaqelAppRoot());
|
||||
}
|
||||
|
||||
class SaqelAppRoot extends StatefulWidget {
|
||||
const SaqelAppRoot({super.key});
|
||||
|
||||
@override
|
||||
State<SaqelAppRoot> createState() => _SaqelAppRootState();
|
||||
}
|
||||
|
||||
class _SaqelAppRootState extends State<SaqelAppRoot> {
|
||||
final ThemeMode _themeMode = ThemeMode.dark;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider<AuthCubit>(
|
||||
create: (context) => AuthCubit()..checkSession(),
|
||||
),
|
||||
BlocProvider<StudentCubit>(
|
||||
create: (context) => StudentCubit(),
|
||||
),
|
||||
BlocProvider<GuardianCubit>(
|
||||
create: (context) => GuardianCubit(),
|
||||
),
|
||||
],
|
||||
child: MaterialApp(
|
||||
title: AppConfig.appNameAr,
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.lightTheme,
|
||||
darkTheme: AppTheme.darkTheme,
|
||||
themeMode: _themeMode,
|
||||
builder: (context, child) {
|
||||
// RTL / LTR Directionality Control
|
||||
return Directionality(
|
||||
textDirection: AppStrings.isArabic ? TextDirection.rtl : TextDirection.ltr,
|
||||
child: child!,
|
||||
);
|
||||
},
|
||||
home: const AuthGate(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Global Auth Gate: Auto-Directs to Unified Dashboard if Logged In, or AuthScreen
|
||||
class AuthGate extends StatelessWidget {
|
||||
const AuthGate({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<AuthCubit, AuthState>(
|
||||
builder: (context, state) {
|
||||
if (state is Authenticated) {
|
||||
return UnifiedHomeScreen(
|
||||
user: state.user,
|
||||
activeRole: state.activeRole,
|
||||
);
|
||||
} else if (state is AuthLoading) {
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
// Default to AuthScreen for unauthenticated or OTP states
|
||||
return const AuthScreen();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user