fix(preview): keep source navigation and canvas interactions responsive

This commit is contained in:
lingjhf committed 2026-10-09 19:23:49 +08:00
1 parent 107e93b959
commit 77dbb1897f
4 files changed
+685 -22

No files matched your search

+65 -8
View File
@@ -621,6 +621,22 @@ class _PreviewToolbar extends StatelessWidget {
final PreviewController? controller;
final SourcePreviewController? source;
ButtonStyle? _compactButtonStyle(BuildContext context) =>
AppTheme.isDesktop(context)
? IconButton.styleFrom(
fixedSize: const Size.square(AppInspectorMetrics.action),
minimumSize: const Size.square(AppInspectorMetrics.action),
maximumSize: const Size.square(AppInspectorMetrics.action),
padding: EdgeInsets.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(AppInspectorMetrics.radius),
),
),
)
: null;
@override
Widget build(BuildContext context) {
if (PreviewFullscreenScope.of(context)?.fullscreen == true) {
@@ -661,7 +677,7 @@ class _PreviewToolbar extends StatelessWidget {
try {
final time = CommandTime(tick, TimelineClock.ticksPerSecond);
if (source case final source?) {
await source.control(SourcePreviewAction.seek, at: time);
await source.seekInteractive(tick);
} else if (preview?.activeSequence() case final sequence?) {
await preview!.controlPreview(sequence, PreviewAction.seek, at: time);
}
@@ -705,12 +721,25 @@ class _PreviewToolbar extends StatelessWidget {
);
},
icon: Icon(direction < 0 ? AppIcons.previousFrame : AppIcons.nextFrame),
style: _compactButtonStyle(context),
),
);
Widget _build(BuildContext context) {
final preview = controller;
final playing = source?.playing ?? preview?.playing ?? false;
final timeTextStyle = AppTheme.isDesktop(context)
? Theme.of(context).textTheme.bodyMedium?.copyWith(
fontFamily: 'packages/cutdex_ui/Inter',
fontSize: AppInspectorMetrics.fontSize,
height:
AppInspectorMetrics.lineHeight / AppInspectorMetrics.fontSize,
fontVariations: const [FontVariation('wght', 450)],
letterSpacing: AppInspectorMetrics.fontSize * .005,
fontFeatures: [const FontFeature.tabularFigures()],
)
: Theme.of(context).textTheme.bodySmall
?.copyWith(fontFeatures: [const FontFeature.tabularFigures()]);
final frameDuration =
source?.frameDuration ??
preview?.frameDuration ??
@@ -762,7 +791,9 @@ class _PreviewToolbar extends StatelessWidget {
? AppDesktopMetrics.playbackBar
: AppControlSize.panelHeader,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.compact),
padding: const EdgeInsets.symmetric(
horizontal: AppInspectorMetrics.padding,
),
child: LayoutBuilder(
builder: (context, constraints) {
final controls = Row(
@@ -803,13 +834,14 @@ class _PreviewToolbar extends StatelessWidget {
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
fontFeatures: [const FontFeature.tabularFigures()],
),
style: timeTextStyle,
),
),
),
if (AppTheme.isDesktop(context)) _frameButton(context, -1),
if (AppTheme.isDesktop(context)) ...[
const SizedBox(width: AppSpacing.small),
_frameButton(context, -1),
],
ListenableSelector(
listenable: source ?? preview,
select: () => (
@@ -826,10 +858,14 @@ class _PreviewToolbar extends StatelessWidget {
? preview.togglePlayback
: null,
icon: Icon(playing ? AppIcons.pause : AppIcons.play),
style: _compactButtonStyle(context),
);
},
),
if (AppTheme.isDesktop(context)) _frameButton(context, 1),
if (AppTheme.isDesktop(context)) ...[
_frameButton(context, 1),
const SizedBox(width: AppSpacing.small),
],
Expanded(
child: ListenableSelector(
listenable: source ?? preview,
@@ -854,8 +890,9 @@ class _PreviewToolbar extends StatelessWidget {
tooltip: context.l10n.retryPreview,
onPressed: preview.busy ? null : preview.retry,
icon: const Icon(AppIcons.refresh),
style: _compactButtonStyle(context),
),
const SizedBox(width: AppSpacing.gap),
const SizedBox(width: AppSpacing.small),
],
if (source == null &&
PreviewFullscreenScope.of(context)?.fullscreen !=
@@ -865,6 +902,25 @@ class _PreviewToolbar extends StatelessWidget {
emptyLabel: context.l10n.noMatchingOptions,
label: context.l10n.canvasRatio,
outlined: false,
controlHeight: AppTheme.isDesktop(context)
? AppInspectorMetrics.input
: null,
textStyle: AppTheme.isDesktop(context)
? Theme.of(
context,
).textTheme.bodyMedium?.copyWith(
fontFamily: 'packages/cutdex_ui/Inter',
fontSize: AppInspectorMetrics.fontSize,
height:
AppInspectorMetrics.lineHeight /
AppInspectorMetrics.fontSize,
fontVariations: const [
FontVariation('wght', 450),
],
letterSpacing:
AppInspectorMetrics.fontSize * .005,
)
: null,
value:
preview?.canvas ?? ProjectCanvas.widescreen,
onChanged: preview?.setCanvas,
@@ -894,6 +950,7 @@ class _PreviewToolbar extends StatelessWidget {
? AppIcons.exitFullscreen
: AppIcons.fullscreen,
),
style: _compactButtonStyle(context),
),
],
),