diff --git a/packages/neon/neon_files/lib/dialogs/choose_create.dart b/packages/neon/neon_files/lib/dialogs/choose_create.dart index 38ad27d5..dbb68051 100644 --- a/packages/neon/neon_files/lib/dialogs/choose_create.dart +++ b/packages/neon/neon_files/lib/dialogs/choose_create.dart @@ -77,7 +77,7 @@ class _FilesChooseCreateDialogState extends State { } }, ), - if (NeonPlatform.instance.canUseCamera) ...[ + if (NeonPlatform.instance.canUseCamera) ListTile( leading: Icon( MdiIcons.cameraPlus, @@ -94,7 +94,6 @@ class _FilesChooseCreateDialogState extends State { } }, ), - ], ListTile( leading: Icon( MdiIcons.folderPlus, diff --git a/packages/neon/neon_files/lib/options.dart b/packages/neon/neon_files/lib/options.dart index 2e8d5ab0..f7799500 100644 --- a/packages/neon/neon_files/lib/options.dart +++ b/packages/neon/neon_files/lib/options.dart @@ -67,9 +67,7 @@ class FilesAppSpecificOptions extends NextcloudAppOptions { label: (final context) => FilesLocalizations.of(context).optionsUploadQueueParallelism, defaultValue: 4, values: { - for (var i = 1; i <= 16; i = i * 2) ...{ - i: (final _) => i.toString(), - }, + for (var i = 1; i <= 16; i = i * 2) i: (final _) => i.toString(), }, ); @@ -80,9 +78,7 @@ class FilesAppSpecificOptions extends NextcloudAppOptions { label: (final context) => FilesLocalizations.of(context).optionsDownloadQueueParallelism, defaultValue: 4, values: { - for (var i = 1; i <= 16; i = i * 2) ...{ - i: (final _) => i.toString(), - }, + for (var i = 1; i <= 16; i = i * 2) i: (final _) => i.toString(), }, ); @@ -96,9 +92,8 @@ class FilesAppSpecificOptions extends NextcloudAppOptions { 2 * 2024, 6 * 1024, 10 * 1024, - ]) ...{ + ]) _mb(i): (final _) => filesize(_mb(i)), - }, }; int _mb(final int i) => i * 1024 * 1024; diff --git a/packages/neon/neon_files/lib/pages/details.dart b/packages/neon/neon_files/lib/pages/details.dart index 36d50c1f..fab48f88 100644 --- a/packages/neon/neon_files/lib/pages/details.dart +++ b/packages/neon/neon_files/lib/pages/details.dart @@ -11,66 +11,72 @@ class FilesDetailsPage extends StatelessWidget { final FileDetails details; @override - Widget build(final BuildContext context) => Scaffold( - resizeToAvoidBottomInset: false, - appBar: AppBar( - title: Text(details.name), - ), - body: SafeArea( - child: ListView( - primary: true, - children: [ - ColoredBox( - color: Theme.of(context).colorScheme.primary, - child: FilePreview( - bloc: bloc, - details: details, - color: Theme.of(context).colorScheme.onPrimary, - size: Size( - MediaQuery.of(context).size.width, - MediaQuery.of(context).size.height / 4, - ), + Widget build(final BuildContext context) { + final l10n = FilesLocalizations.of(context); + + return Scaffold( + resizeToAvoidBottomInset: false, + appBar: AppBar( + title: Text(details.name), + ), + body: SafeArea( + child: ListView( + primary: true, + children: [ + ColoredBox( + color: Theme.of(context).colorScheme.primary, + child: FilePreview( + bloc: bloc, + details: details, + color: Theme.of(context).colorScheme.onPrimary, + size: Size( + MediaQuery.of(context).size.width, + MediaQuery.of(context).size.height / 4, ), ), - DataTable( - headingRowHeight: 0, - columns: const [ - DataColumn(label: SizedBox()), - DataColumn(label: SizedBox()), - ], - rows: [ - for (final entry in { - details.isDirectory - ? FilesLocalizations.of(context).detailsFolderName - : FilesLocalizations.of(context).detailsFileName: details.name, - FilesLocalizations.of(context).detailsParentFolder: - details.path.length == 1 ? '/' : details.path.sublist(0, details.path.length - 1).join('/'), - if (details.size != null) ...{ - details.isDirectory - ? FilesLocalizations.of(context).detailsFolderSize - : FilesLocalizations.of(context).detailsFileSize: filesize(details.size, 1), - }, - if (details.lastModified != null) ...{ - FilesLocalizations.of(context).detailsLastModified: - details.lastModified!.toLocal().toIso8601String(), - }, - if (details.isFavorite != null) ...{ - FilesLocalizations.of(context).detailsIsFavorite: details.isFavorite! - ? FilesLocalizations.of(context).actionYes - : FilesLocalizations.of(context).actionNo, - }, - }.entries) ...[ - DataRow( - cells: [ - DataCell(Text(entry.key)), - DataCell(Text(entry.value)), - ], - ), - ], - ], - ), - ], - ), + ), + DataTable( + headingRowHeight: 0, + columns: const [ + DataColumn(label: SizedBox()), + DataColumn(label: SizedBox()), + ], + rows: [ + _buildDataRow( + details.isDirectory ? l10n.detailsFolderName : l10n.detailsFileName, + details.name, + ), + _buildDataRow( + l10n.detailsParentFolder, + details.path.length == 1 ? '/' : details.path.sublist(0, details.path.length - 1).join('/'), + ), + if (details.size != null) + _buildDataRow( + details.isDirectory ? l10n.detailsFolderSize : l10n.detailsFileSize, + filesize(details.size, 1), + ), + if (details.lastModified != null) + _buildDataRow( + l10n.detailsLastModified, + details.lastModified!.toLocal().toIso8601String(), + ), + if (details.isFavorite != null) + _buildDataRow( + l10n.detailsIsFavorite, + details.isFavorite! ? l10n.actionYes : l10n.actionNo, + ), + ], + ), + ], ), + ), + ); + } + + DataRow _buildDataRow(final String key, final String value) => DataRow( + cells: [ + DataCell(Text(key)), + DataCell(Text(value)), + ], ); } diff --git a/packages/neon/neon_files/lib/widgets/actions.dart b/packages/neon/neon_files/lib/widgets/actions.dart index aa9eb789..2022aa95 100644 --- a/packages/neon/neon_files/lib/widgets/actions.dart +++ b/packages/neon/neon_files/lib/widgets/actions.dart @@ -119,13 +119,12 @@ class FileActions extends StatelessWidget { @override Widget build(final BuildContext context) => PopupMenuButton( itemBuilder: (final context) => [ - if (!details.isDirectory && NeonPlatform.instance.canUseSharing) ...[ + if (!details.isDirectory && NeonPlatform.instance.canUseSharing) PopupMenuItem( value: FilesFileAction.share, child: Text(FilesLocalizations.of(context).actionShare), ), - ], - if (details.isFavorite != null) ...[ + if (details.isFavorite != null) PopupMenuItem( value: FilesFileAction.toggleFavorite, child: Text( @@ -134,7 +133,6 @@ class FileActions extends StatelessWidget { : FilesLocalizations.of(context).addToFavorites, ), ), - ], PopupMenuItem( value: FilesFileAction.details, child: Text(FilesLocalizations.of(context).details), @@ -152,12 +150,11 @@ class FileActions extends StatelessWidget { child: Text(FilesLocalizations.of(context).actionCopy), ), // TODO: https://github.com/provokateurin/nextcloud-neon/issues/4 - if (!details.isDirectory) ...[ + if (!details.isDirectory) PopupMenuItem( value: FilesFileAction.sync, child: Text(FilesLocalizations.of(context).actionSync), ), - ], PopupMenuItem( value: FilesFileAction.delete, child: Text(FilesLocalizations.of(context).actionDelete), diff --git a/packages/neon/neon_files/lib/widgets/file_list_tile.dart b/packages/neon/neon_files/lib/widgets/file_list_tile.dart index 85426f9f..0e1a0646 100644 --- a/packages/neon/neon_files/lib/widgets/file_list_tile.dart +++ b/packages/neon/neon_files/lib/widgets/file_list_tile.dart @@ -56,17 +56,16 @@ class FileListTile extends StatelessWidget { RelativeTime( date: details.lastModified!, ), - if (details.size != null && details.size! > 0) ...[ - const SizedBox( - width: 10, + if (details.size != null && details.size! > 0) + Padding( + padding: const EdgeInsets.only(left: 10), + child: Text( + filesize(details.size, 1), + style: DefaultTextStyle.of(context).style.copyWith( + color: Colors.grey, + ), + ), ), - Text( - filesize(details.size, 1), - style: DefaultTextStyle.of(context).style.copyWith( - color: Colors.grey, - ), - ), - ], ], ), leading: _FileIcon(