Files
cutdex/lib/integrations/application_command_dependencies.dart
lingjhf 27e77fff39 feat: initial Cutdex application
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.
2026-10-05 23:36:23 +08:00

71 lines
2.3 KiB
Dart

import 'dart:ui';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../features/settings/language_settings.dart';
import '../l10n/app_localizations.dart';
import '../workspace/project_state.dart';
import '../workspace/projects.dart';
import '../workspace/preview_target.dart';
import '../workspace/timeline_provider.dart';
import '../workspace/timeline_session.dart';
abstract interface class ApplicationCommandDependencies {
Future<ProjectState> projectState();
Future<bool> createProject(String name);
Future<bool> openProject(String path, {String? expectedId});
Future<bool> createTimeline(String name);
Future<bool> openTimeline(String projectId, String timelineId);
Future<EditorTimelineSession> timeline(String projectId, String timelineId);
PreviewTarget preview(String projectId, String timelineId);
}
/// Riverpod is confined to the composition adapter, not the command host.
class RiverpodApplicationCommandDependencies
implements ApplicationCommandDependencies {
const RiverpodApplicationCommandDependencies(this._ref);
final Ref _ref;
Projects get _projects => _ref.read(projectsProvider.notifier);
@override
Future<ProjectState> projectState() => _ref.read(projectsProvider.future);
@override
Future<bool> createProject(String name) {
final configured = _ref.read(languageSettingsProvider).asData?.value;
final locale =
configured?.locale ??
resolveAppLocale(
PlatformDispatcher.instance.locales,
AppLocalizations.supportedLocales,
);
return _projects.createProject(
name,
initialTimelineName: lookupAppLocalizations(locale)
.defaultTimelineName(1),
);
}
@override
Future<bool> openProject(String path, {String? expectedId}) =>
_projects.open(path, expectedId: expectedId);
@override
Future<bool> createTimeline(String name) =>
_projects.createTimeline(name: name);
@override
Future<bool> openTimeline(String projectId, String timelineId) =>
_projects.openTimeline(projectId, timelineId);
@override
Future<EditorTimelineSession> timeline(String projectId, String timelineId) =>
_ref.read(editorTimelineProvider(projectId, timelineId).future);
@override
PreviewTarget preview(String projectId, String timelineId) =>
_ref.read(previewTargetProvider(projectId, timelineId));
}