Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
53 lines
1.8 KiB
Dart
53 lines
1.8 KiB
Dart
import 'package:cutdex/l10n/l10n.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:cutdex_ui/theme.dart';
|
|
|
|
import '../../integrations/runtime/processing_resource_repository.dart';
|
|
import '../../workspace/background_task_registry.dart';
|
|
import '../../workspace/background_task_state.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});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final registry = ref.watch(backgroundTaskRegistryProvider);
|
|
final resources = ref
|
|
.watch(processingResourceRepositoryProvider)
|
|
.asData
|
|
?.value;
|
|
final tasks = ref.watch(backgroundTasksProvider(registry: registry));
|
|
final downloads = resources == null
|
|
? null
|
|
: ref.watch(processingResourcesProvider(resources));
|
|
bool hasRunningTasks() =>
|
|
tasks.runningCount > 0 ||
|
|
downloads?.subtitleDownloading == true ||
|
|
(downloads?.installs.any(
|
|
(install) => install.state == ProcessingResourceState.downloading,
|
|
) ??
|
|
false);
|
|
Widget button(VoidCallback toggle) => IconButton(
|
|
key: const ValueKey('background-tasks-button'),
|
|
tooltip: context.l10n.backgroundTasks,
|
|
onPressed: toggle,
|
|
icon: Badge(
|
|
isLabelVisible: hasRunningTasks(),
|
|
child: const Icon(Icons.task_alt_outlined, size: AppIconSize.header),
|
|
),
|
|
);
|
|
return AppPopover(
|
|
width: 384,
|
|
builder: (_, toggle) => button(toggle),
|
|
child: BackgroundTasksContent(registry: registry, repository: resources),
|
|
);
|
|
}
|
|
}
|