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

@@ -2,11 +2,12 @@ import 'package:cutdex/l10n/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import '../../integrations/runtime/processing_resource_repository.dart';
import '../../workspace/background_task_registry.dart';
import '../../workspace/background_task_state.dart';
import '../../shared/widgets/listenable_selector.dart';
import '../../integrations/runtime/processing_resource_state.dart';
import 'package:cutdex_ui/widgets.dart';
@@ -14,9 +15,14 @@ import 'package:cutdex_ui/widgets.dart';
import '../media/background_tasks_dialog.dart';
class BackgroundTasksButton extends ConsumerWidget {
const BackgroundTasksButton({super.key, this.iconSize = AppIconSize.header});
const BackgroundTasksButton({
super.key,
this.iconSize = AppIconSize.header,
this.alignment = AlignmentDirectional.bottomStart,
});
final double iconSize;
final AlignmentGeometry alignment;
@override
Widget build(BuildContext context, WidgetRef ref) {
@@ -25,30 +31,39 @@ class BackgroundTasksButton extends ConsumerWidget {
.watch(processingResourceRepositoryProvider)
.asData
?.value;
final tasks = ref.watch(backgroundTasksProvider(registry: registry));
final downloads = resources == null
? null
: ref.watch(processingResourcesProvider(resources));
bool hasRunningTasks() =>
tasks.runningCount > 0 ||
downloads?.subtitleDownloading == true ||
(downloads?.installs.any(
(install) => install.state == ProcessingResourceState.downloading,
) ??
false);
Widget button(VoidCallback toggle) => IconButton(
: ref.watch(
processingResourcesProvider(resources).select(
(downloads) =>
downloads.subtitleDownloading ||
downloads.installs.any(
(install) =>
install.state == ProcessingResourceState.downloading,
),
),
);
Widget button(VoidCallback toggle, bool running) => IconButton(
key: const ValueKey('background-tasks-button'),
tooltip: context.l10n.backgroundTasks,
onPressed: toggle,
icon: Badge(
isLabelVisible: hasRunningTasks(),
child: Icon(Icons.task_alt_outlined, size: iconSize),
isLabelVisible: running || downloads == true,
child: Icon(AppIcons.success, size: iconSize),
),
);
return AppPopover(
width: 384,
builder: (_, toggle) => button(toggle),
child: BackgroundTasksContent(registry: registry, repository: resources),
return ListenableSelector<bool>(
listenable: registry,
select: () => registry.runningCount > 0,
builder: (context, running) => AppPopover(
width: 384,
alignment: alignment,
builder: (_, toggle) => button(toggle, running),
child: BackgroundTasksContent(
registry: registry,
repository: resources,
),
),
);
}
}
+182 -72
View File
@@ -1,3 +1,5 @@
import '../../shared/widgets/listenable_selector.dart';
import 'dart:async';
import 'package:cutdex/l10n/l10n.dart';
@@ -11,9 +13,12 @@ import 'package:cutdex_native/cutdex_native.dart';
import '../../persistence/app_settings_repositories.dart';
import '../../shared/layout/workspace_layout_metrics.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import '../../workspace/timeline_provider.dart';
import '../../workspace/preview_target.dart';
import '../../workspace/projects.dart';
import '../../workspace/view_settings.dart';
import '../media/media_browser_page.dart';
import '../media/media_panel.dart';
@@ -23,6 +28,7 @@ import '../properties/properties_panel.dart';
import '../timeline/timeline_panel.dart';
import 'editor_presentation_controller.dart';
import 'editor_panel_defaults.dart';
import 'timeline_operation_region.dart';
import 'layouts/bounded_editor_layout.dart';
import 'layouts/expanded_editor_layout.dart';
@@ -42,6 +48,8 @@ class EditorWorkspace extends ConsumerStatefulWidget {
});
final bool projectLoading;
/// Navigation is preparing another timeline; the current content stays visible.
final bool timelineLoading;
final String projectId;
final String timelineId;
@@ -57,7 +65,13 @@ class EditorWorkspace extends ConsumerStatefulWidget {
class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
final _previewKey = GlobalKey();
bool get _timelinePending => widget.projectLoading || widget.timelineLoading;
bool get _timelinePending => widget.projectLoading;
Widget _timelineInteraction(Widget child) => TimelineOperationRegion(
projectId: widget.projectId,
loading: widget.timelineLoading,
child: child,
);
EditorPresentationController get _presentation =>
ref.read(editorPresentationProvider(widget.projectId));
ProjectViewSettingsData get _viewSettings =>
@@ -69,7 +83,8 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
double? get _timelineHeight => _viewSettings.timelineHeight;
void _saveViewSettings() {
if (!ref.read(projectViewSettingsProvider(widget.projectId)).hasValue) {
if (widget.projectId.isEmpty ||
!ref.read(projectViewSettingsProvider(widget.projectId)).hasValue) {
return;
}
unawaited(_viewController.save());
@@ -82,10 +97,12 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
);
final preview = KeyedSubtree(
key: _previewKey,
child: EditorPreviewPanel(
projectId: widget.projectId,
timelineId: widget.timelineId,
pending: _timelinePending,
child: _timelineInteraction(
EditorPreviewPanel(
projectId: widget.projectId,
timelineId: widget.timelineId,
pending: _timelinePending,
),
),
);
final timeline = EditorTimelinePanel(
@@ -94,35 +111,81 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
pending: widget.projectLoading,
timelineLoading: widget.timelineLoading,
);
final properties = _timelinePending
? const EditorEmptyPanel()
: EditorPropertiesPanel(
projectId: widget.projectId,
timelineId: widget.timelineId,
);
final properties = _timelineInteraction(
_timelinePending
? const EditorEmptyPanel()
: EditorPropertiesPanel(
projectId: widget.projectId,
timelineId: widget.timelineId,
),
);
final media = widget.projectLoading
? const EditorEmptyPanel()
: MediaPanel(projectId: widget.projectId);
: MediaPanel(projectId: widget.projectId, projectScoped: true);
return ListenableBuilder(
listenable: ref.watch(editorPresentationProvider(widget.projectId)),
builder: (context, _) => LayoutBuilder(
builder: (context, constraints) {
final desktop = widget.experience == DeviceExperience.desktop;
final mediaOpen = desktop
? _presentation.mediaOpen
: _presentation.activeTool == EditorTool.media;
final mediaWidth = mediaOpen
? WorkspaceLayoutMetrics.mediaPanelWidth +
WorkspaceLayoutMetrics.desktopSpacing
: 0.0;
final sideWidth = (_propertiesOpen
? WorkspaceLayoutMetrics.propertiesPanelWidth + 1
? WorkspaceLayoutMetrics.propertiesPanelWidth +
WorkspaceLayoutMetrics.desktopSpacing
: 0);
final dockPanels =
final dockMedia =
desktop &&
mediaOpen &&
constraints.maxWidth >=
WorkspaceLayoutMetrics.previewMinimumWidth + sideWidth;
final desktopTool = _propertiesOpen ? EditorTool.properties : null;
final headerHeight = desktop ? AppControlSize.panelToolbar : 48.0;
final mediaOpen = _presentation.activeTool == EditorTool.media;
WorkspaceLayoutMetrics.previewMinimumWidth + mediaWidth;
final dockProperties =
desktop &&
_propertiesOpen &&
constraints.maxWidth >=
WorkspaceLayoutMetrics.previewMinimumWidth +
sideWidth +
(dockMedia ? mediaWidth : 0);
final desktopTool =
mediaOpen && !dockMedia && _presentation.desktopToolRequested
? _presentation.desktopTool(propertiesOpen: _propertiesOpen)
: _propertiesOpen && !dockProperties
? EditorTool.properties
: null;
final headerHeight = desktop ? AppDesktopMetrics.panelHeader : 48.0;
final propertiesOpen = desktop
? dockPanels
? dockProperties
? _propertiesOpen
: desktopTool == EditorTool.properties
: _presentation.activeTool == EditorTool.properties;
final mediaButton = HeaderControlRegion(
child: SizedBox.square(
dimension: desktop ? AppControlSize.headerButton : 48,
child: IconButton(
key: const Key('editor-media-button'),
tooltip: context.l10n.materials,
isSelected: mediaOpen,
onPressed: () {
if (desktop) {
if (!dockMedia &&
desktopTool != EditorTool.media &&
_presentation.mediaOpen) {
_presentation.preferDesktopTool(EditorTool.media);
} else {
_presentation.toggleMedia();
}
} else {
_presentation.toggleTool(EditorTool.media);
}
},
icon: const Icon(AppIcons.mediaLibrary),
),
),
);
final header = Material(
color: Theme.of(context).colorScheme.surface,
child: SizedBox(
@@ -132,15 +195,22 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
padding: desktop
? const EdgeInsets.symmetric(
horizontal: AppSidebarMetrics.outerPadding,
vertical: AppSpacing.gap,
vertical: AppSpacing.tiny,
)
: EdgeInsets.zero,
child: WindowHeaderPadding(
child: Row(
children: [
widget.headerLeading,
if (desktop) mediaButton,
Expanded(
child: widget.showProjectName
child: desktop
? _PreviewHeaderTitle(
projectId: widget.projectId,
timelineId: widget.timelineId,
pending: _timelinePending,
)
: widget.showProjectName
? Row(
children: [
Flexible(
@@ -168,35 +238,7 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
)
: const SizedBox.shrink(),
),
if (!desktop)
HeaderControlRegion(
child: SizedBox.square(
dimension: desktop
? AppControlSize.headerButton
: 48,
child: IconButton(
key: const Key('editor-media-button'),
tooltip: context.l10n.materials,
isSelected: mediaOpen,
onPressed: () {
if (desktop) {
if (!dockPanels &&
desktopTool != EditorTool.media &&
_presentation.mediaOpen) {
_presentation.preferDesktopTool(
EditorTool.media,
);
} else {
_presentation.toggleMedia();
}
} else {
_presentation.toggleTool(EditorTool.media);
}
},
icon: const Icon(Icons.perm_media_outlined),
),
),
),
if (!desktop) mediaButton,
if (!desktop) const SizedBox(width: AppSpacing.tiny),
HeaderControlRegion(
child: SizedBox.square(
@@ -211,7 +253,7 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
? null
: () {
if (desktop) {
if (dockPanels ||
if (dockProperties ||
desktopTool ==
EditorTool.properties ||
!_propertiesOpen) {
@@ -230,7 +272,7 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
}
},
icon: const Icon(
Icons.tune,
AppIcons.tune,
size: AppIconSize.header,
),
),
@@ -249,8 +291,8 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
header: header,
properties: properties,
media: media,
showMedia: false,
showProperties: showTools && _propertiesOpen,
showMedia: dockMedia,
showProperties: showTools && dockProperties,
timelineHeight: _timelineHeight,
onTimelineHeightChanged: (height) {
if (viewSettings.hasValue) {
@@ -267,7 +309,7 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
children: [
if (!desktop) header,
Expanded(
child: dockPanels
child: desktop && desktopTool == null
? dockedEditing(showTools: true)
: BoundedEditorLayout(
experience: widget.experience,
@@ -297,14 +339,18 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
: switch (widget.experience) {
DeviceExperience.desktop => properties,
DeviceExperience.tablet =>
PropertiesToolPanel(
projectId: widget.projectId,
timelineId: widget.timelineId,
_timelineInteraction(
PropertiesToolPanel(
projectId: widget.projectId,
timelineId: widget.timelineId,
),
),
DeviceExperience.phone =>
PropertiesEditorPage(
projectId: widget.projectId,
timelineId: widget.timelineId,
_timelineInteraction(
PropertiesEditorPage(
projectId: widget.projectId,
timelineId: widget.timelineId,
),
),
},
onCloseTool: () {
@@ -338,6 +384,73 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
}
}
class _PreviewHeaderTitle extends ConsumerWidget {
const _PreviewHeaderTitle({
required this.projectId,
required this.timelineId,
required this.pending,
});
final String projectId;
final String timelineId;
final bool pending;
@override
Widget build(BuildContext context, WidgetRef ref) {
final navigation = pending
? const PreviewTargetState.timeline()
: ref.watch(previewNavigationProvider(projectId, timelineId));
final name = pending
? context.l10n.preview
: ref.watch(
projectsProvider.select((value) {
final workspace = value.value;
return switch (navigation) {
SourcePreviewTarget(:final asset) =>
workspace?.assets
.where((item) => item.id == asset.id)
.firstOrNull
?.name ??
asset.name,
_ =>
workspace?.timeline?.id == timelineId
? workspace!.timeline!.name
: context.l10n.preview,
};
}),
);
final session = pending
? null
: ref.watch(editorTimelineProvider(projectId, timelineId)).value;
Widget title(String? saveStatus) => Tooltip(
message: saveStatus == null ? name : '$name\n$saveStatus',
child: Text(
name,
key: const Key('editor-preview-title'),
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.titleSmall,
),
);
if (session == null) return title(null);
return ListenableSelector<(bool, bool, bool)>(
listenable: session,
select: () => (session.error != null, session.saving, session.dirty),
builder: (context, value) => title(_timelineSaveLabel(context, value)),
);
}
}
String _timelineSaveLabel(BuildContext context, (bool, bool, bool) value) =>
value.$1
? context.l10n.unsaved
: value.$2
? context.l10n.saving
: value.$3
? context.l10n.pendingSave
: context.l10n.saved;
class _TimelineSaveStatus extends ConsumerWidget {
const _TimelineSaveStatus({
required this.projectId,
@@ -354,22 +467,19 @@ class _TimelineSaveStatus extends ConsumerWidget {
.asData
?.value;
if (session == null) return const SizedBox.shrink();
return ListenableBuilder(
return ListenableSelector<(bool, bool, bool)>(
listenable: session,
builder: (context, _) => Padding(
select: () => (session.error != null, session.saving, session.dirty),
builder: (context, value) => Padding(
padding: const EdgeInsets.only(left: AppSpacing.small),
child: Text(
session.error != null
? context.l10n.unsaved
: session.saving
? context.l10n.saving
: session.dirty
? context.l10n.pendingSave
: context.l10n.saved,
_timelineSaveLabel(context, value),
key: const Key('timeline-save-status'),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodySmall?.copyWith(fontSize: 10),
style: AppTheme.isDesktop(context)
? Theme.of(context).textTheme.bodySmall
: Theme.of(context).textTheme.bodySmall?.copyWith(fontSize: 10),
),
),
);
+102 -25
View File
@@ -1,4 +1,7 @@
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:flutter/material.dart';
/// Empty values while a project's content is being bound to its cards.
@@ -19,40 +22,114 @@ class EditorTimelineDefaults extends StatelessWidget {
Widget build(BuildContext context) => Column(
children: [
if (showTabs) ...[
const SizedBox(
key: Key('timeline-tabs-bar'),
height: 26,
child: Row(
children: [
IconButton(onPressed: null, icon: Icon(Icons.add, size: 16)),
],
ColoredBox(
key: const Key('timeline-tabs-background'),
color: AppTheme.timelineTabsBackground(context),
child: SizedBox(
key: const Key('timeline-tabs-bar'),
height: AppTheme.isDesktop(context)
? AppDesktopMetrics.timelineTabs
: 26,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: AppTheme.isDesktop(context) ? AppSpacing.tiny : 0,
),
child: Row(
children: [
if (AppTheme.isDesktop(context))
SizedBox.square(
dimension: AppDesktopMetrics.timelineTabControl,
child: IconButton(
key: const Key('timeline-add-button'),
onPressed: null,
style: AppTheme.timelineTabActionStyle,
icon: const Icon(AppIcons.add, size: 16),
),
)
else
const IconButton(
onPressed: null,
icon: Icon(AppIcons.add, size: 16),
),
],
),
),
),
),
const Divider(height: 1),
],
Expanded(
child: WorkspacePanel(
headerHeight: 32,
headerHeight: AppTheme.isDesktop(context)
? AppDesktopMetrics.timelineToolbar
: 32,
headerPadding: EdgeInsets.zero,
controls: SizedBox(
key: const Key('timeline-toolbar'),
height: 32,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
for (final icon in [
Icons.undo,
Icons.redo,
Icons.content_cut,
Icons.align_horizontal_left,
Icons.align_horizontal_right,
Icons.delete_outline,
])
IconButton(onPressed: null, icon: Icon(icon, size: 16)),
],
),
),
height: AppTheme.isDesktop(context)
? AppDesktopMetrics.timelineToolbar
: 32,
child: !AppTheme.isDesktop(context)
? SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
for (final icon in [
AppIcons.undo,
AppIcons.redo,
AppIcons.cut,
AppIcons.alignLeft,
AppIcons.alignRight,
AppIcons.delete,
])
IconButton(
onPressed: null,
icon: Icon(icon, size: 16),
),
],
),
)
: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: AppCommandToolbar(
groups: [
[
AppToolbarCommand(
label: context.l10n.undo,
icon: AppIcons.undo,
onPressed: null,
),
AppToolbarCommand(
label: context.l10n.redo,
icon: AppIcons.redo,
onPressed: null,
),
],
[
AppToolbarCommand(
label: context.l10n.splitAtPlayhead,
icon: AppIcons.cut,
onPressed: null,
),
AppToolbarCommand(
label: context.l10n.trimLeftTooltip,
icon: AppIcons.alignLeft,
onPressed: null,
),
AppToolbarCommand(
label: context.l10n.trimRightTooltip,
icon: AppIcons.alignRight,
onPressed: null,
),
AppToolbarCommand(
label: context.l10n.deleteSelectedClips,
icon: AppIcons.delete,
onPressed: null,
),
],
],
),
),
),
child: const SizedBox.expand(key: Key('timeline-default-tracks')),
),
@@ -12,12 +12,14 @@ final editorPresentationProvider =
/// Presentation choices survive shell changes without changing project data.
class EditorPresentationController extends ChangeNotifier {
bool _mediaOpen = false;
bool _mediaOpen = true;
EditorTool? _activeTool;
EditorTool _preferredDesktopTool = EditorTool.properties;
bool _desktopToolRequested = false;
bool get mediaOpen => _mediaOpen;
EditorTool? get activeTool => _activeTool;
bool get desktopToolRequested => _desktopToolRequested;
EditorTool desktopTool({required bool propertiesOpen}) =>
_preferredDesktopTool == EditorTool.media && _mediaOpen
? EditorTool.media
@@ -26,12 +28,14 @@ class EditorPresentationController extends ChangeNotifier {
: EditorTool.media;
void preferDesktopTool(EditorTool tool) {
_desktopToolRequested = true;
_preferredDesktopTool = tool;
notifyListeners();
}
void toggleMedia() {
_mediaOpen = !_mediaOpen;
_desktopToolRequested = _mediaOpen;
if (_mediaOpen) _preferredDesktopTool = EditorTool.media;
notifyListeners();
}
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import '../../../integrations/platform/device_experience.dart';
import '../../../l10n/l10n.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import '../editor_presentation_controller.dart';
@@ -36,29 +37,34 @@ class BoundedEditorLayout extends StatelessWidget {
Widget toolSurface() => Column(
children: [
SizedBox(
height: desktop ? AppControlSize.panelToolbar : 48,
child: Row(
children: [
SizedBox.square(
dimension: desktop ? AppControlSize.headerButton : 48,
child: IconButton(
key: const Key('editor-tool-close'),
tooltip: MaterialLocalizations.of(context)
.closeButtonTooltip,
onPressed: onCloseTool,
icon: Icon(page ? Icons.arrow_back : Icons.close),
height: desktop ? AppDesktopMetrics.panelHeader : 48,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: desktop ? AppSpacing.small : 0,
),
child: Row(
children: [
SizedBox.square(
dimension: desktop ? AppControlSize.headerButton : 48,
child: IconButton(
key: const Key('editor-tool-close'),
tooltip: MaterialLocalizations.of(context)
.closeButtonTooltip,
onPressed: onCloseTool,
icon: Icon(page ? AppIcons.arrowBack : AppIcons.close),
),
),
),
Expanded(
child: Text(
tool == EditorTool.media
? context.l10n.materials
: context.l10n.expandProperties,
maxLines: 1,
overflow: TextOverflow.ellipsis,
Expanded(
child: Text(
tool == EditorTool.media
? context.l10n.materials
: context.l10n.expandProperties,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
],
],
),
),
),
const Divider(height: 1),
@@ -92,7 +98,7 @@ class BoundedEditorLayout extends StatelessWidget {
),
if (tool != null)
Positioned(
top: desktop ? AppControlSize.panelToolbar + 1 : 0,
top: desktop ? AppDesktopMetrics.panelHeader + 1 : 0,
bottom: 0,
right: 0,
width: page
@@ -1,7 +1,6 @@
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:cutdex_ui/theme.dart';
import '../../../shared/layout/workspace_layout_metrics.dart';
import '../../../shared/widgets/workspace_card.dart';
@@ -39,6 +38,13 @@ class ExpandedEditorLayout extends StatefulWidget {
class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
static const gap = WorkspaceLayoutMetrics.desktopSpacing;
late bool _mediaVisited = widget.showMedia;
@override
void didUpdateWidget(covariant ExpandedEditorLayout oldWidget) {
super.didUpdateWidget(oldWidget);
_mediaVisited |= widget.showMedia;
}
Widget _card(String name, Widget child) =>
WorkspaceCard(key: Key('editor-$name-card'), child: child);
@@ -50,8 +56,7 @@ class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
0.0,
constraints.maxHeight -
gap -
AppControlSize.panelToolbar -
WorkspaceLayoutMetrics.timelineMinimumHeight,
WorkspaceLayoutMetrics.previewMinimumHeight,
);
final minimum = math.min(
WorkspaceLayoutMetrics.timelineMinimumHeight,
@@ -63,9 +68,7 @@ class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
WorkspaceLayoutMetrics.timelineDefaultHeightFraction)
.clamp(minimum, maximum)
.toDouble();
final mediaWidth = widget.showMedia
? WorkspaceLayoutMetrics.mediaPanelWidth
: 0.0;
const mediaWidth = WorkspaceLayoutMetrics.mediaPanelWidth;
final propertiesWidth = widget.showProperties
? WorkspaceLayoutMetrics.propertiesPanelWidth
: 0.0;
@@ -75,48 +78,49 @@ class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
Column(
children: [
Expanded(
child: _card(
'preview',
Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: Column(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (_mediaVisited)
Offstage(
offstage: !widget.showMedia,
child: ExcludeFocus(
excluding: !widget.showMedia,
child: TickerMode(
enabled: widget.showMedia,
child: SizedBox(
key: const Key('editor-media-region'),
width: mediaWidth,
child: _card('media', widget.media),
),
),
),
),
if (widget.showMedia) const SizedBox(width: gap),
Expanded(
child: _card(
'preview',
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
widget.header,
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (widget.showMedia) ...[
SizedBox(
key: const Key('editor-media-region'),
width: mediaWidth,
child: widget.media,
),
const VerticalDivider(width: 1),
],
Expanded(child: widget.preview),
],
),
),
Expanded(child: widget.preview),
],
),
),
if (widget.showProperties) ...[
const VerticalDivider(
key: Key('editor-properties-divider'),
width: 1,
),
SizedBox(
key: const Key('editor-properties-region'),
width: propertiesWidth,
child: widget.properties,
),
],
),
if (widget.showProperties) ...[
const SizedBox(
key: Key('editor-properties-divider'),
width: gap,
),
SizedBox(
key: const Key('editor-properties-region'),
width: propertiesWidth,
child: _card('properties', widget.properties),
),
],
),
],
),
),
const SizedBox(height: gap),
@@ -0,0 +1,34 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../workspace/projects.dart';
/// Keeps the surface mounted while a timeline operation temporarily blocks edits.
class TimelineOperationRegion extends ConsumerWidget {
const TimelineOperationRegion({
super.key,
required this.projectId,
required this.child,
this.loading = false,
});
final String projectId;
final bool loading;
final Widget child;
@override
Widget build(BuildContext context, WidgetRef ref) {
final creating = ref.watch(
projectsProvider.select(
(value) =>
value.value?.activeProject?.id == projectId &&
value.value?.creatingTimeline == true,
),
);
final blocked = loading || creating;
return IgnorePointer(
ignoring: blocked,
child: ExcludeFocus(excluding: blocked, child: child),
);
}
}