81 lines
2.3 KiB
Dart
81 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'pages/battery_health_page.dart';
|
|
import 'services/saf_storage_service.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await SafStorageService().init();
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: '电池健康度',
|
|
theme: _lightTheme(),
|
|
darkTheme: _darkTheme(),
|
|
themeMode: ThemeMode.system, // 默认跟随系统
|
|
home: const BatteryHealthPage(),
|
|
debugShowCheckedModeBanner: false,
|
|
);
|
|
}
|
|
|
|
ThemeData _lightTheme() {
|
|
return ThemeData(
|
|
fontFamily: 'HarmonyOS_Sans_SC',
|
|
fontFamilyFallback: const ['Flyme'],
|
|
useMaterial3: true,
|
|
brightness: Brightness.light,
|
|
scaffoldBackgroundColor: Colors.white,
|
|
appBarTheme: const AppBarTheme(
|
|
backgroundColor: Colors.white,
|
|
foregroundColor: Colors.black,
|
|
elevation: 0,
|
|
centerTitle: false,
|
|
),
|
|
iconTheme: const IconThemeData(color: Colors.black),
|
|
colorScheme: const ColorScheme.light(
|
|
primary: Color(0xFF1A73E8),
|
|
secondary: Color(0xFF1A73E8),
|
|
),
|
|
textTheme: const TextTheme(
|
|
bodyLarge: TextStyle(color: Colors.black),
|
|
bodyMedium: TextStyle(color: Colors.black87),
|
|
labelLarge: TextStyle(color: Colors.black),
|
|
),
|
|
dividerColor: Colors.grey.shade200,
|
|
);
|
|
}
|
|
|
|
ThemeData _darkTheme() {
|
|
return ThemeData(
|
|
fontFamily: 'HarmonyOS_Sans_SC',
|
|
fontFamilyFallback: const ['Flyme'],
|
|
useMaterial3: true,
|
|
brightness: Brightness.dark,
|
|
scaffoldBackgroundColor: const Color(0xFF121212),
|
|
appBarTheme: const AppBarTheme(
|
|
backgroundColor: Color(0xFF1E1E1E),
|
|
foregroundColor: Colors.white,
|
|
elevation: 0,
|
|
centerTitle: false,
|
|
),
|
|
iconTheme: const IconThemeData(color: Colors.white),
|
|
colorScheme: const ColorScheme.dark(
|
|
primary: Color(0xFF4FC3F7),
|
|
secondary: Color(0xFF4FC3F7),
|
|
),
|
|
textTheme: const TextTheme(
|
|
bodyLarge: TextStyle(color: Colors.white),
|
|
bodyMedium: TextStyle(color: Colors.white70),
|
|
labelLarge: TextStyle(color: Colors.white),
|
|
),
|
|
dividerColor: Colors.grey.shade800,
|
|
);
|
|
}
|
|
}
|