Browse Source

Merge pull request #383 from provokateurin/fix/webdav-props-not-available

neon_files: Do not expect props to be available
pull/386/head
Kate 1 year ago committed by GitHub
parent
commit
52f72353f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      packages/neon/neon_files/lib/models/file_details.dart
  2. 7
      packages/neon/neon_files/lib/pages/details.dart
  3. 2
      packages/neon/neon_files/lib/pages/main.dart
  4. 12
      packages/neon/neon_files/lib/widgets/browser_view.dart

4
packages/neon/neon_files/lib/models/file_details.dart

@ -19,13 +19,13 @@ class FileDetails {
final bool isDirectory; final bool isDirectory;
final int size; final int? size;
final String? etag; final String? etag;
final String? mimeType; final String? mimeType;
final DateTime lastModified; final DateTime? lastModified;
final bool? hasPreview; final bool? hasPreview;

7
packages/neon/neon_files/lib/pages/details.dart

@ -46,10 +46,15 @@ class FilesDetailsPage extends StatelessWidget {
: AppLocalizations.of(context).detailsFileName: details.name, : AppLocalizations.of(context).detailsFileName: details.name,
AppLocalizations.of(context).detailsParentFolder: AppLocalizations.of(context).detailsParentFolder:
details.path.length == 1 ? '/' : details.path.sublist(0, details.path.length - 1).join('/'), details.path.length == 1 ? '/' : details.path.sublist(0, details.path.length - 1).join('/'),
if (details.size != null) ...{
details.isDirectory details.isDirectory
? AppLocalizations.of(context).detailsFolderSize ? AppLocalizations.of(context).detailsFolderSize
: AppLocalizations.of(context).detailsFileSize: filesize(details.size, 1), : AppLocalizations.of(context).detailsFileSize: filesize(details.size, 1),
AppLocalizations.of(context).detailsLastModified: details.lastModified.toLocal().toIso8601String(), },
if (details.lastModified != null) ...{
AppLocalizations.of(context).detailsLastModified:
details.lastModified!.toLocal().toIso8601String(),
},
if (details.isFavorite != null) ...{ if (details.isFavorite != null) ...{
AppLocalizations.of(context).detailsIsFavorite: details.isFavorite! AppLocalizations.of(context).detailsIsFavorite: details.isFavorite!
? AppLocalizations.of(context).actionYes ? AppLocalizations.of(context).actionYes

2
packages/neon/neon_files/lib/pages/main.dart

@ -29,7 +29,7 @@ class _FilesMainPageState extends State<FilesMainPage> {
filesBloc: bloc, filesBloc: bloc,
onPickFile: (final details) async { onPickFile: (final details) async {
final sizeWarning = bloc.options.downloadSizeWarning.value; final sizeWarning = bloc.options.downloadSizeWarning.value;
if (sizeWarning != null && details.size > sizeWarning) { if (sizeWarning != null && details.size != null && details.size! > sizeWarning) {
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
if (!(await showConfirmationDialog( if (!(await showConfirmationDialog(
context, context,

12
packages/neon/neon_files/lib/widgets/browser_view.dart

@ -116,12 +116,12 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
isDirectory: matchingUploadTasks.isEmpty && file.isDirectory, isDirectory: matchingUploadTasks.isEmpty && file.isDirectory,
size: matchingUploadTasks.isNotEmpty size: matchingUploadTasks.isNotEmpty
? matchingUploadTasks.first.size ? matchingUploadTasks.first.size
: file.size!, : file.size,
etag: matchingUploadTasks.isNotEmpty ? null : file.etag, etag: matchingUploadTasks.isNotEmpty ? null : file.etag,
mimeType: matchingUploadTasks.isNotEmpty ? null : file.mimeType, mimeType: matchingUploadTasks.isNotEmpty ? null : file.mimeType,
lastModified: matchingUploadTasks.isNotEmpty lastModified: matchingUploadTasks.isNotEmpty
? matchingUploadTasks.first.lastModified ? matchingUploadTasks.first.lastModified
: file.lastModified!, : file.lastModified,
hasPreview: matchingUploadTasks.isNotEmpty ? null : file.hasPreview, hasPreview: matchingUploadTasks.isNotEmpty ? null : file.hasPreview,
isFavorite: matchingUploadTasks.isNotEmpty ? null : file.favorite, isFavorite: matchingUploadTasks.isNotEmpty ? null : file.favorite,
), ),
@ -235,10 +235,12 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
), ),
subtitle: Row( subtitle: Row(
children: [ children: [
if (details.lastModified != null) ...[
RelativeTime( RelativeTime(
date: details.lastModified, date: details.lastModified!,
), ),
if (details.size > 0) ...[ ],
if (details.size != null && details.size! > 0) ...[
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
@ -396,7 +398,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
break; break;
case FilesFileAction.sync: case FilesFileAction.sync:
final sizeWarning = widget.bloc.options.downloadSizeWarning.value; final sizeWarning = widget.bloc.options.downloadSizeWarning.value;
if (sizeWarning != null && details.size > sizeWarning) { if (sizeWarning != null && details.size != null && details.size! > sizeWarning) {
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
if (!(await showConfirmationDialog( if (!(await showConfirmationDialog(
context, context,

Loading…
Cancel
Save