fix: set dark theme globally to prevent white flash on page transitions
This commit is contained in:
parent
4f16db59b2
commit
4bbc0bcdcb
2 changed files with 37 additions and 10 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:traccar_client/main_screen.dart';
|
||||
import 'package:traccar_client/permission_screen.dart';
|
||||
import 'package:traccar_client/preferences.dart';
|
||||
|
|
@ -6,6 +7,15 @@ import 'package:traccar_client/preferences.dart';
|
|||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await Preferences.init();
|
||||
|
||||
// Keep status bar dark throughout the app
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarColor: Color(0xFF0d0d0d),
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
),
|
||||
);
|
||||
|
||||
runApp(const TraccarClientApp());
|
||||
}
|
||||
|
||||
|
|
@ -19,8 +29,32 @@ class TraccarClientApp extends StatelessWidget {
|
|||
debugShowCheckedModeBanner: false,
|
||||
theme: ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
|
||||
appBarTheme: const AppBarTheme(centerTitle: true),
|
||||
brightness: Brightness.dark,
|
||||
scaffoldBackgroundColor: const Color(0xFF0d0d0d),
|
||||
colorScheme: const ColorScheme.dark(
|
||||
surface: Color(0xFF0d0d0d),
|
||||
primary: Color(0xFF00bcd4),
|
||||
secondary: Color(0xFF00e676),
|
||||
),
|
||||
appBarTheme: const AppBarTheme(
|
||||
centerTitle: true,
|
||||
backgroundColor: Color(0xFF161616),
|
||||
foregroundColor: Color(0xFFe0e0e0),
|
||||
elevation: 0,
|
||||
),
|
||||
snackBarTheme: const SnackBarThemeData(
|
||||
backgroundColor: Color(0xFF1a1a1a),
|
||||
contentTextStyle: TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
color: Color(0xFFe0e0e0),
|
||||
),
|
||||
),
|
||||
pageTransitionsTheme: const PageTransitionsTheme(
|
||||
builders: {
|
||||
TargetPlatform.android: ZoomPageTransitionsBuilder(),
|
||||
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
|
||||
},
|
||||
),
|
||||
),
|
||||
home: Preferences.permissionsGranted
|
||||
? const MainScreen()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue