|
|
@ -1,7 +1,9 @@ |
|
|
|
import 'package:filesize/filesize.dart'; |
|
|
|
import 'package:filesize/filesize.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; |
|
|
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; |
|
|
|
|
|
|
|
import 'package:neon/utils.dart'; |
|
|
|
import 'package:neon/widgets.dart'; |
|
|
|
import 'package:neon/widgets.dart'; |
|
|
|
|
|
|
|
import 'package:neon_files/l10n/localizations.dart'; |
|
|
|
import 'package:neon_files/neon_files.dart'; |
|
|
|
import 'package:neon_files/neon_files.dart'; |
|
|
|
import 'package:neon_files/widgets/actions.dart'; |
|
|
|
import 'package:neon_files/widgets/actions.dart'; |
|
|
|
|
|
|
|
|
|
|
@ -10,66 +12,72 @@ class FileListTile extends StatelessWidget { |
|
|
|
required this.bloc, |
|
|
|
required this.bloc, |
|
|
|
required this.browserBloc, |
|
|
|
required this.browserBloc, |
|
|
|
required this.details, |
|
|
|
required this.details, |
|
|
|
this.enableFileActions = true, |
|
|
|
this.mode = FilesBrowserMode.browser, |
|
|
|
this.onPickFile, |
|
|
|
|
|
|
|
super.key, |
|
|
|
super.key, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
final FilesBloc bloc; |
|
|
|
final FilesBloc bloc; |
|
|
|
final FilesBrowserBloc browserBloc; |
|
|
|
final FilesBrowserBloc browserBloc; |
|
|
|
final FileDetails details; |
|
|
|
final FileDetails details; |
|
|
|
final bool enableFileActions; |
|
|
|
final FilesBrowserMode mode; |
|
|
|
final Function(FileDetails)? onPickFile; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
Future<void> _onTap(final BuildContext context, final FileDetails details) async { |
|
|
|
Widget build(final BuildContext context) { |
|
|
|
if (details.isDirectory) { |
|
|
|
// When the ETag is null it means we are uploading this file right now |
|
|
|
browserBloc.setPath(details.path); |
|
|
|
final onTap = details.isDirectory || details.etag != null |
|
|
|
} else if (mode == FilesBrowserMode.browser) { |
|
|
|
? () { |
|
|
|
final sizeWarning = bloc.options.downloadSizeWarning.value; |
|
|
|
if (details.isDirectory) { |
|
|
|
if (sizeWarning != null && details.size != null && details.size! > sizeWarning) { |
|
|
|
browserBloc.setPath(details.path); |
|
|
|
if (!(await showConfirmationDialog( |
|
|
|
} else { |
|
|
|
context, |
|
|
|
onPickFile?.call(details); |
|
|
|
AppLocalizations.of(context).downloadConfirmSizeWarning( |
|
|
|
} |
|
|
|
filesize(sizeWarning), |
|
|
|
} |
|
|
|
filesize(details.size), |
|
|
|
: null; |
|
|
|
), |
|
|
|
|
|
|
|
))) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
bloc.openFile(details.path, details.etag!, details.mimeType); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ListTile( |
|
|
|
@override |
|
|
|
onTap: onTap, |
|
|
|
Widget build(final BuildContext context) => ListTile( |
|
|
|
title: Text( |
|
|
|
// When the ETag is null it means we are uploading this file right now |
|
|
|
details.name, |
|
|
|
onTap: details.isDirectory || details.etag != null ? () async => _onTap(context, details) : null, |
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
title: Text( |
|
|
|
), |
|
|
|
details.name, |
|
|
|
subtitle: Row( |
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
children: [ |
|
|
|
), |
|
|
|
if (details.lastModified != null) |
|
|
|
subtitle: Row( |
|
|
|
RelativeTime( |
|
|
|
children: [ |
|
|
|
date: details.lastModified!, |
|
|
|
if (details.lastModified != null) |
|
|
|
), |
|
|
|
RelativeTime( |
|
|
|
if (details.size != null && details.size! > 0) ...[ |
|
|
|
date: details.lastModified!, |
|
|
|
const SizedBox( |
|
|
|
), |
|
|
|
width: 10, |
|
|
|
if (details.size != null && details.size! > 0) ...[ |
|
|
|
), |
|
|
|
const SizedBox( |
|
|
|
Text( |
|
|
|
width: 10, |
|
|
|
filesize(details.size, 1), |
|
|
|
), |
|
|
|
style: DefaultTextStyle.of(context).style.copyWith( |
|
|
|
Text( |
|
|
|
color: Colors.grey, |
|
|
|
filesize(details.size, 1), |
|
|
|
), |
|
|
|
style: DefaultTextStyle.of(context).style.copyWith( |
|
|
|
), |
|
|
|
color: Colors.grey, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
leading: _FileIcon( |
|
|
|
leading: _FileIcon( |
|
|
|
details: details, |
|
|
|
details: details, |
|
|
|
bloc: bloc, |
|
|
|
bloc: bloc, |
|
|
|
), |
|
|
|
), |
|
|
|
trailing: !details.hasTask && mode != FilesBrowserMode.noActions |
|
|
|
trailing: !details.hasTask && enableFileActions |
|
|
|
? FileActions(details: details) |
|
|
|
? FileActions(details: details) |
|
|
|
: const SizedBox.square( |
|
|
|
: const SizedBox.square( |
|
|
|
dimension: 48, |
|
|
|
dimension: 48, |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class _FileIcon extends StatelessWidget { |
|
|
|
class _FileIcon extends StatelessWidget { |
|
|
|