feat: initial Cutdex application
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.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,16 @@
|
||||
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;
|
||||
|
||||
double? get agentWidth => _agentWidth;
|
||||
bool get editorCollapsedByAgent => _editorCollapsedByAgent;
|
||||
|
||||
void setSplit(double? width, {required bool editorCollapsed}) {
|
||||
_agentWidth = width;
|
||||
_editorCollapsedByAgent = editorCollapsed;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import 'package:cutdex/app/editor_theme.dart';
|
||||
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../features/settings/language_settings.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'router/app_router.dart';
|
||||
import '../integrations/app_updates.dart';
|
||||
import '../integrations/editor_tools.dart';
|
||||
import '../features/settings/appearance_settings.dart';
|
||||
|
||||
class CutdexApp extends ConsumerWidget {
|
||||
const CutdexApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
ref.watch(applicationMcpConnectionProvider);
|
||||
ref.watch(appUpdateLifecycleProvider);
|
||||
final appearance =
|
||||
ref.watch(appearanceSettingsProvider).asData?.value ??
|
||||
AppAppearance.system;
|
||||
return MaterialApp.router(
|
||||
title: 'Cutdex',
|
||||
locale: ref.watch(languageSettingsProvider).asData?.value.locale,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localeListResolutionCallback: resolveAppLocale,
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: EditorTheme.penLight,
|
||||
darkTheme: EditorTheme.penDark,
|
||||
themeMode: appearance.themeMode,
|
||||
routerConfig: ref.watch(appRouterProvider),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex_sdk/timeline_ui.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Connects the application palette to the SDK timeline presentation.
|
||||
abstract final class EditorTheme {
|
||||
static ThemeData get penLight => adapt(AppTheme.penLight);
|
||||
static ThemeData get penDark => adapt(AppTheme.penDark);
|
||||
|
||||
static ThemeData adapt(ThemeData theme) {
|
||||
final palette = theme.brightness == Brightness.dark
|
||||
? AppColors.penDark
|
||||
: AppColors.penLight;
|
||||
final dark = theme.brightness == Brightness.dark;
|
||||
final text = theme.textTheme;
|
||||
final timelineBorder = palette.divider;
|
||||
final timelineSecondary = dark
|
||||
? palette.foreground.withValues(alpha: .71)
|
||||
: palette.mutedForeground;
|
||||
final timelineTertiary = dark
|
||||
? palette.foreground.withValues(alpha: .498)
|
||||
: palette.mutedForeground.withValues(alpha: .8);
|
||||
return theme.copyWith(
|
||||
extensions: [
|
||||
...theme.extensions.values,
|
||||
const TimelineThemeData.dark().copyWith(
|
||||
backgroundColor: palette.background,
|
||||
primaryLaneBackgroundColor: palette.sidebar,
|
||||
visualClipColor: palette.visualClip,
|
||||
audioClipColor: palette.popover,
|
||||
audioAccentColor: timelineSecondary,
|
||||
gapColor: timelineBorder,
|
||||
gapBorderColor: timelineBorder,
|
||||
containerAccentColor: timelineSecondary,
|
||||
transitionColor: timelineTertiary,
|
||||
connectionLineColor: timelineBorder,
|
||||
connectionLineWidth: 3,
|
||||
clipBorderColor: timelineBorder,
|
||||
clipBorderWidth: 1,
|
||||
selectionOutlineColor: palette.foreground,
|
||||
selectionOutlineWidth: 2,
|
||||
keyframeColor: timelineSecondary,
|
||||
keyframeBorderColor: palette.background,
|
||||
keyframeInvalidColor: palette.destructive,
|
||||
disabledOverlayColor: palette.background.withValues(alpha: 0.5),
|
||||
outsideSourceRangeOverlayColor: palette.background.withValues(
|
||||
alpha: 0.65,
|
||||
),
|
||||
clipCornerRadius: AppRadius.small,
|
||||
clipHeaderHeight: 16,
|
||||
clipHeaderPadding: 2,
|
||||
clipNameTextStyle: text.bodySmall!.copyWith(
|
||||
color: palette.foreground,
|
||||
fontSize: 10,
|
||||
height: 1.4,
|
||||
),
|
||||
rulerHeight: 20,
|
||||
rulerBackgroundColor: palette.background,
|
||||
rulerTickColor: timelineTertiary,
|
||||
rulerTextStyle: text.bodySmall!.copyWith(
|
||||
height: 16 / 12,
|
||||
color: timelineSecondary,
|
||||
),
|
||||
playheadColor: palette.foreground,
|
||||
scrollbarThickness: AppSpacing.compact,
|
||||
scrollbarTrackColor: Colors.transparent,
|
||||
scrollbarThumbColor: palette.foreground.withValues(alpha: .084),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import 'package:cutdex/l10n/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../../features/projects/projects_page.dart';
|
||||
|
||||
part 'app_router.g.dart';
|
||||
|
||||
// The router is an application resource, independent of editor state changes.
|
||||
@Riverpod(keepAlive: true)
|
||||
GoRouter appRouter(Ref ref) {
|
||||
final router = GoRouter(
|
||||
routes: [
|
||||
GoRoute(path: '/', builder: (context, state) => const EditingPage()),
|
||||
],
|
||||
errorBuilder: (context, state) => Scaffold(
|
||||
body: Center(
|
||||
child: FilledButton(
|
||||
onPressed: () => context.go('/'),
|
||||
child: Text(context.l10n.backToProjects),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
ref.onDispose(router.dispose);
|
||||
return router;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'app_router.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(appRouter)
|
||||
final appRouterProvider = AppRouterProvider._();
|
||||
|
||||
final class AppRouterProvider
|
||||
extends $FunctionalProvider<GoRouter, GoRouter, GoRouter>
|
||||
with $Provider<GoRouter> {
|
||||
AppRouterProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'appRouterProvider',
|
||||
isAutoDispose: false,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$appRouterHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
$ProviderElement<GoRouter> $createElement($ProviderPointer pointer) =>
|
||||
$ProviderElement(pointer);
|
||||
|
||||
@override
|
||||
GoRouter create(Ref ref) {
|
||||
return appRouter(ref);
|
||||
}
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(GoRouter value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<GoRouter>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$appRouterHash() => r'ebb3f9239a43568767def98552081806bd614bb4';
|
||||
@@ -0,0 +1,276 @@
|
||||
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/workspace_layout_policy.dart';
|
||||
|
||||
typedef WorkspaceSidebarBuilder = Widget Function(
|
||||
DesktopWorkspaceGeometry geometry,
|
||||
VoidCallback expandEditor,
|
||||
);
|
||||
|
||||
/// Arranges slots and handles splitters; it does not own editing sessions.
|
||||
class DesktopWorkspaceShell extends StatefulWidget {
|
||||
const DesktopWorkspaceShell({
|
||||
super.key,
|
||||
required this.mode,
|
||||
required this.controller,
|
||||
required this.sidebarCollapsed,
|
||||
required this.sidebarWidth,
|
||||
required this.onSidebarCollapsedChanged,
|
||||
required this.onSidebarWidthChanged,
|
||||
required this.sidebarBuilder,
|
||||
required this.editor,
|
||||
required this.scaffoldKey,
|
||||
required this.navigationDrawer,
|
||||
});
|
||||
|
||||
final WorkspaceMode mode;
|
||||
final DesktopWorkspaceController controller;
|
||||
final bool sidebarCollapsed;
|
||||
final double? sidebarWidth;
|
||||
final ValueChanged<bool> onSidebarCollapsedChanged;
|
||||
final ValueChanged<double> onSidebarWidthChanged;
|
||||
final WorkspaceSidebarBuilder sidebarBuilder;
|
||||
final Widget editor;
|
||||
final GlobalKey<ScaffoldState> scaffoldKey;
|
||||
final Widget navigationDrawer;
|
||||
|
||||
@override
|
||||
State<DesktopWorkspaceShell> createState() => _DesktopWorkspaceShellState();
|
||||
}
|
||||
|
||||
class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
|
||||
double? get _agentWidth => widget.controller.agentWidth;
|
||||
bool get _editorCollapsedByAgent => widget.controller.editorCollapsedByAgent;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
widget.controller.addListener(_changed);
|
||||
}
|
||||
|
||||
void _changed() => setState(() {});
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant DesktopWorkspaceShell oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.controller != widget.controller) {
|
||||
oldWidget.controller.removeListener(_changed);
|
||||
widget.controller.addListener(_changed);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
widget.controller.removeListener(_changed);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
double? _sidebarDragStart;
|
||||
double _sidebarDragWidth = 0;
|
||||
double? _agentDragStart;
|
||||
double _agentDragWidth = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final width = constraints.maxWidth;
|
||||
final geometry = DesktopWorkspaceGeometry.resolve(
|
||||
width: width,
|
||||
mode: widget.mode,
|
||||
sidebarCollapsed: widget.sidebarCollapsed,
|
||||
sidebarWidth: widget.sidebarWidth,
|
||||
agentWidth: _agentWidth,
|
||||
editorCollapsedByAgent: _editorCollapsedByAgent,
|
||||
);
|
||||
final navigationSpace = widget.sidebarCollapsed
|
||||
? 0.0
|
||||
: geometry.sidebarWidth;
|
||||
void expandEditor() {
|
||||
final collapseNavigation = width - navigationSpace - 1 < 780;
|
||||
if (collapseNavigation) widget.onSidebarCollapsedChanged(true);
|
||||
widget.controller.setSplit(
|
||||
width -
|
||||
(collapseNavigation ? 0 : navigationSpace) -
|
||||
DesktopWorkspaceGeometry.editorRestoreWidth -
|
||||
1,
|
||||
editorCollapsed: false,
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
key: widget.scaffoldKey,
|
||||
drawer: Drawer(
|
||||
width: 320,
|
||||
child: SafeArea(child: widget.navigationDrawer),
|
||||
),
|
||||
body: Stack(
|
||||
key: const Key('desktop-workspace-shell'),
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
if (!widget.sidebarCollapsed ||
|
||||
widget.mode == WorkspaceMode.agent)
|
||||
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),
|
||||
),
|
||||
),
|
||||
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: WindowHeaderPane(
|
||||
offset: Offset(
|
||||
navigationSpace +
|
||||
geometry.agentWidth +
|
||||
(!widget.sidebarCollapsed &&
|
||||
!geometry.editorHidden
|
||||
? 1
|
||||
: 0),
|
||||
0,
|
||||
),
|
||||
child: widget.editor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (!widget.sidebarCollapsed)
|
||||
Positioned(
|
||||
key: const Key('project-sidebar-divider'),
|
||||
top: AppControlSize.panelHeader,
|
||||
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(),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (widget.mode == WorkspaceMode.agent &&
|
||||
width - navigationSpace - 1 >= 220)
|
||||
Positioned(
|
||||
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(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../l10n/l10n.dart';
|
||||
|
||||
import '../../workspace/workspace_mode.dart';
|
||||
import 'workspace_frame.dart';
|
||||
|
||||
/// A focused surface; hidden features keep their state in workspace controllers.
|
||||
class PhoneWorkspaceShell extends StatelessWidget {
|
||||
const PhoneWorkspaceShell({
|
||||
super.key,
|
||||
required this.mode,
|
||||
required this.onModeChanged,
|
||||
required this.navigation,
|
||||
required this.headerActions,
|
||||
required this.title,
|
||||
required this.integratedTitlebar,
|
||||
required this.agent,
|
||||
required this.editor,
|
||||
});
|
||||
|
||||
final WorkspaceMode mode;
|
||||
final ValueChanged<WorkspaceMode> onModeChanged;
|
||||
final Widget navigation;
|
||||
final Widget headerActions;
|
||||
final String title;
|
||||
final bool integratedTitlebar;
|
||||
final Widget agent;
|
||||
final Widget editor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => WorkspaceFrame(
|
||||
key: const Key('phone-workspace-shell'),
|
||||
navigation: navigation,
|
||||
headerActions: headerActions,
|
||||
title: title,
|
||||
integratedTitlebar: integratedTitlebar,
|
||||
bottomNavigationBar: NavigationBar(
|
||||
height: 64,
|
||||
selectedIndex: mode == WorkspaceMode.agent ? 0 : 1,
|
||||
onDestinationSelected: (index) =>
|
||||
onModeChanged(index == 0 ? WorkspaceMode.agent : WorkspaceMode.cut),
|
||||
destinations: [
|
||||
NavigationDestination(
|
||||
key: const Key('workspace-agent-destination'),
|
||||
icon: const Icon(Icons.chat_bubble_outline),
|
||||
label: context.l10n.workspaceAgent,
|
||||
),
|
||||
NavigationDestination(
|
||||
key: const Key('workspace-cut-destination'),
|
||||
icon: const Icon(Icons.movie_outlined),
|
||||
label: context.l10n.workspaceCut,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: mode == WorkspaceMode.agent ? agent : editor,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../l10n/l10n.dart';
|
||||
|
||||
import '../../workspace/workspace_mode.dart';
|
||||
import '../adaptive/workspace_layout_policy.dart';
|
||||
import 'workspace_frame.dart';
|
||||
|
||||
/// Two working surfaces when space permits, with project navigation on demand.
|
||||
class TabletWorkspaceShell extends StatelessWidget {
|
||||
const TabletWorkspaceShell({
|
||||
super.key,
|
||||
required this.mode,
|
||||
required this.onModeChanged,
|
||||
required this.navigation,
|
||||
required this.headerActions,
|
||||
required this.title,
|
||||
required this.integratedTitlebar,
|
||||
required this.agent,
|
||||
required this.editor,
|
||||
});
|
||||
|
||||
final WorkspaceMode mode;
|
||||
final ValueChanged<WorkspaceMode> onModeChanged;
|
||||
final Widget navigation;
|
||||
final Widget headerActions;
|
||||
final String title;
|
||||
final bool integratedTitlebar;
|
||||
final Widget agent;
|
||||
final Widget editor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => WorkspaceFrame(
|
||||
key: const Key('tablet-workspace-shell'),
|
||||
navigation: navigation,
|
||||
headerActions: headerActions,
|
||||
title: title,
|
||||
integratedTitlebar: integratedTitlebar,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 72,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
height: math.max(240, constraints.maxHeight),
|
||||
child: NavigationRail(
|
||||
selectedIndex: mode == WorkspaceMode.agent ? 0 : 1,
|
||||
labelType: NavigationRailLabelType.all,
|
||||
onDestinationSelected: (index) => onModeChanged(
|
||||
index == 0 ? WorkspaceMode.agent : WorkspaceMode.cut,
|
||||
),
|
||||
destinations: [
|
||||
NavigationRailDestination(
|
||||
icon: const Icon(
|
||||
Icons.chat_bubble_outline,
|
||||
key: Key('workspace-agent-destination'),
|
||||
),
|
||||
label: Text(context.l10n.workspaceAgent),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: const Icon(
|
||||
Icons.movie_outlined,
|
||||
key: Key('workspace-cut-destination'),
|
||||
),
|
||||
label: Text(context.l10n.workspaceCut),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const VerticalDivider(width: 1),
|
||||
Expanded(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) =>
|
||||
mode == WorkspaceMode.agent &&
|
||||
WorkspaceLayoutPolicy.showAgentBesideEditor(
|
||||
constraints.maxWidth,
|
||||
)
|
||||
? Row(
|
||||
children: [
|
||||
SizedBox(width: constraints.maxWidth * .38, child: agent),
|
||||
const VerticalDivider(width: 1),
|
||||
Expanded(child: editor),
|
||||
],
|
||||
)
|
||||
: mode == WorkspaceMode.agent
|
||||
? agent
|
||||
: editor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../integrations/platform/editor_window_chrome.dart';
|
||||
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
|
||||
import '../../l10n/l10n.dart';
|
||||
|
||||
/// Navigation and mode controls for bounded workspaces. Drawer visibility is
|
||||
/// local presentation state and never overwrites the desktop sidebar preference.
|
||||
class WorkspaceFrame extends StatelessWidget {
|
||||
const WorkspaceFrame({
|
||||
super.key,
|
||||
required this.navigation,
|
||||
required this.headerActions,
|
||||
required this.title,
|
||||
required this.integratedTitlebar,
|
||||
required this.child,
|
||||
this.bottomNavigationBar,
|
||||
});
|
||||
|
||||
final Widget navigation;
|
||||
final Widget headerActions;
|
||||
final String title;
|
||||
final bool integratedTitlebar;
|
||||
final Widget child;
|
||||
final Widget? bottomNavigationBar;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
drawer: Drawer(width: 320, child: SafeArea(child: navigation)),
|
||||
body: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
key: const Key('workspace-window-header'),
|
||||
height: 48,
|
||||
child: WindowHeaderPadding(
|
||||
child: Row(
|
||||
children: [
|
||||
if (integratedTitlebar)
|
||||
SizedBox(width: EditorWindowChrome.leadingWidth),
|
||||
HeaderControlRegion(
|
||||
child: Builder(
|
||||
builder: (context) => IconButton(
|
||||
key: const Key('workspace-navigation-button'),
|
||||
tooltip: context.l10n.expandSidebar,
|
||||
onPressed: () => Scaffold.of(context).openDrawer(),
|
||||
icon: const Icon(Icons.menu),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
headerActions,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
Expanded(child: child),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: bottomNavigationBar,
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user