2022-12-15 11:00:28 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
2023-02-11 19:19:18 +00:00
|
|
|
import 'package:lightmeter/data/models/supported_locale.dart';
|
2023-05-11 13:30:18 +00:00
|
|
|
import 'package:lightmeter/environment.dart';
|
|
|
|
import 'package:lightmeter/generated/l10n.dart';
|
2023-06-04 11:04:04 +00:00
|
|
|
import 'package:lightmeter/providers.dart';
|
2023-05-11 13:30:18 +00:00
|
|
|
import 'package:lightmeter/screens/metering/flow_metering.dart';
|
|
|
|
import 'package:lightmeter/screens/settings/flow_settings.dart';
|
2023-06-04 11:04:04 +00:00
|
|
|
import 'package:lightmeter/utils/inherited_generics.dart';
|
2022-12-15 11:00:28 +00:00
|
|
|
|
2023-01-07 09:14:18 +00:00
|
|
|
class Application extends StatelessWidget {
|
2023-01-25 10:08:11 +00:00
|
|
|
final Environment env;
|
2022-12-15 11:00:28 +00:00
|
|
|
|
2023-07-06 15:43:57 +00:00
|
|
|
const Application(this.env, {super.key});
|
2022-12-15 11:00:28 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-06-04 11:04:04 +00:00
|
|
|
return LightmeterProviders(
|
|
|
|
env: env,
|
|
|
|
builder: (context, ready) => ready
|
|
|
|
? _AnnotatedRegionWrapper(
|
|
|
|
child: MaterialApp(
|
|
|
|
theme: context.listen<ThemeData>(),
|
|
|
|
locale: Locale(context.listen<SupportedLocale>().intlName),
|
|
|
|
localizationsDelegates: const [
|
|
|
|
S.delegate,
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
GlobalCupertinoLocalizations.delegate,
|
|
|
|
],
|
|
|
|
supportedLocales: S.delegate.supportedLocales,
|
2023-07-06 15:43:57 +00:00
|
|
|
builder: (context, child) => MediaQuery(
|
|
|
|
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
|
|
|
|
child: child!,
|
2023-01-29 16:57:47 +00:00
|
|
|
),
|
2023-06-04 11:04:04 +00:00
|
|
|
initialRoute: "metering",
|
|
|
|
routes: {
|
|
|
|
"metering": (context) => const MeteringFlow(),
|
|
|
|
"settings": (context) => const SettingsFlow(),
|
|
|
|
},
|
2022-12-16 08:08:12 +00:00
|
|
|
),
|
2023-06-04 11:04:04 +00:00
|
|
|
)
|
|
|
|
: const SizedBox(),
|
2022-12-15 11:00:28 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2023-02-11 19:19:18 +00:00
|
|
|
|
|
|
|
class _AnnotatedRegionWrapper extends StatelessWidget {
|
|
|
|
final Widget child;
|
|
|
|
|
|
|
|
const _AnnotatedRegionWrapper({required this.child});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final systemIconsBrightness = ThemeData.estimateBrightnessForColor(
|
2023-06-04 11:04:04 +00:00
|
|
|
context.listen<ThemeData>().colorScheme.onSurface,
|
2023-02-11 19:19:18 +00:00
|
|
|
);
|
|
|
|
return AnnotatedRegion(
|
|
|
|
value: SystemUiOverlayStyle(
|
|
|
|
statusBarColor: Colors.transparent,
|
|
|
|
statusBarBrightness:
|
|
|
|
systemIconsBrightness == Brightness.light ? Brightness.dark : Brightness.light,
|
|
|
|
statusBarIconBrightness: systemIconsBrightness,
|
|
|
|
systemNavigationBarColor: Colors.transparent,
|
|
|
|
systemNavigationBarIconBrightness: systemIconsBrightness,
|
|
|
|
),
|
|
|
|
child: child,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|