Skip to content

Commit

Permalink
refactor(neon_framework): Hide the drawer when only a single app is s…
Browse files Browse the repository at this point in the history
…upported

Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Apr 4, 2024
1 parent a67df8e commit eb9ee0b
Showing 1 changed file with 48 additions and 50 deletions.
98 changes: 48 additions & 50 deletions packages/neon_framework/lib/src/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,73 +105,71 @@ class _HomePageState extends State<HomePage> {

@override
Widget build(BuildContext context) {
const drawer = NeonDrawer();
const appBar = NeonAppBar();

final appView = ResultBuilder.behaviorSubject(
return ResultBuilder.behaviorSubject(

Check warning on line 108 in packages/neon_framework/lib/src/pages/home.dart

View check run for this annotation

Codecov / codecov/patch

packages/neon_framework/lib/src/pages/home.dart#L108

Added line #L108 was not covered by tests
subject: _appsBloc.appImplementations,
builder: (context, appImplementations) {
Widget appView;
if (!appImplementations.hasData) {
return const SizedBox();
}

if (appImplementations.requireData.isEmpty) {
return Center(
appView = const SizedBox();
} else if (appImplementations.requireData.isEmpty) {
appView = Center(

Check warning on line 115 in packages/neon_framework/lib/src/pages/home.dart

View check run for this annotation

Codecov / codecov/patch

packages/neon_framework/lib/src/pages/home.dart#L114-L115

Added lines #L114 - L115 were not covered by tests
child: Text(
NeonLocalizations.of(context).errorNoCompatibleNextcloudAppsFound,
textAlign: TextAlign.center,
),
);
} else {
appView = StreamBuilder(
stream: _appsBloc.activeApp,
builder: (context, activeAppSnapshot) {
if (!activeAppSnapshot.hasData) {

Check warning on line 125 in packages/neon_framework/lib/src/pages/home.dart

View check run for this annotation

Codecov / codecov/patch

packages/neon_framework/lib/src/pages/home.dart#L122-L125

Added lines #L122 - L125 were not covered by tests
return const SizedBox();
}

return SafeArea(
child: activeAppSnapshot.requireData.page,

Check warning on line 130 in packages/neon_framework/lib/src/pages/home.dart

View check run for this annotation

Codecov / codecov/patch

packages/neon_framework/lib/src/pages/home.dart#L129-L130

Added lines #L129 - L130 were not covered by tests
);
},
);
}

return StreamBuilder(
stream: _appsBloc.activeApp,
builder: (context, activeAppSnapshot) {
if (!activeAppSnapshot.hasData) {
return const SizedBox();
}
final showDrawer = !appImplementations.hasData || appImplementations.requireData.length > 2;

Check warning on line 136 in packages/neon_framework/lib/src/pages/home.dart

View check run for this annotation

Codecov / codecov/patch

packages/neon_framework/lib/src/pages/home.dart#L136

Added line #L136 was not covered by tests

return SafeArea(
child: activeAppSnapshot.requireData.page,
final body = ValueListenableBuilder(
valueListenable: _globalOptions.navigationMode,
builder: (context, navigationMode, _) {
final drawerAlwaysVisible = navigationMode == global_options.NavigationMode.drawerAlwaysVisible;

Check warning on line 141 in packages/neon_framework/lib/src/pages/home.dart

View check run for this annotation

Codecov / codecov/patch

packages/neon_framework/lib/src/pages/home.dart#L138-L141

Added lines #L138 - L141 were not covered by tests

final body = Scaffold(

Check warning on line 143 in packages/neon_framework/lib/src/pages/home.dart

View check run for this annotation

Codecov / codecov/patch

packages/neon_framework/lib/src/pages/home.dart#L143

Added line #L143 was not covered by tests
resizeToAvoidBottomInset: false,
drawer: showDrawer && !drawerAlwaysVisible ? const NeonDrawer() : null,
appBar: const NeonAppBar(),
body: appView,
);
},
);
},
);

final body = ValueListenableBuilder(
valueListenable: _globalOptions.navigationMode,
builder: (context, navigationMode, _) {
final drawerAlwaysVisible = navigationMode == global_options.NavigationMode.drawerAlwaysVisible;
if (showDrawer && drawerAlwaysVisible) {
return Row(
children: [
ColoredBox(
color: Theme.of(context).colorScheme.background,

Check warning on line 154 in packages/neon_framework/lib/src/pages/home.dart

View check run for this annotation

Codecov / codecov/patch

packages/neon_framework/lib/src/pages/home.dart#L151-L154

Added lines #L151 - L154 were not covered by tests
child: const NeonDrawer(),
),
Expanded(

Check warning on line 157 in packages/neon_framework/lib/src/pages/home.dart

View check run for this annotation

Codecov / codecov/patch

packages/neon_framework/lib/src/pages/home.dart#L157

Added line #L157 was not covered by tests
child: body,
),
],
);
}

final body = Scaffold(
resizeToAvoidBottomInset: false,
drawer: !drawerAlwaysVisible ? drawer : null,
appBar: appBar,
body: appView,
return body;
},
);

if (drawerAlwaysVisible) {
return Row(
children: [
ColoredBox(
color: Theme.of(context).colorScheme.background,
child: drawer,
),
Expanded(
child: body,
),
],
);
}

return body;
return MultiProvider(
providers: _appsBloc.appBlocProviders,

Check warning on line 169 in packages/neon_framework/lib/src/pages/home.dart

View check run for this annotation

Codecov / codecov/patch

packages/neon_framework/lib/src/pages/home.dart#L168-L169

Added lines #L168 - L169 were not covered by tests
child: body,
);
},
);

return MultiProvider(
providers: _appsBloc.appBlocProviders,
child: body,
);
}
}

0 comments on commit eb9ee0b

Please sign in to comment.