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, create: (final _) => branding,
), ),
], ],
child: NeonApp( child: const NeonApp(),
accountsBloc: accountsBloc,
sharedPreferences: sharedPreferences,
platform: platform,
globalOptions: globalOptions,
),
), ),
); );
} }

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

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

Loading…
Cancel
Save