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
76 lines
2.5 KiB
Dart
76 lines
2.5 KiB
Dart
import 'dart:math' as math;
|
|
|
|
import '../../workspace/workspace_mode.dart';
|
|
import '../../shared/layout/workspace_layout_metrics.dart';
|
|
|
|
/// Spatial rules used within a device experience; never selects a device shell.
|
|
abstract final class WorkspaceLayoutPolicy {
|
|
static bool desktopNavigationFits(double width) =>
|
|
width >=
|
|
WorkspaceLayoutMetrics.sidebarMinimumWidth +
|
|
WorkspaceLayoutMetrics.contentMinimumWidth +
|
|
WorkspaceLayoutMetrics.desktopSpacing;
|
|
|
|
static bool showAgentBesideEditor(double width) =>
|
|
width >= WorkspaceLayoutMetrics.dualPaneMinimumWidth;
|
|
}
|
|
|
|
/// Desktop geometry is resolved without mutating preferences during build.
|
|
final class DesktopWorkspaceGeometry {
|
|
const DesktopWorkspaceGeometry({
|
|
required this.sidebarWidth,
|
|
required this.agentWidth,
|
|
required this.editorHidden,
|
|
});
|
|
|
|
static const editorMinimumWidth = 480.0;
|
|
static const editorRestoreWidth = 560.0;
|
|
|
|
final double sidebarWidth;
|
|
final double agentWidth;
|
|
final bool editorHidden;
|
|
|
|
static double sidebarMaximum(double width, WorkspaceMode mode) =>
|
|
WorkspaceLayoutMetrics.sidebarMaximumWidth(
|
|
width - (mode == WorkspaceMode.agent ? 221 : 0),
|
|
);
|
|
|
|
factory DesktopWorkspaceGeometry.resolve({
|
|
required double width,
|
|
required WorkspaceMode mode,
|
|
required bool sidebarCollapsed,
|
|
double? sidebarWidth,
|
|
double? agentWidth,
|
|
bool agentFullscreen = false,
|
|
}) {
|
|
final navigationWidth =
|
|
(sidebarWidth ?? WorkspaceLayoutMetrics.sidebarDefaultWidth)
|
|
.clamp(
|
|
WorkspaceLayoutMetrics.sidebarMinimumWidth,
|
|
sidebarMaximum(width, mode),
|
|
)
|
|
.toDouble();
|
|
final navigationSpace = sidebarCollapsed ? 0.0 : navigationWidth;
|
|
final requestedAgentWidth = mode == WorkspaceMode.agent
|
|
? (agentWidth ?? (width * .25).clamp(260.0, 320.0))
|
|
.clamp(220.0, math.max(220.0, width - navigationSpace - 1))
|
|
.toDouble()
|
|
: 0.0;
|
|
final hidden =
|
|
mode == WorkspaceMode.agent &&
|
|
(width - navigationSpace - 1 < 220 + editorMinimumWidth ||
|
|
agentFullscreen);
|
|
return DesktopWorkspaceGeometry(
|
|
sidebarWidth: navigationWidth,
|
|
agentWidth: hidden
|
|
? width - navigationSpace
|
|
: mode == WorkspaceMode.agent
|
|
? requestedAgentWidth
|
|
.clamp(220.0, width - navigationSpace - editorMinimumWidth - 1)
|
|
.toDouble()
|
|
: 0,
|
|
editorHidden: hidden,
|
|
);
|
|
}
|
|
}
|