dart format

This commit is contained in:
2026-05-08 20:12:40 +02:00
parent 9e139b5704
commit 3b8da1d3d6
295 changed files with 6404 additions and 4161 deletions
+34 -16
View File
@@ -25,7 +25,8 @@ class Files extends StatelessWidget {
Files({List<String>? path, super.key}) : path = path ?? [];
@override
Widget build(BuildContext context) => BlocModule<FilesBloc, LoadableState<FilesState>>(
Widget build(BuildContext context) =>
BlocModule<FilesBloc, LoadableState<FilesState>>(
create: (_) => FilesBloc(initialPath: path),
child: (context, _, _) => _FilesView(path: path),
);
@@ -51,7 +52,8 @@ class _FilesViewState extends State<_FilesView> {
// Relative folder path matching the WebDAV format used by `CacheableFile.path`
// (no leading slash; trailing slash for non-root). Empty string means root.
String get _currentFolderPath => widget.path.isEmpty ? '' : '${widget.path.join('/')}/';
String get _currentFolderPath =>
widget.path.isEmpty ? '' : '${widget.path.join('/')}/';
@override
void initState() {
@@ -59,7 +61,9 @@ class _FilesViewState extends State<_FilesView> {
settings = context.read<SettingsCubit>();
currentSort = settings.val().fileSettings.sortBy;
currentSortDirection = settings.val().fileSettings.ascending;
_invalidationSub = CacheInvalidationBus.listFilesStream.listen(_onInvalidation);
_invalidationSub = CacheInvalidationBus.listFilesStream.listen(
_onInvalidation,
);
}
void _onInvalidation(String invalidatedPath) {
@@ -77,15 +81,17 @@ class _FilesViewState extends State<_FilesView> {
Future<void> _mediaUpload(List<String>? paths) async {
if (paths == null) return;
final bloc = context.read<FilesBloc>();
unawaited(pushScreen(
context,
withNavBar: false,
screen: FilesUploadDialog(
filePaths: paths,
remotePath: widget.path.join('/'),
onUploadFinished: (_) => bloc.refresh(),
unawaited(
pushScreen(
context,
withNavBar: false,
screen: FilesUploadDialog(
filePaths: paths,
remotePath: widget.path.join('/'),
onUploadFinished: (_) => bloc.refresh(),
),
),
));
);
}
@override
@@ -116,29 +122,41 @@ class _FilesViewState extends State<_FilesView> {
floatingActionButton: FloatingActionButton(
heroTag: 'uploadFile',
backgroundColor: Theme.of(context).primaryColor,
onPressed: () => showAddFileSheet(context, bloc: bloc, onPickedFiles: _mediaUpload),
onPressed: () =>
showAddFileSheet(context, bloc: bloc, onPickedFiles: _mediaUpload),
child: const Icon(Icons.add),
),
body: Column(
children: [
ClipboardBanner(currentFolder: _currentFolderPath, onPasteDone: bloc.refresh),
ClipboardBanner(
currentFolder: _currentFolderPath,
onPasteDone: bloc.refresh,
),
Expanded(
child: LoadableStateConsumer<FilesBloc, FilesState>(
isReady: (state) => state.listing != null,
child: (state, _) {
final listing = state.listing!;
if (listing.files.isEmpty) {
return const PlaceholderView(icon: Icons.folder_off_rounded, text: 'Der Ordner ist leer');
return const PlaceholderView(
icon: Icons.folder_off_rounded,
text: 'Der Ordner ist leer',
);
}
final files = listing.sortBy(
sortOption: currentSort,
foldersToTop: context.watch<SettingsCubit>().val().fileSettings.sortFoldersToTop,
foldersToTop: context
.watch<SettingsCubit>()
.val()
.fileSettings
.sortFoldersToTop,
reversed: currentSortDirection,
);
return ListView.builder(
padding: EdgeInsets.zero,
itemCount: files.length,
itemBuilder: (context, index) => FileElement(files[index], widget.path, bloc.refresh),
itemBuilder: (context, index) =>
FileElement(files[index], widget.path, bloc.refresh),
);
},
),