Update Saqel Platform: 2026-09-08 13:43:36
This commit is contained in:
@@ -4,6 +4,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'logic/cubits/directorate_cubit.dart';
|
||||
import 'presentation/screens/directorate_command_screen.dart';
|
||||
import 'presentation/screens/school_principal_screen.dart';
|
||||
import 'presentation/screens/admin_auth_screen.dart';
|
||||
import 'services/directorate_api_service.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const SaqelAdminApp());
|
||||
@@ -42,10 +44,43 @@ class SaqelAdminApp extends StatelessWidget {
|
||||
child: child ?? const SizedBox(),
|
||||
);
|
||||
},
|
||||
home: BlocProvider(
|
||||
create: (context) => DirectorateCubit(),
|
||||
child: const UnifiedSupervisorShell(),
|
||||
),
|
||||
home: const AdminAuthGate(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AdminAuthGate extends StatefulWidget {
|
||||
const AdminAuthGate({super.key});
|
||||
|
||||
@override
|
||||
State<AdminAuthGate> createState() => _AdminAuthGateState();
|
||||
}
|
||||
|
||||
class _AdminAuthGateState extends State<AdminAuthGate> {
|
||||
late Future<bool> _session;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_session = DirectorateApiService.hasValidSession();
|
||||
}
|
||||
|
||||
void _authenticated() => setState(() => _session = Future.value(true));
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<bool>(
|
||||
future: _session,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return const Scaffold(body: Center(child: CircularProgressIndicator()));
|
||||
}
|
||||
if (snapshot.data != true) return AdminAuthScreen(onAuthenticated: _authenticated);
|
||||
return BlocProvider(
|
||||
create: (_) => DirectorateCubit(),
|
||||
child: const UnifiedSupervisorShell(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user