|
|
|
@ -28,24 +28,10 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra
|
|
|
|
|
late final _routerDelegate = AppRouter( |
|
|
|
|
navigatorKey: _navigatorKey, |
|
|
|
|
accountsBloc: _accountsBloc, |
|
|
|
|
onThemeChanged: (final nextcloudTheme) { |
|
|
|
|
setState(() { |
|
|
|
|
_nextcloudTheme = nextcloudTheme; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
NextcloudCoreServerCapabilities_Ocs_Data_Capabilities_Theming? _nextcloudTheme; |
|
|
|
|
final _platformBrightness = BehaviorSubject<Brightness>.seeded(WidgetsBinding.instance.window.platformBrightness); |
|
|
|
|
Rect? _lastBounds; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void didChangePlatformBrightness() { |
|
|
|
|
_platformBrightness.add(WidgetsBinding.instance.window.platformBrightness); |
|
|
|
|
|
|
|
|
|
super.didChangePlatformBrightness(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
@ -260,42 +246,46 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra
|
|
|
|
|
if (_platform.canUseWindowManager) { |
|
|
|
|
windowManager.removeListener(this); |
|
|
|
|
} |
|
|
|
|
unawaited(_platformBrightness.close()); |
|
|
|
|
|
|
|
|
|
super.dispose(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(final BuildContext context) => StreamBuilder<Brightness>( |
|
|
|
|
stream: _platformBrightness, |
|
|
|
|
builder: (final context, final platformBrightnessSnapshot) => OptionBuilder( |
|
|
|
|
option: widget.globalOptions.themeMode, |
|
|
|
|
builder: (final context, final themeMode) => OptionBuilder( |
|
|
|
|
option: widget.globalOptions.themeOLEDAsDark, |
|
|
|
|
builder: (final context, final themeOLEDAsDark) => OptionBuilder( |
|
|
|
|
option: widget.globalOptions.themeKeepOriginalAccentColor, |
|
|
|
|
builder: (final context, final themeKeepOriginalAccentColor) => StreamBuilder<Account?>( |
|
|
|
|
stream: widget.accountsBloc.activeAccount, |
|
|
|
|
builder: (final context, final activeAccountSnapshot) { |
|
|
|
|
if (themeMode == null || !platformBrightnessSnapshot.hasData || themeOLEDAsDark == null) { |
|
|
|
|
return Container(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
FlutterNativeSplash.remove(); |
|
|
|
|
return MaterialApp.router( |
|
|
|
|
Widget build(final BuildContext context) => OptionBuilder( |
|
|
|
|
option: widget.globalOptions.themeMode, |
|
|
|
|
builder: (final context, final themeMode) => OptionBuilder( |
|
|
|
|
option: widget.globalOptions.themeOLEDAsDark, |
|
|
|
|
builder: (final context, final themeOLEDAsDark) => OptionBuilder( |
|
|
|
|
option: widget.globalOptions.themeKeepOriginalAccentColor, |
|
|
|
|
builder: (final context, final themeKeepOriginalAccentColor) => StreamBuilder<Account?>( |
|
|
|
|
stream: widget.accountsBloc.activeAccount, |
|
|
|
|
builder: (final context, final activeAccountSnapshot) { |
|
|
|
|
if (themeMode == null || themeOLEDAsDark == null) { |
|
|
|
|
return Container(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
FlutterNativeSplash.remove(); |
|
|
|
|
return ValueListenableBuilder( |
|
|
|
|
valueListenable: themeNotifier, |
|
|
|
|
builder: (final context, final nextcloudTheme, final child) => MaterialApp.router( |
|
|
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates, |
|
|
|
|
supportedLocales: AppLocalizations.supportedLocales, |
|
|
|
|
themeMode: themeMode, |
|
|
|
|
theme: getThemeFromNextcloudTheme( |
|
|
|
|
_nextcloudTheme, |
|
|
|
|
themeMode, |
|
|
|
|
platformBrightnessSnapshot.data!, |
|
|
|
|
nextcloudTheme, |
|
|
|
|
Brightness.light, |
|
|
|
|
keepOriginalAccentColor: nextcloudTheme == null || (themeKeepOriginalAccentColor ?? false), |
|
|
|
|
), |
|
|
|
|
darkTheme: getThemeFromNextcloudTheme( |
|
|
|
|
nextcloudTheme, |
|
|
|
|
Brightness.dark, |
|
|
|
|
keepOriginalAccentColor: nextcloudTheme == null || (themeKeepOriginalAccentColor ?? false), |
|
|
|
|
oledAsDark: themeOLEDAsDark, |
|
|
|
|
keepOriginalAccentColor: _nextcloudTheme == null || (themeKeepOriginalAccentColor ?? false), |
|
|
|
|
), |
|
|
|
|
routerDelegate: _routerDelegate, |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|