Browse Source

neon: refactor page loading

pull/402/head
Nikolas Rimikis 1 year ago
parent
commit
2c7e8b74c8
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 148
      packages/neon/neon/lib/src/pages/home.dart

148
packages/neon/neon/lib/src/pages/home.dart

@ -98,79 +98,81 @@ class _HomePageState extends State<HomePage> {
} }
@override @override
Widget build(final BuildContext context) => ResultBuilder<Iterable<AppImplementation>>.behaviorSubject( Widget build(final BuildContext context) {
stream: _appsBloc.appImplementations, const drawer = NeonDrawer();
builder: (final context, final appImplementations) => StreamBuilder<AppImplementation>( const appBar = NeonAppBar();
final appView = ResultBuilder<Iterable<AppImplementation>>.behaviorSubject(
stream: _appsBloc.appImplementations,
builder: (final context, final appImplementations) {
if (!appImplementations.hasData) {
return const SizedBox();
}
if (appImplementations.requireData.isEmpty) {
return Center(
child: Text(
AppLocalizations.of(context).errorNoCompatibleNextcloudAppsFound,
textAlign: TextAlign.center,
),
);
}
return StreamBuilder<AppImplementation>(
stream: _appsBloc.activeApp, stream: _appsBloc.activeApp,
builder: (final context, final activeAppSnapshot) => OptionBuilder<NavigationMode>( builder: (final context, final activeAppIDSnapshot) {
option: _globalOptions.navigationMode, if (!activeAppIDSnapshot.hasData) {
builder: (final context, final navigationMode) { return const SizedBox();
final drawerAlwaysVisible = navigationMode == NavigationMode.drawerAlwaysVisible; }
const drawer = NeonDrawer(); return activeAppIDSnapshot.requireData.page;
const appBar = NeonAppBar(); },
);
Widget body = Builder( },
builder: (final context) => Column( );
children: [
if (appImplementations.hasData) ...[ final body = OptionBuilder<NavigationMode>(
if (appImplementations.requireData.isEmpty) ...[ option: _globalOptions.navigationMode,
Expanded( builder: (final context, final navigationMode) {
child: Center( final drawerAlwaysVisible = navigationMode == NavigationMode.drawerAlwaysVisible;
child: Text(
AppLocalizations.of(context).errorNoCompatibleNextcloudAppsFound, final body = Scaffold(
textAlign: TextAlign.center, key: _scaffoldKey,
), resizeToAvoidBottomInset: false,
), drawer: !drawerAlwaysVisible ? drawer : null,
), appBar: appBar,
] else ...[ body: appView,
if (activeAppSnapshot.hasData) ...[ );
Expanded(
child: activeAppSnapshot.requireData.page, if (drawerAlwaysVisible) {
), return Row(
], children: [
], drawer,
], Expanded(
],
),
);
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, child: body,
); ),
}, ],
), );
), }
);
return body;
},
);
return WillPopScope(
onWillPop: () async {
if (_scaffoldKey.currentState!.isDrawerOpen) {
Navigator.pop(context);
return true;
}
_scaffoldKey.currentState!.openDrawer();
return false;
},
child: MultiProvider(
providers: _appsBloc.appBlocProviders,
child: body,
),
);
}
} }

Loading…
Cancel
Save