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,110 @@
|
||||
import 'package:cutdex_sdk/timeline/model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../workspace/projects.dart';
|
||||
import '../../workspace/timeline_session.dart';
|
||||
import '../media/media_asset_drag.dart';
|
||||
import 'timeline_external_drop_target.dart';
|
||||
|
||||
class TimelineAssetDropTarget extends ConsumerStatefulWidget {
|
||||
const TimelineAssetDropTarget({
|
||||
super.key,
|
||||
required this.projectId,
|
||||
required this.session,
|
||||
required this.sequenceId,
|
||||
required this.child,
|
||||
});
|
||||
final String projectId;
|
||||
final EditorTimelineSession session;
|
||||
final SequenceId sequenceId;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
ConsumerState<TimelineAssetDropTarget> createState() =>
|
||||
_TimelineAssetDropTargetState();
|
||||
}
|
||||
|
||||
class _TimelineAssetDropTargetState
|
||||
extends ConsumerState<TimelineAssetDropTarget> {
|
||||
final _target = GlobalKey<TimelineExternalDropTargetState>();
|
||||
final _incoming = ValueNotifier<TimelineIncomingAsset?>(null);
|
||||
MediaAssetDrag? _drag;
|
||||
|
||||
void _updateIncoming(DragTargetDetails<MediaAssetDrag> details) {
|
||||
if (!_accepts(details.data)) return;
|
||||
final asset = ref
|
||||
.read(projectsProvider)
|
||||
.asData
|
||||
?.value
|
||||
.assets
|
||||
.where((asset) => asset.id == details.data.assetId)
|
||||
.firstOrNull;
|
||||
if (asset == null) return;
|
||||
if (_drag != details.data) {
|
||||
_clearIncoming();
|
||||
_drag = details.data;
|
||||
}
|
||||
details.data.feedbackVisible.value = false;
|
||||
_incoming.value = (asset: asset, globalPosition: details.offset);
|
||||
}
|
||||
|
||||
void _clearIncoming() {
|
||||
_drag?.feedbackVisible.value = true;
|
||||
_drag = null;
|
||||
_incoming.value = null;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_clearIncoming();
|
||||
_incoming.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
bool _inserting = false;
|
||||
|
||||
bool _accepts(MediaAssetDrag data) {
|
||||
final state = ref.read(projectsProvider).asData?.value;
|
||||
return !_inserting &&
|
||||
data.projectId == widget.projectId &&
|
||||
state?.activeProject?.id == widget.projectId &&
|
||||
state?.timeline?.id == widget.session.document.id &&
|
||||
state?.projectBusy == false;
|
||||
}
|
||||
|
||||
Future<void> _drop(DragTargetDetails<MediaAssetDrag> details) async {
|
||||
if (!_accepts(details.data)) return;
|
||||
_updateIncoming(details);
|
||||
_inserting = true;
|
||||
try {
|
||||
await _target.currentState?.drop();
|
||||
} finally {
|
||||
if (mounted) {
|
||||
_clearIncoming();
|
||||
_inserting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => DragTarget<MediaAssetDrag>(
|
||||
hitTestBehavior: HitTestBehavior.opaque,
|
||||
onWillAcceptWithDetails: (details) {
|
||||
final accepts = _accepts(details.data);
|
||||
if (accepts) _updateIncoming(details);
|
||||
return accepts;
|
||||
},
|
||||
onMove: _updateIncoming,
|
||||
onLeave: (_) => _clearIncoming(),
|
||||
onAcceptWithDetails: _drop,
|
||||
builder: (context, candidates, rejected) => TimelineExternalDropTarget(
|
||||
key: _target,
|
||||
projectId: widget.projectId,
|
||||
session: widget.session,
|
||||
sequenceId: widget.sequenceId,
|
||||
incoming: _incoming,
|
||||
child: widget.child,
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user