From 7ec8b1e7bcf5c097d8937cd1a638aecf6e6ffe95 Mon Sep 17 00:00:00 2001 From: Vaibhav Surve Date: Wed, 6 Aug 2025 18:14:23 +0530 Subject: [PATCH] added edge to edge in app --- lib/helpers/services/app_initializer.dart | 40 +++++++++++++++-------- lib/main.dart | 8 +++-- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/lib/helpers/services/app_initializer.dart b/lib/helpers/services/app_initializer.dart index 5d55b0c..3f11fe7 100644 --- a/lib/helpers/services/app_initializer.dart +++ b/lib/helpers/services/app_initializer.dart @@ -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 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()) { Get.put(PermissionController()); logSafe("💡 PermissionController injected."); @@ -53,13 +65,13 @@ Future initializeApp() async { logSafe("💡 ProjectController injected as permanent."); } - // Load data into controllers if required - await Get.find().loadData(token); + await Get.find().loadData(token!); await Get.find().fetchProjects(); } else { logSafe("⚠️ No valid JWT token found. Skipping controller initialization."); } + // Final style setup AppStyle.init(); logSafe("💡 AppStyle initialized."); diff --git a/lib/main.dart b/lib/main.dart index e624408..af77945 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -66,7 +66,8 @@ class _MainWrapperState extends State { super.initState(); _initializeConnectivity(); // Listen for changes, the callback now provides a List - _connectivity.onConnectivityChanged.listen((List results) { + _connectivity.onConnectivityChanged + .listen((List results) { setState(() { _connectivityStatus = results; }); @@ -84,7 +85,8 @@ class _MainWrapperState extends State { @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 { // Show main app if online return const MyApp(); } -} \ No newline at end of file +}