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.
332 lines
9.9 KiB
Dart
332 lines
9.9 KiB
Dart
import 'package:cutdex/l10n/l10n.dart';
|
|
import 'package:cutdex_sdk/timeline/engine.dart';
|
|
import 'package:cutdex_sdk/timeline/model.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:cutdex_ui/theme.dart';
|
|
|
|
import 'properties_inspector_controller.dart';
|
|
|
|
import 'package:cutdex_ui/widgets.dart';
|
|
|
|
import '../../workspace/timeline_provider.dart';
|
|
import '../../workspace/timeline_session.dart';
|
|
import 'audio_properties.dart';
|
|
import 'caption_properties.dart';
|
|
import 'color_interpretation_properties.dart';
|
|
import 'mask_properties.dart';
|
|
import 'picture_properties.dart';
|
|
import 'project_properties.dart';
|
|
import 'properties_presentation_state.dart';
|
|
import 'speed_properties.dart';
|
|
|
|
export 'properties_presentation_state.dart';
|
|
|
|
typedef PropertyCategoryControls = Widget Function(
|
|
BuildContext context,
|
|
List<PropertyCategory> categories,
|
|
PropertyCategory selected,
|
|
ValueChanged<PropertyCategory> onSelected,
|
|
);
|
|
|
|
class PropertiesContent extends ConsumerWidget {
|
|
const PropertiesContent({
|
|
super.key,
|
|
required this.projectId,
|
|
required this.timelineId,
|
|
required this.categoryControls,
|
|
required this.categoryHeaderHeight,
|
|
});
|
|
final String projectId;
|
|
final String timelineId;
|
|
final PropertyCategoryControls categoryControls;
|
|
final double categoryHeaderHeight;
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final state = ref.watch(editorTimelineProvider(projectId, timelineId));
|
|
final content = state.when(
|
|
error: (_, _) => WorkspacePanel(
|
|
paintBackground: false,
|
|
child: _Message(context.l10n.loadClipPropertiesFailed),
|
|
),
|
|
data: (session) {
|
|
final inspector = ref.watch(
|
|
propertiesInspectorProvider((projectId, timelineId)),
|
|
);
|
|
if (inspector == null) return const SizedBox.shrink();
|
|
return ListenableBuilder(
|
|
listenable: inspector,
|
|
builder: (context, _) => _selection(context, inspector, ref),
|
|
);
|
|
},
|
|
loading: () => const WorkspacePanel(
|
|
key: Key('properties-pending'),
|
|
paintBackground: false,
|
|
child: SizedBox.expand(),
|
|
),
|
|
);
|
|
return Theme(
|
|
data: AppTheme.propertiesPanelTheme(Theme.of(context)),
|
|
child: content,
|
|
);
|
|
}
|
|
|
|
Widget _selection(
|
|
BuildContext context,
|
|
PropertiesInspectorController inspector,
|
|
WidgetRef ref,
|
|
) {
|
|
final session = inspector.session;
|
|
final sequence = inspector.sequence;
|
|
final clips = inspector.selectedClips;
|
|
if (sequence == null || clips.isEmpty) {
|
|
return ProjectProperties(session: session);
|
|
}
|
|
if (clips.length > 1) {
|
|
return WorkspacePanel(
|
|
paintBackground: false,
|
|
child: _Message(context.l10n.selectedClipsHint(clips.length)),
|
|
);
|
|
}
|
|
final clip = clips.single;
|
|
final payload = clip.payloadRef == null
|
|
? null
|
|
: session.payloadFor(clip.payloadRef!);
|
|
final binding = clip.payloadRef == null
|
|
? null
|
|
: session.mediaBinding(clip.payloadRef!);
|
|
final hasAudio = binding?.audioSelection != null;
|
|
if (payload?.type == 'caption' || payload?.type == 'caption-role') {
|
|
return CaptionProperties(
|
|
session: session,
|
|
sequence: sequence,
|
|
clipId: clip.id.value,
|
|
transformProperties: payload?.type == 'caption'
|
|
? PictureProperties(
|
|
key: ValueKey((sequence, clip.id, 'caption-transform')),
|
|
projectId: projectId,
|
|
timelineId: timelineId,
|
|
session: session,
|
|
sequence: sequence,
|
|
clip: clip,
|
|
)
|
|
: null,
|
|
);
|
|
}
|
|
return _ClipProperties(
|
|
key: ValueKey((sequence, clip.id)),
|
|
categoryControls: categoryControls,
|
|
categoryHeaderHeight: categoryHeaderHeight,
|
|
category: ref.watch(
|
|
propertyCategoryProvider((
|
|
projectId,
|
|
timelineId,
|
|
'${sequence.value}/${clip.id.value}',
|
|
)),
|
|
),
|
|
session: session,
|
|
sequence: sequence,
|
|
clip: clip,
|
|
mask: MaskProperties(
|
|
projectId: projectId,
|
|
timelineId: timelineId,
|
|
element: clip.id,
|
|
),
|
|
speed: SpeedProperties(
|
|
session: session,
|
|
sequence: sequence,
|
|
clip: clip.id,
|
|
),
|
|
audio: AudioProperties(
|
|
key: ValueKey((sequence, clip.id, 'audio')),
|
|
session: session,
|
|
sequence: sequence,
|
|
clip: clip,
|
|
hasAudio: hasAudio,
|
|
),
|
|
picture: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
if (payload?.type == 'video' && binding?.videoTrackIndex != null)
|
|
ColorInterpretationProperties(
|
|
projectId: projectId,
|
|
timelineId: timelineId,
|
|
session: session,
|
|
assetId: payload!.assetIds.single,
|
|
trackIndex: binding!.videoTrackIndex!,
|
|
),
|
|
PictureProperties(
|
|
key: ValueKey((sequence, clip.id)),
|
|
projectId: projectId,
|
|
timelineId: timelineId,
|
|
session: session,
|
|
sequence: sequence,
|
|
clip: clip,
|
|
),
|
|
],
|
|
),
|
|
animation: PictureProperties(
|
|
key: ValueKey((sequence, clip.id, 'animation')),
|
|
projectId: projectId,
|
|
timelineId: timelineId,
|
|
session: session,
|
|
sequence: sequence,
|
|
clip: clip,
|
|
animationView: true,
|
|
),
|
|
type: payload?.type,
|
|
hasAudio: hasAudio,
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ClipProperties extends StatefulWidget {
|
|
const _ClipProperties({
|
|
super.key,
|
|
required this.session,
|
|
required this.sequence,
|
|
required this.clip,
|
|
required this.picture,
|
|
required this.mask,
|
|
required this.audio,
|
|
required this.speed,
|
|
required this.animation,
|
|
required this.type,
|
|
required this.hasAudio,
|
|
required this.categoryControls,
|
|
required this.categoryHeaderHeight,
|
|
required this.category,
|
|
});
|
|
final EditorTimelineSession session;
|
|
final SequenceId sequence;
|
|
final ElementRecord clip;
|
|
final Widget picture;
|
|
final Widget mask;
|
|
final Widget audio;
|
|
final Widget speed;
|
|
final Widget animation;
|
|
final String? type;
|
|
final bool hasAudio;
|
|
final PropertyCategoryControls categoryControls;
|
|
final double categoryHeaderHeight;
|
|
final ValueNotifier<PropertyCategory?> category;
|
|
@override
|
|
State<_ClipProperties> createState() => _ClipPropertiesState();
|
|
}
|
|
|
|
class _ClipPropertiesState extends State<_ClipProperties> {
|
|
PropertyCategory get _selected {
|
|
final categories = categoriesForClip(widget.clip, widget.type);
|
|
return categories.contains(widget.category.value)
|
|
? widget.category.value!
|
|
: categories.first;
|
|
}
|
|
|
|
void _selectCategory(PropertyCategory category) =>
|
|
widget.category.value = category;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => ListenableBuilder(
|
|
listenable: widget.category,
|
|
builder: (context, _) => _buildProperties(context),
|
|
);
|
|
|
|
Widget _buildProperties(BuildContext context) {
|
|
final clip = widget.clip;
|
|
return WorkspacePanel(
|
|
paintBackground: false,
|
|
headerHeight: widget.categoryHeaderHeight,
|
|
headerPadding: EdgeInsets.zero,
|
|
showHeaderDivider: false,
|
|
controls: widget.categoryControls(
|
|
context,
|
|
categoriesForClip(clip, widget.type),
|
|
_selected,
|
|
_selectCategory,
|
|
),
|
|
child: ScrollEdgeFadeBuilder(
|
|
key: PageStorageKey((clip.id, _selected)),
|
|
builder: (controller) => SingleChildScrollView(
|
|
controller: controller,
|
|
// Inspector controls stop at their bounds; macOS's default elastic
|
|
// physics repeatedly displaces the content during edge scrolling.
|
|
physics: const ClampingScrollPhysics(),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
...switch (_selected) {
|
|
PropertyCategory.picture => [widget.picture],
|
|
PropertyCategory.mask => [widget.mask],
|
|
PropertyCategory.audio => [widget.audio],
|
|
PropertyCategory.speed => [widget.speed],
|
|
PropertyCategory.animation => [widget.animation],
|
|
PropertyCategory.basic => [
|
|
_Property(context.l10n.type, switch (clip.structure) {
|
|
ElementStructure.gap => context.l10n.gap,
|
|
ElementStructure.container => context.l10n.compoundClip,
|
|
ElementStructure.content =>
|
|
widget.type ?? context.l10n.unboundMedia,
|
|
}),
|
|
_Property(
|
|
context.l10n.status,
|
|
clip.enabled ? context.l10n.enable : context.l10n.disable,
|
|
),
|
|
],
|
|
},
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _Property extends StatelessWidget {
|
|
const _Property(this.label, this.value);
|
|
final String label;
|
|
final String value;
|
|
@override
|
|
Widget build(BuildContext context) => Padding(
|
|
padding: AppSpacing.panelSection,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
spacing: AppSpacing.small,
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
label,
|
|
style: AppTheme.propertySectionTitleStyle(context),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Text(
|
|
value,
|
|
textAlign: TextAlign.right,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
class _Message extends StatelessWidget {
|
|
const _Message(this.text);
|
|
final String text;
|
|
@override
|
|
Widget build(BuildContext context) => Center(
|
|
child: Padding(
|
|
padding: AppSpacing.panelSection,
|
|
child: Text(
|
|
text,
|
|
textAlign: TextAlign.center,
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
),
|
|
),
|
|
);
|
|
}
|