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
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
enum DesktopContent { workspace, library, settings }
|
||||
|
||||
typedef DesktopContentSelection = ({
|
||||
DesktopContent surface,
|
||||
int settingsTab,
|
||||
int settingsRequest,
|
||||
(String, String)? workspace,
|
||||
bool settingsVisited,
|
||||
bool resourcesSelected,
|
||||
});
|
||||
|
||||
final desktopContentProvider =
|
||||
NotifierProvider<DesktopContentController, DesktopContentSelection>(
|
||||
DesktopContentController.new,
|
||||
);
|
||||
|
||||
/// Navigation changes visibility without disposing any visited content.
|
||||
class DesktopContentController extends Notifier<DesktopContentSelection> {
|
||||
@override
|
||||
DesktopContentSelection build() => (
|
||||
surface: DesktopContent.workspace,
|
||||
settingsTab: 0,
|
||||
settingsRequest: 0,
|
||||
workspace: null,
|
||||
settingsVisited: false,
|
||||
resourcesSelected: false,
|
||||
);
|
||||
|
||||
void select(DesktopContent surface) {
|
||||
state = (
|
||||
surface: surface,
|
||||
settingsTab: state.settingsTab,
|
||||
settingsRequest: state.settingsRequest,
|
||||
workspace: state.workspace,
|
||||
settingsVisited:
|
||||
state.settingsVisited || surface == DesktopContent.settings,
|
||||
resourcesSelected: surface == DesktopContent.library,
|
||||
);
|
||||
}
|
||||
|
||||
void showSettings({int? tab, (String, String)? workspace}) {
|
||||
state = (
|
||||
surface: DesktopContent.settings,
|
||||
settingsTab: tab ?? state.settingsTab,
|
||||
settingsRequest: state.settingsRequest + (tab == null ? 0 : 1),
|
||||
workspace: workspace ?? state.workspace,
|
||||
settingsVisited: true,
|
||||
resourcesSelected: state.resourcesSelected,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,19 @@ import 'package:flutter/foundation.dart';
|
||||
/// Desktop split preferences outlive the desktop shell when a window narrows.
|
||||
class DesktopWorkspaceController extends ChangeNotifier {
|
||||
double? _agentWidth;
|
||||
bool _editorCollapsedByAgent = false;
|
||||
bool _agentFullscreen = false;
|
||||
|
||||
double? get agentWidth => _agentWidth;
|
||||
bool get editorCollapsedByAgent => _editorCollapsedByAgent;
|
||||
bool get agentFullscreen => _agentFullscreen;
|
||||
|
||||
void setSplit(double? width, {required bool editorCollapsed}) {
|
||||
void setAgentWidth(double width) {
|
||||
_agentWidth = width;
|
||||
_editorCollapsedByAgent = editorCollapsed;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setAgentFullscreen(bool value) {
|
||||
if (_agentFullscreen == value) return;
|
||||
_agentFullscreen = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,7 @@ final class DesktopWorkspaceGeometry {
|
||||
required this.editorHidden,
|
||||
});
|
||||
|
||||
static const editorCollapseWidth = 480.0;
|
||||
static const editorCollapseDragBuffer = editorCollapseWidth / 3;
|
||||
static const editorMinimumWidth = 480.0;
|
||||
static const editorRestoreWidth = 560.0;
|
||||
|
||||
final double sidebarWidth;
|
||||
@@ -42,7 +41,7 @@ final class DesktopWorkspaceGeometry {
|
||||
required bool sidebarCollapsed,
|
||||
double? sidebarWidth,
|
||||
double? agentWidth,
|
||||
bool editorCollapsedByAgent = false,
|
||||
bool agentFullscreen = false,
|
||||
}) {
|
||||
final navigationWidth =
|
||||
(sidebarWidth ?? WorkspaceLayoutMetrics.sidebarDefaultWidth)
|
||||
@@ -57,19 +56,17 @@ final class DesktopWorkspaceGeometry {
|
||||
.clamp(220.0, math.max(220.0, width - navigationSpace - 1))
|
||||
.toDouble()
|
||||
: 0.0;
|
||||
final remaining = width - navigationSpace - requestedAgentWidth - 1;
|
||||
final hidden =
|
||||
mode == WorkspaceMode.agent &&
|
||||
(width - navigationSpace - 1 < 220 + editorCollapseWidth ||
|
||||
(editorCollapsedByAgent && remaining < editorRestoreWidth) ||
|
||||
remaining <= editorCollapseWidth - editorCollapseDragBuffer);
|
||||
(width - navigationSpace - 1 < 220 + editorMinimumWidth ||
|
||||
agentFullscreen);
|
||||
return DesktopWorkspaceGeometry(
|
||||
sidebarWidth: navigationWidth,
|
||||
agentWidth: hidden
|
||||
? width - navigationSpace
|
||||
: mode == WorkspaceMode.agent
|
||||
? requestedAgentWidth
|
||||
.clamp(220.0, width - navigationSpace - editorCollapseWidth - 1)
|
||||
.clamp(220.0, width - navigationSpace - editorMinimumWidth - 1)
|
||||
.toDouble()
|
||||
: 0,
|
||||
editorHidden: hidden,
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'router/app_router.dart';
|
||||
import '../integrations/app_updates.dart';
|
||||
import '../integrations/editor_tools.dart';
|
||||
import '../features/settings/appearance_settings.dart';
|
||||
import '../shared/widgets/error_notification_host.dart';
|
||||
|
||||
class CutdexApp extends ConsumerWidget {
|
||||
const CutdexApp({super.key});
|
||||
@@ -22,6 +23,8 @@ class CutdexApp extends ConsumerWidget {
|
||||
ref.watch(appearanceSettingsProvider).asData?.value ??
|
||||
AppAppearance.system;
|
||||
return MaterialApp.router(
|
||||
builder: (context, child) =>
|
||||
ErrorNotificationHost(child: child ?? const SizedBox.shrink()),
|
||||
title: 'Cutdex',
|
||||
locale: ref.watch(languageSettingsProvider).asData?.value.locale,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../../features/projects/projects_page.dart';
|
||||
import '../../features/settings/settings_page.dart';
|
||||
|
||||
part 'app_router.g.dart';
|
||||
|
||||
@@ -12,7 +13,23 @@ part 'app_router.g.dart';
|
||||
GoRouter appRouter(Ref ref) {
|
||||
final router = GoRouter(
|
||||
routes: [
|
||||
GoRoute(path: '/', builder: (context, state) => const EditingPage()),
|
||||
GoRoute(
|
||||
path: '/',
|
||||
builder: (context, state) => const EditingPage(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'settings',
|
||||
builder: (context, state) => SettingsPage(
|
||||
initialTab:
|
||||
(int.tryParse(state.uri.queryParameters['tab'] ?? '') ?? 0)
|
||||
.clamp(0, 2),
|
||||
workspace: state.extra is (String, String)
|
||||
? state.extra as (String, String)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
errorBuilder: (context, state) => Scaffold(
|
||||
body: Center(
|
||||
|
||||
@@ -48,4 +48,4 @@ final class AppRouterProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$appRouterHash() => r'ebb3f9239a43568767def98552081806bd614bb4';
|
||||
String _$appRouterHash() => r'00e948f9d82c1f07ecdfc62b3c1ec833cb03edfe';
|
||||
@@ -0,0 +1,163 @@
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../integrations/platform/editor_window_chrome.dart';
|
||||
import '../../l10n/l10n.dart';
|
||||
import '../../shared/layout/workspace_layout_metrics.dart';
|
||||
import '../../workspace/workspace_mode.dart';
|
||||
|
||||
/// Keeps window chrome outside the shared workspace surface.
|
||||
class DesktopWindowFrame extends StatelessWidget {
|
||||
const DesktopWindowFrame({
|
||||
super.key,
|
||||
required this.integratedTitlebar,
|
||||
required this.headerControls,
|
||||
required this.librarySelected,
|
||||
this.settingsSelected = false,
|
||||
required this.onModeChanged,
|
||||
required this.onLibraryPressed,
|
||||
required this.onSettingsPressed,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
static const railWidth = 44.0;
|
||||
static const railButtonSize = 32.0;
|
||||
static const railIconSize = 22.0;
|
||||
static const headerHeight = 40.0;
|
||||
static const contentInset = WorkspaceLayoutMetrics.desktopSpacing;
|
||||
final bool integratedTitlebar;
|
||||
final Widget headerControls;
|
||||
final bool librarySelected;
|
||||
final bool settingsSelected;
|
||||
final ValueChanged<WorkspaceMode> onModeChanged;
|
||||
final VoidCallback? onLibraryPressed;
|
||||
final VoidCallback onSettingsPressed;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ColoredBox(
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(
|
||||
key: const Key('desktop-window-header'),
|
||||
height: headerHeight,
|
||||
child: WindowHeaderPadding(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
if (integratedTitlebar)
|
||||
SizedBox(
|
||||
key: const Key('native-window-controls-space'),
|
||||
width: EditorWindowChrome.leadingWidth,
|
||||
height: headerHeight,
|
||||
),
|
||||
headerControls,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
key: const Key('desktop-navigation-rail'),
|
||||
width: railWidth,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
for (final library in [false, true])
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: IconButton.filledTonal(
|
||||
key: ValueKey(
|
||||
library
|
||||
? 'desktop-rail-library'
|
||||
: 'desktop-rail-cut',
|
||||
),
|
||||
tooltip: library
|
||||
? context.l10n.navigationLibrary
|
||||
: context.l10n.navigationChat,
|
||||
isSelected:
|
||||
!settingsSelected && library == librarySelected,
|
||||
style: IconButton.styleFrom(
|
||||
fixedSize: const Size.square(railButtonSize),
|
||||
minimumSize: const Size.square(railButtonSize),
|
||||
maximumSize: const Size.square(railButtonSize),
|
||||
padding: EdgeInsets.zero,
|
||||
iconSize: railIconSize,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
backgroundColor:
|
||||
!settingsSelected &&
|
||||
library == librarySelected
|
||||
? null
|
||||
: Colors.transparent,
|
||||
),
|
||||
onPressed: library
|
||||
? onLibraryPressed
|
||||
: () => onModeChanged(WorkspaceMode.cut),
|
||||
icon: Icon(
|
||||
library
|
||||
? Icons.video_library_outlined
|
||||
: Icons.chat_bubble_outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
key: const Key('project-settings-button'),
|
||||
tooltip: context.l10n.settings,
|
||||
isSelected: settingsSelected,
|
||||
onPressed: onSettingsPressed,
|
||||
style: IconButton.styleFrom(
|
||||
fixedSize: const Size.square(railButtonSize),
|
||||
minimumSize: const Size.square(railButtonSize),
|
||||
maximumSize: const Size.square(railButtonSize),
|
||||
padding: EdgeInsets.zero,
|
||||
iconSize: railIconSize,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
icon: const Icon(Icons.settings_outlined),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
right: contentInset,
|
||||
bottom: contentInset,
|
||||
),
|
||||
child: SizedBox(
|
||||
key: const Key('desktop-content-container'),
|
||||
child: WindowHeaderPane(
|
||||
offset: const Offset(railWidth, headerHeight),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) =>
|
||||
constraints.maxWidth < 200
|
||||
? SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: 200,
|
||||
height: constraints.maxHeight,
|
||||
child: child,
|
||||
),
|
||||
)
|
||||
: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1,22 +1,18 @@
|
||||
import '../adaptive/desktop_workspace_controller.dart';
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../workspace/workspace_mode.dart';
|
||||
import '../../shared/layout/workspace_layout_metrics.dart';
|
||||
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
|
||||
import '../adaptive/desktop_workspace_controller.dart';
|
||||
import '../adaptive/workspace_layout_policy.dart';
|
||||
import '../../shared/layout/workspace_layout_metrics.dart';
|
||||
import '../../shared/widgets/workspace_card.dart';
|
||||
import '../../shared/widgets/workspace_resize_handle.dart';
|
||||
import '../../workspace/workspace_mode.dart';
|
||||
|
||||
typedef WorkspaceSidebarBuilder = Widget Function(
|
||||
DesktopWorkspaceGeometry geometry,
|
||||
VoidCallback expandEditor,
|
||||
);
|
||||
|
||||
/// Arranges slots and handles splitters; it does not own editing sessions.
|
||||
/// Three independent desktop surfaces with resize gutters between them.
|
||||
class DesktopWorkspaceShell extends StatefulWidget {
|
||||
const DesktopWorkspaceShell({
|
||||
super.key,
|
||||
@@ -27,11 +23,13 @@ class DesktopWorkspaceShell extends StatefulWidget {
|
||||
required this.onSidebarCollapsedChanged,
|
||||
required this.onSidebarWidthChanged,
|
||||
required this.sidebarBuilder,
|
||||
required this.agentBuilder,
|
||||
required this.editor,
|
||||
required this.scaffoldKey,
|
||||
required this.navigationDrawer,
|
||||
});
|
||||
|
||||
static const gutterWidth = WorkspaceLayoutMetrics.desktopSpacing;
|
||||
final WorkspaceMode mode;
|
||||
final DesktopWorkspaceController controller;
|
||||
final bool sidebarCollapsed;
|
||||
@@ -39,6 +37,7 @@ class DesktopWorkspaceShell extends StatefulWidget {
|
||||
final ValueChanged<bool> onSidebarCollapsedChanged;
|
||||
final ValueChanged<double> onSidebarWidthChanged;
|
||||
final WorkspaceSidebarBuilder sidebarBuilder;
|
||||
final WorkspaceSidebarBuilder agentBuilder;
|
||||
final Widget editor;
|
||||
final GlobalKey<ScaffoldState> scaffoldKey;
|
||||
final Widget navigationDrawer;
|
||||
@@ -48,9 +47,6 @@ class DesktopWorkspaceShell extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
|
||||
double? get _agentWidth => widget.controller.agentWidth;
|
||||
bool get _editorCollapsedByAgent => widget.controller.editorCollapsedByAgent;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -74,65 +70,101 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
double? _sidebarDragStart;
|
||||
double _sidebarDragWidth = 0;
|
||||
double? _agentDragStart;
|
||||
double _agentDragWidth = 0;
|
||||
Widget _card(String name, Widget child) =>
|
||||
WorkspaceCard(key: Key('desktop-$name-card'), child: child);
|
||||
|
||||
Widget _gutter({
|
||||
required String name,
|
||||
required double initialWidth,
|
||||
required ValueChanged<double> onResize,
|
||||
double direction = 1,
|
||||
VoidCallback? onEnd,
|
||||
}) => SizedBox(
|
||||
width: WorkspaceLayoutMetrics.desktopResizeHitExtent,
|
||||
height: double.infinity,
|
||||
child: WorkspaceResizeHandle(
|
||||
key: Key('$name-resize'),
|
||||
axis: Axis.horizontal,
|
||||
initialValue: initialWidth,
|
||||
direction: direction,
|
||||
onResize: onResize,
|
||||
onEnd: onEnd,
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
const gap = DesktopWorkspaceShell.gutterWidth;
|
||||
final width = constraints.maxWidth;
|
||||
final geometry = DesktopWorkspaceGeometry.resolve(
|
||||
width: width,
|
||||
mode: widget.mode,
|
||||
final navigationGap = widget.sidebarCollapsed ? 0.0 : gap;
|
||||
final resolved = DesktopWorkspaceGeometry.resolve(
|
||||
// The geometry policy accounts for a one-pixel divider; reserve gutters.
|
||||
width: width - navigationGap - gap + 1,
|
||||
mode: WorkspaceMode.agent,
|
||||
sidebarCollapsed: widget.sidebarCollapsed,
|
||||
sidebarWidth: widget.sidebarWidth,
|
||||
agentWidth: _agentWidth,
|
||||
editorCollapsedByAgent: _editorCollapsedByAgent,
|
||||
agentWidth: widget.controller.agentWidth,
|
||||
agentFullscreen: widget.controller.agentFullscreen,
|
||||
);
|
||||
final navigationSpace = widget.sidebarCollapsed
|
||||
? 0.0
|
||||
: geometry.sidebarWidth;
|
||||
: resolved.sidebarWidth;
|
||||
final agentHidden =
|
||||
resolved.editorHidden &&
|
||||
widget.mode == WorkspaceMode.cut &&
|
||||
!widget.controller.agentFullscreen;
|
||||
final geometry = DesktopWorkspaceGeometry(
|
||||
sidebarWidth: resolved.sidebarWidth,
|
||||
agentWidth: agentHidden
|
||||
? 0
|
||||
: resolved.editorHidden
|
||||
? width - navigationSpace - navigationGap
|
||||
: resolved.agentWidth,
|
||||
editorHidden: resolved.editorHidden && !agentHidden,
|
||||
);
|
||||
final available = width - navigationSpace - navigationGap;
|
||||
void expandEditor() {
|
||||
final collapseNavigation = width - navigationSpace - 1 < 780;
|
||||
final collapseNavigation =
|
||||
available < 220 + gap + DesktopWorkspaceGeometry.editorMinimumWidth;
|
||||
if (collapseNavigation) widget.onSidebarCollapsedChanged(true);
|
||||
widget.controller.setSplit(
|
||||
width -
|
||||
(collapseNavigation ? 0 : navigationSpace) -
|
||||
DesktopWorkspaceGeometry.editorRestoreWidth -
|
||||
1,
|
||||
editorCollapsed: false,
|
||||
);
|
||||
widget.controller.setAgentFullscreen(false);
|
||||
}
|
||||
|
||||
void resizeAgent(double requested) {
|
||||
final maximum =
|
||||
available - gap - DesktopWorkspaceGeometry.editorMinimumWidth;
|
||||
if (maximum < 220) return;
|
||||
final agentWidth = requested.clamp(220.0, maximum);
|
||||
widget.controller.setAgentWidth(agentWidth);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
key: widget.scaffoldKey,
|
||||
backgroundColor: Colors.transparent,
|
||||
drawer: Drawer(
|
||||
width: 320,
|
||||
child: SafeArea(child: widget.navigationDrawer),
|
||||
),
|
||||
body: Stack(
|
||||
key: const Key('desktop-workspace-shell'),
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (!widget.sidebarCollapsed ||
|
||||
widget.mode == WorkspaceMode.agent)
|
||||
if (!widget.sidebarCollapsed) ...[
|
||||
SizedBox(
|
||||
width: navigationSpace + geometry.agentWidth,
|
||||
child: widget.sidebarBuilder(geometry, expandEditor),
|
||||
),
|
||||
if (!widget.sidebarCollapsed && !geometry.editorHidden)
|
||||
SizedBox(
|
||||
width: 1,
|
||||
height: double.infinity,
|
||||
child: ColoredBox(
|
||||
key: const Key('project-sidebar-separator'),
|
||||
color: AppTheme.sidebarDividerColor(context),
|
||||
width: navigationSpace,
|
||||
child: _card(
|
||||
'project',
|
||||
widget.sidebarBuilder(geometry, expandEditor),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
key: Key('project-sidebar-divider'),
|
||||
width: gap,
|
||||
),
|
||||
],
|
||||
Expanded(
|
||||
child: Offstage(
|
||||
key: const Key('editor-auto-collapse'),
|
||||
@@ -147,125 +179,66 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
|
||||
maxWidth: geometry.editorHidden
|
||||
? DesktopWorkspaceGeometry.editorRestoreWidth
|
||||
: null,
|
||||
child: WindowHeaderPane(
|
||||
offset: Offset(
|
||||
navigationSpace +
|
||||
geometry.agentWidth +
|
||||
(!widget.sidebarCollapsed &&
|
||||
!geometry.editorHidden
|
||||
? 1
|
||||
: 0),
|
||||
0,
|
||||
),
|
||||
child: SizedBox(
|
||||
key: const Key('desktop-editor-card'),
|
||||
child: widget.editor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!agentHidden && !geometry.editorHidden)
|
||||
const SizedBox(width: gap),
|
||||
if (!agentHidden)
|
||||
SizedBox(
|
||||
key: const Key('desktop-agent-slot'),
|
||||
width: geometry.agentWidth,
|
||||
child: _card(
|
||||
'agent',
|
||||
widget.agentBuilder(geometry, expandEditor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (!widget.sidebarCollapsed)
|
||||
Positioned(
|
||||
key: const Key('project-sidebar-divider'),
|
||||
top: AppControlSize.panelHeader,
|
||||
left:
|
||||
navigationSpace - WorkspaceLayoutMetrics.desktopResizeSlop,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: geometry.sidebarWidth - 4,
|
||||
width: 8,
|
||||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.resizeColumn,
|
||||
child: GestureDetector(
|
||||
key: const Key('project-sidebar-resize'),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
onHorizontalDragStart: (details) {
|
||||
_sidebarDragStart = details.globalPosition.dx;
|
||||
_sidebarDragWidth = geometry.sidebarWidth;
|
||||
},
|
||||
onHorizontalDragUpdate: (details) {
|
||||
final start = _sidebarDragStart;
|
||||
if (start == null) return;
|
||||
widget.onSidebarWidthChanged(
|
||||
(_sidebarDragWidth + details.globalPosition.dx - start)
|
||||
.clamp(
|
||||
WorkspaceLayoutMetrics.sidebarMinimumWidth,
|
||||
DesktopWorkspaceGeometry.sidebarMaximum(
|
||||
width,
|
||||
widget.mode,
|
||||
),
|
||||
)
|
||||
.toDouble(),
|
||||
);
|
||||
},
|
||||
onHorizontalDragEnd: (_) => _sidebarDragStart = null,
|
||||
onHorizontalDragCancel: () => _sidebarDragStart = null,
|
||||
child: const SizedBox.expand(),
|
||||
child: _gutter(
|
||||
name: 'project-sidebar',
|
||||
initialWidth: navigationSpace,
|
||||
onResize: (value) => widget.onSidebarWidthChanged(
|
||||
value.clamp(
|
||||
WorkspaceLayoutMetrics.sidebarMinimumWidth,
|
||||
DesktopWorkspaceGeometry.sidebarMaximum(
|
||||
width - 2 * gap + 1,
|
||||
WorkspaceMode.agent,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (widget.mode == WorkspaceMode.agent &&
|
||||
width - navigationSpace - 1 >= 220)
|
||||
if (!agentHidden && !geometry.editorHidden)
|
||||
Positioned(
|
||||
left: geometry.editorHidden
|
||||
? navigationSpace +
|
||||
navigationGap +
|
||||
(widget.sidebarCollapsed
|
||||
? 0
|
||||
: WorkspaceLayoutMetrics.desktopResizeSlop)
|
||||
: width -
|
||||
geometry.agentWidth -
|
||||
gap -
|
||||
WorkspaceLayoutMetrics.desktopResizeSlop,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left:
|
||||
navigationSpace +
|
||||
geometry.agentWidth -
|
||||
(geometry.editorHidden ? 8 : 4),
|
||||
width: 8,
|
||||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.resizeColumn,
|
||||
child: GestureDetector(
|
||||
key: const Key('agent-panel-resize'),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
onHorizontalDragStart: (details) {
|
||||
_agentDragStart = details.globalPosition.dx;
|
||||
_agentDragWidth = geometry.agentWidth;
|
||||
},
|
||||
onHorizontalDragUpdate: (details) {
|
||||
final start = _agentDragStart;
|
||||
if (start == null) return;
|
||||
final agentWidth =
|
||||
(_agentDragWidth + details.globalPosition.dx - start)
|
||||
.clamp(220.0, width - navigationSpace - 1);
|
||||
final remaining =
|
||||
width - navigationSpace - agentWidth - 1;
|
||||
widget.controller.setSplit(
|
||||
agentWidth,
|
||||
editorCollapsed: geometry.editorHidden
|
||||
? remaining <
|
||||
DesktopWorkspaceGeometry.editorRestoreWidth
|
||||
: remaining <=
|
||||
DesktopWorkspaceGeometry.editorCollapseWidth -
|
||||
DesktopWorkspaceGeometry
|
||||
.editorCollapseDragBuffer,
|
||||
);
|
||||
},
|
||||
onHorizontalDragEnd: (_) {
|
||||
_agentDragStart = null;
|
||||
if (!_editorCollapsedByAgent &&
|
||||
_agentWidth != null &&
|
||||
width -
|
||||
navigationSpace -
|
||||
DesktopWorkspaceGeometry.editorCollapseWidth -
|
||||
1 >=
|
||||
220) {
|
||||
widget.controller.setSplit(
|
||||
_agentWidth!.clamp(
|
||||
220.0,
|
||||
width -
|
||||
navigationSpace -
|
||||
DesktopWorkspaceGeometry.editorCollapseWidth -
|
||||
1,
|
||||
),
|
||||
editorCollapsed: false,
|
||||
);
|
||||
}
|
||||
},
|
||||
onHorizontalDragCancel: () => _agentDragStart = null,
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
child: _gutter(
|
||||
name: 'agent-panel',
|
||||
initialWidth: geometry.agentWidth,
|
||||
direction: -1,
|
||||
onResize: resizeAgent,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user