Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
1000 lines
47 KiB
Dart
1000 lines
47 KiB
Dart
import '../../shared/widgets/presentation_list.dart';
|
|
import '../assistant/agent_panel_presentation.dart';
|
|
|
|
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
|
import 'package:cutdex/errors/app_failure.dart';
|
|
|
|
import 'dart:async';
|
|
|
|
import 'package:cutdex/l10n/l10n.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../../app/adaptive/desktop_workspace_controller.dart';
|
|
import '../../app/adaptive/desktop_content_controller.dart';
|
|
import '../settings/settings_content.dart';
|
|
import '../../app/adaptive/workspace_layout_policy.dart';
|
|
import '../../app/shells/phone_workspace_shell.dart';
|
|
import '../../app/shells/desktop_workspace_shell.dart';
|
|
import '../../app/shells/desktop_window_frame.dart';
|
|
import '../../app/shells/tablet_workspace_shell.dart';
|
|
import '../../integrations/platform/device_experience.dart';
|
|
import '../../integrations/platform/editor_window_chrome.dart';
|
|
import '../../integrations/platform/file_picker.dart';
|
|
|
|
import 'package:cutdex_native/cutdex_native.dart';
|
|
|
|
import '../../persistence/app_settings_repositories.dart';
|
|
|
|
import 'package:cutdex_ui/icons.dart';
|
|
import 'package:cutdex_ui/widgets.dart';
|
|
import 'package:cutdex_ui/theme.dart';
|
|
|
|
import '../../workspace/project_state.dart';
|
|
import '../../workspace/projects.dart';
|
|
import '../../workspace/view_settings.dart';
|
|
import '../../workspace/workspace_mode.dart';
|
|
import '../../workspace/workspace_navigation.dart';
|
|
import '../../workspace/workspace_session_scope.dart';
|
|
import '../assistant/workspace_agent_surface.dart';
|
|
import '../editor/background_tasks_button.dart';
|
|
import '../editor/editor_page.dart';
|
|
import '../settings/settings_page.dart';
|
|
import 'editor_loading_region.dart';
|
|
import 'project_switch_region.dart';
|
|
import 'project_sidebar.dart';
|
|
import 'project_tabs_bar.dart';
|
|
import 'project_tabs_controller.dart';
|
|
import 'widgets/name_dialog.dart';
|
|
|
|
/// The single application surface: project navigation beside the editor.
|
|
|
|
class EditingPage extends ConsumerStatefulWidget {
|
|
const EditingPage({super.key});
|
|
|
|
@override
|
|
ConsumerState<EditingPage> createState() => _EditingPageState();
|
|
}
|
|
|
|
class _EditingPageState extends ConsumerState<EditingPage> {
|
|
final _desktopSplits = DesktopWorkspaceController();
|
|
final _editorKey = GlobalKey();
|
|
final _agentKey = GlobalKey();
|
|
final _navigationKey = GlobalKey();
|
|
final _drawerNavigationKey = GlobalKey();
|
|
final _desktopScaffoldKey = GlobalKey<ScaffoldState>();
|
|
WorkspaceViewSettingsData get _viewSettings =>
|
|
ref.read(workspaceViewSettingsProvider).value ??
|
|
const WorkspaceViewSettingsData();
|
|
WorkspaceViewSettings get _viewController =>
|
|
ref.read(workspaceViewSettingsProvider.notifier);
|
|
WorkspaceMode get _mode => _viewSettings.mode;
|
|
set _mode(WorkspaceMode value) => _viewController.setMode(value);
|
|
bool get _sidebarCollapsed => _viewSettings.sidebarCollapsed;
|
|
set _sidebarCollapsed(bool value) =>
|
|
_viewController.setSidebarCollapsed(value);
|
|
double? get _sidebarWidthOverride => _viewSettings.sidebarWidth;
|
|
set _sidebarWidthOverride(double? value) =>
|
|
_viewController.setSidebarWidth(value);
|
|
bool get _startupReady => ref.read(workspaceNavigationProvider).ready;
|
|
bool get _switchingProject =>
|
|
ref.read(workspaceNavigationProvider).switchingProject;
|
|
String? get _selectedProjectId =>
|
|
ref.read(workspaceNavigationProvider).selectedProjectId;
|
|
|
|
void _saveViewState({String? activeProjectId}) {
|
|
if (!_startupReady) return;
|
|
final current = ref.read(projectsProvider).value;
|
|
unawaited(
|
|
_viewController.save(
|
|
activeProjectId: activeProjectId ?? current?.activeProject?.id,
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> _selectProject(
|
|
BuildContext context,
|
|
WidgetRef ref, {
|
|
required bool create,
|
|
}) async {
|
|
if (_switchingProject ||
|
|
ref.read(projectsProvider).value?.projectBusy == true) {
|
|
return;
|
|
}
|
|
FocusManager.instance.primaryFocus?.unfocus();
|
|
try {
|
|
if (create) {
|
|
final name = await askName(
|
|
context,
|
|
title: context.l10n.newProject,
|
|
label: context.l10n.projectName,
|
|
validateName: (name) async {
|
|
final failure = await ref
|
|
.read(projectsProvider.notifier)
|
|
.validateNewProjectName(name);
|
|
if (!context.mounted) return null;
|
|
return failure == null
|
|
? null
|
|
: context.l10n.failureMessage(failure);
|
|
},
|
|
);
|
|
if (name == null || !context.mounted) return;
|
|
final created = await ref
|
|
.read(projectsProvider.notifier)
|
|
.createProject(
|
|
name,
|
|
initialTimelineName: context.l10n.defaultTimelineName(1),
|
|
);
|
|
if (!created && context.mounted) {
|
|
final error = ref.read(projectsProvider).value?.error;
|
|
if (error?.requiresProjectLocation == true) {
|
|
await showSettingsPage(context);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
final directory = await ref
|
|
.read(filePickerProvider)
|
|
.pickDirectory(confirmButtonText: context.l10n.openProject);
|
|
if (directory == null || !context.mounted) return;
|
|
await ref.read(projectsProvider.notifier).open(directory);
|
|
} catch (error) {
|
|
if (context.mounted) {
|
|
ErrorNotificationHost.of(context).show(
|
|
ErrorNotification(
|
|
content: Text(context.l10n.selectDirectoryFailed),
|
|
details: error.toString(),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
Future<void> _openProject(WidgetRef ref, RecentProject project) {
|
|
FocusManager.instance.primaryFocus?.unfocus();
|
|
return ref.read(workspaceNavigationProvider.notifier).openProject(project);
|
|
}
|
|
|
|
Future<void> _closeProjectTab(RecentProject project) async {
|
|
if (_switchingProject ||
|
|
ref.read(projectsProvider).value?.projectBusy == true) {
|
|
return;
|
|
}
|
|
FocusManager.instance.primaryFocus?.unfocus();
|
|
final tabs = ref.read(projectTabsProvider);
|
|
if (ref.read(projectsProvider).value?.activeProject?.id == project.id) {
|
|
final index = tabs.indexWhere((tab) => tab.id == project.id);
|
|
final neighbors = [
|
|
...tabs.skip(index + 1),
|
|
...tabs.take(index).toList().reversed,
|
|
];
|
|
final next = neighbors.firstOrNull;
|
|
if (next != null) {
|
|
await _openProject(ref, next);
|
|
if (!mounted ||
|
|
ref.read(projectsProvider).value?.activeProject?.id != next.id) {
|
|
return;
|
|
}
|
|
} else {
|
|
final closed = await ref
|
|
.read(projectsProvider.notifier)
|
|
.closeActiveProject();
|
|
if (!closed || !mounted) return;
|
|
}
|
|
}
|
|
if (mounted) ref.read(projectTabsProvider.notifier).remove(project.id);
|
|
}
|
|
|
|
Future<bool> _renameProject(
|
|
BuildContext context,
|
|
WidgetRef ref,
|
|
RecentProject project,
|
|
) async {
|
|
if (_switchingProject ||
|
|
ref.read(projectsProvider).value?.projectBusy == true) {
|
|
return false;
|
|
}
|
|
final name = await askName(
|
|
context,
|
|
title: context.l10n.rename,
|
|
label: context.l10n.projectName,
|
|
initialValue: project.name,
|
|
submitLabel: context.l10n.rename,
|
|
);
|
|
if (name == null || !context.mounted || name == project.name) return false;
|
|
final renamed = await ref
|
|
.read(projectsProvider.notifier)
|
|
.renameProject(project, name);
|
|
if (renamed && mounted) {
|
|
ref
|
|
.read(projectTabsProvider.notifier)
|
|
.updateProject(project.copyWith(name: name.trim()));
|
|
}
|
|
return renamed;
|
|
}
|
|
|
|
Future<void> _removeRecentProject(RecentProject project) async {
|
|
if (_switchingProject ||
|
|
ref.read(projectsProvider).value?.projectBusy == true) {
|
|
return;
|
|
}
|
|
final recent = ref.read(projectsProvider).value?.recent ?? const [];
|
|
final index = recent.indexWhere((item) => item.id == project.id);
|
|
final removed = await ref
|
|
.read(projectsProvider.notifier)
|
|
.removeRecentProject(project.id);
|
|
if (!removed || !mounted) return;
|
|
ErrorNotificationHost.of(context).showMessage(
|
|
content: Text(context.l10n.projectRemoved),
|
|
actionLabel: context.l10n.undo,
|
|
onAction: () => ref
|
|
.read(projectsProvider.notifier)
|
|
.restoreRecentProject(project, index),
|
|
);
|
|
}
|
|
|
|
Future<void> _relocateProject(
|
|
BuildContext context,
|
|
WidgetRef ref,
|
|
RecentProject project,
|
|
) async {
|
|
if (_switchingProject ||
|
|
ref.read(projectsProvider).value?.projectBusy == true) {
|
|
return;
|
|
}
|
|
final directory = await ref
|
|
.read(filePickerProvider)
|
|
.pickDirectory(confirmButtonText: context.l10n.openProject);
|
|
if (directory == null || !context.mounted) return;
|
|
await ref
|
|
.read(projectsProvider.notifier)
|
|
.open(directory, expectedId: project.id);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_desktopSplits.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _setMode(WorkspaceMode mode) {
|
|
_mode = mode;
|
|
_saveViewState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
ref.watch(workspaceViewSettingsProvider);
|
|
ref.watch(workspaceNavigationProvider);
|
|
final experience = ref.watch(deviceExperienceProvider);
|
|
final desktop = experience == DeviceExperience.desktop;
|
|
final contentSelection = ref.watch(desktopContentProvider);
|
|
final openProjects = ref.watch(projectTabsProvider);
|
|
// Window/navigation subscribe to chrome only. Content owns live values.
|
|
ref.watch(
|
|
projectsProvider.select((value) {
|
|
final state = value.value;
|
|
return (
|
|
value.isLoading,
|
|
value.error,
|
|
state?.activeProject,
|
|
PresentationList(state?.recent ?? const <RecentProject>[]),
|
|
state?.timeline?.id,
|
|
state?.projectBusy,
|
|
state?.openingTimelineId,
|
|
state?.error,
|
|
PresentationList(
|
|
state?.timelines.map(
|
|
(timeline) => (timeline.id, timeline.name, timeline.pinned),
|
|
) ??
|
|
const <(String, String, bool)>[],
|
|
),
|
|
);
|
|
}),
|
|
);
|
|
final projects = ref.read(projectsProvider);
|
|
final state = projects.value ?? const ProjectState();
|
|
return EditorWindowChrome(
|
|
headerHeight: desktop ? DesktopWindowFrame.headerHeight : 48,
|
|
builder: (context, integrated) => Scaffold(
|
|
body: SafeArea(
|
|
top: !integrated,
|
|
child: AnimatedSwitcher(
|
|
duration: const Duration(milliseconds: 320),
|
|
child: !_startupReady
|
|
? const _StartupLoading(key: ValueKey('startup-loading'))
|
|
: WorkspaceSessionScope(
|
|
key: const ValueKey('workspace-content'),
|
|
state: state,
|
|
child: Stack(
|
|
children: [
|
|
LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
final navigationHiddenBySpace =
|
|
desktop &&
|
|
!WorkspaceLayoutPolicy.desktopNavigationFits(
|
|
constraints.maxWidth -
|
|
DesktopWindowFrame.railWidth -
|
|
DesktopWindowFrame.contentInset,
|
|
);
|
|
final navigationCollapsed =
|
|
_sidebarCollapsed || navigationHiddenBySpace;
|
|
void toggleSidebar() {
|
|
if (desktop && _desktopSplits.agentFloating) {
|
|
_desktopSplits.setAgentFloating(false);
|
|
_sidebarCollapsed = false;
|
|
_saveViewState();
|
|
if (navigationHiddenBySpace) {
|
|
_desktopScaffoldKey.currentState
|
|
?.openDrawer();
|
|
}
|
|
} else if (navigationHiddenBySpace) {
|
|
final scaffold =
|
|
_desktopScaffoldKey.currentState;
|
|
if (scaffold?.isDrawerOpen == true) {
|
|
scaffold?.closeDrawer();
|
|
} else {
|
|
scaffold?.openDrawer();
|
|
}
|
|
} else {
|
|
_sidebarCollapsed = !_sidebarCollapsed;
|
|
_saveViewState();
|
|
}
|
|
}
|
|
|
|
void toggleAgentFloating() {
|
|
final floating = !_desktopSplits.agentFloating;
|
|
if (floating) {
|
|
_desktopScaffoldKey.currentState?.closeDrawer();
|
|
_sidebarCollapsed = false;
|
|
_saveViewState();
|
|
}
|
|
_desktopSplits.setAgentFloating(floating);
|
|
if (!floating && navigationHiddenBySpace) {
|
|
_desktopScaffoldKey.currentState?.openDrawer();
|
|
}
|
|
}
|
|
|
|
Widget controlSlot(Widget child) {
|
|
if (!desktop) {
|
|
return SizedBox.square(
|
|
dimension: 48,
|
|
child: child,
|
|
);
|
|
}
|
|
const buttonSize = AppControlSize.headerButton;
|
|
return SizedBox(
|
|
width: buttonSize,
|
|
height: buttonSize,
|
|
child: Center(
|
|
child: IconButtonTheme(
|
|
data: IconButtonThemeData(
|
|
style: Theme.of(context)
|
|
.iconButtonTheme
|
|
.style
|
|
?.copyWith(
|
|
fixedSize:
|
|
const WidgetStatePropertyAll(
|
|
Size.square(buttonSize),
|
|
),
|
|
minimumSize:
|
|
const WidgetStatePropertyAll(
|
|
Size.square(buttonSize),
|
|
),
|
|
maximumSize:
|
|
const WidgetStatePropertyAll(
|
|
Size.square(buttonSize),
|
|
),
|
|
padding:
|
|
const WidgetStatePropertyAll(
|
|
EdgeInsets.zero,
|
|
),
|
|
tapTargetSize: MaterialTapTargetSize
|
|
.shrinkWrap,
|
|
),
|
|
),
|
|
child: SizedBox.square(
|
|
dimension: buttonSize,
|
|
child: child,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget controls({
|
|
bool navigationToggle = true,
|
|
}) => HeaderControlRegion(
|
|
child: Padding(
|
|
padding: EdgeInsets.only(
|
|
left: desktop
|
|
? DesktopWindowFrame.headerInset
|
|
: 0,
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
spacing: AppSpacing.tiny,
|
|
children: [
|
|
if (navigationToggle)
|
|
controlSlot(
|
|
IconButton(
|
|
key: const Key(
|
|
'project-sidebar-toggle',
|
|
),
|
|
tooltip: navigationCollapsed
|
|
? context.l10n.expandSidebar
|
|
: context.l10n.collapseSidebar,
|
|
onPressed: toggleSidebar,
|
|
style: sidebarActionButtonStyle(
|
|
context,
|
|
),
|
|
icon: const Icon(
|
|
AppIcons.sidebar,
|
|
size: AppIconSize.header,
|
|
),
|
|
),
|
|
),
|
|
if (!desktop)
|
|
SizedBox.square(
|
|
dimension: desktop
|
|
? AppControlSize.headerButton
|
|
: 48,
|
|
child: IconButton(
|
|
key: const Key(
|
|
'project-settings-button',
|
|
),
|
|
tooltip: context.l10n.settings,
|
|
onPressed: () =>
|
|
showSettingsPage(context),
|
|
style: sidebarActionButtonStyle(
|
|
context,
|
|
),
|
|
icon: const Icon(
|
|
AppIcons.settings,
|
|
size: AppIconSize.header,
|
|
),
|
|
),
|
|
),
|
|
controlSlot(const BackgroundTasksButton()),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
Widget leading() => Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (!desktop &&
|
|
navigationCollapsed &&
|
|
integrated)
|
|
SizedBox(
|
|
width: EditorWindowChrome.leadingWidth,
|
|
),
|
|
if (!desktop && navigationCollapsed) controls(),
|
|
const SizedBox(width: AppSpacing.compact),
|
|
],
|
|
);
|
|
void selectProject(RecentProject project) {
|
|
if (project.availability.canOpen) {
|
|
_openProject(ref, project);
|
|
} else {
|
|
_relocateProject(context, ref, project);
|
|
}
|
|
}
|
|
|
|
final agent = WorkspaceAgentSurface(
|
|
key: _agentKey,
|
|
showProjectSelector: !desktop,
|
|
state: state,
|
|
onSelectProject: (project) =>
|
|
project.availability.canOpen
|
|
? _openProject(ref, project)
|
|
: _relocateProject(context, ref, project),
|
|
onCreateProject: () =>
|
|
_selectProject(context, ref, create: true),
|
|
);
|
|
void selectSidebar(DesktopContent surface) {
|
|
ref
|
|
.read(desktopContentProvider.notifier)
|
|
.select(surface);
|
|
setState(() => _sidebarCollapsed = false);
|
|
_saveViewState();
|
|
if (navigationHiddenBySpace) {
|
|
WidgetsBinding.instance.addPostFrameCallback((
|
|
_,
|
|
) {
|
|
if (mounted) {
|
|
_desktopScaffoldKey.currentState
|
|
?.openDrawer();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
Widget navigation({
|
|
DesktopWorkspaceGeometry? geometry,
|
|
VoidCallback? expandEditor,
|
|
bool drawer = false,
|
|
}) => ProjectSidebar(
|
|
chatOnly: desktop,
|
|
experience: experience,
|
|
librarySelected:
|
|
desktop && contentSelection.librarySelected,
|
|
resourcesSelected:
|
|
desktop && contentSelection.resourcesSelected,
|
|
onResourcesSelected: desktop
|
|
? (media) => selectSidebar(
|
|
media
|
|
? DesktopContent.library
|
|
: DesktopContent.workspace,
|
|
)
|
|
: null,
|
|
key: drawer
|
|
? _drawerNavigationKey
|
|
: _navigationKey,
|
|
agent: desktop ? agent : const SizedBox.shrink(),
|
|
navigationOnly: true,
|
|
onNavigationComplete: desktop && !drawer
|
|
? null
|
|
: () => Navigator.of(context).maybePop(),
|
|
editorHidden: geometry?.editorHidden ?? false,
|
|
onExpandEditor: expandEditor,
|
|
agentHeaderLeading: desktop
|
|
? leading()
|
|
: const SizedBox.shrink(),
|
|
navigationCollapsed:
|
|
desktop && !drawer && navigationCollapsed,
|
|
mode: _mode,
|
|
onModeChanged: _setMode,
|
|
navigationWidth: geometry?.sidebarWidth ?? 320,
|
|
state: state,
|
|
selectedProjectId:
|
|
_selectedProjectId ?? state.activeProject?.id,
|
|
integratedTitlebar: !desktop && integrated,
|
|
externalWindowFrame: desktop && !drawer,
|
|
onCreateProject: () =>
|
|
_selectProject(context, ref, create: true),
|
|
onSelectProject: selectProject,
|
|
onRenameProject: (project) =>
|
|
_renameProject(context, ref, project),
|
|
headerControls: desktop && !drawer
|
|
? const SizedBox.shrink()
|
|
: HeaderControlRegion(
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Builder(
|
|
builder: (context) => IconButton(
|
|
tooltip: MaterialLocalizations.of(
|
|
context,
|
|
).closeButtonTooltip,
|
|
onPressed: () =>
|
|
Scaffold.of(context)
|
|
.closeDrawer(),
|
|
icon: const Icon(AppIcons.close),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
final selectedProjectId =
|
|
_selectedProjectId ?? state.activeProject?.id;
|
|
final pendingProject = _selectedProjectId == null
|
|
? null
|
|
: state.recent
|
|
.where(
|
|
(item) => item.id == selectedProjectId,
|
|
)
|
|
.firstOrNull;
|
|
final visibleProjects = [
|
|
...openProjects,
|
|
if (pendingProject != null &&
|
|
!openProjects.any(
|
|
(item) => item.id == pendingProject.id,
|
|
))
|
|
pendingProject,
|
|
];
|
|
final editor = ProjectSwitchRegion(
|
|
pendingProjectId:
|
|
selectedProjectId != state.activeProject?.id
|
|
? _selectedProjectId
|
|
: null,
|
|
child:
|
|
state.activeProject != null &&
|
|
state.timeline != null
|
|
? EditorWorkspace(
|
|
key: _editorKey,
|
|
experience: experience,
|
|
projectId: state.activeProject!.id,
|
|
timelineId: state.timeline!.id,
|
|
projectName: state.activeProject!.name,
|
|
timelineLoading:
|
|
state.openingTimelineId != null,
|
|
showProjectName: false,
|
|
integratedTitlebar: false,
|
|
headerLeading: desktop
|
|
? const SizedBox.shrink()
|
|
: const SizedBox(
|
|
width: AppSpacing.compact,
|
|
),
|
|
)
|
|
: EmptyEditor(
|
|
experience: experience,
|
|
desktop: desktop,
|
|
state: state,
|
|
showProjectName:
|
|
desktop && _mode == WorkspaceMode.cut,
|
|
headerLeading: desktop
|
|
? const SizedBox.shrink()
|
|
: const SizedBox(
|
|
width: AppSpacing.compact,
|
|
),
|
|
),
|
|
);
|
|
Widget contentSurface(
|
|
DesktopContent surface,
|
|
Widget child,
|
|
) => ExcludeFocus(
|
|
excluding:
|
|
(contentSelection.surface ==
|
|
DesktopContent.settings) !=
|
|
(surface == DesktopContent.settings),
|
|
child: TickerMode(
|
|
enabled:
|
|
(contentSelection.surface ==
|
|
DesktopContent.settings) ==
|
|
(surface == DesktopContent.settings),
|
|
child: child,
|
|
),
|
|
);
|
|
Widget desktopContents(
|
|
Widget workspace,
|
|
) => IndexedStack(
|
|
index:
|
|
contentSelection.surface ==
|
|
DesktopContent.settings
|
|
? 1
|
|
: 0,
|
|
children: [
|
|
contentSurface(
|
|
DesktopContent.workspace,
|
|
workspace,
|
|
),
|
|
contentSurface(
|
|
DesktopContent.settings,
|
|
contentSelection.settingsVisited
|
|
? SizedBox(
|
|
key: const Key(
|
|
'desktop-settings-workspace',
|
|
),
|
|
child: SettingsContent(
|
|
cardLayout: true,
|
|
onBack: () => ref
|
|
.read(
|
|
desktopContentProvider
|
|
.notifier,
|
|
)
|
|
.closeSettings(),
|
|
initialTab:
|
|
contentSelection.settingsTab,
|
|
navigationRequest: contentSelection
|
|
.settingsRequest,
|
|
workspace:
|
|
contentSelection.workspace,
|
|
),
|
|
)
|
|
: const SizedBox.shrink(),
|
|
),
|
|
],
|
|
);
|
|
return switch (experience) {
|
|
DeviceExperience.desktop => DesktopWindowFrame(
|
|
integratedTitlebar: integrated,
|
|
headerControls: const SizedBox.shrink(),
|
|
projectTabs: ListenableBuilder(
|
|
listenable: _desktopSplits,
|
|
builder: (context, _) => ProjectTabsBar(
|
|
projects: visibleProjects,
|
|
recent: state.recent,
|
|
selectedId: selectedProjectId,
|
|
onSelect: (project) {
|
|
ref
|
|
.read(desktopContentProvider.notifier)
|
|
.select(DesktopContent.workspace);
|
|
selectProject(project);
|
|
},
|
|
onClose: _closeProjectTab,
|
|
onCreate: () => _selectProject(
|
|
context,
|
|
ref,
|
|
create: true,
|
|
),
|
|
onOpen: () => _selectProject(
|
|
context,
|
|
ref,
|
|
create: false,
|
|
),
|
|
onRename: (project) =>
|
|
_renameProject(context, ref, project),
|
|
onRemoveRecent: _removeRecentProject,
|
|
leadingActions: [
|
|
IconButton(
|
|
key: const Key(
|
|
'project-sidebar-toggle',
|
|
),
|
|
tooltip:
|
|
navigationCollapsed ||
|
|
_desktopSplits.agentFloating
|
|
? context.l10n.expandSidebar
|
|
: context.l10n.collapseSidebar,
|
|
onPressed: toggleSidebar,
|
|
style: AppTheme.projectTabActionStyle(
|
|
context,
|
|
),
|
|
icon: const Icon(
|
|
AppIcons.sidebar,
|
|
size: 16,
|
|
),
|
|
),
|
|
],
|
|
trailingActions: [
|
|
IconButton(
|
|
key: const Key('agent-minimize-button'),
|
|
tooltip: _desktopSplits.agentFloating
|
|
? context.l10n.agentDock
|
|
: context.l10n.agentMinimize,
|
|
onPressed: toggleAgentFloating,
|
|
isSelected:
|
|
_desktopSplits.agentFloating,
|
|
style: AppTheme.projectTabActionStyle(
|
|
context,
|
|
),
|
|
icon: const Icon(
|
|
AppIcons.fullscreen,
|
|
size: 16,
|
|
),
|
|
),
|
|
const BackgroundTasksButton(
|
|
iconSize: 16,
|
|
alignment:
|
|
AlignmentDirectional.bottomEnd,
|
|
),
|
|
],
|
|
projectMenuActions: [
|
|
AppMenuItem(
|
|
key: const Key(
|
|
'project-settings-button',
|
|
),
|
|
label: context.l10n.settings,
|
|
icon: AppIcons.settings,
|
|
onPressed: () =>
|
|
showSettingsPage(context),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
resourceLibrarySelected:
|
|
contentSelection.surface ==
|
|
DesktopContent.resourceLibrary,
|
|
onResourceLibraryPressed: () => selectSidebar(
|
|
DesktopContent.resourceLibrary,
|
|
),
|
|
settingsSelected:
|
|
contentSelection.surface ==
|
|
DesktopContent.settings,
|
|
onHomePressed: () =>
|
|
selectSidebar(DesktopContent.workspace),
|
|
onSettingsPressed: () =>
|
|
showSettingsPage(context),
|
|
child: desktopContents(
|
|
DesktopWorkspaceShell(
|
|
projectTabsLayout: true,
|
|
controller: _desktopSplits,
|
|
scaffoldKey: _desktopScaffoldKey,
|
|
navigationDrawer: navigation(drawer: true),
|
|
mode: _mode,
|
|
sidebarCollapsed: navigationCollapsed,
|
|
sidebarWidth: _sidebarWidthOverride,
|
|
onSidebarCollapsedChanged: (value) {
|
|
_sidebarCollapsed = value;
|
|
_saveViewState();
|
|
},
|
|
onSidebarWidthChanged: (value) {
|
|
_sidebarWidthOverride = value;
|
|
_saveViewState();
|
|
},
|
|
sidebarBuilder: (geometry, expand) =>
|
|
navigation(
|
|
geometry: geometry,
|
|
expandEditor: expand,
|
|
),
|
|
agentBuilder: (geometry, expand) =>
|
|
_desktopSplits.agentFloating
|
|
? AgentPanelPresentation(
|
|
compact: true,
|
|
expanded: _desktopSplits
|
|
.agentFloatingExpanded,
|
|
onToggleExpanded: _desktopSplits
|
|
.toggleFloatingConversation,
|
|
onDock: () => _desktopSplits
|
|
.setAgentFloating(false),
|
|
child: agent,
|
|
)
|
|
: Column(
|
|
children: [
|
|
SizedBox(
|
|
key: const Key(
|
|
'agent-content-header',
|
|
),
|
|
height: AppDesktopMetrics
|
|
.panelHeader,
|
|
child: Padding(
|
|
padding:
|
|
const EdgeInsets.symmetric(
|
|
horizontal: 12,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
const Icon(
|
|
AppIcons.chat,
|
|
size: 16,
|
|
),
|
|
const SizedBox(width: 8),
|
|
Expanded(
|
|
child: Text(
|
|
context
|
|
.l10n
|
|
.workspaceAgent,
|
|
maxLines: 1,
|
|
overflow: TextOverflow
|
|
.ellipsis,
|
|
),
|
|
),
|
|
HeaderControlRegion(
|
|
child: IconButton(
|
|
key: const Key(
|
|
'agent-fullscreen-button',
|
|
),
|
|
isSelected:
|
|
_desktopSplits
|
|
.agentFullscreen,
|
|
tooltip:
|
|
geometry
|
|
.editorHidden
|
|
? context
|
|
.l10n
|
|
.expandEditor
|
|
: context
|
|
.l10n
|
|
.agentFullscreen,
|
|
onPressed:
|
|
geometry
|
|
.editorHidden
|
|
? expand
|
|
: () => _desktopSplits
|
|
.setAgentFullscreen(
|
|
true,
|
|
),
|
|
icon: Icon(
|
|
geometry.editorHidden
|
|
? AppIcons
|
|
.splitVertical
|
|
: AppIcons
|
|
.fullscreen,
|
|
size: 16,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(child: agent),
|
|
],
|
|
),
|
|
editor: editor,
|
|
),
|
|
),
|
|
),
|
|
DeviceExperience.tablet => TabletWorkspaceShell(
|
|
mode: _mode,
|
|
onModeChanged: _setMode,
|
|
navigation: navigation(),
|
|
headerActions: controls(
|
|
navigationToggle: false,
|
|
),
|
|
title: state.activeProject?.name ?? 'Cutdex',
|
|
integratedTitlebar: integrated,
|
|
agent: agent,
|
|
editor: editor,
|
|
),
|
|
DeviceExperience.phone => PhoneWorkspaceShell(
|
|
mode: _mode,
|
|
onModeChanged: _setMode,
|
|
navigation: navigation(),
|
|
headerActions: controls(
|
|
navigationToggle: false,
|
|
),
|
|
title: state.activeProject?.name ?? 'Cutdex',
|
|
integratedTitlebar: integrated,
|
|
agent: agent,
|
|
editor: editor,
|
|
),
|
|
};
|
|
},
|
|
),
|
|
PositionedDirectional(
|
|
top: AppSpacing.compact,
|
|
end: AppSpacing.compact,
|
|
child: ErrorFailureListener(
|
|
message: projects.hasError
|
|
? AppFailure(
|
|
AppErrorCode.loadProjectsFailed,
|
|
diagnostic: projects.error.toString(),
|
|
)
|
|
: state.error,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _StartupLoading extends StatefulWidget {
|
|
const _StartupLoading({super.key});
|
|
|
|
@override
|
|
State<_StartupLoading> createState() => _StartupLoadingState();
|
|
}
|
|
|
|
class _StartupLoadingState extends State<_StartupLoading>
|
|
with SingleTickerProviderStateMixin {
|
|
late final AnimationController _pulse = AnimationController(
|
|
vsync: this,
|
|
duration: const Duration(milliseconds: 1800),
|
|
)..repeat(reverse: true);
|
|
|
|
late final Animation<double> _opacity = Tween<double>(
|
|
begin: 0.5,
|
|
end: 1,
|
|
).animate(CurvedAnimation(parent: _pulse, curve: Curves.easeInOut));
|
|
|
|
@override
|
|
void dispose() {
|
|
_pulse.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Center(
|
|
child: Semantics(
|
|
liveRegion: true,
|
|
child: FadeTransition(
|
|
opacity: _opacity,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
'CUTDEX',
|
|
style: Theme.of(context).textTheme.titleMedium
|
|
?.copyWith(fontWeight: FontWeight.w600, letterSpacing: 3),
|
|
),
|
|
const SizedBox(height: AppSpacing.medium),
|
|
Text(
|
|
context.l10n.openingWorkspace,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|