mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Backend: notifications now show a plain "-" for an absent name, vendor, or device type (was empty string / "(unknown)" / "Unknown"), via a single UNKNOWN_PLACEHOLDER constant. Frontend: - Empty/unknown values render as an em dash everywhere, centralised in a new Placeholders.emptyValue constant (replaces inline '—' and '(unknown)'). - Route paths moved to a new Routes class, used by the router and every navigation call site. - Device event type modelled as a DeviceEventType enum mirroring the backend (NewDevice/DeviceSeen) instead of bare string comparisons. - Hardcoded EdgeInsets/SizedBox spacing replaced with existing Insets tokens. Tests and formatting updated; all backend and frontend tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
82 lines
2.1 KiB
Dart
82 lines
2.1 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:frontend/theme/catppuccin_mocha_theme.dart';
|
|
import 'package:frontend/utils/pref_utils.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'navigation.dart';
|
|
import 'theme/gruvbox_theme.dart';
|
|
|
|
void main() {
|
|
runZonedGuarded(
|
|
() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
FlutterError.onError = (details) {
|
|
FlutterError.presentError(details);
|
|
debugPrint('FlutterError: ${details.exceptionAsString()}');
|
|
};
|
|
PlatformDispatcher.instance.onError = (error, stack) {
|
|
debugPrint('Uncaught platform error: $error\n$stack');
|
|
return true;
|
|
};
|
|
|
|
try {
|
|
await PrefUtil.init();
|
|
} catch (e, stack) {
|
|
debugPrint(
|
|
'PrefUtil.init failed, continuing with defaults: $e\n$stack',
|
|
);
|
|
}
|
|
|
|
runApp(const MainApp());
|
|
},
|
|
(error, stack) {
|
|
debugPrint('Uncaught zone error: $error\n$stack');
|
|
},
|
|
);
|
|
}
|
|
|
|
final class MainApp extends StatelessWidget {
|
|
const MainApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ChangeNotifierProvider(
|
|
create: (context) => AppState(),
|
|
child: Consumer<AppState>(
|
|
builder: (context, appState, _) => MaterialApp.router(
|
|
title: 'OOTT',
|
|
theme: appState.theme,
|
|
routerConfig: router,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
final _themes = {
|
|
'catppuccin_mocha': catppuccinMochaDarkTheme,
|
|
'gruvbox_dark': gruvboxDarkTheme,
|
|
};
|
|
|
|
class AppState extends ChangeNotifier {
|
|
AppState() {
|
|
final saved = PrefUtil.getValue('theme', 'gruvbox_dark') as String;
|
|
_themeKey = _themes.containsKey(saved) ? saved : 'gruvbox_dark';
|
|
}
|
|
|
|
late String _themeKey;
|
|
String get themeKey => _themeKey;
|
|
ThemeData get theme => _themes[_themeKey]!;
|
|
|
|
Future<bool> setTheme(String key) async {
|
|
if (!_themes.containsKey(key)) return false;
|
|
if (key == _themeKey) return true;
|
|
_themeKey = key;
|
|
notifyListeners();
|
|
return PrefUtil.setValue('theme', key);
|
|
}
|
|
}
|