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,6 +1,6 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
enum DesktopContent { workspace, library, settings }
|
||||
enum DesktopContent { workspace, library, resourceLibrary, settings }
|
||||
|
||||
typedef DesktopContentSelection = ({
|
||||
DesktopContent surface,
|
||||
@@ -9,6 +9,7 @@ typedef DesktopContentSelection = ({
|
||||
(String, String)? workspace,
|
||||
bool settingsVisited,
|
||||
bool resourcesSelected,
|
||||
bool librarySelected,
|
||||
});
|
||||
|
||||
final desktopContentProvider =
|
||||
@@ -18,6 +19,8 @@ final desktopContentProvider =
|
||||
|
||||
/// Navigation changes visibility without disposing any visited content.
|
||||
class DesktopContentController extends Notifier<DesktopContentSelection> {
|
||||
DesktopContent _settingsReturnSurface = DesktopContent.workspace;
|
||||
|
||||
@override
|
||||
DesktopContentSelection build() => (
|
||||
surface: DesktopContent.workspace,
|
||||
@@ -26,6 +29,7 @@ class DesktopContentController extends Notifier<DesktopContentSelection> {
|
||||
workspace: null,
|
||||
settingsVisited: false,
|
||||
resourcesSelected: false,
|
||||
librarySelected: false,
|
||||
);
|
||||
|
||||
void select(DesktopContent surface) {
|
||||
@@ -37,10 +41,14 @@ class DesktopContentController extends Notifier<DesktopContentSelection> {
|
||||
settingsVisited:
|
||||
state.settingsVisited || surface == DesktopContent.settings,
|
||||
resourcesSelected: surface == DesktopContent.library,
|
||||
librarySelected: surface == DesktopContent.resourceLibrary,
|
||||
);
|
||||
}
|
||||
|
||||
void showSettings({int? tab, (String, String)? workspace}) {
|
||||
if (state.surface != DesktopContent.settings) {
|
||||
_settingsReturnSurface = state.surface;
|
||||
}
|
||||
state = (
|
||||
surface: DesktopContent.settings,
|
||||
settingsTab: tab ?? state.settingsTab,
|
||||
@@ -48,6 +56,13 @@ class DesktopContentController extends Notifier<DesktopContentSelection> {
|
||||
workspace: workspace ?? state.workspace,
|
||||
settingsVisited: true,
|
||||
resourcesSelected: state.resourcesSelected,
|
||||
librarySelected: state.librarySelected,
|
||||
);
|
||||
}
|
||||
|
||||
void closeSettings() {
|
||||
if (state.surface == DesktopContent.settings) {
|
||||
select(_settingsReturnSurface);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,17 +4,49 @@ import 'package:flutter/foundation.dart';
|
||||
class DesktopWorkspaceController extends ChangeNotifier {
|
||||
double? _agentWidth;
|
||||
bool _agentFullscreen = false;
|
||||
bool _agentFloating = false;
|
||||
bool _agentFloatingExpanded = false;
|
||||
bool _agentVisible = false;
|
||||
|
||||
double? get agentWidth => _agentWidth;
|
||||
bool get agentFullscreen => _agentFullscreen;
|
||||
bool get agentFloating => _agentFloating;
|
||||
bool get agentFloatingExpanded => _agentFloatingExpanded;
|
||||
bool get agentVisible => _agentVisible;
|
||||
|
||||
void setAgentVisible(bool value) {
|
||||
if (_agentVisible == value) return;
|
||||
_agentVisible = value;
|
||||
if (!value) {
|
||||
_agentFloating = false;
|
||||
_agentFullscreen = false;
|
||||
_agentFloatingExpanded = false;
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void toggleFloatingConversation() {
|
||||
_agentFloatingExpanded = !_agentFloatingExpanded;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setAgentWidth(double width) {
|
||||
_agentWidth = width;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setAgentFloating(bool value) {
|
||||
if (_agentFloating == value) return;
|
||||
_agentFloating = value;
|
||||
_agentVisible = true;
|
||||
if (!value) _agentFloatingExpanded = false;
|
||||
if (value) _agentFullscreen = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setAgentFullscreen(bool value) {
|
||||
if (_agentFullscreen == value) return;
|
||||
if (_agentFullscreen == value && !(value && _agentFloating)) return;
|
||||
if (value) _agentFloating = false;
|
||||
_agentFullscreen = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ abstract final class WorkspaceLayoutPolicy {
|
||||
width >=
|
||||
WorkspaceLayoutMetrics.sidebarMinimumWidth +
|
||||
WorkspaceLayoutMetrics.contentMinimumWidth +
|
||||
1;
|
||||
WorkspaceLayoutMetrics.desktopSpacing;
|
||||
|
||||
static bool showAgentBesideEditor(double width) =>
|
||||
width >= WorkspaceLayoutMetrics.dualPaneMinimumWidth;
|
||||
|
||||
+14
-4
@@ -11,17 +11,27 @@ import '../integrations/app_updates.dart';
|
||||
import '../integrations/editor_tools.dart';
|
||||
import '../features/settings/appearance_settings.dart';
|
||||
import '../shared/widgets/error_notification_host.dart';
|
||||
import '../integrations/platform/device_experience.dart';
|
||||
|
||||
class CutdexApp extends ConsumerWidget {
|
||||
const CutdexApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
ref.watch(applicationMcpConnectionProvider);
|
||||
ref.watch(appUpdateLifecycleProvider);
|
||||
ref.watch(applicationMcpConnectionProvider.select((_) => null));
|
||||
ref.watch(appUpdateLifecycleProvider.select((_) => null));
|
||||
final appearance =
|
||||
ref.watch(appearanceSettingsProvider).asData?.value ??
|
||||
AppAppearance.system;
|
||||
final palette =
|
||||
ref.watch(paletteSettingsProvider).asData?.value ?? AppPalette.graphite;
|
||||
final desktop =
|
||||
ref.watch(deviceExperienceProvider) == DeviceExperience.desktop;
|
||||
ThemeData theme(Brightness brightness) {
|
||||
final base = EditorTheme.forPalette(palette, brightness);
|
||||
return desktop ? EditorTheme.desktop(base) : base;
|
||||
}
|
||||
|
||||
return MaterialApp.router(
|
||||
builder: (context, child) =>
|
||||
ErrorNotificationHost(child: child ?? const SizedBox.shrink()),
|
||||
@@ -31,8 +41,8 @@ class CutdexApp extends ConsumerWidget {
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localeListResolutionCallback: resolveAppLocale,
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: EditorTheme.penLight,
|
||||
darkTheme: EditorTheme.penDark,
|
||||
theme: theme(Brightness.light),
|
||||
darkTheme: theme(Brightness.dark),
|
||||
themeMode: appearance.themeMode,
|
||||
routerConfig: ref.watch(appRouterProvider),
|
||||
);
|
||||
|
||||
@@ -7,10 +7,39 @@ abstract final class EditorTheme {
|
||||
static ThemeData get penLight => adapt(AppTheme.penLight);
|
||||
static ThemeData get penDark => adapt(AppTheme.penDark);
|
||||
|
||||
static ThemeData forPalette(AppPalette palette, Brightness brightness) =>
|
||||
adapt(AppTheme.forPalette(palette, brightness));
|
||||
|
||||
static ThemeData desktop(ThemeData theme) {
|
||||
final desktop = AppTheme.desktopWorkspaceTheme(theme);
|
||||
final timeline = desktop.extension<TimelineThemeData>();
|
||||
if (timeline == null) return desktop;
|
||||
return desktop.copyWith(
|
||||
extensions: [
|
||||
...desktop.extensions.values.where(
|
||||
(value) => value is! TimelineThemeData,
|
||||
),
|
||||
timeline.copyWith(
|
||||
rulerHeight: AppDesktopMetrics.timelineRuler,
|
||||
rulerTextStyle: timeline.rulerTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
height: 16 / 12,
|
||||
fontFeatures: const [FontFeature.tabularFigures()],
|
||||
),
|
||||
playheadColor: desktop.colorScheme.primary,
|
||||
clipHeaderHeight: 20,
|
||||
clipHeaderPadding: 4,
|
||||
clipNameTextStyle: timeline.clipNameTextStyle.copyWith(
|
||||
fontSize: 11,
|
||||
height: 16 / 11,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
static ThemeData adapt(ThemeData theme) {
|
||||
final palette = theme.brightness == Brightness.dark
|
||||
? AppColors.penDark
|
||||
: AppColors.penLight;
|
||||
final palette = AppColors.of(theme);
|
||||
final dark = theme.brightness == Brightness.dark;
|
||||
final text = theme.textTheme;
|
||||
final timelineBorder = palette.divider;
|
||||
@@ -27,8 +56,8 @@ abstract final class EditorTheme {
|
||||
backgroundColor: palette.background,
|
||||
primaryLaneBackgroundColor: palette.sidebar,
|
||||
visualClipColor: palette.visualClip,
|
||||
audioClipColor: palette.popover,
|
||||
audioAccentColor: timelineSecondary,
|
||||
audioClipColor: palette.audioClip,
|
||||
audioAccentColor: palette.audioWaveform,
|
||||
gapColor: timelineBorder,
|
||||
gapBorderColor: timelineBorder,
|
||||
containerAccentColor: timelineSecondary,
|
||||
@@ -37,7 +66,7 @@ abstract final class EditorTheme {
|
||||
connectionLineWidth: 3,
|
||||
clipBorderColor: timelineBorder,
|
||||
clipBorderWidth: 1,
|
||||
selectionOutlineColor: palette.foreground,
|
||||
selectionOutlineColor: palette.selection,
|
||||
selectionOutlineWidth: 2,
|
||||
keyframeColor: timelineSecondary,
|
||||
keyframeBorderColor: palette.background,
|
||||
|
||||
@@ -22,7 +22,7 @@ GoRouter appRouter(Ref ref) {
|
||||
builder: (context, state) => SettingsPage(
|
||||
initialTab:
|
||||
(int.tryParse(state.uri.queryParameters['tab'] ?? '') ?? 0)
|
||||
.clamp(0, 2),
|
||||
.clamp(0, 3),
|
||||
workspace: state.extra is (String, String)
|
||||
? state.extra as (String, String)
|
||||
: null,
|
||||
|
||||
@@ -48,4 +48,4 @@ final class AppRouterProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$appRouterHash() => r'00e948f9d82c1f07ecdfc62b3c1ec833cb03edfe';
|
||||
String _$appRouterHash() => r'ea1ed83ca5ca1f7079b268b1a94940d575b6ddf9';
|
||||
@@ -1,10 +1,12 @@
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
import 'package:cutdex_ui/icons.dart';
|
||||
import 'package:cutdex_ui/theme.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';
|
||||
import '../editor_theme.dart';
|
||||
|
||||
/// Keeps window chrome outside the shared workspace surface.
|
||||
class DesktopWindowFrame extends StatelessWidget {
|
||||
@@ -12,30 +14,40 @@ class DesktopWindowFrame extends StatelessWidget {
|
||||
super.key,
|
||||
required this.integratedTitlebar,
|
||||
required this.headerControls,
|
||||
required this.librarySelected,
|
||||
this.projectTabs,
|
||||
this.headerTrailing = const SizedBox.shrink(),
|
||||
this.settingsSelected = false,
|
||||
required this.onModeChanged,
|
||||
required this.onLibraryPressed,
|
||||
this.resourceLibrarySelected = false,
|
||||
this.onResourceLibraryPressed,
|
||||
required this.onHomePressed,
|
||||
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;
|
||||
static const railIconSize = 20.0;
|
||||
static const headerHeight = AppDesktopMetrics.windowHeader;
|
||||
static const headerInset = (railWidth - AppControlSize.headerButton) / 2;
|
||||
static const contentInset = WorkspaceLayoutMetrics.desktopOuterSpacing;
|
||||
final bool integratedTitlebar;
|
||||
final Widget headerControls;
|
||||
final bool librarySelected;
|
||||
final Widget? projectTabs;
|
||||
final Widget headerTrailing;
|
||||
final bool settingsSelected;
|
||||
final ValueChanged<WorkspaceMode> onModeChanged;
|
||||
final VoidCallback? onLibraryPressed;
|
||||
final bool resourceLibrarySelected;
|
||||
final VoidCallback? onResourceLibraryPressed;
|
||||
final VoidCallback onHomePressed;
|
||||
final VoidCallback onSettingsPressed;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ColoredBox(
|
||||
Widget build(BuildContext context) => Theme(
|
||||
data: EditorTheme.desktop(Theme.of(context)),
|
||||
child: Builder(builder: _buildFrame),
|
||||
);
|
||||
|
||||
Widget _buildFrame(BuildContext context) => ColoredBox(
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -44,99 +56,153 @@ class DesktopWindowFrame extends StatelessWidget {
|
||||
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,
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: projectTabs != null
|
||||
? LayoutBuilder(
|
||||
builder: (context, constraints) =>
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: constraints.maxWidth.clamp(
|
||||
240.0,
|
||||
double.infinity,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
if (integratedTitlebar)
|
||||
SizedBox(
|
||||
key: const Key(
|
||||
'native-window-controls-space',
|
||||
),
|
||||
width:
|
||||
EditorWindowChrome.leadingWidth,
|
||||
height: headerHeight,
|
||||
),
|
||||
headerControls,
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: headerInset,
|
||||
),
|
||||
child: projectTabs!,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
if (integratedTitlebar)
|
||||
SizedBox(
|
||||
key: const Key(
|
||||
'native-window-controls-space',
|
||||
),
|
||||
width: EditorWindowChrome.leadingWidth,
|
||||
height: headerHeight,
|
||||
),
|
||||
headerControls,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
headerTrailing,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
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:
|
||||
if (projectTabs == null)
|
||||
SizedBox(
|
||||
key: const Key('desktop-navigation-rail'),
|
||||
width: railWidth,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
for (final section in [0, 2])
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: IconButton.filledTonal(
|
||||
key: ValueKey(switch (section) {
|
||||
0 => 'desktop-rail-home',
|
||||
_ => 'desktop-rail-resources',
|
||||
}),
|
||||
tooltip: switch (section) {
|
||||
0 => context.l10n.navigationHome,
|
||||
_ => context.l10n.navigationLibrary,
|
||||
},
|
||||
isSelected:
|
||||
!settingsSelected &&
|
||||
library == librarySelected
|
||||
? null
|
||||
: Colors.transparent,
|
||||
),
|
||||
onPressed: library
|
||||
? onLibraryPressed
|
||||
: () => onModeChanged(WorkspaceMode.cut),
|
||||
icon: Icon(
|
||||
library
|
||||
? Icons.video_library_outlined
|
||||
: Icons.chat_bubble_outline,
|
||||
(section == 2
|
||||
? resourceLibrarySelected
|
||||
: !resourceLibrarySelected),
|
||||
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 &&
|
||||
(section == 2
|
||||
? resourceLibrarySelected
|
||||
: !resourceLibrarySelected)
|
||||
? null
|
||||
: Colors.transparent,
|
||||
),
|
||||
onPressed: switch (section) {
|
||||
0 => onHomePressed,
|
||||
_ => onResourceLibraryPressed,
|
||||
},
|
||||
icon: Icon(switch (section) {
|
||||
0 => AppIcons.home,
|
||||
_ => AppIcons.folder,
|
||||
}),
|
||||
),
|
||||
),
|
||||
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(AppIcons.settings),
|
||||
),
|
||||
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(
|
||||
padding: EdgeInsets.only(
|
||||
left: projectTabs == null ? 0 : contentInset,
|
||||
right: contentInset,
|
||||
bottom: contentInset,
|
||||
),
|
||||
child: SizedBox(
|
||||
key: const Key('desktop-content-container'),
|
||||
child: WindowHeaderPane(
|
||||
offset: const Offset(railWidth, headerHeight),
|
||||
offset: Offset(
|
||||
projectTabs == null ? railWidth : contentInset,
|
||||
headerHeight,
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) =>
|
||||
constraints.maxWidth < 200
|
||||
|
||||
@@ -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, () {}),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:cutdex_ui/icons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../l10n/l10n.dart';
|
||||
@@ -43,12 +44,12 @@ class PhoneWorkspaceShell extends StatelessWidget {
|
||||
destinations: [
|
||||
NavigationDestination(
|
||||
key: const Key('workspace-agent-destination'),
|
||||
icon: const Icon(Icons.chat_bubble_outline),
|
||||
icon: const Icon(AppIcons.chat),
|
||||
label: context.l10n.workspaceAgent,
|
||||
),
|
||||
NavigationDestination(
|
||||
key: const Key('workspace-cut-destination'),
|
||||
icon: const Icon(Icons.movie_outlined),
|
||||
icon: const Icon(AppIcons.video),
|
||||
label: context.l10n.workspaceCut,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:cutdex_ui/icons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../l10n/l10n.dart';
|
||||
@@ -55,14 +56,14 @@ class TabletWorkspaceShell extends StatelessWidget {
|
||||
destinations: [
|
||||
NavigationRailDestination(
|
||||
icon: const Icon(
|
||||
Icons.chat_bubble_outline,
|
||||
AppIcons.chat,
|
||||
key: Key('workspace-agent-destination'),
|
||||
),
|
||||
label: Text(context.l10n.workspaceAgent),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: const Icon(
|
||||
Icons.movie_outlined,
|
||||
AppIcons.video,
|
||||
key: Key('workspace-cut-destination'),
|
||||
),
|
||||
label: Text(context.l10n.workspaceCut),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:cutdex_ui/icons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../integrations/platform/editor_window_chrome.dart';
|
||||
@@ -45,7 +46,7 @@ class WorkspaceFrame extends StatelessWidget {
|
||||
key: const Key('workspace-navigation-button'),
|
||||
tooltip: context.l10n.expandSidebar,
|
||||
onPressed: () => Scaffold.of(context).openDrawer(),
|
||||
icon: const Icon(Icons.menu),
|
||||
icon: const Icon(AppIcons.menu),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user