Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
79 lines
2.7 KiB
Dart
79 lines
2.7 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 +
|
|
1;
|
|
|
|
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 editorCollapseWidth = 480.0;
|
|
static const editorCollapseDragBuffer = editorCollapseWidth / 3;
|
|
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 editorCollapsedByAgent = 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 remaining = width - navigationSpace - requestedAgentWidth - 1;
|
|
final hidden =
|
|
mode == WorkspaceMode.agent &&
|
|
(width - navigationSpace - 1 < 220 + editorCollapseWidth ||
|
|
(editorCollapsedByAgent && remaining < editorRestoreWidth) ||
|
|
remaining <= editorCollapseWidth - editorCollapseDragBuffer);
|
|
return DesktopWorkspaceGeometry(
|
|
sidebarWidth: navigationWidth,
|
|
agentWidth: hidden
|
|
? width - navigationSpace
|
|
: mode == WorkspaceMode.agent
|
|
? requestedAgentWidth
|
|
.clamp(220.0, width - navigationSpace - editorCollapseWidth - 1)
|
|
.toDouble()
|
|
: 0,
|
|
editorHidden: hidden,
|
|
);
|
|
}
|
|
}
|