feat(workspace): add workflow navigation and resizable desktop panels

This commit is contained in:
lingjhf committed 2026-10-09 19:23:49 +08:00
1 parent 02413383d8
commit 1acfe4a005
17 files changed
+2008 -277

No files matched your search

+33 -11
View File
@@ -80,7 +80,6 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
ProjectViewSettings get _viewController =>
ref.read(projectViewSettingsProvider(widget.projectId).notifier);
bool get _propertiesOpen => _viewSettings.propertiesOpen;
double? get _timelineHeight => _viewSettings.timelineHeight;
void _saveViewSettings() {
if (widget.projectId.isEmpty ||
@@ -93,7 +92,8 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
@override
Widget build(BuildContext context) {
final viewSettings = ref.watch(
projectViewSettingsProvider(widget.projectId),
projectViewSettingsProvider(widget.projectId)
.select((value) => (value.hasValue, value.value?.propertiesOpen)),
);
final preview = KeyedSubtree(
key: _previewKey,
@@ -205,10 +205,15 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
if (desktop) mediaButton,
Expanded(
child: desktop
? _PreviewHeaderTitle(
projectId: widget.projectId,
timelineId: widget.timelineId,
pending: _timelinePending,
? Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.small,
),
child: _PreviewHeaderTitle(
projectId: widget.projectId,
timelineId: widget.timelineId,
pending: _timelinePending,
),
)
: widget.showProjectName
? Row(
@@ -249,7 +254,7 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
? context.l10n.collapseProperties
: context.l10n.expandProperties,
isSelected: propertiesOpen,
onPressed: !viewSettings.hasValue
onPressed: !viewSettings.$1
? null
: () {
if (desktop) {
@@ -285,23 +290,40 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
),
),
);
Widget dockedEditing({required bool showTools}) =>
ExpandedEditorLayout(
Widget dockedEditing({required bool showTools}) => Consumer(
builder: (context, ref, _) {
final dimensions = ref.watch(
projectViewSettingsProvider(widget.projectId).select(
(value) =>
(value.value?.mediaWidth, value.value?.timelineHeight),
),
);
return ExpandedEditorLayout(
preview: preview,
header: header,
properties: properties,
media: media,
showMedia: dockMedia,
showProperties: showTools && dockProperties,
timelineHeight: _timelineHeight,
mediaWidth: dimensions.$1,
onMediaWidthChanged: (width) {
if (viewSettings.$1) {
_viewController.setMediaWidth(width);
}
},
onMediaWidthChangeEnd: _saveViewSettings,
timelineHeight: dimensions.$2,
onTimelineHeightChanged: (height) {
if (viewSettings.hasValue) {
if (viewSettings.$1) {
_viewController.setTimelineHeight(height);
}
},
onTimelineHeightChangeEnd: _saveViewSettings,
onJunctionResizeEnd: _saveViewSettings,
timeline: timeline,
);
},
);
return Stack(
fit: StackFit.expand,
children: [
@@ -32,7 +32,7 @@ class EditorTimelineDefaults extends StatelessWidget {
: 26,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: AppTheme.isDesktop(context) ? AppSpacing.tiny : 0,
horizontal: AppTheme.isDesktop(context) ? AppSpacing.small : 0,
),
child: Row(
children: [
@@ -90,7 +90,9 @@ class EditorTimelineDefaults extends StatelessWidget {
),
)
: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.medium,
),
child: AppCommandToolbar(
groups: [
[
@@ -15,9 +15,13 @@ class ExpandedEditorLayout extends StatefulWidget {
required this.media,
required this.showMedia,
required this.showProperties,
required this.mediaWidth,
required this.onMediaWidthChanged,
required this.onMediaWidthChangeEnd,
required this.timelineHeight,
required this.onTimelineHeightChanged,
required this.onTimelineHeightChangeEnd,
required this.onJunctionResizeEnd,
required this.timeline,
});
@@ -27,9 +31,13 @@ class ExpandedEditorLayout extends StatefulWidget {
final Widget media;
final bool showMedia;
final bool showProperties;
final double? mediaWidth;
final ValueChanged<double> onMediaWidthChanged;
final VoidCallback onMediaWidthChangeEnd;
final double? timelineHeight;
final ValueChanged<double> onTimelineHeightChanged;
final VoidCallback onTimelineHeightChangeEnd;
final VoidCallback onJunctionResizeEnd;
final Widget timeline;
@override
@@ -50,28 +58,35 @@ class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
WorkspaceCard(key: Key('editor-$name-card'), child: child);
@override
Widget build(BuildContext context) => LayoutBuilder(
Widget build(BuildContext context) =>
WorkspaceResizeHighlightScope(child: _layout());
Widget _layout() => LayoutBuilder(
builder: (context, constraints) {
final maximum = math.max(
0.0,
constraints.maxHeight -
gap -
WorkspaceLayoutMetrics.previewMinimumHeight,
);
final minimum = math.min(
WorkspaceLayoutMetrics.timelineMinimumHeight,
maximum,
);
final timelineHeight =
(widget.timelineHeight ??
constraints.maxHeight *
WorkspaceLayoutMetrics.timelineDefaultHeightFraction)
.clamp(minimum, maximum)
.toDouble();
const mediaWidth = WorkspaceLayoutMetrics.mediaPanelWidth;
double resolveTimelineHeight(double? height) =>
WorkspaceLayoutMetrics.resolveTimelineHeight(
constraints.maxHeight,
height,
);
final timelineHeight = resolveTimelineHeight(widget.timelineHeight);
final propertiesWidth = widget.showProperties
? WorkspaceLayoutMetrics.propertiesPanelWidth
: 0.0;
final mediaMaximumWidth = math.max(
0.0,
constraints.maxWidth -
WorkspaceLayoutMetrics.previewMinimumWidth -
gap -
(widget.showProperties ? propertiesWidth + gap : 0),
);
final mediaMinimumWidth = math.min(
WorkspaceLayoutMetrics.mediaPanelMinimumWidth,
mediaMaximumWidth,
);
final mediaWidth =
(widget.mediaWidth ?? WorkspaceLayoutMetrics.mediaPanelWidth)
.clamp(mediaMinimumWidth, mediaMaximumWidth)
.toDouble();
return Stack(
fit: StackFit.expand,
children: [
@@ -130,6 +145,24 @@ class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
),
],
),
if (widget.showMedia)
Positioned(
key: const Key('editor-media-divider'),
left: mediaWidth - WorkspaceLayoutMetrics.desktopResizeSlop,
top: 0,
bottom: timelineHeight + gap,
width: WorkspaceLayoutMetrics.desktopResizeHitExtent,
child: WorkspaceResizeHandle(
key: const Key('editor-media-resize'),
highlightTargets: const {WorkspaceResizeBoundary.media},
axis: Axis.horizontal,
initialValue: mediaWidth,
onResize: (width) => widget.onMediaWidthChanged(
width.clamp(mediaMinimumWidth, mediaMaximumWidth).toDouble(),
),
onEnd: widget.onMediaWidthChangeEnd,
),
),
Positioned(
key: const Key('editor-timeline-divider'),
left: 0,
@@ -138,15 +171,39 @@ class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
height: WorkspaceLayoutMetrics.desktopResizeHitExtent,
child: WorkspaceResizeHandle(
key: const Key('editor-timeline-resize'),
highlightTargets: const {WorkspaceResizeBoundary.timeline},
axis: Axis.vertical,
initialValue: timelineHeight,
direction: -1,
onResize: (height) => widget.onTimelineHeightChanged(
height.clamp(minimum, maximum).toDouble(),
),
onResize: (height) =>
widget.onTimelineHeightChanged(resolveTimelineHeight(height)),
onEnd: widget.onTimelineHeightChangeEnd,
),
),
if (widget.showMedia)
Positioned(
left: mediaWidth - WorkspaceLayoutMetrics.desktopResizeSlop,
bottom: timelineHeight - WorkspaceLayoutMetrics.desktopResizeSlop,
width: WorkspaceLayoutMetrics.desktopResizeHitExtent,
height: WorkspaceLayoutMetrics.desktopResizeHitExtent,
child: WorkspaceResizeHandle.junction(
key: const Key('editor-media-timeline-junction'),
highlightTargets: const {
WorkspaceResizeBoundary.media,
WorkspaceResizeBoundary.timeline,
},
initialWidth: mediaWidth,
initialHeight: timelineHeight,
verticalDirection: -1,
onWidthChanged: (width) => widget.onMediaWidthChanged(
width.clamp(mediaMinimumWidth, mediaMaximumWidth).toDouble(),
),
onHeightChanged: (height) => widget.onTimelineHeightChanged(
resolveTimelineHeight(height),
),
onEnd: widget.onJunctionResizeEnd,
),
),
],
);
},