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:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,151 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:cutdex_sdk/project.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../l10n/app_localizations.dart';
|
||||
import 'composer_document.dart';
|
||||
|
||||
part 'composer_suggestions.freezed.dart';
|
||||
|
||||
enum ComposerOptionGroup { media, timeline }
|
||||
|
||||
@freezed
|
||||
sealed class ComposerOption with _$ComposerOption {
|
||||
const factory ComposerOption.reference({
|
||||
required String trigger,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
required IconData icon,
|
||||
ComposerOptionGroup? group,
|
||||
required ComposerReference reference,
|
||||
}) = ComposerReferenceOption;
|
||||
const factory ComposerOption.text({
|
||||
required String trigger,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
required IconData icon,
|
||||
ComposerOptionGroup? group,
|
||||
required String text,
|
||||
}) = ComposerTextOption;
|
||||
const factory ComposerOption.invoke({
|
||||
required String trigger,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
required IconData icon,
|
||||
ComposerOptionGroup? group,
|
||||
required VoidCallback onInvoke,
|
||||
}) = ComposerInvokeOption;
|
||||
const factory ComposerOption.openPicker({
|
||||
required String trigger,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
required IconData icon,
|
||||
ComposerOptionGroup? group,
|
||||
required VoidCallback onInvoke,
|
||||
}) = ComposerPickerOption;
|
||||
}
|
||||
|
||||
/// System-owned entries. More triggers and actions register here later.
|
||||
abstract final class ComposerOptionCatalog {
|
||||
static List<ComposerOption> forTrigger(
|
||||
String trigger, {
|
||||
required AppLocalizations l10n,
|
||||
required String? projectId,
|
||||
required Iterable<AssetDocument> assets,
|
||||
required Iterable<TimelineSummary> timelines,
|
||||
}) {
|
||||
if (trigger != '@' || projectId == null) return const [];
|
||||
return [
|
||||
for (final asset in assets)
|
||||
ComposerOption.reference(
|
||||
trigger: '@',
|
||||
title: asset.name,
|
||||
subtitle: l10n.materials,
|
||||
icon: switch (asset.metadata['kind']) {
|
||||
'video' => Icons.movie_outlined,
|
||||
'audio' => Icons.audiotrack_outlined,
|
||||
'image' => Icons.image_outlined,
|
||||
_ => Icons.insert_drive_file_outlined,
|
||||
},
|
||||
group: ComposerOptionGroup.media,
|
||||
reference: ComposerReference(
|
||||
kind: ComposerReferenceKind.media,
|
||||
projectId: projectId,
|
||||
id: asset.id,
|
||||
label: asset.name,
|
||||
),
|
||||
),
|
||||
for (final timeline in timelines)
|
||||
ComposerOption.reference(
|
||||
trigger: '@',
|
||||
title: timeline.name,
|
||||
subtitle: l10n.timelines,
|
||||
icon: Icons.view_timeline_outlined,
|
||||
group: ComposerOptionGroup.timeline,
|
||||
reference: ComposerReference(
|
||||
kind: ComposerReferenceKind.timeline,
|
||||
projectId: projectId,
|
||||
id: timeline.id,
|
||||
label: timeline.name,
|
||||
),
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class ComposerTriggerQuery with _$ComposerTriggerQuery {
|
||||
const factory ComposerTriggerQuery({
|
||||
required String trigger,
|
||||
required int start,
|
||||
required int end,
|
||||
required String query,
|
||||
}) = _ComposerTriggerQuery;
|
||||
}
|
||||
|
||||
ComposerTriggerQuery? findComposerTrigger(
|
||||
TextEditingValue value,
|
||||
Iterable<ComposerMark> marks,
|
||||
) {
|
||||
if (!value.selection.isValid || !value.selection.isCollapsed) return null;
|
||||
if (value.composing.isValid && !value.composing.isCollapsed) return null;
|
||||
final caret = value.selection.extentOffset;
|
||||
if (caret <= 0 || caret > value.text.length) return null;
|
||||
for (final mark in marks) {
|
||||
if (caret > mark.start && caret <= mark.end) return null;
|
||||
}
|
||||
final lineStart = value.text.lastIndexOf('\n', caret - 1) + 1;
|
||||
for (var i = caret - 1; i >= lineStart; i--) {
|
||||
final char = value.text[i];
|
||||
if (char != '@' && char != '/' && char != r'$') continue;
|
||||
if (i > 0 &&
|
||||
!RegExp(r'[\s(\[{,;:!?,。!?;:、(“\u3400-\u9fff]')
|
||||
.hasMatch(value.text[i - 1])) {
|
||||
continue;
|
||||
}
|
||||
if (caret - i > 128) return null;
|
||||
if (marks.any((mark) => i >= mark.start && i < mark.end)) return null;
|
||||
final query = value.text.substring(i + 1, caret);
|
||||
if (char == '/' && (query.contains('/') || query.contains('\\'))) {
|
||||
return null;
|
||||
}
|
||||
return ComposerTriggerQuery(
|
||||
trigger: char,
|
||||
start: i,
|
||||
end: caret,
|
||||
query: query,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ComposerOption> filterComposerOptions(
|
||||
Iterable<ComposerOption> options,
|
||||
String query,
|
||||
) {
|
||||
final normalized = query.trim().toLowerCase();
|
||||
if (normalized.isEmpty) return options.toList();
|
||||
return options
|
||||
.where((option) => option.title.toLowerCase().contains(normalized))
|
||||
.toList();
|
||||
}
|
||||
Reference in new issue
Block a user