💄 Optimize task overlay
This commit is contained in:
@@ -1587,5 +1587,10 @@
|
|||||||
"fediversePostDescribe": "Post from the Fediverse Network",
|
"fediversePostDescribe": "Post from the Fediverse Network",
|
||||||
"settingsShowFediverseContent": "Show Fediverse Content",
|
"settingsShowFediverseContent": "Show Fediverse Content",
|
||||||
"universalSearch": "Universal Search",
|
"universalSearch": "Universal Search",
|
||||||
"universalSearchDescription": "Search content across the Solar Network and the fediverse network."
|
"universalSearchDescription": "Search content across the Solar Network and the fediverse network.",
|
||||||
|
"tasks": "Tasks",
|
||||||
|
"tasksCount": {
|
||||||
|
"one": "{} task",
|
||||||
|
"other": "{} tasks"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ class TaskOverlay extends HookConsumerWidget {
|
|||||||
|
|
||||||
final isDesktop = isWideScreen(context);
|
final isDesktop = isWideScreen(context);
|
||||||
|
|
||||||
// Auto-compact timer for mobile when expanded
|
// Auto-compact timer for mobile when not expanded
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
if (!isDesktop && !isCompactLocal.value) {
|
if (!isDesktop && !isCompactLocal.value && !isExpandedLocal.value) {
|
||||||
// Start timer to auto-compact after 5 seconds
|
// Start timer to auto-compact after 5 seconds
|
||||||
autoCompactTimer.value?.cancel();
|
autoCompactTimer.value?.cancel();
|
||||||
autoCompactTimer.value = Timer(const Duration(seconds: 5), () {
|
autoCompactTimer.value = Timer(const Duration(seconds: 5), () {
|
||||||
@@ -87,7 +87,7 @@ class TaskOverlay extends HookConsumerWidget {
|
|||||||
autoCompactTimer.value = null;
|
autoCompactTimer.value = null;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}, [isCompactLocal.value, isDesktop]);
|
}, [isCompactLocal.value, isExpandedLocal.value, isDesktop]);
|
||||||
final isVisible =
|
final isVisible =
|
||||||
(isVisibleOverride.value ?? activeTasks.isNotEmpty) &&
|
(isVisibleOverride.value ?? activeTasks.isNotEmpty) &&
|
||||||
!pendingHide.value;
|
!pendingHide.value;
|
||||||
@@ -438,11 +438,13 @@ class _TaskOverlayContent extends HookConsumerWidget {
|
|||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
// Clear completed tasks button
|
|
||||||
if (_hasCompletedTasks(activeTasks))
|
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
|
contentPadding: const EdgeInsets.only(
|
||||||
|
left: 18,
|
||||||
|
right: 16,
|
||||||
|
),
|
||||||
title: const Text(
|
title: const Text(
|
||||||
'clearCompleted',
|
'clearCompleted',
|
||||||
).tr(),
|
).tr(),
|
||||||
@@ -457,34 +459,21 @@ class _TaskOverlayContent extends HookConsumerWidget {
|
|||||||
taskNotifier.clearCompletedTasks();
|
taskNotifier.clearCompletedTasks();
|
||||||
onExpansionChanged?.call(false);
|
onExpansionChanged?.call(false);
|
||||||
},
|
},
|
||||||
|
trailing: IconButton(
|
||||||
tileColor: Theme.of(
|
tooltip: 'clearAll'.tr(),
|
||||||
context,
|
icon: Icon(
|
||||||
).colorScheme.surfaceContainerHighest,
|
Symbols.close,
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Clear all tasks button
|
|
||||||
if (activeTasks.any(
|
|
||||||
(task) =>
|
|
||||||
task.status !=
|
|
||||||
DriveTaskStatus.completed,
|
|
||||||
))
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: ListTile(
|
|
||||||
dense: true,
|
|
||||||
title: const Text('Clear All'),
|
|
||||||
leading: Icon(
|
|
||||||
Symbols.clear_all,
|
|
||||||
size: 18,
|
size: 18,
|
||||||
color: Theme.of(
|
color: Theme.of(
|
||||||
context,
|
context,
|
||||||
).colorScheme.error,
|
).colorScheme.error,
|
||||||
),
|
),
|
||||||
onTap: () {
|
padding: EdgeInsets.zero,
|
||||||
|
onPressed: () {
|
||||||
taskNotifier.clearAllTasks();
|
taskNotifier.clearAllTasks();
|
||||||
onExpansionChanged?.call(false);
|
onExpansionChanged?.call(false);
|
||||||
},
|
},
|
||||||
|
),
|
||||||
tileColor: Theme.of(
|
tileColor: Theme.of(
|
||||||
context,
|
context,
|
||||||
).colorScheme.surfaceContainerHighest,
|
).colorScheme.surfaceContainerHighest,
|
||||||
@@ -618,7 +607,7 @@ class _TaskOverlayContent extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _getOverallStatusText(List<DriveTask> tasks) {
|
String _getOverallStatusText(List<DriveTask> tasks) {
|
||||||
if (tasks.isEmpty) return '0 tasks';
|
if (tasks.isEmpty) return 'tasks'.plural(0);
|
||||||
|
|
||||||
final hasDownload = tasks.any((task) => task.type == 'FileDownload');
|
final hasDownload = tasks.any((task) => task.type == 'FileDownload');
|
||||||
final hasInProgress = tasks.any(
|
final hasInProgress = tasks.any(
|
||||||
@@ -656,20 +645,10 @@ class _TaskOverlayContent extends HookConsumerWidget {
|
|||||||
} else if (hasCompleted) {
|
} else if (hasCompleted) {
|
||||||
return '${tasks.length} ${'completed'.tr()}';
|
return '${tasks.length} ${'completed'.tr()}';
|
||||||
} else {
|
} else {
|
||||||
return '${tasks.length} ${'tasks'.tr()}';
|
return 'tasks'.plural(tasks.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _hasCompletedTasks(List<DriveTask> tasks) {
|
|
||||||
return tasks.any(
|
|
||||||
(task) =>
|
|
||||||
task.status == DriveTaskStatus.completed ||
|
|
||||||
task.status == DriveTaskStatus.failed ||
|
|
||||||
task.status == DriveTaskStatus.cancelled ||
|
|
||||||
task.status == DriveTaskStatus.expired,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
double _getCompactWidth(List<DriveTask> tasks) {
|
double _getCompactWidth(List<DriveTask> tasks) {
|
||||||
// Base width for icon and padding
|
// Base width for icon and padding
|
||||||
double width = 16 + 12 + 12; // icon size + padding + spacing
|
double width = 16 + 12 + 12; // icon size + padding + spacing
|
||||||
|
|||||||
Reference in New Issue
Block a user