Files
cutdex/lib/features/editor/background_tasks_button.dart
lingjhf abc1868550
Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s
feat(workspace): 桌面工作区、主题与交互更新,发布 0.1.2
2026-10-08 18:17:12 +00:00

70 lines
2.2 KiB
Dart

import 'package:cutdex/l10n/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import '../../integrations/runtime/processing_resource_repository.dart';
import '../../workspace/background_task_registry.dart';
import '../../shared/widgets/listenable_selector.dart';
import '../../integrations/runtime/processing_resource_state.dart';
import 'package:cutdex_ui/widgets.dart';
import '../media/background_tasks_dialog.dart';
class BackgroundTasksButton extends ConsumerWidget {
const BackgroundTasksButton({
super.key,
this.iconSize = AppIconSize.header,
this.alignment = AlignmentDirectional.bottomStart,
});
final double iconSize;
final AlignmentGeometry alignment;
@override
Widget build(BuildContext context, WidgetRef ref) {
final registry = ref.watch(backgroundTaskRegistryProvider);
final resources = ref
.watch(processingResourceRepositoryProvider)
.asData
?.value;
final downloads = resources == null
? null
: ref.watch(
processingResourcesProvider(resources).select(
(downloads) =>
downloads.subtitleDownloading ||
downloads.installs.any(
(install) =>
install.state == ProcessingResourceState.downloading,
),
),
);
Widget button(VoidCallback toggle, bool running) => IconButton(
key: const ValueKey('background-tasks-button'),
tooltip: context.l10n.backgroundTasks,
onPressed: toggle,
icon: Badge(
isLabelVisible: running || downloads == true,
child: Icon(AppIcons.success, size: iconSize),
),
);
return ListenableSelector<bool>(
listenable: registry,
select: () => registry.runningCount > 0,
builder: (context, running) => AppPopover(
width: 384,
alignment: alignment,
builder: (_, toggle) => button(toggle, running),
child: BackgroundTasksContent(
registry: registry,
repository: resources,
),
),
);
}
}