Browse Source

neon: deprecate NavigationMode.quickBar

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

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

@ -187,235 +187,159 @@ class _HomePageState extends State<HomePage> {
return const Scaffold(); return const Scaffold();
} }
final isQuickBar = navigationMode == NavigationMode.quickBar; final drawerAlwaysVisible = navigationMode == NavigationMode.drawerAlwaysVisible;
final drawer = Builder( final drawer = Builder(
builder: (final context) => Drawer( builder: (final context) => Drawer(
width: isQuickBar ? kQuickBarWidth : null, child: Column(
child: Container( children: [
padding: isQuickBar ? const EdgeInsets.all(5) : null, Expanded(
child: Column( child: Scrollbar(
children: [ controller: drawerScrollController,
Expanded( interactive: true,
child: Scrollbar( child: ListView(
controller: drawerScrollController, controller: drawerScrollController,
interactive: true, // Needed for the drawer header to also render in the statusbar
child: ListView( padding: EdgeInsets.zero,
controller: drawerScrollController, children: [
// Needed for the drawer header to also render in the statusbar Builder(
padding: EdgeInsets.zero, builder: (final context) {
children: [ if (accountsSnapshot.hasData) {
Builder( return DrawerHeader(
builder: (final context) { decoration: BoxDecoration(
if (accountsSnapshot.hasData) { color: Theme.of(context).colorScheme.primary,
if (isQuickBar) { ),
return Column( child: Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
if (accounts.length != 1) ...[ mainAxisAlignment: MainAxisAlignment.spaceBetween,
for (final account in accounts) ...[ children: [
Container( if (capabilities.data != null) ...[
margin: const EdgeInsets.symmetric( if (capabilities.data!.capabilities.theming?.name != null) ...[
vertical: 5, Text(
), capabilities.data!.capabilities.theming!.name!,
child: IconButton( style: DefaultTextStyle.of(context).style.copyWith(
onPressed: () { color: Theme.of(context).appBarTheme.foregroundColor,
_accountsBloc.setActiveAccount(account);
},
tooltip: account.client.humanReadableID,
icon: IntrinsicHeight(
child: NeonUserAvatar(
account: account,
),
), ),
),
),
],
Container(
margin: const EdgeInsets.only(
top: 10,
),
child: Divider(
height: 5,
color: Theme.of(context).appBarTheme.foregroundColor,
),
), ),
], ],
], if (capabilities.data!.capabilities.theming?.logo != null) ...[
); Flexible(
} child: NeonCachedUrlImage(
return DrawerHeader( url: capabilities.data!.capabilities.theming!.logo!,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (capabilities.data != 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,
),
), ),
],
if (capabilities.data!.capabilities.theming?.logo != null) ...[
Flexible(
child: NeonCachedUrlImage(
url: capabilities.data!.capabilities.theming!.logo!,
),
),
],
] else ...[
NeonException(
capabilities.error,
onRetry: _capabilitiesBloc.refresh,
),
NeonLinearProgressIndicator(
visible: capabilities.loading,
), ),
], ],
if (accounts.length != 1) ...[ ] else ...[
DropdownButtonHideUnderline( NeonException(
child: DropdownButton<String>( capabilities.error,
isExpanded: true, onRetry: _capabilitiesBloc.refresh,
dropdownColor: Theme.of(context).colorScheme.primary, ),
iconEnabledColor: Theme.of(context).colorScheme.onBackground, NeonLinearProgressIndicator(
value: _account.id, visible: capabilities.loading,
items: accounts ),
.map<DropdownMenuItem<String>>( ],
(final account) => DropdownMenuItem<String>( if (accounts.length != 1) ...[
value: account.id, DropdownButtonHideUnderline(
child: NeonAccountTile( child: DropdownButton<String>(
account: account, isExpanded: true,
dense: true, dropdownColor: Theme.of(context).colorScheme.primary,
textColor: iconEnabledColor: Theme.of(context).colorScheme.onBackground,
Theme.of(context).appBarTheme.foregroundColor, value: _account.id,
), items: accounts
.map<DropdownMenuItem<String>>(
(final account) => DropdownMenuItem<String>(
value: account.id,
child: NeonAccountTile(
account: account,
dense: true,
textColor:
Theme.of(context).appBarTheme.foregroundColor,
), ),
) ),
.toList(), )
onChanged: (final id) { .toList(),
if (id != null) { onChanged: (final id) {
_accountsBloc.setActiveAccount(accounts.find(id)!); if (id != null) {
} _accountsBloc.setActiveAccount(accounts.find(id)!);
}, }
},
),
),
],
],
),
);
}
return Container();
},
),
NeonException(
appImplementations.error,
onRetry: _appsBloc.refresh,
),
NeonLinearProgressIndicator(
visible: appImplementations.loading,
),
if (appImplementations.data != null) ...[
for (final appImplementation in appImplementations.data!) ...[
StreamBuilder<int>(
stream: appImplementation.getUnreadCounter(_appsBloc),
builder: (final context, final unreadCounterSnapshot) {
final unreadCount = unreadCounterSnapshot.data ?? 0;
return ListTile(
key: Key('app-${appImplementation.id}'),
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(appImplementation.name(context)),
if (unreadCount > 0) ...[
Text(
unreadCount.toString(),
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
fontWeight: FontWeight.bold,
fontSize: 14,
), ),
), ),
], ],
], ],
), ),
); leading: appImplementation.buildIcon(),
} minLeadingWidth: 0,
return Container(); onTap: () async {
}, await _appsBloc.setActiveApp(appImplementation.id);
),
NeonException(
appImplementations.error,
onlyIcon: isQuickBar,
onRetry: _appsBloc.refresh,
),
NeonLinearProgressIndicator(
visible: appImplementations.loading,
),
if (appImplementations.data != null) ...[
for (final appImplementation in appImplementations.data!) ...[
StreamBuilder<int>(
stream: appImplementation.getUnreadCounter(_appsBloc) ??
BehaviorSubject<int>.seeded(0),
builder: (final context, final unreadCounterSnapshot) {
final unreadCount = unreadCounterSnapshot.data ?? 0;
if (isQuickBar) {
return IconButton(
onPressed: () async {
await _appsBloc.setActiveApp(appImplementation.id);
},
tooltip: appImplementation.name(context),
icon: NeonAppImplementationIcon(
appImplementation: appImplementation,
unreadCount: unreadCount,
color: Theme.of(context).colorScheme.primary,
),
);
}
return ListTile(
key: Key('app-${appImplementation.id}'),
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(appImplementation.name(context)),
if (unreadCount > 0) ...[
Text(
unreadCount.toString(),
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
],
],
),
leading: appImplementation.buildIcon(),
minLeadingWidth: 0,
onTap: () async {
await _appsBloc.setActiveApp(appImplementation.id);
if (!mounted) { if (!mounted) {
return; return;
} }
Scaffold.maybeOf(context)?.closeDrawer(); Scaffold.maybeOf(context)?.closeDrawer();
}, },
); );
}, },
), ),
],
], ],
], ],
), ],
), ),
), ),
if (isQuickBar) ...[ ),
IconButton( ListTile(
onPressed: () => const SettingsRoute().go(context), key: const Key('settings'),
tooltip: AppLocalizations.of(context).settings, title: Text(AppLocalizations.of(context).settings),
icon: Icon( leading: const Icon(Icons.settings),
Icons.settings, minLeadingWidth: 0,
color: Theme.of(context).appBarTheme.foregroundColor, onTap: () async {
), Scaffold.maybeOf(context)?.closeDrawer();
), const SettingsRoute().go(context);
] else ...[ },
ListTile( ),
key: const Key('settings'), ],
title: Text(AppLocalizations.of(context).settings),
leading: const Icon(Icons.settings),
minLeadingWidth: 0,
onTap: () async {
Scaffold.maybeOf(context)?.closeDrawer();
const SettingsRoute().go(context);
},
),
],
],
),
), ),
), ),
); );
final appBar = AppBar( final appBar = AppBar(
scrolledUnderElevation: navigationMode != NavigationMode.drawer ? 0 : null, automaticallyImplyLeading: !drawerAlwaysVisible,
automaticallyImplyLeading: navigationMode == NavigationMode.drawer,
leadingWidth: isQuickBar ? kQuickBarWidth : null,
leading: isQuickBar
? Container(
padding: const EdgeInsets.all(5),
child: capabilities.data?.capabilities.theming?.logo != null
? NeonCachedUrlImage(
url: capabilities.data!.capabilities.theming!.logo!,
svgColor: Theme.of(context).iconTheme.color,
)
: null,
)
: null,
title: Column( title: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -501,44 +425,52 @@ class _HomePageState extends State<HomePage> {
); );
Widget body = Builder( Widget body = Builder(
builder: (final context) => Row( builder: (final context) => Column(
children: [ children: [
if (navigationMode == NavigationMode.quickBar) ...[ if (appImplementations.data != null) ...[
drawer, if (appImplementations.data!.isEmpty) ...[
], Expanded(
Expanded( child: Center(
child: Column( child: Text(
children: [ AppLocalizations.of(context).errorNoCompatibleNextcloudAppsFound,
if (appImplementations.data != null) ...[ textAlign: TextAlign.center,
if (appImplementations.data!.isEmpty) ...[ ),
Expanded( ),
child: Center( ),
child: Text( ] else ...[
AppLocalizations.of(context).errorNoCompatibleNextcloudAppsFound, if (activeAppIDSnapshot.hasData) ...[
textAlign: TextAlign.center, Expanded(
), child: appImplementations.data!.find(activeAppIDSnapshot.data!)!.page,
), ),
),
] else ...[
if (activeAppIDSnapshot.hasData) ...[
Expanded(
child: appImplementations.data!.find(activeAppIDSnapshot.data!)!.page,
),
],
],
],
], ],
), ],
), ],
], ],
), ),
); );
body = MultiProvider( body = MultiProvider(
providers: _appsBloc.appBlocProviders, providers: _appsBloc.appBlocProviders,
child: body, 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( return WillPopScope(
onWillPop: () async { onWillPop: () async {
if (_scaffoldKey.currentState!.isDrawerOpen) { if (_scaffoldKey.currentState!.isDrawerOpen) {
@ -549,22 +481,7 @@ class _HomePageState extends State<HomePage> {
_scaffoldKey.currentState!.openDrawer(); _scaffoldKey.currentState!.openDrawer();
return false; return false;
}, },
child: Row( child: body,
children: [
if (navigationMode == NavigationMode.drawerAlwaysVisible) ...[
drawer,
],
Expanded(
child: Scaffold(
key: _scaffoldKey,
resizeToAvoidBottomInset: false,
drawer: navigationMode == NavigationMode.drawer ? drawer : null,
appBar: appBar,
body: body,
),
),
],
),
); );
}, },
), ),

2
packages/neon/neon/lib/src/utils/global_options.dart

@ -224,6 +224,7 @@ class GlobalOptions {
NavigationMode.drawerAlwaysVisible: (final context) => NavigationMode.drawerAlwaysVisible: (final context) =>
AppLocalizations.of(context).globalOptionsNavigationModeDrawerAlwaysVisible, AppLocalizations.of(context).globalOptionsNavigationModeDrawerAlwaysVisible,
}, },
// ignore: deprecated_member_use_from_same_package
NavigationMode.quickBar: (final context) => AppLocalizations.of(context).globalOptionsNavigationModeQuickBar, NavigationMode.quickBar: (final context) => AppLocalizations.of(context).globalOptionsNavigationModeQuickBar,
}), }),
); );
@ -232,5 +233,6 @@ class GlobalOptions {
enum NavigationMode { enum NavigationMode {
drawer, drawer,
drawerAlwaysVisible, drawerAlwaysVisible,
@Deprecated("The new design won't use this anymore")
quickBar, quickBar,
} }

Loading…
Cancel
Save