Browse Source

Merge pull request #362 from Leptopoda/feature/adaptive-layout

neon: refractor HomePage
pull/364/head
Nikolas Rimikis 1 year ago committed by GitHub
parent
commit
1f94382948
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 92
      packages/neon/neon/lib/src/pages/home.dart

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

@ -183,22 +183,13 @@ class _HomePageState extends State<HomePage> {
) =>
OptionBuilder<NavigationMode>(
option: _globalOptions.navigationMode,
builder: (final context, final navigationMode) => WillPopScope(
onWillPop: () async {
if (_scaffoldKey.currentState!.isDrawerOpen) {
Navigator.pop(context);
return true;
builder: (final context, final navigationMode) {
final accounts = accountsSnapshot.data;
final account = accounts?.find(_account.id);
if (accounts == null || account == null) {
return const Scaffold();
}
_scaffoldKey.currentState!.openDrawer();
return false;
},
child: Builder(
builder: (final context) {
if (accountsSnapshot.hasData) {
final accounts = accountsSnapshot.data!;
final account = accounts.find(_account.id);
if (account != null) {
final isQuickBar = navigationMode == NavigationMode.quickBar;
final drawer = Builder(
builder: (final context) => Drawer(
@ -263,18 +254,15 @@ class _HomePageState extends State<HomePage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (capabilities.data != null) ...[
if (capabilities.data!.capabilities.theming?.name !=
null) ...[
if (capabilities.data!.capabilities.theming?.name != null) ...[
Text(
capabilities.data!.capabilities.theming!.name!,
style: DefaultTextStyle.of(context).style.copyWith(
color:
Theme.of(context).appBarTheme.foregroundColor,
color: Theme.of(context).appBarTheme.foregroundColor,
),
),
],
if (capabilities.data!.capabilities.theming?.logo !=
null) ...[
if (capabilities.data!.capabilities.theming?.logo != null) ...[
Flexible(
child: NeonCachedUrlImage(
url: capabilities.data!.capabilities.theming!.logo!,
@ -295,8 +283,7 @@ class _HomePageState extends State<HomePage> {
child: DropdownButton<String>(
isExpanded: true,
dropdownColor: Theme.of(context).colorScheme.primary,
iconEnabledColor:
Theme.of(context).colorScheme.onBackground,
iconEnabledColor: Theme.of(context).colorScheme.onBackground,
value: _account.id,
items: accounts
.map<DropdownMenuItem<String>>(
@ -305,9 +292,8 @@ class _HomePageState extends State<HomePage> {
child: NeonAccountTile(
account: account,
dense: true,
textColor: Theme.of(context)
.appBarTheme
.foregroundColor,
textColor:
Theme.of(context).appBarTheme.foregroundColor,
),
),
)
@ -418,18 +404,7 @@ class _HomePageState extends State<HomePage> {
),
),
);
return Row(
children: [
if (navigationMode == NavigationMode.drawerAlwaysVisible) ...[
drawer,
],
Expanded(
child: Scaffold(
key: _scaffoldKey,
resizeToAvoidBottomInset: false,
drawer: navigationMode == NavigationMode.drawer ? drawer : null,
appBar: AppBar(
final appBar = AppBar(
scrolledUnderElevation: navigationMode != NavigationMode.drawer ? 0 : null,
automaticallyImplyLeading: navigationMode == NavigationMode.drawer,
leadingWidth: isQuickBar ? kQuickBarWidth : null,
@ -452,9 +427,7 @@ class _HomePageState extends State<HomePage> {
if (appImplementations.data != null && activeAppIDSnapshot.hasData) ...[
Flexible(
child: Text(
appImplementations.data!
.find(activeAppIDSnapshot.data!)!
.name(context),
appImplementations.data!.find(activeAppIDSnapshot.data!)!.name(context),
),
),
],
@ -529,8 +502,10 @@ class _HomePageState extends State<HomePage> {
),
),
],
),
body: Row(
);
final body = Builder(
builder: (final context) => Row(
children: [
if (navigationMode == NavigationMode.quickBar) ...[
drawer,
@ -543,8 +518,7 @@ class _HomePageState extends State<HomePage> {
Expanded(
child: Center(
child: Text(
AppLocalizations.of(context)
.errorNoCompatibleNextcloudAppsFound,
AppLocalizations.of(context).errorNoCompatibleNextcloudAppsFound,
textAlign: TextAlign.center,
),
),
@ -564,16 +538,36 @@ class _HomePageState extends State<HomePage> {
),
],
),
),
),
],
);
return WillPopScope(
onWillPop: () async {
if (_scaffoldKey.currentState!.isDrawerOpen) {
Navigator.pop(context);
return true;
}
}
return const Scaffold();
_scaffoldKey.currentState!.openDrawer();
return false;
},
child: Row(
children: [
if (navigationMode == NavigationMode.drawerAlwaysVisible) ...[
drawer,
],
Expanded(
child: Scaffold(
key: _scaffoldKey,
resizeToAvoidBottomInset: false,
drawer: navigationMode == NavigationMode.drawer ? drawer : null,
appBar: appBar,
body: body,
),
),
],
),
);
},
),
),
),

Loading…
Cancel
Save