refactor(desktop): reorganize workspace panels and navigation
This commit is contained in:
1 parent
826745b407
commit
1f73765745
92 files changed
+5811
-2650
No files matched your search
@@ -22,6 +22,7 @@ import '../properties/properties_editor_page.dart';
|
||||
import '../properties/properties_panel.dart';
|
||||
import '../timeline/timeline_panel.dart';
|
||||
import 'editor_presentation_controller.dart';
|
||||
import 'editor_panel_defaults.dart';
|
||||
import 'layouts/bounded_editor_layout.dart';
|
||||
import 'layouts/expanded_editor_layout.dart';
|
||||
|
||||
@@ -34,10 +35,12 @@ class EditorWorkspace extends ConsumerStatefulWidget {
|
||||
required this.projectName,
|
||||
required this.integratedTitlebar,
|
||||
required this.headerLeading,
|
||||
this.projectLoading = false,
|
||||
this.showProjectName = true,
|
||||
this.experience = DeviceExperience.desktop,
|
||||
});
|
||||
|
||||
final bool projectLoading;
|
||||
final String projectId;
|
||||
final String timelineId;
|
||||
final String projectName;
|
||||
@@ -79,53 +82,170 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
||||
child: EditorPreviewPanel(
|
||||
projectId: widget.projectId,
|
||||
timelineId: widget.timelineId,
|
||||
pending: widget.projectLoading,
|
||||
),
|
||||
);
|
||||
final timeline = EditorTimelinePanel(
|
||||
projectId: widget.projectId,
|
||||
timelineId: widget.timelineId,
|
||||
pending: widget.projectLoading,
|
||||
);
|
||||
final properties = EditorPropertiesPanel(
|
||||
projectId: widget.projectId,
|
||||
timelineId: widget.timelineId,
|
||||
);
|
||||
final media = MediaPanel(projectId: widget.projectId);
|
||||
final properties = widget.projectLoading
|
||||
? const EditorEmptyPanel()
|
||||
: EditorPropertiesPanel(
|
||||
projectId: widget.projectId,
|
||||
timelineId: widget.timelineId,
|
||||
);
|
||||
final media = widget.projectLoading
|
||||
? const EditorEmptyPanel()
|
||||
: MediaPanel(projectId: widget.projectId);
|
||||
return ListenableBuilder(
|
||||
listenable: ref.watch(editorPresentationProvider(widget.projectId)),
|
||||
builder: (context, _) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final desktop = widget.experience == DeviceExperience.desktop;
|
||||
final sideWidth =
|
||||
(_presentation.mediaOpen
|
||||
? WorkspaceLayoutMetrics.mediaPanelWidth + 1
|
||||
: 0) +
|
||||
(_propertiesOpen
|
||||
? WorkspaceLayoutMetrics.propertiesPanelWidth + 1
|
||||
: 0);
|
||||
final sideWidth = (_propertiesOpen
|
||||
? WorkspaceLayoutMetrics.propertiesPanelWidth + 1
|
||||
: 0);
|
||||
final dockPanels =
|
||||
desktop &&
|
||||
constraints.maxWidth >=
|
||||
WorkspaceLayoutMetrics.previewMinimumWidth + sideWidth;
|
||||
final desktopTool = sideWidth == 0
|
||||
? null
|
||||
: _presentation.desktopTool(propertiesOpen: _propertiesOpen);
|
||||
final headerHeight = desktop ? AppControlSize.panelHeader : 48.0;
|
||||
final mediaOpen = desktop
|
||||
? dockPanels
|
||||
? _presentation.mediaOpen
|
||||
: desktopTool == EditorTool.media
|
||||
: _presentation.activeTool == EditorTool.media;
|
||||
final desktopTool = _propertiesOpen ? EditorTool.properties : null;
|
||||
final headerHeight = desktop ? AppControlSize.panelToolbar : 48.0;
|
||||
final mediaOpen = _presentation.activeTool == EditorTool.media;
|
||||
final propertiesOpen = desktop
|
||||
? dockPanels
|
||||
? _propertiesOpen
|
||||
: desktopTool == EditorTool.properties
|
||||
: _presentation.activeTool == EditorTool.properties;
|
||||
final header = Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: SizedBox(
|
||||
key: const Key('editor-content-header'),
|
||||
height: headerHeight,
|
||||
child: Padding(
|
||||
padding: desktop
|
||||
? const EdgeInsets.symmetric(
|
||||
horizontal: AppSidebarMetrics.outerPadding,
|
||||
vertical: AppSpacing.gap,
|
||||
)
|
||||
: EdgeInsets.zero,
|
||||
child: WindowHeaderPadding(
|
||||
child: Row(
|
||||
children: [
|
||||
widget.headerLeading,
|
||||
Expanded(
|
||||
child: widget.showProjectName
|
||||
? Row(
|
||||
children: [
|
||||
Flexible(
|
||||
fit: FlexFit.loose,
|
||||
child: Text(
|
||||
widget.projectName,
|
||||
key: const Key('workspace-project-title'),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleSmall,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
fit: FlexFit.loose,
|
||||
child: widget.projectLoading
|
||||
? const SizedBox.shrink()
|
||||
: _TimelineSaveStatus(
|
||||
projectId: widget.projectId,
|
||||
timelineId: widget.timelineId,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: 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) const SizedBox(width: AppSpacing.tiny),
|
||||
HeaderControlRegion(
|
||||
child: SizedBox.square(
|
||||
dimension: desktop ? AppControlSize.headerButton : 48,
|
||||
child: IconButton(
|
||||
key: const Key('editor-properties-button'),
|
||||
tooltip: propertiesOpen
|
||||
? context.l10n.collapseProperties
|
||||
: context.l10n.expandProperties,
|
||||
isSelected: propertiesOpen,
|
||||
onPressed: !viewSettings.hasValue
|
||||
? null
|
||||
: () {
|
||||
if (desktop) {
|
||||
if (dockPanels ||
|
||||
desktopTool ==
|
||||
EditorTool.properties ||
|
||||
!_propertiesOpen) {
|
||||
_viewController.setPropertiesOpen(
|
||||
!_propertiesOpen,
|
||||
);
|
||||
_saveViewSettings();
|
||||
}
|
||||
_presentation.preferDesktopTool(
|
||||
EditorTool.properties,
|
||||
);
|
||||
} else {
|
||||
_presentation.toggleTool(
|
||||
EditorTool.properties,
|
||||
);
|
||||
}
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.tune,
|
||||
size: AppIconSize.header,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!desktop) const SizedBox(width: AppSpacing.compact),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
Widget dockedEditing({required bool showTools}) =>
|
||||
ExpandedEditorLayout(
|
||||
preview: preview,
|
||||
header: header,
|
||||
properties: properties,
|
||||
media: media,
|
||||
showMedia: showTools && _presentation.mediaOpen,
|
||||
showMedia: false,
|
||||
showProperties: showTools && _propertiesOpen,
|
||||
timelineHeight: _timelineHeight,
|
||||
onTimelineHeightChanged: (height) {
|
||||
@@ -141,121 +261,7 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: SizedBox(
|
||||
key: const Key('editor-content-header'),
|
||||
height: headerHeight,
|
||||
child: WindowHeaderPadding(
|
||||
child: Row(
|
||||
children: [
|
||||
widget.headerLeading,
|
||||
Expanded(
|
||||
child: widget.showProjectName
|
||||
? Row(
|
||||
children: [
|
||||
Flexible(
|
||||
fit: FlexFit.loose,
|
||||
child: Text(
|
||||
widget.projectName,
|
||||
key: const Key(
|
||||
'workspace-project-title',
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleSmall,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
fit: FlexFit.loose,
|
||||
child: _TimelineSaveStatus(
|
||||
projectId: widget.projectId,
|
||||
timelineId: widget.timelineId,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
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),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.tiny),
|
||||
HeaderControlRegion(
|
||||
child: SizedBox.square(
|
||||
dimension: desktop
|
||||
? AppControlSize.headerButton
|
||||
: 48,
|
||||
child: IconButton(
|
||||
key: const Key('editor-properties-button'),
|
||||
tooltip: propertiesOpen
|
||||
? context.l10n.collapseProperties
|
||||
: context.l10n.expandProperties,
|
||||
isSelected: propertiesOpen,
|
||||
onPressed: !viewSettings.hasValue
|
||||
? null
|
||||
: () {
|
||||
if (desktop) {
|
||||
if (dockPanels ||
|
||||
desktopTool ==
|
||||
EditorTool.properties ||
|
||||
!_propertiesOpen) {
|
||||
_viewController.setPropertiesOpen(
|
||||
!_propertiesOpen,
|
||||
);
|
||||
_saveViewSettings();
|
||||
}
|
||||
_presentation.preferDesktopTool(
|
||||
EditorTool.properties,
|
||||
);
|
||||
} else {
|
||||
_presentation.toggleTool(
|
||||
EditorTool.properties,
|
||||
);
|
||||
}
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.tune,
|
||||
size: AppIconSize.header,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.compact),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!desktop) header,
|
||||
Expanded(
|
||||
child: dockPanels
|
||||
? dockedEditing(showTools: true)
|
||||
@@ -270,26 +276,33 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
||||
tool: desktop
|
||||
? desktopTool
|
||||
: _presentation.activeTool,
|
||||
media: switch (widget.experience) {
|
||||
DeviceExperience.desktop => media,
|
||||
DeviceExperience.tablet => MediaBrowserDrawer(
|
||||
projectId: widget.projectId,
|
||||
),
|
||||
DeviceExperience.phone => MediaBrowserPage(
|
||||
projectId: widget.projectId,
|
||||
),
|
||||
},
|
||||
properties: switch (widget.experience) {
|
||||
DeviceExperience.desktop => properties,
|
||||
DeviceExperience.tablet => PropertiesToolPanel(
|
||||
projectId: widget.projectId,
|
||||
timelineId: widget.timelineId,
|
||||
),
|
||||
DeviceExperience.phone => PropertiesEditorPage(
|
||||
projectId: widget.projectId,
|
||||
timelineId: widget.timelineId,
|
||||
),
|
||||
},
|
||||
media: widget.projectLoading
|
||||
? media
|
||||
: switch (widget.experience) {
|
||||
DeviceExperience.desktop => media,
|
||||
DeviceExperience.tablet =>
|
||||
MediaBrowserDrawer(
|
||||
projectId: widget.projectId,
|
||||
),
|
||||
DeviceExperience.phone => MediaBrowserPage(
|
||||
projectId: widget.projectId,
|
||||
),
|
||||
},
|
||||
properties: widget.projectLoading
|
||||
? properties
|
||||
: switch (widget.experience) {
|
||||
DeviceExperience.desktop => properties,
|
||||
DeviceExperience.tablet =>
|
||||
PropertiesToolPanel(
|
||||
projectId: widget.projectId,
|
||||
timelineId: widget.timelineId,
|
||||
),
|
||||
DeviceExperience.phone =>
|
||||
PropertiesEditorPage(
|
||||
projectId: widget.projectId,
|
||||
timelineId: widget.timelineId,
|
||||
),
|
||||
},
|
||||
onCloseTool: () {
|
||||
if (!desktop) {
|
||||
_presentation.closeTool();
|
||||
@@ -304,14 +317,15 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
||||
),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
key: const Key('editing-top-divider'),
|
||||
top: headerHeight,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: 1,
|
||||
child: const Divider(height: 1),
|
||||
),
|
||||
if (!desktop)
|
||||
Positioned(
|
||||
key: const Key('editing-top-divider'),
|
||||
top: headerHeight,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: 1,
|
||||
child: const Divider(height: 1),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user