💄 File list loading indicator

This commit is contained in:
2025-11-17 23:10:13 +08:00
parent 256024fb46
commit b233f9a410

View File

@@ -62,6 +62,14 @@ class FileListView extends HookConsumerWidget {
if (usage == null) return const SizedBox.shrink(); if (usage == null) return const SizedBox.shrink();
final isRefreshing = ref.watch(
mode.value == FileListMode.normal
? cloudFileListNotifierProvider.select((value) => value.isLoading)
: unindexedFileListNotifierProvider.select(
(value) => value.isLoading,
),
);
final bodyWidget = switch (mode.value) { final bodyWidget = switch (mode.value) {
FileListMode.unindexed => PagingHelperSliverView( FileListMode.unindexed => PagingHelperSliverView(
provider: unindexedFileListNotifierProvider, provider: unindexedFileListNotifierProvider,
@@ -141,7 +149,10 @@ class FileListView extends HookConsumerWidget {
child: DropdownButton2<SnFilePool>( child: DropdownButton2<SnFilePool>(
value: selectedPool.value, value: selectedPool.value,
items: unindexedItems, items: unindexedItems,
onChanged: (value) { onChanged:
isRefreshing
? null
: (value) {
selectedPool.value = value; selectedPool.value = value;
unindexedNotifier.setPool(value?.id); unindexedNotifier.setPool(value?.id);
}, },
@@ -284,9 +295,7 @@ class FileListView extends HookConsumerWidget {
child: Column( child: Column(
children: [ children: [
const Gap(8), const Gap(8),
SizedBox( Card(
height: 64,
child: Card(
child: Padding( child: Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Row( child: Row(
@@ -299,7 +308,10 @@ class FileListView extends HookConsumerWidget {
? Symbols.arrow_back ? Symbols.arrow_back
: Symbols.folder, : Symbols.folder,
), ),
onPressed: () { onPressed:
isRefreshing
? null
: () {
if (mode.value == FileListMode.unindexed) { if (mode.value == FileListMode.unindexed) {
mode.value = FileListMode.normal; mode.value = FileListMode.normal;
currentPath.value = '/'; currentPath.value = '/';
@@ -324,7 +336,12 @@ class FileListView extends HookConsumerWidget {
), ),
), ),
const Gap(8), const Gap(8),
Expanded(child: pathContent), Expanded(
child: AbsorbPointer(
absorbing: isRefreshing,
child: pathContent,
),
),
IconButton( IconButton(
icon: Icon( icon: Icon(
viewMode.value == FileListViewMode.list viewMode.value == FileListViewMode.list
@@ -350,10 +367,8 @@ class FileListView extends HookConsumerWidget {
IconButton( IconButton(
icon: const Icon(Symbols.create_new_folder), icon: const Icon(Symbols.create_new_folder),
onPressed: onPressed:
() => onShowCreateDirectory( () =>
ref.context, onShowCreateDirectory(ref.context, currentPath),
currentPath,
),
tooltip: 'Create Directory', tooltip: 'Create Directory',
visualDensity: const VisualDensity( visualDensity: const VisualDensity(
horizontal: -4, horizontal: -4,
@@ -393,7 +408,10 @@ class FileListView extends HookConsumerWidget {
), ),
), ),
).padding(horizontal: 8), ).padding(horizontal: 8),
), if (isRefreshing)
const LinearProgressIndicator(
minHeight: 4,
).padding(horizontal: 16, top: 6, bottom: 4),
const Gap(8), const Gap(8),
if (mode.value == FileListMode.normal && currentPath.value == '/') if (mode.value == FileListMode.normal && currentPath.value == '/')
_buildUnindexedFilesEntry(ref).padding(bottom: 12), _buildUnindexedFilesEntry(ref).padding(bottom: 12),