feat(workspace): add workflow navigation and resizable desktop panels
This commit is contained in:
1 parent
02413383d8
commit
1acfe4a005
17 files changed
+2008
-277
No files matched your search
@@ -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,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
||||
@@ -45,6 +45,7 @@ import 'project_switch_region.dart';
|
||||
import 'project_sidebar.dart';
|
||||
import 'project_tabs_bar.dart';
|
||||
import 'project_tabs_controller.dart';
|
||||
import 'workflow_page.dart';
|
||||
import 'widgets/name_dialog.dart';
|
||||
|
||||
/// The single application surface: project navigation beside the editor.
|
||||
@@ -294,6 +295,19 @@ class _EditingPageState extends ConsumerState<EditingPage> {
|
||||
);
|
||||
final projects = ref.read(projectsProvider);
|
||||
final state = projects.value ?? const ProjectState();
|
||||
final editorProjectId = state.timeline == null
|
||||
? null
|
||||
: state.activeProject?.id;
|
||||
final editorViewSettings = desktop && editorProjectId != null
|
||||
? ref.watch(
|
||||
projectViewSettingsProvider(editorProjectId).select(
|
||||
(value) => (
|
||||
ready: value.hasValue,
|
||||
timelineHeight: value.value?.timelineHeight,
|
||||
),
|
||||
),
|
||||
)
|
||||
: null;
|
||||
return EditorWindowChrome(
|
||||
headerHeight: desktop ? DesktopWindowFrame.headerHeight : 48,
|
||||
builder: (context, integrated) => Scaffold(
|
||||
@@ -631,30 +645,33 @@ class _EditingPageState extends ConsumerState<EditingPage> {
|
||||
),
|
||||
),
|
||||
);
|
||||
bool isActiveContent(DesktopContent surface) =>
|
||||
surface == DesktopContent.workspace
|
||||
? contentSelection.surface ==
|
||||
DesktopContent.workspace ||
|
||||
contentSelection.surface ==
|
||||
DesktopContent.library ||
|
||||
contentSelection.surface ==
|
||||
DesktopContent.resourceLibrary
|
||||
: contentSelection.surface == surface;
|
||||
Widget contentSurface(
|
||||
DesktopContent surface,
|
||||
Widget child,
|
||||
) => ExcludeFocus(
|
||||
excluding:
|
||||
(contentSelection.surface ==
|
||||
DesktopContent.settings) !=
|
||||
(surface == DesktopContent.settings),
|
||||
excluding: !isActiveContent(surface),
|
||||
child: TickerMode(
|
||||
enabled:
|
||||
(contentSelection.surface ==
|
||||
DesktopContent.settings) ==
|
||||
(surface == DesktopContent.settings),
|
||||
enabled: isActiveContent(surface),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
Widget desktopContents(
|
||||
Widget workspace,
|
||||
) => IndexedStack(
|
||||
index:
|
||||
contentSelection.surface ==
|
||||
DesktopContent.settings
|
||||
? 1
|
||||
: 0,
|
||||
index: switch (contentSelection.surface) {
|
||||
DesktopContent.settings => 1,
|
||||
DesktopContent.workflow => 2,
|
||||
_ => 0,
|
||||
},
|
||||
children: [
|
||||
contentSurface(
|
||||
DesktopContent.workspace,
|
||||
@@ -685,6 +702,10 @@ class _EditingPageState extends ConsumerState<EditingPage> {
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
contentSurface(
|
||||
DesktopContent.workflow,
|
||||
const WorkflowPage(),
|
||||
),
|
||||
],
|
||||
);
|
||||
return switch (experience) {
|
||||
@@ -773,17 +794,23 @@ class _EditingPageState extends ConsumerState<EditingPage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
resourceLibrarySelected:
|
||||
contentSelection.surface ==
|
||||
DesktopContent.resourceLibrary,
|
||||
onResourceLibraryPressed: () => selectSidebar(
|
||||
DesktopContent.resourceLibrary,
|
||||
),
|
||||
settingsSelected:
|
||||
contentSelection.surface ==
|
||||
DesktopContent.settings,
|
||||
onHomePressed: () =>
|
||||
selectSidebar(DesktopContent.workspace),
|
||||
workflowSelected:
|
||||
contentSelection.surface ==
|
||||
DesktopContent.workflow,
|
||||
onHomePressed: () {
|
||||
selectSidebar(DesktopContent.workspace);
|
||||
_setMode(WorkspaceMode.agent);
|
||||
},
|
||||
onWorkflowPressed: () {
|
||||
ref
|
||||
.read(desktopContentProvider.notifier)
|
||||
.select(DesktopContent.workflow);
|
||||
_desktopScaffoldKey.currentState
|
||||
?.closeDrawer();
|
||||
},
|
||||
onSettingsPressed: () =>
|
||||
showSettingsPage(context),
|
||||
child: desktopContents(
|
||||
@@ -794,15 +821,43 @@ class _EditingPageState extends ConsumerState<EditingPage> {
|
||||
navigationDrawer: navigation(drawer: true),
|
||||
mode: _mode,
|
||||
sidebarCollapsed: navigationCollapsed,
|
||||
sidebarCanExpand: !navigationHiddenBySpace,
|
||||
sidebarWidth: _sidebarWidthOverride,
|
||||
timelineHeight:
|
||||
editorViewSettings?.timelineHeight,
|
||||
onTimelineHeightChanged:
|
||||
editorViewSettings?.ready == true &&
|
||||
!_switchingProject
|
||||
? (height) => ref
|
||||
.read(
|
||||
projectViewSettingsProvider(
|
||||
editorProjectId!,
|
||||
).notifier,
|
||||
)
|
||||
.setTimelineHeight(height)
|
||||
: null,
|
||||
onJunctionResizeEnd: () {
|
||||
_saveViewState();
|
||||
if (editorViewSettings?.ready == true) {
|
||||
unawaited(
|
||||
ref
|
||||
.read(
|
||||
projectViewSettingsProvider(
|
||||
editorProjectId!,
|
||||
).notifier,
|
||||
)
|
||||
.save(),
|
||||
);
|
||||
}
|
||||
},
|
||||
onSidebarCollapsedChanged: (value) {
|
||||
_sidebarCollapsed = value;
|
||||
_saveViewState();
|
||||
},
|
||||
onSidebarWidthChanged: (value) {
|
||||
_sidebarWidthOverride = value;
|
||||
_saveViewState();
|
||||
},
|
||||
onSidebarResizeEnd: _saveViewState,
|
||||
sidebarBuilder: (geometry, expand) =>
|
||||
navigation(
|
||||
geometry: geometry,
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import 'package:cutdex/l10n/l10n.dart';
|
||||
import 'package:cutdex/shared/layout/workspace_layout_metrics.dart';
|
||||
import 'package:cutdex_ui/icons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class WorkflowPage extends StatelessWidget {
|
||||
const WorkflowPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ColoredBox(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(WorkspaceLayoutMetrics.desktopOuterSpacing),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
context.l10n.workflow,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 420),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
AppIcons.timeline,
|
||||
size: 40,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
context.l10n.workflowDescription,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user