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
@@ -36,7 +36,7 @@ class BoundedEditorLayout extends StatelessWidget {
|
||||
Widget toolSurface() => Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: desktop ? AppControlSize.panelHeader : 48,
|
||||
height: desktop ? AppControlSize.panelToolbar : 48,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox.square(
|
||||
@@ -92,7 +92,7 @@ class BoundedEditorLayout extends StatelessWidget {
|
||||
),
|
||||
if (tool != null)
|
||||
Positioned(
|
||||
top: 0,
|
||||
top: desktop ? AppControlSize.panelToolbar + 1 : 0,
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
width: page
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
|
||||
import '../../../shared/layout/workspace_layout_metrics.dart';
|
||||
import '../../../shared/widgets/workspace_card.dart';
|
||||
import '../../../shared/widgets/workspace_resize_handle.dart';
|
||||
|
||||
class ExpandedEditorLayout extends StatefulWidget {
|
||||
const ExpandedEditorLayout({
|
||||
super.key,
|
||||
required this.preview,
|
||||
required this.header,
|
||||
required this.properties,
|
||||
required this.media,
|
||||
required this.showMedia,
|
||||
@@ -20,6 +23,7 @@ class ExpandedEditorLayout extends StatefulWidget {
|
||||
});
|
||||
|
||||
final Widget preview;
|
||||
final Widget header;
|
||||
final Widget properties;
|
||||
final Widget media;
|
||||
final bool showMedia;
|
||||
@@ -34,15 +38,20 @@ class ExpandedEditorLayout extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
|
||||
double? _timelineDragStartY;
|
||||
double _timelineDragStartHeight = 0;
|
||||
static const gap = WorkspaceLayoutMetrics.desktopSpacing;
|
||||
|
||||
Widget _card(String name, Widget child) =>
|
||||
WorkspaceCard(key: Key('editor-$name-card'), child: child);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final maximum = math.max(
|
||||
0.0,
|
||||
constraints.maxHeight - WorkspaceLayoutMetrics.timelineMinimumHeight,
|
||||
constraints.maxHeight -
|
||||
gap -
|
||||
AppControlSize.panelToolbar -
|
||||
WorkspaceLayoutMetrics.timelineMinimumHeight,
|
||||
);
|
||||
final minimum = math.min(
|
||||
WorkspaceLayoutMetrics.timelineMinimumHeight,
|
||||
@@ -66,76 +75,72 @@ class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
|
||||
Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (widget.showMedia) ...[
|
||||
SizedBox(
|
||||
key: const Key('editor-media-region'),
|
||||
width: mediaWidth,
|
||||
child: widget.media,
|
||||
child: _card(
|
||||
'preview',
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Expanded(
|
||||
child: 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),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const VerticalDivider(width: 1),
|
||||
if (widget.showProperties) ...[
|
||||
const VerticalDivider(
|
||||
key: Key('editor-properties-divider'),
|
||||
width: 1,
|
||||
),
|
||||
SizedBox(
|
||||
key: const Key('editor-properties-region'),
|
||||
width: propertiesWidth,
|
||||
child: widget.properties,
|
||||
),
|
||||
],
|
||||
],
|
||||
Expanded(child: widget.preview),
|
||||
if (widget.showProperties) ...[
|
||||
const VerticalDivider(width: 1),
|
||||
SizedBox(
|
||||
key: const Key('editor-properties-region'),
|
||||
width: propertiesWidth,
|
||||
child: widget.properties,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
SizedBox(height: timelineHeight, child: widget.timeline),
|
||||
const SizedBox(height: gap),
|
||||
SizedBox(
|
||||
height: timelineHeight,
|
||||
child: _card('timeline', widget.timeline),
|
||||
),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
key: const Key('editor-timeline-divider'),
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: timelineHeight - 4,
|
||||
height: 8,
|
||||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.resizeRow,
|
||||
child: GestureDetector(
|
||||
key: const Key('editor-timeline-resize'),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
onVerticalDragStart: (details) {
|
||||
_timelineDragStartY = details.globalPosition.dy;
|
||||
_timelineDragStartHeight = timelineHeight;
|
||||
},
|
||||
onVerticalDragUpdate: (details) {
|
||||
final start = _timelineDragStartY;
|
||||
if (start == null) return;
|
||||
widget.onTimelineHeightChanged(
|
||||
(_timelineDragStartHeight +
|
||||
start -
|
||||
details.globalPosition.dy)
|
||||
.clamp(minimum, maximum)
|
||||
.toDouble(),
|
||||
);
|
||||
},
|
||||
onVerticalDragEnd: (_) {
|
||||
_timelineDragStartY = null;
|
||||
widget.onTimelineHeightChangeEnd();
|
||||
},
|
||||
onVerticalDragCancel: () {
|
||||
_timelineDragStartY = null;
|
||||
widget.onTimelineHeightChangeEnd();
|
||||
},
|
||||
child: const Center(
|
||||
child: SizedBox(
|
||||
height: 1,
|
||||
width: double.infinity,
|
||||
child: Divider(height: 1),
|
||||
),
|
||||
),
|
||||
bottom: timelineHeight - WorkspaceLayoutMetrics.desktopResizeSlop,
|
||||
height: WorkspaceLayoutMetrics.desktopResizeHitExtent,
|
||||
child: WorkspaceResizeHandle(
|
||||
key: const Key('editor-timeline-resize'),
|
||||
axis: Axis.vertical,
|
||||
initialValue: timelineHeight,
|
||||
direction: -1,
|
||||
onResize: (height) => widget.onTimelineHeightChanged(
|
||||
height.clamp(minimum, maximum).toDouble(),
|
||||
),
|
||||
onEnd: widget.onTimelineHeightChangeEnd,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user