From ed618cab0b5cf6426dc43d86f0102709e7d60497 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sun, 18 Jun 2023 18:09:56 +0200 Subject: [PATCH] neon: remove unused builders from HomePage --- packages/neon/neon/lib/src/pages/home.dart | 162 +++++++++------------ 1 file changed, 68 insertions(+), 94 deletions(-) diff --git a/packages/neon/neon/lib/src/pages/home.dart b/packages/neon/neon/lib/src/pages/home.dart index 52bbe074..56a937ad 100644 --- a/packages/neon/neon/lib/src/pages/home.dart +++ b/packages/neon/neon/lib/src/pages/home.dart @@ -11,16 +11,13 @@ class HomePage extends StatefulWidget { State createState() => _HomePageState(); } -// ignore: prefer_mixin class _HomePageState extends State { final _scaffoldKey = GlobalKey(); - final drawerScrollController = ScrollController(); late Account _account; late GlobalOptions _globalOptions; late AccountsBloc _accountsBloc; late AppsBloc _appsBloc; - late CapabilitiesBloc _capabilitiesBloc; @override void initState() { @@ -29,7 +26,6 @@ class _HomePageState extends State { _accountsBloc = Provider.of(context, listen: false); _account = _accountsBloc.activeAccount.value!; _appsBloc = _accountsBloc.activeAppsBloc; - _capabilitiesBloc = _accountsBloc.activeCapabilitiesBloc; _appsBloc.appVersions.listen((final values) { if (values == null || !mounted) { @@ -98,100 +94,78 @@ class _HomePageState extends State { } @override - void dispose() { - drawerScrollController.dispose(); - super.dispose(); - } - - @override - Widget build(final BuildContext context) => ResultBuilder.behaviorSubject( - stream: _capabilitiesBloc.capabilities, - builder: (final context, final capabilities) => ResultBuilder>.behaviorSubject( - stream: _appsBloc.appImplementations, - builder: (final context, final appImplementations) => - ResultBuilder.behaviorSubject( - stream: _appsBloc.notificationsAppImplementation, - builder: (final context, final notificationsAppImplementation) => StreamBuilder( - stream: _appsBloc.activeAppID, - builder: (final context, final activeAppIDSnapshot) => StreamBuilder>( - stream: _accountsBloc.accounts, - builder: (final context, final accountsSnapshot) => OptionBuilder( - option: _globalOptions.navigationMode, - builder: (final context, final navigationMode) { - final accounts = accountsSnapshot.data; - final account = accounts?.find(_account.id); - if (accounts == null || account == null) { - return const Scaffold(); - } - - final drawerAlwaysVisible = navigationMode == NavigationMode.drawerAlwaysVisible; - - const drawer = NeonDrawer(); - const appBar = NeonAppBar(); - - Widget body = Builder( - builder: (final context) => Column( - children: [ - if (appImplementations.data != null) ...[ - if (appImplementations.data!.isEmpty) ...[ - Expanded( - child: Center( - child: Text( - AppLocalizations.of(context).errorNoCompatibleNextcloudAppsFound, - textAlign: TextAlign.center, - ), - ), - ), - ] else ...[ - if (activeAppIDSnapshot.hasData) ...[ - Expanded( - child: appImplementations.data!.find(activeAppIDSnapshot.data!)!.page, - ), - ], - ], - ], - ], - ), - ); - - body = MultiProvider( - providers: _appsBloc.appBlocProviders, - child: Scaffold( - key: _scaffoldKey, - resizeToAvoidBottomInset: false, - drawer: !drawerAlwaysVisible ? drawer : null, - appBar: appBar, - body: body, - ), - ); - - if (drawerAlwaysVisible) { - body = Row( - children: [ - drawer, + Widget build(final BuildContext context) => ResultBuilder>.behaviorSubject( + stream: _appsBloc.appImplementations, + builder: (final context, final appImplementations) => StreamBuilder( + stream: _appsBloc.activeAppID, + builder: (final context, final activeAppIDSnapshot) => OptionBuilder( + option: _globalOptions.navigationMode, + builder: (final context, final navigationMode) { + final drawerAlwaysVisible = navigationMode == NavigationMode.drawerAlwaysVisible; + + const drawer = NeonDrawer(); + const appBar = NeonAppBar(); + + Widget body = Builder( + builder: (final context) => Column( + children: [ + if (appImplementations.data != null) ...[ + if (appImplementations.data!.isEmpty) ...[ + Expanded( + child: Center( + child: Text( + AppLocalizations.of(context).errorNoCompatibleNextcloudAppsFound, + textAlign: TextAlign.center, + ), + ), + ), + ] else ...[ + if (activeAppIDSnapshot.hasData) ...[ Expanded( - child: body, + child: appImplementations.data!.find(activeAppIDSnapshot.data!)!.page, ), ], - ); - } - - return WillPopScope( - onWillPop: () async { - if (_scaffoldKey.currentState!.isDrawerOpen) { - Navigator.pop(context); - return true; - } - - _scaffoldKey.currentState!.openDrawer(); - return false; - }, - child: body, - ); - }, + ], + ], + ], ), - ), - ), + ); + + body = MultiProvider( + providers: _appsBloc.appBlocProviders, + child: Scaffold( + key: _scaffoldKey, + resizeToAvoidBottomInset: false, + drawer: !drawerAlwaysVisible ? drawer : null, + appBar: appBar, + body: body, + ), + ); + + if (drawerAlwaysVisible) { + body = Row( + children: [ + drawer, + Expanded( + child: body, + ), + ], + ); + } + + return WillPopScope( + onWillPop: () async { + if (_scaffoldKey.currentState!.isDrawerOpen) { + Navigator.pop(context); + return true; + } + + _scaffoldKey.currentState!.openDrawer(); + return false; + }, + child: body, + ); + }, ), ), );