mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-11 17:33:56 +01:00
Replaces the dead ColorScheme.fromSeed(Colors.indigo) (declared but never consumed by any screen/widget) with theme.dart: an explicit dark ColorScheme plus a real AppStatusColors extension, since this app genuinely uses success/warning status colors throughout (unlike dufs-cloud's app). Routes all 10 screen/widget files' ~280 hardcoded Colors.*/fontSize literals through it. Fixes the two flagged DESIGN_AUDIT_TODO violations: home_screen's Resume/Start buttons now use a real 2x horizontal:vertical padding ratio, and rep_circle's BoxShadow (the one shadow in an otherwise flat dark UI) is removed.
74 lines
2.3 KiB
Dart
74 lines
2.3 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:workout_app/screens/home_screen.dart';
|
|
import 'package:workout_app/services/backup_service.dart';
|
|
import 'package:workout_app/services/http_server_service.dart';
|
|
import 'package:workout_app/services/storage_service.dart';
|
|
import 'package:workout_app/ui/theme.dart';
|
|
|
|
// coverage:ignore-start
|
|
// App bootstrap: permission request, DB init, and a real listening socket —
|
|
// platform-channel work that can't run on the CI test host. The pieces it wires
|
|
// up are unit-tested individually; the entry point itself is not.
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await BackupService.instance.requestStoragePermission();
|
|
await StorageService.init();
|
|
await StorageService.instance.restoreFromBackupIfNeeded();
|
|
await HttpServerService.instance.start();
|
|
runApp(const WorkoutApp());
|
|
}
|
|
// coverage:ignore-end
|
|
|
|
/// Root widget that bootstraps the app with Material 3 dark theming.
|
|
///
|
|
/// Also owns the app-lifecycle observer that stops [HttpServerService]'s
|
|
/// listening socket while the app is backgrounded, so the process (and its
|
|
/// open socket) doesn't sit alive indefinitely and block Doze/App-Standby.
|
|
class WorkoutApp extends StatefulWidget {
|
|
/// Creates the root app widget.
|
|
const WorkoutApp({super.key});
|
|
|
|
@override
|
|
State<WorkoutApp> createState() => _WorkoutAppState();
|
|
}
|
|
|
|
class _WorkoutAppState extends State<WorkoutApp> with WidgetsBindingObserver {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
WidgetsBinding.instance.addObserver(this);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
WidgetsBinding.instance.removeObserver(this);
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
|
switch (state) {
|
|
case AppLifecycleState.paused:
|
|
case AppLifecycleState.detached:
|
|
unawaited(HttpServerService.instance.stop());
|
|
case AppLifecycleState.resumed:
|
|
unawaited(HttpServerService.instance.start());
|
|
case AppLifecycleState.inactive:
|
|
case AppLifecycleState.hidden:
|
|
break;
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Workout Tracker',
|
|
debugShowCheckedModeBanner: false,
|
|
theme: buildAppTheme(),
|
|
home: const HomeScreen(),
|
|
);
|
|
}
|
|
}
|