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. 131
      packages/neon/neon/lib/src/pages/home.dart
  2. 2
      packages/neon/neon/lib/src/utils/global_options.dart

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

@ -187,12 +187,10 @@ 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: Container(
padding: isQuickBar ? const EdgeInsets.all(5) : null,
child: Column( child: Column(
children: [ children: [
Expanded( Expanded(
@ -207,41 +205,6 @@ class _HomePageState extends State<HomePage> {
Builder( Builder(
builder: (final context) { builder: (final context) {
if (accountsSnapshot.hasData) { if (accountsSnapshot.hasData) {
if (isQuickBar) {
return Column(
children: [
if (accounts.length != 1) ...[
for (final account in accounts) ...[
Container(
margin: const EdgeInsets.symmetric(
vertical: 5,
),
child: IconButton(
onPressed: () {
_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,
),
),
],
],
);
}
return DrawerHeader( return DrawerHeader(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
@ -312,7 +275,6 @@ class _HomePageState extends State<HomePage> {
), ),
NeonException( NeonException(
appImplementations.error, appImplementations.error,
onlyIcon: isQuickBar,
onRetry: _appsBloc.refresh, onRetry: _appsBloc.refresh,
), ),
NeonLinearProgressIndicator( NeonLinearProgressIndicator(
@ -321,23 +283,10 @@ class _HomePageState extends State<HomePage> {
if (appImplementations.data != null) ...[ if (appImplementations.data != null) ...[
for (final appImplementation in appImplementations.data!) ...[ for (final appImplementation in appImplementations.data!) ...[
StreamBuilder<int>( StreamBuilder<int>(
stream: appImplementation.getUnreadCounter(_appsBloc) ?? stream: appImplementation.getUnreadCounter(_appsBloc),
BehaviorSubject<int>.seeded(0),
builder: (final context, final unreadCounterSnapshot) { builder: (final context, final unreadCounterSnapshot) {
final unreadCount = unreadCounterSnapshot.data ?? 0; 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( return ListTile(
key: Key('app-${appImplementation.id}'), key: Key('app-${appImplementation.id}'),
title: Row( title: Row(
@ -375,16 +324,6 @@ class _HomePageState extends State<HomePage> {
), ),
), ),
), ),
if (isQuickBar) ...[
IconButton(
onPressed: () => const SettingsRoute().go(context),
tooltip: AppLocalizations.of(context).settings,
icon: Icon(
Icons.settings,
color: Theme.of(context).appBarTheme.foregroundColor,
),
),
] else ...[
ListTile( ListTile(
key: const Key('settings'), key: const Key('settings'),
title: Text(AppLocalizations.of(context).settings), title: Text(AppLocalizations.of(context).settings),
@ -396,26 +335,11 @@ class _HomePageState extends State<HomePage> {
}, },
), ),
], ],
],
),
), ),
), ),
); );
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,13 +425,7 @@ class _HomePageState extends State<HomePage> {
); );
Widget body = Builder( Widget body = Builder(
builder: (final context) => Row( builder: (final context) => Column(
children: [
if (navigationMode == NavigationMode.quickBar) ...[
drawer,
],
Expanded(
child: Column(
children: [ children: [
if (appImplementations.data != null) ...[ if (appImplementations.data != null) ...[
if (appImplementations.data!.isEmpty) ...[ if (appImplementations.data!.isEmpty) ...[
@ -529,15 +447,29 @@ class _HomePageState extends State<HomePage> {
], ],
], ],
), ),
),
],
),
); );
body = MultiProvider( body = MultiProvider(
providers: _appsBloc.appBlocProviders, 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, child: body,
),
],
); );
}
return WillPopScope( return WillPopScope(
onWillPop: () async { onWillPop: () async {
@ -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