feat(workspace): refresh desktop editing experience and prepare 0.1.2
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
This commit is contained in:
1 parent
aa5255d1e4
commit
2e0033ce2d
260 files changed
+43963
-5591
No files matched your search
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../l10n/l10n.dart';
|
||||
|
||||
import 'package:cutdex_ui/icons.dart';
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
|
||||
class FullscreenPlaybackBar extends StatefulWidget {
|
||||
@@ -84,7 +85,7 @@ class _FullscreenPlaybackBarState extends State<FullscreenPlaybackBar> {
|
||||
alignment: Alignment.centerLeft,
|
||||
child: _button(
|
||||
context,
|
||||
Icons.first_page,
|
||||
AppIcons.seekStart,
|
||||
context.l10n.previewGoToStart,
|
||||
enabled ? () => widget.onSeek!(0) : null,
|
||||
),
|
||||
@@ -94,20 +95,20 @@ class _FullscreenPlaybackBarState extends State<FullscreenPlaybackBar> {
|
||||
children: [
|
||||
_button(
|
||||
context,
|
||||
Icons.skip_previous,
|
||||
AppIcons.previousFrame,
|
||||
context.l10n.previewPreviousFrame,
|
||||
enabled && _position > 0 ? () => _step(-1) : null,
|
||||
),
|
||||
_button(
|
||||
context,
|
||||
widget.playing ? Icons.pause : Icons.play_arrow,
|
||||
widget.playing ? AppIcons.pause : AppIcons.play,
|
||||
widget.playing ? context.l10n.pause : context.l10n.play,
|
||||
widget.onPlayPause,
|
||||
size: 32,
|
||||
),
|
||||
_button(
|
||||
context,
|
||||
Icons.skip_next,
|
||||
AppIcons.nextFrame,
|
||||
context.l10n.previewNextFrame,
|
||||
enabled && _position < widget.durationTick
|
||||
? () => _step(1)
|
||||
@@ -119,7 +120,7 @@ class _FullscreenPlaybackBarState extends State<FullscreenPlaybackBar> {
|
||||
alignment: Alignment.centerRight,
|
||||
child: _button(
|
||||
context,
|
||||
Icons.fullscreen_exit,
|
||||
AppIcons.exitFullscreen,
|
||||
context.l10n.exitPreviewFullscreen,
|
||||
widget.onExit,
|
||||
key: const Key('preview-fullscreen'),
|
||||
|
||||
@@ -136,7 +136,11 @@ class PreviewFullscreenLayout extends StatelessWidget {
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Positioned.fill(
|
||||
bottom: fullscreen ? 0 : AppControlSize.panelHeader,
|
||||
bottom: fullscreen
|
||||
? 0
|
||||
: AppTheme.isDesktop(context)
|
||||
? AppDesktopMetrics.playbackBar
|
||||
: AppControlSize.panelHeader,
|
||||
child: canvas,
|
||||
),
|
||||
Align(
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'package:cutdex_ui/icons.dart';
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex_ui/widgets.dart';
|
||||
|
||||
@@ -118,9 +119,10 @@ FutureOr<PreviewController?> _preparePreview(
|
||||
}
|
||||
try {
|
||||
if (!ref.mounted) throw StateError('Editor closed');
|
||||
final result = ref
|
||||
.read(previewControllerRegistryProvider)
|
||||
.prepare(ids, timeline);
|
||||
final registry = ref.read(previewControllerRegistryProvider);
|
||||
final release = registry.retain(ids);
|
||||
ref.onDispose(release);
|
||||
final result = registry.prepare(ids, timeline);
|
||||
if (result case Future<PreviewController?> future) {
|
||||
return future.catchError((Object error, StackTrace stack) {
|
||||
AppDiagnostics.failure(
|
||||
@@ -183,10 +185,12 @@ class _EditorPreviewContent extends ConsumerWidget {
|
||||
final watched = pending
|
||||
? const AsyncData<PreviewController?>(null)
|
||||
: ref.watch(provider);
|
||||
final registry = ref.watch(previewControllerRegistryProvider);
|
||||
final cached = watched.isLoading && !watched.hasError
|
||||
? registry.cached((projectId, timelineId))
|
||||
: null;
|
||||
final prepared = ref.watch(
|
||||
previewControllerRegistryProvider.select(
|
||||
(registry) => registry.cached((projectId, timelineId)),
|
||||
),
|
||||
);
|
||||
final cached = watched.isLoading && !watched.hasError ? prepared : null;
|
||||
final state = cached == null
|
||||
? watched
|
||||
: AsyncData<PreviewController?>(cached);
|
||||
@@ -219,8 +223,14 @@ class _EditorPreviewContent extends ConsumerWidget {
|
||||
PreviewFullscreenScope.of(context)?.fullscreen != true &&
|
||||
activeController.session != null &&
|
||||
activeController.error == null
|
||||
? (Rect rect) => ListenableBuilder(
|
||||
? (Rect rect) => ListenableSelector<Object>(
|
||||
listenable: activeController.positionChanges,
|
||||
select: () => (
|
||||
activeController.positionTick,
|
||||
activeController.selectedVisualIds.isNotEmpty,
|
||||
activeController.maskEditingElement,
|
||||
activeController.obscureEditingElement,
|
||||
),
|
||||
builder: (context, _) => Theme(
|
||||
data: AppTheme.previewCanvasTheme,
|
||||
child: NativePreviewOverlay(
|
||||
@@ -263,6 +273,8 @@ class _EditorPreviewContent extends ConsumerWidget {
|
||||
padding:
|
||||
PreviewFullscreenScope.of(context)?.fullscreen == true
|
||||
? EdgeInsets.zero
|
||||
: AppTheme.isDesktop(context)
|
||||
? const EdgeInsets.all(AppDesktopMetrics.panelPadding)
|
||||
: AppSpacing.panelSection,
|
||||
child: PreviewCanvas(
|
||||
alignment: Alignment.center,
|
||||
@@ -490,9 +502,11 @@ class _SourcePreviewPanel extends ConsumerWidget {
|
||||
child: Focus(
|
||||
autofocus: true,
|
||||
child: WorkspacePanel(
|
||||
title: asset.name,
|
||||
title: AppTheme.isDesktop(context) ? null : asset.name,
|
||||
showHeaderDivider: false,
|
||||
headerHeight: PreviewFullscreenScope.of(context)?.fullscreen == true
|
||||
headerHeight:
|
||||
AppTheme.isDesktop(context) ||
|
||||
PreviewFullscreenScope.of(context)?.fullscreen == true
|
||||
? 0
|
||||
: AppControlSize.panelHeader,
|
||||
child: PreviewFullscreenLayout(
|
||||
@@ -520,6 +534,8 @@ class _SourcePreviewPanel extends ConsumerWidget {
|
||||
padding:
|
||||
PreviewFullscreenScope.of(context)?.fullscreen == true
|
||||
? EdgeInsets.zero
|
||||
: AppTheme.isDesktop(context)
|
||||
? const EdgeInsets.all(AppDesktopMetrics.panelPadding)
|
||||
: AppSpacing.panelSection,
|
||||
child: PreviewCanvas(
|
||||
alignment: Alignment.center,
|
||||
@@ -634,6 +650,64 @@ class _PreviewToolbar extends StatelessWidget {
|
||||
controller?.frameDuration ??
|
||||
TimelineFormat.fps30.frameDuration;
|
||||
|
||||
Future<void> _seek(BuildContext context, int requested) async {
|
||||
final preview = controller;
|
||||
final duration = source?.durationTick ?? preview?.durationTick ?? 0;
|
||||
final frameTick = TimelineClock.standard.toTicks(_frameDuration);
|
||||
final lastTick = duration > 0
|
||||
? ((duration - 1) ~/ frameTick) * frameTick
|
||||
: 0;
|
||||
final tick = requested.clamp(0, lastTick);
|
||||
try {
|
||||
final time = CommandTime(tick, TimelineClock.ticksPerSecond);
|
||||
if (source case final source?) {
|
||||
await source.control(SourcePreviewAction.seek, at: time);
|
||||
} else if (preview?.activeSequence() case final sequence?) {
|
||||
await preview!.controlPreview(sequence, PreviewAction.seek, at: time);
|
||||
}
|
||||
} catch (error) {
|
||||
if (context.mounted) {
|
||||
ErrorNotificationHost.maybeOf(context)?.show(
|
||||
ErrorNotification(
|
||||
content: Text(previewErrorMessage(error, context.l10n)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widget _frameButton(
|
||||
BuildContext context,
|
||||
int direction,
|
||||
) => ListenableSelector(
|
||||
listenable: _clock,
|
||||
select: () => (
|
||||
source?.canPlay ?? controller?.canPlay ?? false,
|
||||
source?.durationTick ?? controller?.durationTick ?? 0,
|
||||
),
|
||||
builder: (context, state) => IconButton(
|
||||
key: Key(direction < 0 ? 'preview-previous-frame' : 'preview-next-frame'),
|
||||
tooltip: direction < 0
|
||||
? context.l10n.previewPreviousFrame
|
||||
: context.l10n.previewNextFrame,
|
||||
onPressed: !state.$1 || state.$2 <= 0
|
||||
? null
|
||||
: () {
|
||||
final position =
|
||||
source?.positionTick ?? controller?.positionTick ?? 0;
|
||||
unawaited(
|
||||
_seek(
|
||||
context,
|
||||
position +
|
||||
direction *
|
||||
TimelineClock.standard.toTicks(_frameDuration),
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: Icon(direction < 0 ? AppIcons.previousFrame : AppIcons.nextFrame),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _build(BuildContext context) {
|
||||
final preview = controller;
|
||||
final playing = source?.playing ?? preview?.playing ?? false;
|
||||
@@ -646,32 +720,7 @@ class _PreviewToolbar extends StatelessWidget {
|
||||
final duration = source?.durationTick ?? preview?.durationTick ?? 0;
|
||||
final frameTick = TimelineClock.standard.toTicks(frameDuration);
|
||||
final canPlay = source?.canPlay ?? preview?.canPlay ?? false;
|
||||
Future<void> seek(int requested) async {
|
||||
final lastTick = duration > 0
|
||||
? ((duration - 1) ~/ frameTick) * frameTick
|
||||
: 0;
|
||||
final tick = requested.clamp(0, lastTick);
|
||||
try {
|
||||
final time = CommandTime(tick, TimelineClock.ticksPerSecond);
|
||||
if (source case final source?) {
|
||||
await source.control(SourcePreviewAction.seek, at: time);
|
||||
} else if (preview?.activeSequence() case final sequence?) {
|
||||
await preview!.controlPreview(
|
||||
sequence,
|
||||
PreviewAction.seek,
|
||||
at: time,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
if (context.mounted) {
|
||||
ErrorNotificationHost.maybeOf(context)?.show(
|
||||
ErrorNotification(
|
||||
content: Text(previewErrorMessage(error, context.l10n)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Future<void> seek(int requested) => _seek(context, requested);
|
||||
|
||||
final sequence = preview?.activeSequence();
|
||||
final view = sequence == null ? null : preview!.viewForSequence(sequence);
|
||||
@@ -709,138 +758,158 @@ class _PreviewToolbar extends StatelessWidget {
|
||||
}
|
||||
return SizedBox(
|
||||
key: const Key('preview-toolbar'),
|
||||
height: AppControlSize.panelHeader,
|
||||
height: AppTheme.isDesktop(context)
|
||||
? AppDesktopMetrics.playbackBar
|
||||
: AppControlSize.panelHeader,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.compact),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListenableSelector(
|
||||
key: const Key('preview-time'),
|
||||
listenable: _clock,
|
||||
select: () => (
|
||||
source?.positionTick ?? preview?.positionTick ?? 0,
|
||||
source?.durationTick ?? preview?.durationTick ?? 0,
|
||||
_frameDuration,
|
||||
),
|
||||
builder: (context, _) => Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final controls = Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListenableSelector(
|
||||
key: const Key('preview-time'),
|
||||
listenable: _clock,
|
||||
select: () => (
|
||||
source?.positionTick ?? preview?.positionTick ?? 0,
|
||||
source?.durationTick ?? preview?.durationTick ?? 0,
|
||||
_frameDuration,
|
||||
),
|
||||
builder: (context, _) => Text.rich(
|
||||
TextSpan(
|
||||
text: _time(
|
||||
source?.positionTick ?? preview?.positionTick ?? 0,
|
||||
_frameDuration,
|
||||
),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text:
|
||||
' / ${_time(source?.durationTick ?? preview?.durationTick ?? 0, _frameDuration)}',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
fontFeatures: [const FontFeature.tabularFigures()],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
ListenableSelector(
|
||||
listenable: source ?? preview,
|
||||
select: () => (
|
||||
source?.playing ?? preview?.playing ?? false,
|
||||
source?.canPlay ?? preview?.canPlay ?? false,
|
||||
),
|
||||
builder: (context, value) {
|
||||
final playing = value.$1;
|
||||
return IconButton(
|
||||
tooltip: playing ? context.l10n.pause : context.l10n.play,
|
||||
onPressed: source != null
|
||||
? (source!.canPlay ? source!.togglePlayback : null)
|
||||
: preview != null && preview.canPlay
|
||||
? preview.togglePlayback
|
||||
: null,
|
||||
icon: Icon(playing ? Icons.pause : Icons.play_arrow),
|
||||
);
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: ListenableSelector(
|
||||
listenable: source ?? preview,
|
||||
select: () => (
|
||||
preview?.canvas,
|
||||
preview?.error,
|
||||
preview?.hasUnavailableMedia,
|
||||
preview?.busy,
|
||||
preview?.session,
|
||||
source?.session,
|
||||
source?.image,
|
||||
),
|
||||
builder: (context, _) => Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (preview != null &&
|
||||
(preview.error != null ||
|
||||
preview.hasUnavailableMedia)) ...[
|
||||
IconButton(
|
||||
tooltip: context.l10n.retryPreview,
|
||||
onPressed: preview.busy ? null : preview.retry,
|
||||
icon: const Icon(Icons.refresh),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.gap),
|
||||
],
|
||||
if (source == null &&
|
||||
PreviewFullscreenScope.of(context)?.fullscreen !=
|
||||
true)
|
||||
Flexible(
|
||||
child: AppSelect<ProjectCanvas>(
|
||||
emptyLabel: context.l10n.noMatchingOptions,
|
||||
label: context.l10n.canvasRatio,
|
||||
outlined: false,
|
||||
value: preview?.canvas ?? ProjectCanvas.widescreen,
|
||||
onChanged: preview?.setCanvas,
|
||||
options: [
|
||||
for (final entry
|
||||
in ProjectCanvasPresets.values.entries)
|
||||
AppSelectOption(entry.value, entry.key),
|
||||
],
|
||||
children: [
|
||||
TextSpan(
|
||||
text: _time(
|
||||
source?.positionTick ??
|
||||
preview?.positionTick ??
|
||||
0,
|
||||
_frameDuration,
|
||||
),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (PreviewFullscreenScope.of(context)
|
||||
case final fullscreen?)
|
||||
IconButton(
|
||||
key: const Key('preview-fullscreen'),
|
||||
tooltip: fullscreen.fullscreen
|
||||
? context.l10n.exitPreviewFullscreen
|
||||
: context.l10n.previewFullscreen,
|
||||
onPressed:
|
||||
fullscreen.fullscreen ||
|
||||
source?.session != null ||
|
||||
source?.image != null ||
|
||||
preview?.session != null
|
||||
? fullscreen.toggle
|
||||
: null,
|
||||
icon: Icon(
|
||||
fullscreen.fullscreen
|
||||
? Icons.fullscreen_exit
|
||||
: Icons.fullscreen,
|
||||
TextSpan(
|
||||
text:
|
||||
' / ${_time(source?.durationTick ?? preview?.durationTick ?? 0, _frameDuration)}',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
fontFeatures: [const FontFeature.tabularFigures()],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
if (AppTheme.isDesktop(context)) _frameButton(context, -1),
|
||||
ListenableSelector(
|
||||
listenable: source ?? preview,
|
||||
select: () => (
|
||||
source?.playing ?? preview?.playing ?? false,
|
||||
source?.canPlay ?? preview?.canPlay ?? false,
|
||||
),
|
||||
builder: (context, value) {
|
||||
final playing = value.$1;
|
||||
return IconButton(
|
||||
tooltip: playing ? context.l10n.pause : context.l10n.play,
|
||||
onPressed: source != null
|
||||
? (source!.canPlay ? source!.togglePlayback : null)
|
||||
: preview != null && preview.canPlay
|
||||
? preview.togglePlayback
|
||||
: null,
|
||||
icon: Icon(playing ? AppIcons.pause : AppIcons.play),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (AppTheme.isDesktop(context)) _frameButton(context, 1),
|
||||
Expanded(
|
||||
child: ListenableSelector(
|
||||
listenable: source ?? preview,
|
||||
select: () => (
|
||||
preview?.canvas,
|
||||
preview?.error,
|
||||
preview?.hasUnavailableMedia,
|
||||
preview?.busy,
|
||||
preview?.session,
|
||||
source?.session,
|
||||
source?.image,
|
||||
),
|
||||
builder: (context, _) => Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (preview != null &&
|
||||
(preview.error != null ||
|
||||
preview.hasUnavailableMedia)) ...[
|
||||
IconButton(
|
||||
tooltip: context.l10n.retryPreview,
|
||||
onPressed: preview.busy ? null : preview.retry,
|
||||
icon: const Icon(AppIcons.refresh),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.gap),
|
||||
],
|
||||
if (source == null &&
|
||||
PreviewFullscreenScope.of(context)?.fullscreen !=
|
||||
true)
|
||||
Flexible(
|
||||
child: AppSelect<ProjectCanvas>(
|
||||
emptyLabel: context.l10n.noMatchingOptions,
|
||||
label: context.l10n.canvasRatio,
|
||||
outlined: false,
|
||||
value:
|
||||
preview?.canvas ?? ProjectCanvas.widescreen,
|
||||
onChanged: preview?.setCanvas,
|
||||
options: [
|
||||
for (final entry
|
||||
in ProjectCanvasPresets.values.entries)
|
||||
AppSelectOption(entry.value, entry.key),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (PreviewFullscreenScope.of(context)
|
||||
case final fullscreen?)
|
||||
IconButton(
|
||||
key: const Key('preview-fullscreen'),
|
||||
tooltip: fullscreen.fullscreen
|
||||
? context.l10n.exitPreviewFullscreen
|
||||
: context.l10n.previewFullscreen,
|
||||
onPressed:
|
||||
fullscreen.fullscreen ||
|
||||
source?.session != null ||
|
||||
source?.image != null ||
|
||||
preview?.session != null
|
||||
? fullscreen.toggle
|
||||
: null,
|
||||
icon: Icon(
|
||||
fullscreen.fullscreen
|
||||
? AppIcons.exitFullscreen
|
||||
: AppIcons.fullscreen,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
if (AppTheme.isDesktop(context) && constraints.maxWidth < 240) {
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(width: 240, child: controls),
|
||||
);
|
||||
}
|
||||
return controls;
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user