feat(workspace): 桌面工作区、主题与交互更新,发布 0.1.2
Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s
Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s
This commit was merged in pull request #13.
This commit is contained in:
1 parent
aa5255d1e4
commit
abc1868550
260 files changed
+43964
-5591
No files matched your search
@@ -1,4 +1,8 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex_ui/widgets.dart';
|
||||
|
||||
import '../adaptive/desktop_workspace_controller.dart';
|
||||
import '../adaptive/workspace_layout_policy.dart';
|
||||
@@ -27,6 +31,7 @@ class DesktopWorkspaceShell extends StatefulWidget {
|
||||
required this.editor,
|
||||
required this.scaffoldKey,
|
||||
required this.navigationDrawer,
|
||||
this.projectTabsLayout = false,
|
||||
});
|
||||
|
||||
static const gutterWidth = WorkspaceLayoutMetrics.desktopSpacing;
|
||||
@@ -41,6 +46,7 @@ class DesktopWorkspaceShell extends StatefulWidget {
|
||||
final Widget editor;
|
||||
final GlobalKey<ScaffoldState> scaffoldKey;
|
||||
final Widget navigationDrawer;
|
||||
final bool projectTabsLayout;
|
||||
|
||||
@override
|
||||
State<DesktopWorkspaceShell> createState() => _DesktopWorkspaceShellState();
|
||||
@@ -93,58 +99,238 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
Widget build(BuildContext context) => widget.projectTabsLayout
|
||||
? _projectWorkspace(context)
|
||||
: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
const gap = DesktopWorkspaceShell.gutterWidth;
|
||||
final width = constraints.maxWidth;
|
||||
final requestedFloating = widget.controller.agentFloating;
|
||||
final showAgent =
|
||||
widget.mode == WorkspaceMode.agent ||
|
||||
widget.controller.agentVisible;
|
||||
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: requestedFloating || !showAgent
|
||||
? WorkspaceMode.cut
|
||||
: WorkspaceMode.agent,
|
||||
sidebarCollapsed: widget.sidebarCollapsed,
|
||||
sidebarWidth: widget.sidebarWidth,
|
||||
agentWidth: widget.controller.agentWidth,
|
||||
agentFullscreen: widget.controller.agentFullscreen,
|
||||
);
|
||||
final navigationSpace = widget.sidebarCollapsed
|
||||
? 0.0
|
||||
: resolved.sidebarWidth;
|
||||
final floating =
|
||||
requestedFloating ||
|
||||
(showAgent &&
|
||||
widget.mode == WorkspaceMode.cut &&
|
||||
resolved.editorHidden &&
|
||||
!widget.controller.agentFullscreen);
|
||||
final agentHidden =
|
||||
floating ||
|
||||
!showAgent ||
|
||||
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 =
|
||||
available <
|
||||
220 + gap + DesktopWorkspaceGeometry.editorMinimumWidth;
|
||||
if (collapseNavigation) widget.onSidebarCollapsedChanged(true);
|
||||
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'),
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (!widget.sidebarCollapsed) ...[
|
||||
SizedBox(
|
||||
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'),
|
||||
offstage: geometry.editorHidden,
|
||||
child: TickerMode(
|
||||
enabled: !geometry.editorHidden,
|
||||
child: OverflowBox(
|
||||
alignment: Alignment.topLeft,
|
||||
minWidth: geometry.editorHidden
|
||||
? DesktopWorkspaceGeometry.editorRestoreWidth
|
||||
: null,
|
||||
maxWidth: geometry.editorHidden
|
||||
? DesktopWorkspaceGeometry.editorRestoreWidth
|
||||
: null,
|
||||
child: SizedBox(
|
||||
key: const Key('desktop-editor-card'),
|
||||
child: widget.editor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!agentHidden && !geometry.editorHidden)
|
||||
const SizedBox(width: gap),
|
||||
if (!floating)
|
||||
Offstage(
|
||||
offstage: agentHidden,
|
||||
child: ExcludeFocus(
|
||||
excluding: agentHidden,
|
||||
child: TickerMode(
|
||||
enabled: !agentHidden,
|
||||
child: SizedBox(
|
||||
key: const Key('desktop-agent-slot'),
|
||||
width: agentHidden
|
||||
? widget.controller.agentWidth ?? 320
|
||||
: geometry.agentWidth,
|
||||
child: _card(
|
||||
'agent',
|
||||
widget.agentBuilder(geometry, expandEditor),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (floating)
|
||||
Positioned(
|
||||
key: const Key('agent-floating-window'),
|
||||
right: 12,
|
||||
bottom: 12,
|
||||
width: math.min(560, math.max(0, available - 24)),
|
||||
child: AppFloatingDialog(
|
||||
key: const Key('floating-agent-dialog'),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(22),
|
||||
),
|
||||
backgroundColor: AppSurfaces.of(context)
|
||||
.composerBackground,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: math.min(
|
||||
640,
|
||||
math.max(0, constraints.maxHeight - 24),
|
||||
),
|
||||
),
|
||||
child: widget.agentBuilder(geometry, expandEditor),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!widget.sidebarCollapsed)
|
||||
Positioned(
|
||||
left:
|
||||
navigationSpace -
|
||||
WorkspaceLayoutMetrics.desktopResizeSlop,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: _gutter(
|
||||
name: 'project-sidebar',
|
||||
initialWidth: navigationSpace,
|
||||
onResize: (value) => widget.onSidebarWidthChanged(
|
||||
value.clamp(
|
||||
WorkspaceLayoutMetrics.sidebarMinimumWidth,
|
||||
DesktopWorkspaceGeometry.sidebarMaximum(
|
||||
width - 2 * gap + 1,
|
||||
WorkspaceMode.agent,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
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,
|
||||
child: _gutter(
|
||||
name: 'agent-panel',
|
||||
initialWidth: geometry.agentWidth,
|
||||
direction: -1,
|
||||
onResize: resizeAgent,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Widget _projectWorkspace(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
const gap = DesktopWorkspaceShell.gutterWidth;
|
||||
final width = constraints.maxWidth;
|
||||
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: widget.controller.agentWidth,
|
||||
agentFullscreen: widget.controller.agentFullscreen,
|
||||
);
|
||||
final navigationSpace = widget.sidebarCollapsed
|
||||
? 0.0
|
||||
: resolved.sidebarWidth;
|
||||
final agentHidden =
|
||||
resolved.editorHidden &&
|
||||
widget.mode == WorkspaceMode.cut &&
|
||||
!widget.controller.agentFullscreen;
|
||||
final maximum = WorkspaceLayoutMetrics.sidebarMaximumWidth(width - gap);
|
||||
final sidebarWidth =
|
||||
(widget.sidebarWidth ?? WorkspaceLayoutMetrics.sidebarDefaultWidth)
|
||||
.clamp(WorkspaceLayoutMetrics.sidebarMinimumWidth, maximum)
|
||||
.toDouble();
|
||||
final floating = widget.controller.agentFloating;
|
||||
final collapsed = widget.sidebarCollapsed || floating;
|
||||
final geometry = DesktopWorkspaceGeometry(
|
||||
sidebarWidth: resolved.sidebarWidth,
|
||||
agentWidth: agentHidden
|
||||
? 0
|
||||
: resolved.editorHidden
|
||||
? width - navigationSpace - navigationGap
|
||||
: resolved.agentWidth,
|
||||
editorHidden: resolved.editorHidden && !agentHidden,
|
||||
sidebarWidth: sidebarWidth,
|
||||
agentWidth: 0,
|
||||
editorHidden: false,
|
||||
);
|
||||
final available = width - navigationSpace - navigationGap;
|
||||
void expandEditor() {
|
||||
final collapseNavigation =
|
||||
available < 220 + gap + DesktopWorkspaceGeometry.editorMinimumWidth;
|
||||
if (collapseNavigation) widget.onSidebarCollapsedChanged(true);
|
||||
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),
|
||||
child: SafeArea(
|
||||
// The drawer and floating panel share the conversation widget.
|
||||
child: floating ? const SizedBox.shrink() : widget.navigationDrawer,
|
||||
),
|
||||
),
|
||||
body: Stack(
|
||||
key: const Key('desktop-workspace-shell'),
|
||||
@@ -152,93 +338,61 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (!widget.sidebarCollapsed) ...[
|
||||
if (!collapsed) ...[
|
||||
SizedBox(
|
||||
width: navigationSpace,
|
||||
width: sidebarWidth,
|
||||
child: _card(
|
||||
'project',
|
||||
widget.sidebarBuilder(geometry, expandEditor),
|
||||
'chat',
|
||||
widget.sidebarBuilder(geometry, () {}),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
key: Key('project-sidebar-divider'),
|
||||
width: gap,
|
||||
),
|
||||
const SizedBox(width: gap),
|
||||
],
|
||||
Expanded(
|
||||
child: Offstage(
|
||||
key: const Key('editor-auto-collapse'),
|
||||
offstage: geometry.editorHidden,
|
||||
child: TickerMode(
|
||||
enabled: !geometry.editorHidden,
|
||||
child: OverflowBox(
|
||||
alignment: Alignment.topLeft,
|
||||
minWidth: geometry.editorHidden
|
||||
? DesktopWorkspaceGeometry.editorRestoreWidth
|
||||
: null,
|
||||
maxWidth: geometry.editorHidden
|
||||
? DesktopWorkspaceGeometry.editorRestoreWidth
|
||||
: null,
|
||||
child: SizedBox(
|
||||
key: const Key('desktop-editor-card'),
|
||||
child: widget.editor,
|
||||
),
|
||||
),
|
||||
),
|
||||
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)
|
||||
if (!collapsed)
|
||||
Positioned(
|
||||
left:
|
||||
navigationSpace - WorkspaceLayoutMetrics.desktopResizeSlop,
|
||||
left: sidebarWidth - WorkspaceLayoutMetrics.desktopResizeSlop,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: _gutter(
|
||||
name: 'project-sidebar',
|
||||
initialWidth: navigationSpace,
|
||||
initialWidth: sidebarWidth,
|
||||
onResize: (value) => widget.onSidebarWidthChanged(
|
||||
value.clamp(
|
||||
WorkspaceLayoutMetrics.sidebarMinimumWidth,
|
||||
DesktopWorkspaceGeometry.sidebarMaximum(
|
||||
width - 2 * gap + 1,
|
||||
WorkspaceMode.agent,
|
||||
),
|
||||
maximum,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!agentHidden && !geometry.editorHidden)
|
||||
if (floating)
|
||||
Positioned(
|
||||
left: geometry.editorHidden
|
||||
? navigationSpace +
|
||||
navigationGap +
|
||||
(widget.sidebarCollapsed
|
||||
? 0
|
||||
: WorkspaceLayoutMetrics.desktopResizeSlop)
|
||||
: width -
|
||||
geometry.agentWidth -
|
||||
gap -
|
||||
WorkspaceLayoutMetrics.desktopResizeSlop,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: _gutter(
|
||||
name: 'agent-panel',
|
||||
initialWidth: geometry.agentWidth,
|
||||
direction: -1,
|
||||
onResize: resizeAgent,
|
||||
key: const Key('agent-floating-window'),
|
||||
right: 12,
|
||||
bottom: 12,
|
||||
width: math.min(560, math.max(0, width - 24)),
|
||||
child: AppFloatingDialog(
|
||||
key: const Key('floating-agent-dialog'),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(22),
|
||||
),
|
||||
backgroundColor: AppSurfaces.of(context).composerBackground,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: math.min(
|
||||
640,
|
||||
math.max(0, constraints.maxHeight - 24),
|
||||
),
|
||||
),
|
||||
child: widget.agentBuilder(geometry, () {}),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user