loading state and error handling refactor
This commit is contained in:
@@ -2,7 +2,6 @@ import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:loader_overlay/loader_overlay.dart';
|
||||
import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart';
|
||||
|
||||
import '../../../api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart';
|
||||
@@ -12,6 +11,7 @@ import '../../../state/app/infrastructure/utilityWidgets/bloc_module.dart';
|
||||
import '../../../state/app/modules/files/bloc/files_bloc.dart';
|
||||
import '../../../state/app/modules/files/bloc/files_state.dart';
|
||||
import '../../../state/app/modules/settings/bloc/settings_cubit.dart';
|
||||
import '../../../widget/async_action_button.dart';
|
||||
import '../../../widget/file_pick.dart';
|
||||
import '../../../widget/placeholder_view.dart';
|
||||
import 'widgets/file_element.dart';
|
||||
@@ -175,12 +175,10 @@ class _FilesViewState extends State<_FilesView> {
|
||||
foldersToTop: context.watch<SettingsCubit>().val().fileSettings.sortFoldersToTop,
|
||||
reversed: currentSortDirection,
|
||||
);
|
||||
return LoaderOverlay(
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: files.length,
|
||||
itemBuilder: (context, index) => FileElement(files[index], widget.path, bloc.refresh),
|
||||
),
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: files.length,
|
||||
itemBuilder: (context, index) => FileElement(files[index], widget.path, bloc.refresh),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -233,15 +231,17 @@ class _FilesViewState extends State<_FilesView> {
|
||||
content: TextField(
|
||||
controller: inputController,
|
||||
decoration: const InputDecoration(labelText: 'Name'),
|
||||
autofocus: true,
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.of(dialogCtx).pop(), child: const Text('Abbrechen')),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
bloc.createFolder(inputController.text);
|
||||
Navigator.of(dialogCtx).pop();
|
||||
AsyncDialogAction(
|
||||
confirmLabel: 'Ordner erstellen',
|
||||
onConfirm: () async {
|
||||
if (inputController.text.trim().isEmpty) {
|
||||
throw Exception('Bitte einen Namen eingeben.');
|
||||
}
|
||||
await bloc.createFolder(inputController.text.trim());
|
||||
},
|
||||
child: const Text('Ordner erstellen'),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -254,7 +254,7 @@ class _FilesUploadDialogState extends State<FilesUploadDialog> {
|
||||
border: const UnderlineInputBorder(),
|
||||
label: Text('Datei ${index+1}'),
|
||||
errorText: currentFile.isConflicting ? 'existiert bereits' : null,
|
||||
errorStyle: const TextStyle(color: Colors.red),
|
||||
errorStyle: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
onChanged: (input) {
|
||||
currentFile.fileName = input;
|
||||
|
||||
@@ -159,11 +159,12 @@ class _FileElementState extends State<FileElement> {
|
||||
showDialog(context: context, builder: (context) => ConfirmDialog(
|
||||
title: 'Element löschen?',
|
||||
content: 'Das Element wird unwiederruflich gelöscht.',
|
||||
onConfirm: () {
|
||||
WebdavApi.webdav
|
||||
.then((value) => value.delete(PathUri.parse(widget.file.path)))
|
||||
.then((value) => widget.refetch());
|
||||
}
|
||||
confirmButton: 'Löschen',
|
||||
onConfirmAsync: () async {
|
||||
final webdav = await WebdavApi.webdav;
|
||||
await webdav.delete(PathUri.parse(widget.file.path));
|
||||
widget.refetch();
|
||||
},
|
||||
));
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user