From 5cafec49d62fdd8dff296ac427bf73ce529109a0 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sun, 23 Apr 2023 08:41:23 +0200 Subject: [PATCH] neon,neon_files,settings: Make scrollbars draggable --- packages/neon/neon/lib/src/pages/home.dart | 2 + packages/neon/neon/lib/src/pages/login.dart | 128 +++++++++--------- .../neon/neon/lib/src/widgets/list_view.dart | 2 + .../neon/neon_files/lib/pages/details.dart | 90 ++++++------ .../lib/src/widgets/settings_list.dart | 2 + 5 files changed, 119 insertions(+), 105 deletions(-) diff --git a/packages/neon/neon/lib/src/pages/home.dart b/packages/neon/neon/lib/src/pages/home.dart index 6915eac4..a0e42a70 100644 --- a/packages/neon/neon/lib/src/pages/home.dart +++ b/packages/neon/neon/lib/src/pages/home.dart @@ -227,7 +227,9 @@ class _HomePageState extends State { children: [ Expanded( child: Scrollbar( + interactive: true, child: ListView( + primary: true, // Needed for the drawer header to also render in the statusbar padding: EdgeInsets.zero, children: [ diff --git a/packages/neon/neon/lib/src/pages/login.dart b/packages/neon/neon/lib/src/pages/login.dart index 66e24e47..1360b29d 100644 --- a/packages/neon/neon/lib/src/pages/login.dart +++ b/packages/neon/neon/lib/src/pages/login.dart @@ -163,73 +163,77 @@ class _LoginPageState extends State { ), ) : Center( - child: ListView( - shrinkWrap: true, - padding: const EdgeInsets.symmetric(vertical: 40, horizontal: 20), - children: [ - SizedBox( - height: MediaQuery.of(context).size.height / 2, - child: Column( - children: [ - SvgPicture.asset( - 'assets/logo.svg', - width: 100, - height: 100, - ), - Text( - Provider.of(context, listen: false).name, - style: Theme.of(context).textTheme.titleLarge, - ), - const SizedBox( - height: 30, - ), - Text(AppLocalizations.of(context).loginWorksWith), - const SizedBox( - height: 20, - ), - const NextcloudLogo(), - ], - ), - ), - Form( - key: _formKey, - child: TextFormField( - focusNode: _focusNode, - decoration: const InputDecoration( - hintText: 'https://...', + child: Scrollbar( + interactive: true, + child: ListView( + primary: true, + shrinkWrap: true, + padding: const EdgeInsets.symmetric(vertical: 40, horizontal: 20), + children: [ + SizedBox( + height: MediaQuery.of(context).size.height / 2, + child: Column( + children: [ + SvgPicture.asset( + 'assets/logo.svg', + width: 100, + height: 100, + ), + Text( + Provider.of(context, listen: false).name, + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox( + height: 30, + ), + Text(AppLocalizations.of(context).loginWorksWith), + const SizedBox( + height: 20, + ), + const NextcloudLogo(), + ], ), - keyboardType: TextInputType.url, - initialValue: widget.serverURL, - validator: (final input) => validateHttpUrl(context, input), - onFieldSubmitted: (final input) { - if (_formKey.currentState!.validate()) { - _loginBloc.setServerURL(input); - } else { - _focusNode.requestFocus(); - } - }, ), - ), - Column( - children: [ - NeonLinearProgressIndicator( - visible: serverConnectionStateSnapshot.data == ServerConnectionState.loading, - ), - if (serverConnectionStateSnapshot.data == ServerConnectionState.unreachable) ...[ - NeonException( - AppLocalizations.of(context).errorUnableToReachServer, - onRetry: _loginBloc.refresh, + Form( + key: _formKey, + child: TextFormField( + focusNode: _focusNode, + decoration: const InputDecoration( + hintText: 'https://...', ), - ], - if (serverConnectionStateSnapshot.data == ServerConnectionState.maintenanceMode) ...[ - NeonException( - AppLocalizations.of(context).errorServerInMaintenanceMode, - onRetry: _loginBloc.refresh, + keyboardType: TextInputType.url, + initialValue: widget.serverURL, + validator: (final input) => validateHttpUrl(context, input), + onFieldSubmitted: (final input) { + if (_formKey.currentState!.validate()) { + _loginBloc.setServerURL(input); + } else { + _focusNode.requestFocus(); + } + }, + ), + ), + Column( + children: [ + NeonLinearProgressIndicator( + visible: serverConnectionStateSnapshot.data == ServerConnectionState.loading, ), + if (serverConnectionStateSnapshot.data == ServerConnectionState.unreachable) ...[ + NeonException( + AppLocalizations.of(context).errorUnableToReachServer, + onRetry: _loginBloc.refresh, + ), + ], + if (serverConnectionStateSnapshot.data == ServerConnectionState.maintenanceMode) ...[ + NeonException( + AppLocalizations.of(context).errorServerInMaintenanceMode, + onRetry: _loginBloc.refresh, + ), + ], ], - ], - ), - ], + ), + ], + ), ), ), ), diff --git a/packages/neon/neon/lib/src/widgets/list_view.dart b/packages/neon/neon/lib/src/widgets/list_view.dart index 842b7408..c4325500 100644 --- a/packages/neon/neon/lib/src/widgets/list_view.dart +++ b/packages/neon/neon/lib/src/widgets/list_view.dart @@ -41,7 +41,9 @@ class NeonListView extends StatelessWidget { ), Expanded( child: Scrollbar( + interactive: true, child: ListView( + primary: true, key: scrollKey != null ? PageStorageKey(scrollKey!) : null, padding: withFloatingActionButton ? const EdgeInsets.only(bottom: 88) : null, children: [ diff --git a/packages/neon/neon_files/lib/pages/details.dart b/packages/neon/neon_files/lib/pages/details.dart index 15b184a9..7fb0baa3 100644 --- a/packages/neon/neon_files/lib/pages/details.dart +++ b/packages/neon/neon_files/lib/pages/details.dart @@ -16,51 +16,55 @@ class FilesDetailsPage extends StatelessWidget { appBar: AppBar( title: Text(details.name), ), - body: ListView( - children: [ - ColoredBox( - color: Theme.of(context).colorScheme.primary, - child: FilePreview( - bloc: bloc, - details: details, - color: Theme.of(context).colorScheme.onPrimary, - width: MediaQuery.of(context).size.width.toInt(), - height: MediaQuery.of(context).size.height ~/ 4, + body: Scrollbar( + interactive: true, + child: ListView( + primary: true, + children: [ + ColoredBox( + color: Theme.of(context).colorScheme.primary, + child: FilePreview( + bloc: bloc, + details: details, + color: Theme.of(context).colorScheme.onPrimary, + width: MediaQuery.of(context).size.width.toInt(), + height: MediaQuery.of(context).size.height ~/ 4, + ), ), - ), - DataTable( - headingRowHeight: 0, - columns: [ - DataColumn(label: Container()), - DataColumn(label: Container()), - ], - rows: [ - for (final entry in { - details.isDirectory - ? AppLocalizations.of(context).filesDetailsFolderName - : AppLocalizations.of(context).filesDetailsFileName: details.name, - AppLocalizations.of(context).filesDetailsParentFolder: - details.path.length == 1 ? '/' : details.path.sublist(0, details.path.length - 1).join('/'), - details.isDirectory - ? AppLocalizations.of(context).filesDetailsFolderSize - : AppLocalizations.of(context).filesDetailsFileSize: filesize(details.size, 1), - AppLocalizations.of(context).filesDetailsLastModified: - details.lastModified.toLocal().toIso8601String(), - if (details.isFavorite != null) ...{ - AppLocalizations.of(context).filesDetailsIsFavorite: - details.isFavorite! ? AppLocalizations.of(context).yes : AppLocalizations.of(context).no, - }, - }.entries) ...[ - DataRow( - cells: [ - DataCell(Text(entry.key)), - DataCell(Text(entry.value)), - ], - ), + DataTable( + headingRowHeight: 0, + columns: [ + DataColumn(label: Container()), + DataColumn(label: Container()), ], - ], - ), - ], + rows: [ + for (final entry in { + details.isDirectory + ? AppLocalizations.of(context).filesDetailsFolderName + : AppLocalizations.of(context).filesDetailsFileName: details.name, + AppLocalizations.of(context).filesDetailsParentFolder: + details.path.length == 1 ? '/' : details.path.sublist(0, details.path.length - 1).join('/'), + details.isDirectory + ? AppLocalizations.of(context).filesDetailsFolderSize + : AppLocalizations.of(context).filesDetailsFileSize: filesize(details.size, 1), + AppLocalizations.of(context).filesDetailsLastModified: + details.lastModified.toLocal().toIso8601String(), + if (details.isFavorite != null) ...{ + AppLocalizations.of(context).filesDetailsIsFavorite: + details.isFavorite! ? AppLocalizations.of(context).yes : AppLocalizations.of(context).no, + }, + }.entries) ...[ + DataRow( + cells: [ + DataCell(Text(entry.key)), + DataCell(Text(entry.value)), + ], + ), + ], + ], + ), + ], + ), ), ); } diff --git a/packages/settings/lib/src/widgets/settings_list.dart b/packages/settings/lib/src/widgets/settings_list.dart index 15c1f170..6622d14e 100644 --- a/packages/settings/lib/src/widgets/settings_list.dart +++ b/packages/settings/lib/src/widgets/settings_list.dart @@ -10,7 +10,9 @@ class SettingsList extends StatelessWidget { @override Widget build(final BuildContext context) => Scrollbar( + interactive: true, child: ListView( + primary: true, padding: const EdgeInsets.all(20), children: categories.cast().intersperse(const Divider()).toList(), ),