Browse Source

neon: NeonApp unify bloc usage

pull/371/head
Nikolas Rimikis 1 year ago
parent
commit
f3d8b9d203
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 7
      packages/neon/neon/lib/neon.dart
  2. 19
      packages/neon/neon/lib/src/app.dart

7
packages/neon/neon/lib/neon.dart

@ -193,12 +193,7 @@ Future runNeon({
create: (final _) => branding,
),
],
child: NeonApp(
accountsBloc: accountsBloc,
sharedPreferences: sharedPreferences,
platform: platform,
globalOptions: globalOptions,
),
child: const NeonApp(),
),
);
}

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

@ -2,18 +2,9 @@ part of '../../neon.dart';
class NeonApp extends StatefulWidget {
const NeonApp({
required this.accountsBloc,
required this.sharedPreferences,
required this.platform,
required this.globalOptions,
super.key,
});
final AccountsBloc accountsBloc;
final SharedPreferences sharedPreferences;
final NeonPlatform platform;
final GlobalOptions globalOptions;
@override
State<NeonApp> createState() => _NeonAppState();
}
@ -253,13 +244,13 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra
@override
Widget build(final BuildContext context) => OptionBuilder(
option: widget.globalOptions.themeMode,
option: _globalOptions.themeMode,
builder: (final context, final themeMode) => OptionBuilder(
option: widget.globalOptions.themeOLEDAsDark,
option: _globalOptions.themeOLEDAsDark,
builder: (final context, final themeOLEDAsDark) => OptionBuilder(
option: widget.globalOptions.themeKeepOriginalAccentColor,
option: _globalOptions.themeKeepOriginalAccentColor,
builder: (final context, final themeKeepOriginalAccentColor) => StreamBuilder<Account?>(
stream: widget.accountsBloc.activeAccount,
stream: _accountsBloc.activeAccount,
builder: (final context, final activeAccountSnapshot) {
if (themeMode == null || themeOLEDAsDark == null) {
return Container();
@ -268,7 +259,7 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra
FlutterNativeSplash.remove();
return ResultBuilder<Capabilities?>(
stream: activeAccountSnapshot.hasData
? widget.accountsBloc.getCapabilitiesBlocFor(activeAccountSnapshot.data!).capabilities
? _accountsBloc.getCapabilitiesBlocFor(activeAccountSnapshot.data!).capabilities
: null,
builder: (final context, final capabilitiesSnapshot) {
final nextcloudTheme = capabilitiesSnapshot.data?.capabilities.theming;

Loading…
Cancel
Save