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.
This commit is contained in:
lingjhf committed 2026-10-05 23:36:23 +08:00
commit 27e77fff39
718 files changed
+183958

No files matched your search

@@ -0,0 +1,52 @@
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),
);
}
}
+359
View File
@@ -0,0 +1,359 @@
import 'dart:async';
import 'package:cutdex/l10n/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../integrations/platform/device_experience.dart';
import 'package:cutdex_native/cutdex_native.dart';
import '../../persistence/app_settings_repositories.dart';
import '../../shared/layout/workspace_layout_metrics.dart';
import 'package:cutdex_ui/theme.dart';
import '../../workspace/timeline_provider.dart';
import '../../workspace/view_settings.dart';
import '../media/media_browser_page.dart';
import '../media/media_panel.dart';
import '../preview/preview_panel.dart';
import '../properties/properties_editor_page.dart';
import '../properties/properties_panel.dart';
import '../timeline/timeline_panel.dart';
import 'editor_presentation_controller.dart';
import 'layouts/bounded_editor_layout.dart';
import 'layouts/expanded_editor_layout.dart';
/// The single editing surface shown beside the project/timeline navigation.
class EditorWorkspace extends ConsumerStatefulWidget {
const EditorWorkspace({
super.key,
required this.projectId,
required this.timelineId,
required this.projectName,
required this.integratedTitlebar,
required this.headerLeading,
this.showProjectName = true,
this.experience = DeviceExperience.desktop,
});
final String projectId;
final String timelineId;
final String projectName;
final bool integratedTitlebar;
final Widget headerLeading;
final bool showProjectName;
final DeviceExperience experience;
@override
ConsumerState<EditorWorkspace> createState() => _EditorWorkspaceState();
}
class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
final _previewKey = GlobalKey();
EditorPresentationController get _presentation =>
ref.read(editorPresentationProvider(widget.projectId));
ProjectViewSettingsData get _viewSettings =>
ref.read(projectViewSettingsProvider(widget.projectId)).value ??
const ProjectViewSettingsData();
ProjectViewSettings get _viewController =>
ref.read(projectViewSettingsProvider(widget.projectId).notifier);
bool get _propertiesOpen => _viewSettings.propertiesOpen;
double? get _timelineHeight => _viewSettings.timelineHeight;
void _saveViewSettings() {
if (!ref.read(projectViewSettingsProvider(widget.projectId)).hasValue) {
return;
}
unawaited(_viewController.save());
}
@override
Widget build(BuildContext context) {
final viewSettings = ref.watch(
projectViewSettingsProvider(widget.projectId),
);
final preview = KeyedSubtree(
key: _previewKey,
child: EditorPreviewPanel(
projectId: widget.projectId,
timelineId: widget.timelineId,
),
);
final timeline = EditorTimelinePanel(
projectId: widget.projectId,
timelineId: widget.timelineId,
);
final properties = EditorPropertiesPanel(
projectId: widget.projectId,
timelineId: widget.timelineId,
);
final media = MediaPanel(projectId: widget.projectId);
return ListenableBuilder(
listenable: ref.watch(editorPresentationProvider(widget.projectId)),
builder: (context, _) => LayoutBuilder(
builder: (context, constraints) {
final desktop = widget.experience == DeviceExperience.desktop;
final sideWidth =
(_presentation.mediaOpen
? WorkspaceLayoutMetrics.mediaPanelWidth + 1
: 0) +
(_propertiesOpen
? WorkspaceLayoutMetrics.propertiesPanelWidth + 1
: 0);
final dockPanels =
desktop &&
constraints.maxWidth >=
WorkspaceLayoutMetrics.previewMinimumWidth + sideWidth;
final desktopTool = sideWidth == 0
? null
: _presentation.desktopTool(propertiesOpen: _propertiesOpen);
final headerHeight = desktop ? AppControlSize.panelHeader : 48.0;
final mediaOpen = desktop
? dockPanels
? _presentation.mediaOpen
: desktopTool == EditorTool.media
: _presentation.activeTool == EditorTool.media;
final propertiesOpen = desktop
? dockPanels
? _propertiesOpen
: desktopTool == EditorTool.properties
: _presentation.activeTool == EditorTool.properties;
Widget dockedEditing({required bool showTools}) =>
ExpandedEditorLayout(
preview: preview,
properties: properties,
media: media,
showMedia: showTools && _presentation.mediaOpen,
showProperties: showTools && _propertiesOpen,
timelineHeight: _timelineHeight,
onTimelineHeightChanged: (height) {
if (viewSettings.hasValue) {
_viewController.setTimelineHeight(height);
}
},
onTimelineHeightChangeEnd: _saveViewSettings,
timeline: timeline,
);
return Stack(
fit: StackFit.expand,
children: [
Column(
children: [
Material(
color: Theme.of(context).colorScheme.surface,
child: SizedBox(
key: const Key('editor-content-header'),
height: headerHeight,
child: WindowHeaderPadding(
child: Row(
children: [
widget.headerLeading,
Expanded(
child: widget.showProjectName
? Row(
children: [
Flexible(
fit: FlexFit.loose,
child: Text(
widget.projectName,
key: const Key(
'workspace-project-title',
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.titleSmall,
),
),
Flexible(
fit: FlexFit.loose,
child: _TimelineSaveStatus(
projectId: widget.projectId,
timelineId: widget.timelineId,
),
),
],
)
: const SizedBox.shrink(),
),
HeaderControlRegion(
child: SizedBox.square(
dimension: desktop
? AppControlSize.headerButton
: 48,
child: IconButton(
key: const Key('editor-media-button'),
tooltip: context.l10n.materials,
isSelected: mediaOpen,
onPressed: () {
if (desktop) {
if (!dockPanels &&
desktopTool != EditorTool.media &&
_presentation.mediaOpen) {
_presentation.preferDesktopTool(
EditorTool.media,
);
} else {
_presentation.toggleMedia();
}
} else {
_presentation.toggleTool(
EditorTool.media,
);
}
},
icon: const Icon(Icons.perm_media_outlined),
),
),
),
const SizedBox(width: AppSpacing.tiny),
HeaderControlRegion(
child: SizedBox.square(
dimension: desktop
? AppControlSize.headerButton
: 48,
child: IconButton(
key: const Key('editor-properties-button'),
tooltip: propertiesOpen
? context.l10n.collapseProperties
: context.l10n.expandProperties,
isSelected: propertiesOpen,
onPressed: !viewSettings.hasValue
? null
: () {
if (desktop) {
if (dockPanels ||
desktopTool ==
EditorTool.properties ||
!_propertiesOpen) {
_viewController.setPropertiesOpen(
!_propertiesOpen,
);
_saveViewSettings();
}
_presentation.preferDesktopTool(
EditorTool.properties,
);
} else {
_presentation.toggleTool(
EditorTool.properties,
);
}
},
icon: const Icon(
Icons.tune,
size: AppIconSize.header,
),
),
),
),
const SizedBox(width: AppSpacing.compact),
],
),
),
),
),
Expanded(
child: dockPanels
? dockedEditing(showTools: true)
: BoundedEditorLayout(
experience: widget.experience,
editing: desktop
? dockedEditing(showTools: false)
: TouchEditingLayout(
preview: preview,
timeline: timeline,
),
tool: desktop
? desktopTool
: _presentation.activeTool,
media: switch (widget.experience) {
DeviceExperience.desktop => media,
DeviceExperience.tablet => MediaBrowserDrawer(
projectId: widget.projectId,
),
DeviceExperience.phone => MediaBrowserPage(
projectId: widget.projectId,
),
},
properties: switch (widget.experience) {
DeviceExperience.desktop => properties,
DeviceExperience.tablet => PropertiesToolPanel(
projectId: widget.projectId,
timelineId: widget.timelineId,
),
DeviceExperience.phone => PropertiesEditorPage(
projectId: widget.projectId,
timelineId: widget.timelineId,
),
},
onCloseTool: () {
if (!desktop) {
_presentation.closeTool();
} else if (desktopTool == EditorTool.media) {
_presentation.toggleMedia();
} else {
_viewController.setPropertiesOpen(false);
_saveViewSettings();
}
},
),
),
],
),
Positioned(
key: const Key('editing-top-divider'),
top: headerHeight,
left: 0,
right: 0,
height: 1,
child: const Divider(height: 1),
),
],
);
},
),
);
}
}
class _TimelineSaveStatus extends ConsumerWidget {
const _TimelineSaveStatus({
required this.projectId,
required this.timelineId,
});
final String projectId;
final String timelineId;
@override
Widget build(BuildContext context, WidgetRef ref) {
final session = ref
.watch(editorTimelineProvider(projectId, timelineId))
.asData
?.value;
if (session == null) return const SizedBox.shrink();
return ListenableBuilder(
listenable: session,
builder: (context, _) => Padding(
padding: const EdgeInsets.only(left: AppSpacing.small),
child: Text(
session.error != null
? context.l10n.unsaved
: session.saving
? context.l10n.saving
: session.dirty
? context.l10n.pendingSave
: context.l10n.saved,
key: const Key('timeline-save-status'),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodySmall?.copyWith(fontSize: 10),
),
),
);
}
}
@@ -0,0 +1,48 @@
import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
enum EditorTool { media, properties }
final editorPresentationProvider =
Provider.family<EditorPresentationController, String>((ref, projectId) {
final controller = EditorPresentationController();
ref.onDispose(controller.dispose);
return controller;
});
/// Presentation choices survive shell changes without changing project data.
class EditorPresentationController extends ChangeNotifier {
bool _mediaOpen = false;
EditorTool? _activeTool;
EditorTool _preferredDesktopTool = EditorTool.properties;
bool get mediaOpen => _mediaOpen;
EditorTool? get activeTool => _activeTool;
EditorTool desktopTool({required bool propertiesOpen}) =>
_preferredDesktopTool == EditorTool.media && _mediaOpen
? EditorTool.media
: propertiesOpen
? EditorTool.properties
: EditorTool.media;
void preferDesktopTool(EditorTool tool) {
_preferredDesktopTool = tool;
notifyListeners();
}
void toggleMedia() {
_mediaOpen = !_mediaOpen;
if (_mediaOpen) _preferredDesktopTool = EditorTool.media;
notifyListeners();
}
void toggleTool(EditorTool tool) {
_activeTool = _activeTool == tool ? null : tool;
notifyListeners();
}
void closeTool() {
_activeTool = null;
notifyListeners();
}
}
@@ -0,0 +1,146 @@
import 'dart:math' as math;
import 'package:flutter/material.dart';
import '../../../integrations/platform/device_experience.dart';
import '../../../l10n/l10n.dart';
import 'package:cutdex_ui/theme.dart';
import '../editor_presentation_controller.dart';
/// Space changes the tool bounds; device experience determines its interactions.
class BoundedEditorLayout extends StatelessWidget {
const BoundedEditorLayout({
super.key,
required this.experience,
required this.editing,
required this.tool,
required this.media,
required this.properties,
required this.onCloseTool,
});
final DeviceExperience experience;
final Widget editing;
final EditorTool? tool;
final Widget media;
final Widget properties;
final VoidCallback onCloseTool;
@override
Widget build(BuildContext context) => LayoutBuilder(
builder: (context, constraints) {
final page = experience == DeviceExperience.phone;
final desktop = experience == DeviceExperience.desktop;
Widget toolSurface() => Column(
children: [
SizedBox(
height: desktop ? AppControlSize.panelHeader : 48,
child: Row(
children: [
SizedBox.square(
dimension: desktop ? AppControlSize.headerButton : 48,
child: IconButton(
key: const Key('editor-tool-close'),
tooltip: MaterialLocalizations.of(context)
.closeButtonTooltip,
onPressed: onCloseTool,
icon: Icon(page ? Icons.arrow_back : Icons.close),
),
),
Expanded(
child: Text(
tool == EditorTool.media
? context.l10n.materials
: context.l10n.expandProperties,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
),
const Divider(height: 1),
Expanded(child: tool == EditorTool.media ? media : properties),
],
);
return PopScope<Object?>(
canPop: desktop || tool == null,
onPopInvokedWithResult: (didPop, result) {
if (didPop || desktop || tool == null) return;
final scaffold = Scaffold.maybeOf(context);
if (scaffold?.isDrawerOpen ?? false) {
scaffold!.closeDrawer();
} else {
onCloseTool();
}
},
child: Stack(
key: Key('${experience.name}-editor-tools'),
fit: StackFit.expand,
children: [
ExcludeFocus(
excluding: page && tool != null,
child: IgnorePointer(
ignoring: page && tool != null,
child: TickerMode(
enabled: !page || tool == null,
child: editing,
),
),
),
if (tool != null)
Positioned(
top: 0,
bottom: 0,
right: 0,
width: page
? constraints.maxWidth
: math.min(320, constraints.maxWidth),
child: Material(
key: const Key('editor-tool-surface'),
elevation: page ? 0 : 8,
color: Theme.of(context).colorScheme.surface,
child: toolSurface(),
),
),
],
),
);
},
);
}
/// A shared preview/timeline arrangement for touch experiences.
class TouchEditingLayout extends StatelessWidget {
const TouchEditingLayout({
super.key,
required this.preview,
required this.timeline,
});
final Widget preview;
final Widget timeline;
@override
Widget build(BuildContext context) => LayoutBuilder(
builder: (context, constraints) {
final short = constraints.maxHeight < 340 && constraints.maxWidth >= 600;
return short
? Row(
children: [
Expanded(child: preview),
const VerticalDivider(width: 1),
Expanded(child: timeline),
],
)
: Column(
children: [
Expanded(flex: 3, child: preview),
const Divider(height: 1),
Expanded(flex: 2, child: timeline),
],
);
},
);
}
@@ -0,0 +1,145 @@
import 'dart:math' as math;
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import '../../../shared/layout/workspace_layout_metrics.dart';
class ExpandedEditorLayout extends StatefulWidget {
const ExpandedEditorLayout({
super.key,
required this.preview,
required this.properties,
required this.media,
required this.showMedia,
required this.showProperties,
required this.timelineHeight,
required this.onTimelineHeightChanged,
required this.onTimelineHeightChangeEnd,
required this.timeline,
});
final Widget preview;
final Widget properties;
final Widget media;
final bool showMedia;
final bool showProperties;
final double? timelineHeight;
final ValueChanged<double> onTimelineHeightChanged;
final VoidCallback onTimelineHeightChangeEnd;
final Widget timeline;
@override
State<ExpandedEditorLayout> createState() => _ExpandedEditorLayoutState();
}
class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
double? _timelineDragStartY;
double _timelineDragStartHeight = 0;
@override
Widget build(BuildContext context) => LayoutBuilder(
builder: (context, constraints) {
final maximum = math.max(
0.0,
constraints.maxHeight - WorkspaceLayoutMetrics.timelineMinimumHeight,
);
final minimum = math.min(
WorkspaceLayoutMetrics.timelineMinimumHeight,
maximum,
);
final timelineHeight =
(widget.timelineHeight ??
constraints.maxHeight *
WorkspaceLayoutMetrics.timelineDefaultHeightFraction)
.clamp(minimum, maximum)
.toDouble();
final mediaWidth = widget.showMedia
? WorkspaceLayoutMetrics.mediaPanelWidth
: 0.0;
final propertiesWidth = widget.showProperties
? WorkspaceLayoutMetrics.propertiesPanelWidth
: 0.0;
return Stack(
fit: StackFit.expand,
children: [
Column(
children: [
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (widget.showMedia) ...[
SizedBox(
key: const Key('editor-media-region'),
width: mediaWidth,
child: widget.media,
),
const VerticalDivider(width: 1),
],
Expanded(child: widget.preview),
if (widget.showProperties) ...[
const VerticalDivider(width: 1),
SizedBox(
key: const Key('editor-properties-region'),
width: propertiesWidth,
child: widget.properties,
),
],
],
),
),
const SizedBox(height: 1),
SizedBox(height: timelineHeight, child: widget.timeline),
],
),
Positioned(
key: const Key('editor-timeline-divider'),
left: 0,
right: 0,
bottom: timelineHeight - 4,
height: 8,
child: MouseRegion(
cursor: SystemMouseCursors.resizeRow,
child: GestureDetector(
key: const Key('editor-timeline-resize'),
behavior: HitTestBehavior.opaque,
dragStartBehavior: DragStartBehavior.down,
onVerticalDragStart: (details) {
_timelineDragStartY = details.globalPosition.dy;
_timelineDragStartHeight = timelineHeight;
},
onVerticalDragUpdate: (details) {
final start = _timelineDragStartY;
if (start == null) return;
widget.onTimelineHeightChanged(
(_timelineDragStartHeight +
start -
details.globalPosition.dy)
.clamp(minimum, maximum)
.toDouble(),
);
},
onVerticalDragEnd: (_) {
_timelineDragStartY = null;
widget.onTimelineHeightChangeEnd();
},
onVerticalDragCancel: () {
_timelineDragStartY = null;
widget.onTimelineHeightChangeEnd();
},
child: const Center(
child: SizedBox(
height: 1,
width: double.infinity,
child: Divider(height: 1),
),
),
),
),
),
],
);
},
);
}