import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:comwell_key_app/utils/cubit_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:comwell_key_app/common/system_ui.dart';
import 'dart:io' show Platform;
// Routes that should use edge-to-edge mode
final Set<String> edgeToEdgeRoutes = {
'forceUpdate',
// Add other routes that need edge-to-edge mode
};
final Map<String, SystemUiOverlayStyle> routeSystemUiStyles = {
'overview': kDefaultSystemUiOverlayStyle,
// Example custom style for login page:
'login': const SystemUiOverlayStyle(
statusBarColor: colorTertiary,
systemNavigationBarColor: colorTertiary,
statusBarIconBrightness: Brightness.light,
systemNavigationBarIconBrightness: Brightness.light,
),
// Custom style for key page:
'key': const SystemUiOverlayStyle(
statusBarColor: colorTertiary,
systemNavigationBarColor: colorTertiary,
statusBarIconBrightness: Brightness.light,
systemNavigationBarIconBrightness: Brightness.light,
),
'forceUpdate': const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarBrightness: Brightness.dark,
statusBarIconBrightness: Brightness.light,
systemStatusBarContrastEnforced: false,
systemNavigationBarColor: Colors.transparent,
systemNavigationBarDividerColor: Colors.transparent,
systemNavigationBarContrastEnforced: false,
systemNavigationBarIconBrightness: Brightness.light,
),
// Add more custom styles as needed
};
class GoRouterObserver extends NavigatorObserver {
@override
void didPush(Route route, Route? previousRoute) {
final context = route.navigator?.context;
final tracker = context?.tracker;
if (tracker != null && context != null) {
debugPrint('DidPush: ${route.settings.name}');
tracker.trackScreenView(context);
}
super.didPush(route, previousRoute);
}
@override
void didPop(Route route, Route? previousRoute) {
final context = route.navigator?.context;
final tracker = context?.tracker;
if (tracker != null && context != null) {
debugPrint('DidPop: ${route.settings.name}');
tracker.trackScreenView(context);
}
super.didPop(route, previousRoute);
}
@override
void didRemove(Route<dynamic> route, Route<dynamic>? previousRoute) {
debugPrint('DidRemove: $route');
}
@override
void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) {
debugPrint('DidReplace: $newRoute');
}
void _setSystemUiForRoute(Route<dynamic> route) {
// Only apply custom system UI styles on Android
if (!Platform.isAndroid) return;
final routeName = route.settings.name ?? '';
final style = routeSystemUiStyles[routeName] ?? kDefaultSystemUiOverlayStyle;
SystemChrome.setSystemUIOverlayStyle(style);
// Enable edge-to-edge mode for specific routes
if (edgeToEdgeRoutes.contains(routeName)) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
} else {
// Reset to normal mode for other routes
SystemChrome.setEnabledSystemUIMode(
SystemUiMode.manual,
overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom],
);
}
}
}
String getPath(String routeName) {
switch (routeName) {
case '/overview':
return '/overview';
case '/login':
return '/login';
case '/booking-details':
return '/booking-details';
case '/profile':
return 'Profile';
case '/housekeeping':
return 'Bestill housekeeping';
case '/key':
return 'Keycard - read';
case '/hotelInformation':
return 'Hotel information';
case '/restaurant':
return '/hotelInformation/restaurant';
case '/my-booking':
return 'My booking';
case '/spa':
return '/overview/bookingsdetails/hotelInformation/spa';
case '/parking':
return '/overview/bookingsdetails/hotelInformation/parking';
case '/paymentCards':
return '/overview/bookingsdetails/paymentCards';
case '/checkOut':
return 'Check out';
case '/checkIn':
return 'Check-in';
case '/contact':
return '/overview/bookingsdetails/contact';
case '/preregistration':
return 'Preregistration';
case '/findBooking':
return '/overview/findBooking';
case '/pastCancelledBookings':
return '/overview/pastCancelledBookings';
case '/profileSettings':
return 'Profile - Profilindstillinger';
case '/forceUpdate':
return '/forceUpdate';
// Add more cases as needed
default:
return 'Unknown route';
}
}