added edge to edge in app
This commit is contained in:
parent
d205cc2014
commit
7ec8b1e7bc
@ -8,41 +8,53 @@ import 'package:marco/helpers/theme/app_theme.dart';
|
||||
import 'package:url_strategy/url_strategy.dart';
|
||||
import 'package:marco/helpers/services/app_logger.dart';
|
||||
import 'package:marco/helpers/services/auth_service.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<void> initializeApp() async {
|
||||
try {
|
||||
logSafe("💡 Starting app initialization...");
|
||||
|
||||
// UI Setup
|
||||
setPathUrlStrategy();
|
||||
logSafe("💡 URL strategy set.");
|
||||
|
||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
||||
statusBarColor: Color.fromARGB(255, 255, 0, 0),
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
));
|
||||
logSafe("💡 System UI overlay style set.");
|
||||
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
systemNavigationBarColor: Colors.transparent,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
systemNavigationBarIconBrightness: Brightness.dark,
|
||||
),
|
||||
);
|
||||
logSafe("💡 UI setup completed.");
|
||||
|
||||
// Local storage
|
||||
await LocalStorage.init();
|
||||
logSafe("💡 Local storage initialized.");
|
||||
|
||||
// If a refresh token is found, try to refresh the JWT token
|
||||
// Token handling
|
||||
final refreshToken = await LocalStorage.getRefreshToken();
|
||||
if (refreshToken != null && refreshToken.isNotEmpty) {
|
||||
final hasRefreshToken = refreshToken?.isNotEmpty ?? false;
|
||||
|
||||
if (hasRefreshToken) {
|
||||
logSafe("🔁 Refresh token found. Attempting to refresh JWT...");
|
||||
final success = await AuthService.refreshToken();
|
||||
|
||||
if (!success) {
|
||||
logSafe("⚠️ Refresh token invalid or expired. Skipping controller injection.");
|
||||
// Optionally, clear tokens and force logout here if needed
|
||||
// Optionally clear tokens or handle logout here
|
||||
}
|
||||
} else {
|
||||
logSafe("❌ No refresh token found. Skipping refresh.");
|
||||
}
|
||||
|
||||
// Theme setup
|
||||
await ThemeCustomizer.init();
|
||||
logSafe("💡 Theme customizer initialized.");
|
||||
|
||||
// Controller setup
|
||||
final token = LocalStorage.getString('jwt_token');
|
||||
if (token != null && token.isNotEmpty) {
|
||||
final hasJwt = token?.isNotEmpty ?? false;
|
||||
|
||||
if (hasJwt) {
|
||||
if (!Get.isRegistered<PermissionController>()) {
|
||||
Get.put(PermissionController());
|
||||
logSafe("💡 PermissionController injected.");
|
||||
@ -53,13 +65,13 @@ Future<void> initializeApp() async {
|
||||
logSafe("💡 ProjectController injected as permanent.");
|
||||
}
|
||||
|
||||
// Load data into controllers if required
|
||||
await Get.find<PermissionController>().loadData(token);
|
||||
await Get.find<PermissionController>().loadData(token!);
|
||||
await Get.find<ProjectController>().fetchProjects();
|
||||
} else {
|
||||
logSafe("⚠️ No valid JWT token found. Skipping controller initialization.");
|
||||
}
|
||||
|
||||
// Final style setup
|
||||
AppStyle.init();
|
||||
logSafe("💡 AppStyle initialized.");
|
||||
|
||||
|
@ -66,7 +66,8 @@ class _MainWrapperState extends State<MainWrapper> {
|
||||
super.initState();
|
||||
_initializeConnectivity();
|
||||
// Listen for changes, the callback now provides a List<ConnectivityResult>
|
||||
_connectivity.onConnectivityChanged.listen((List<ConnectivityResult> results) {
|
||||
_connectivity.onConnectivityChanged
|
||||
.listen((List<ConnectivityResult> results) {
|
||||
setState(() {
|
||||
_connectivityStatus = results;
|
||||
});
|
||||
@ -84,7 +85,8 @@ class _MainWrapperState extends State<MainWrapper> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Check if any of the connectivity results indicate no internet
|
||||
final bool isOffline = _connectivityStatus.contains(ConnectivityResult.none);
|
||||
final bool isOffline =
|
||||
_connectivityStatus.contains(ConnectivityResult.none);
|
||||
|
||||
// Show OfflineScreen if no internet
|
||||
if (isOffline) {
|
||||
@ -97,4 +99,4 @@ class _MainWrapperState extends State<MainWrapper> {
|
||||
// Show main app if online
|
||||
return const MyApp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user