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

This commit is contained in:
lingjhf committed 2026-10-09 01:56:01 +08:00
1 parent aa5255d1e4
commit 2e0033ce2d
260 files changed
+43963 -5591

No files matched your search

+202 -81
View File
@@ -1,3 +1,5 @@
import '../../shared/widgets/listenable_selector.dart';
import 'package:cutdex/shared/widgets/error_notification_host.dart';
import 'dart:math' as math;
@@ -10,6 +12,7 @@ import 'package:flutter/material.dart';
import '../../l10n/l10n.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
@@ -139,8 +142,37 @@ class _SpeedPropertiesState extends State<SpeedProperties> {
@override
Widget build(BuildContext context) {
final view = widget.session.view(widget.sequence);
return ListenableBuilder(
return ListenableSelector<Object>(
listenable: Listenable.merge([view, widget.session]),
select: () {
final query = view.version.kernelVersion.query();
final handle = query.elementById(widget.clip);
final record = handle == null ? null : query.element(handle);
final segments = record == null
? null
: widget.session.clipSpeedSegments(record);
final custom = widget.session.isCustomSpeedEnabled(
widget.sequence,
widget.clip,
);
final tick = handle == null
? 0
: view.playheadTick - query.absoluteStart(handle);
final split =
custom &&
segments != null &&
tick > 0 &&
tick < record!.duration &&
!segments.any((segment) => segment.projectStart == tick);
return (
record,
custom,
split,
widget.session.acceptsEdits,
view.isDragging,
_version == null || identical(_version, view.version.kernelVersion),
);
},
builder: (context, _) {
final query = view.version.kernelVersion.query();
final handle = query.elementById(widget.clip);
@@ -173,41 +205,54 @@ class _SpeedPropertiesState extends State<SpeedProperties> {
? _timeline ?? saved ?? 1
: saved ?? 1;
return Padding(
padding: AppSpacing.panelSection,
padding: AppTheme.propertySectionPadding(context),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
children: [
Expanded(
child: Text(
context.l10n.speed,
style: AppTheme.propertySectionTitleStyle(context),
ConstrainedBox(
constraints: BoxConstraints(
minHeight: AppTheme.isDesktop(context)
? AppInspectorMetrics.action
: AppControlSize.propertyControl,
),
child: Row(
children: [
Expanded(
child: Text(
context.l10n.speed,
style: AppTheme.propertySectionTitleStyle(context),
),
),
),
Text(
saved == null && segments != null
? context.l10n.segmentedSpeed
: '${value.toStringAsFixed(2)}×',
key: const Key('clip-speed-value'),
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
Text(
saved == null && segments != null
? context.l10n.segmentedSpeed
: '${value.toStringAsFixed(2)}×',
key: const Key('clip-speed-value'),
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
const SizedBox(width: AppSpacing.small),
TextButton(
onPressed: canReset
? () {
_version = null;
_commit(1);
}
: null,
child: const Text('1×'),
),
],
SizedBox(width: AppTheme.propertyRowGap(context)),
TextButton(
style: AppTheme.isDesktop(context)
? TextButton.styleFrom(
minimumSize: const Size(24, 24),
padding: EdgeInsets.zero,
)
: null,
onPressed: canReset
? () {
_version = null;
_commit(1);
}
: null,
child: const Text('1×'),
),
],
),
),
if (saved != null) ...[
const SizedBox(height: AppSpacing.small),
SizedBox(height: AppTheme.propertyRowGap(context)),
AppSlider(
key: const Key('clip-speed-slider'),
value: ((math.log(value.clamp(0.1, 100)) / math.ln10 + 1) / 3)
@@ -252,64 +297,140 @@ class _SpeedPropertiesState extends State<SpeedProperties> {
context.l10n.speedSegmentCount(segments.length),
style: Theme.of(context).textTheme.bodySmall,
),
const SizedBox(height: AppSpacing.small),
Row(
children: [
Expanded(
child: Text(
context.l10n.custom,
style: AppTheme.propertySectionTitleStyle(context),
SizedBox(
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.groupGap
: AppSpacing.small,
),
if (AppTheme.isDesktop(context))
AppPropertyGroup(
label: context.l10n.custom,
actions: [
AppSwitch(
key: const Key('clip-custom-speed-toggle'),
value: custom,
semanticLabel: context.l10n.custom,
onChanged: canReset
? (value) {
_discardPreview();
setState(() {
_timeline = null;
_version = null;
});
widget.session.setCustomSpeedEnabled(
widget.sequence,
widget.clip,
value,
);
}
: null,
),
],
child: SizedBox(
width: double.infinity,
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.input
: AppControlSize.propertyControl,
child: OutlinedButton.icon(
key: const Key('split-speed-segment'),
onPressed: canSplit
? () {
try {
final current = view.version.kernelVersion
.query();
final target = current.elementById(widget.clip);
if (target == null) return;
widget.session.splitClipSpeedAt(
widget.sequence,
widget.clip,
view.playheadTick -
current.absoluteStart(target),
);
} catch (error) {
ErrorNotificationHost.of(context).show(
ErrorNotification(
content: Text(
context.l10n.errorMessage(error),
),
details: error.toString(),
),
);
}
}
: null,
icon: const Icon(AppIcons.cut),
label: Text(context.l10n.splitSpeedAtPlayhead),
),
),
AppSwitch(
key: const Key('clip-custom-speed-toggle'),
value: custom,
semanticLabel: context.l10n.custom,
onChanged: canReset
? (value) {
_discardPreview();
setState(() {
_timeline = null;
_version = null;
});
widget.session.setCustomSpeedEnabled(
widget.sequence,
widget.clip,
value,
);
)
else ...[
Row(
children: [
Expanded(
child: Text(
context.l10n.custom,
style: AppTheme.propertySectionTitleStyle(context),
),
),
AppSwitch(
key: const Key('clip-custom-speed-toggle'),
value: custom,
semanticLabel: context.l10n.custom,
onChanged: canReset
? (value) {
_discardPreview();
setState(() {
_timeline = null;
_version = null;
});
widget.session.setCustomSpeedEnabled(
widget.sequence,
widget.clip,
value,
);
}
: null,
),
],
),
SizedBox(height: AppTheme.propertyRowGap(context)),
SizedBox(
width: double.infinity,
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.input
: AppControlSize.propertyControl,
child: OutlinedButton.icon(
key: const Key('split-speed-segment'),
onPressed: canSplit
? () {
try {
final current = view.version.kernelVersion
.query();
final target = current.elementById(widget.clip);
if (target == null) return;
widget.session.splitClipSpeedAt(
widget.sequence,
widget.clip,
view.playheadTick -
current.absoluteStart(target),
);
} catch (error) {
ErrorNotificationHost.of(context).show(
ErrorNotification(
content: Text(
context.l10n.errorMessage(error),
),
details: error.toString(),
),
);
}
}
: null,
icon: const Icon(AppIcons.cut),
label: Text(context.l10n.splitSpeedAtPlayhead),
),
],
),
const SizedBox(height: AppSpacing.small),
SizedBox(
width: double.infinity,
height: AppControlSize.propertyControl,
child: OutlinedButton.icon(
key: const Key('split-speed-segment'),
onPressed: canSplit
? () {
try {
widget.session.splitClipSpeedAt(
widget.sequence,
widget.clip,
localPlayhead,
);
} catch (error) {
ErrorNotificationHost.of(context).show(
ErrorNotification(
content: Text(context.l10n.errorMessage(error)),
details: error.toString(),
),
);
}
}
: null,
icon: const Icon(Icons.content_cut),
label: Text(context.l10n.splitSpeedAtPlayhead),
),
),
],
if (segments == null)
Text(
context.l10n.speedNotAvailable,