82 lines
2.8 KiB
Dart
82 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'core/theme/super_admin_theme.dart';
|
|
import 'data/repositories/super_admin_repository.dart';
|
|
import 'logic/cubits/super_admin_cubit.dart';
|
|
import 'logic/cubits/treasury_cubit.dart';
|
|
import 'presentation/screens/super_admin_shell.dart';
|
|
import 'presentation/screens/super_admin_auth_screen.dart';
|
|
|
|
/**
|
|
* ==============================================================================
|
|
* SAQEL SOVEREIGN COMMAND - SUPER ADMIN APP (APPLICATION ROOT)
|
|
* ==============================================================================
|
|
*
|
|
* تطبيق القيادة السيادية العليا المخصص للمؤسس والمهندس المعماري التقني
|
|
* (حمزة العائد / Hamza Ayed) لمتابعة وحوكمة المنظومة التعليمية الرقمية.
|
|
*/
|
|
void main() {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
final repository = SuperAdminRepository();
|
|
|
|
runApp(SaqelSuperAdminApp(repository: repository));
|
|
}
|
|
|
|
class SaqelSuperAdminApp extends StatelessWidget {
|
|
final SuperAdminRepository repository;
|
|
|
|
const SaqelSuperAdminApp({super.key, required this.repository});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MultiBlocProvider(
|
|
providers: [
|
|
BlocProvider<SuperAdminCubit>(
|
|
create: (_) => SuperAdminCubit(repository: repository),
|
|
),
|
|
BlocProvider<TreasuryCubit>(
|
|
create: (_) => TreasuryCubit(repository: repository),
|
|
),
|
|
],
|
|
child: MaterialApp(
|
|
title: 'صاقل | القيادة السيادية العليا',
|
|
debugShowCheckedModeBanner: false,
|
|
theme: SuperAdminTheme.darkTheme,
|
|
home: SuperAdminAuthGate(repository: repository),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class SuperAdminAuthGate extends StatefulWidget {
|
|
final SuperAdminRepository repository;
|
|
const SuperAdminAuthGate({super.key, required this.repository});
|
|
|
|
@override
|
|
State<SuperAdminAuthGate> createState() => _SuperAdminAuthGateState();
|
|
}
|
|
|
|
class _SuperAdminAuthGateState extends State<SuperAdminAuthGate> {
|
|
late Future<bool> _session;
|
|
|
|
@override
|
|
void initState() { super.initState(); _session = widget.repository.hasValidSession(); }
|
|
|
|
@override
|
|
Widget build(BuildContext context) => FutureBuilder<bool>(
|
|
future: _session,
|
|
builder: (context, snapshot) {
|
|
if (snapshot.connectionState != ConnectionState.done) {
|
|
return const Scaffold(body: Center(child: CircularProgressIndicator()));
|
|
}
|
|
if (snapshot.data != true) {
|
|
return SuperAdminAuthScreen(
|
|
repository: widget.repository,
|
|
onAuthenticated: () => setState(() => _session = Future.value(true)),
|
|
);
|
|
}
|
|
return const SuperAdminShell();
|
|
},
|
|
);
|
|
}
|