Browse Source

neon: Fix theme switching

pull/320/head
jld3103 2 years ago
parent
commit
00c1411b9d
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 13
      packages/neon/neon/lib/src/app.dart
  2. 4
      packages/neon/neon/lib/src/blocs/accounts.dart
  3. 4
      packages/neon/neon/lib/src/blocs/capabilities.dart
  4. 2
      packages/neon/neon/lib/src/utils/theme.dart
  5. 2
      packages/neon/neon/lib/src/widgets/result_builder.dart

13
packages/neon/neon/lib/src/app.dart

@ -265,9 +265,13 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra
}
FlutterNativeSplash.remove();
return ValueListenableBuilder(
valueListenable: themeNotifier,
builder: (final context, final nextcloudTheme, final child) => MaterialApp.router(
return ResultBuilder<Capabilities?>(
stream: activeAccountSnapshot.hasData
? widget.accountsBloc.getCapabilitiesBloc(activeAccountSnapshot.data!).capabilities
: null,
builder: (final context, final capabilitiesSnapshot) {
final nextcloudTheme = capabilitiesSnapshot.data?.capabilities.theming;
return MaterialApp.router(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
themeMode: themeMode,
@ -283,7 +287,8 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra
oledAsDark: themeOLEDAsDark,
),
routerDelegate: _routerDelegate,
),
);
},
);
},
),

4
packages/neon/neon/lib/src/blocs/accounts.dart

@ -164,9 +164,7 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
CapabilitiesBloc getCapabilitiesBloc(final Account account) {
if (_capabilitiesBlocs[account.id] != null) {
final bloc = _capabilitiesBlocs[account.id]!;
unawaited(bloc.refresh());
return bloc;
return _capabilitiesBlocs[account.id]!;
}
return _capabilitiesBlocs[account.id] = CapabilitiesBloc(

4
packages/neon/neon/lib/src/blocs/capabilities.dart

@ -14,10 +14,6 @@ class CapabilitiesBloc extends InteractiveBloc implements CapabilitiesBlocEvents
this._requestManager,
this._client,
) {
capabilities.listen((final value) {
themeNotifier.value = value.data?.capabilities.theming;
});
unawaited(refresh());
}

2
packages/neon/neon/lib/src/utils/theme.dart

@ -1,7 +1,5 @@
part of '../../neon.dart';
final themeNotifier = ValueNotifier<NextcloudCoreServerCapabilities_Ocs_Data_Capabilities_Theming?>(null);
const themePrimaryColor = Color(0xFFF37736);
ThemeData getThemeFromNextcloudTheme(

2
packages/neon/neon/lib/src/widgets/result_builder.dart

@ -7,7 +7,7 @@ class ResultBuilder<R> extends StatelessWidget {
super.key,
});
final BehaviorSubject<Result<R>> stream;
final BehaviorSubject<Result<R>>? stream;
final Widget Function(BuildContext, Result<R>) builder;

Loading…
Cancel
Save