refactor(desktop): reorganize workspace panels and navigation
Gitea CI / Windows x64 and Android (pull_request) Successful in 16m21s
Gitea CI / Gitea CI passed (pull_request) Successful in 3s

This commit is contained in:
lingjhf committed 2026-10-06 12:11:59 +08:00
1 parent 826745b407
commit 1f73765745
92 files changed
+5811 -2650

No files matched your search

@@ -1,3 +1,5 @@
import 'dart:async';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -97,17 +99,72 @@ class ConversationSidebar extends _$ConversationSidebar {
@override
Future<ConversationSnapshot> build() async {
ref.listen(
projectsProvider.select((value) => value.value?.activeProject?.id),
(before, after) {
if (before != after) unawaited(_refreshContext(after));
},
);
await ref.watch(
projectsProvider.selectAsync(
(workspace) => ConversationWorkspaceKey(
projectId: workspace.activeProject?.id,
projectIds: [for (final project in workspace.recent) project.id],
),
),
);
_revision++;
final workspace = ref.read(projectsProvider).requireValue;
return _load(workspace);
final loaded = await _load(workspace);
if (!ref.mounted) return loaded;
final activeId = ref.read(projectsProvider).value?.activeProject?.id;
return activeId == loaded.projectId
? loaded
: _loadContext(loaded, activeId);
}
/// Project selection changes only contextual data, never the global groups.
Future<ConversationSnapshot> _loadContext(
ConversationSnapshot current,
String? projectId,
) async {
final repository = await ref.read(conversationRepositoryProvider.future);
final trashed = projectId == null
? const <ConversationMetadata>[]
: await repository.list(projectId, trash: true);
final selectedId = await ref.read(
savedConversationSelectionProvider(projectId).future,
);
return current.copyWith(
projectId: projectId,
trashed: List.unmodifiable(trashed),
selectedId: selectedId,
reloadFailed: false,
);
}
Future<void> _refreshContext(String? projectId) async {
final current = state.value;
if (current == null) return; // Initial loading resolves the latest context.
final revision = ++_revision;
state = AsyncData(
current.copyWith(
projectId: projectId,
trashed: const [],
selectedId: null,
),
);
try {
final next = await _loadContext(current, projectId);
if (ref.mounted &&
revision == _revision &&
ref.read(projectsProvider).value?.activeProject?.id == projectId) {
state = AsyncData(next);
}
} catch (_) {
if (ref.mounted && revision == _revision) {
state = AsyncData(state.requireValue.copyWith(reloadFailed: true));
}
}
}
Future<ConversationSnapshot> _load(ProjectState workspace) async {
@@ -220,7 +220,7 @@ final class ConversationSidebarProvider
}
String _$conversationSidebarHash() =>
r'13122a844ce87622c8d4919042e4dbefc69b790f';
r'ccb6d44f3c675b664a0e0925f9257b351061a899';
abstract class _$ConversationSidebar
extends $AsyncNotifier<ConversationSnapshot> {
@@ -5,7 +5,6 @@ import '../../l10n/l10n.dart';
import '../../workspace/project_state.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
class EmptyEditor extends StatelessWidget {
const EmptyEditor({
@@ -13,32 +12,44 @@ class EmptyEditor extends StatelessWidget {
required this.state,
required this.headerLeading,
required this.showProjectName,
this.desktop = false,
});
final ProjectState state;
final Widget headerLeading;
final bool showProjectName;
final bool desktop;
@override
Widget build(BuildContext context) => Column(
children: [
SizedBox(
height: AppControlSize.panelHeader,
child: WindowHeaderPadding(
child: Row(
children: [
headerLeading,
if (showProjectName)
Expanded(
child: Text(
state.activeProject?.name ?? '',
key: const Key('workspace-project-title'),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.titleSmall,
height: desktop
? AppControlSize.panelToolbar
: AppControlSize.panelHeader,
child: Padding(
padding: desktop
? const EdgeInsets.symmetric(
horizontal: AppSidebarMetrics.outerPadding,
vertical: AppSpacing.gap,
)
: EdgeInsets.zero,
child: WindowHeaderPadding(
child: Row(
children: [
headerLeading,
if (showProjectName)
Expanded(
child: Text(
state.activeProject?.name ?? '',
key: const Key('workspace-project-title'),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.titleSmall,
),
),
),
],
],
),
),
),
),
@@ -77,40 +88,3 @@ class EmptyEditor extends StatelessWidget {
],
);
}
class ProjectLoadingRegion extends StatelessWidget {
const ProjectLoadingRegion({
super.key,
required this.loading,
required this.child,
});
final bool loading;
final Widget child;
@override
Widget build(BuildContext context) => Stack(
fit: StackFit.expand,
children: [
ExcludeFocus(
excluding: loading,
child: IgnorePointer(ignoring: loading, child: child),
),
if (loading)
DelayedLoadingIndicator(
child: Positioned.fill(
child: ColoredBox(
key: const Key('editor-project-loading'),
color: Theme.of(context).colorScheme.surface,
child: const Center(
child: SizedBox.square(
dimension: 20,
child: CircularProgressIndicator(strokeWidth: 2),
),
),
),
),
),
],
);
}
+400 -276
View File
@@ -1,5 +1,8 @@
import 'package:cutdex/shared/widgets/error_notification_host.dart';
import '../../integrations/platform/device_experience.dart';
import 'touch_project_navigation.dart';
import '../media/media_panel.dart';
import 'package:cutdex_ui/theme.dart';
@@ -8,6 +11,9 @@ import 'dart:async';
import 'package:cutdex/l10n/l10n.dart';
import 'package:flutter/material.dart';
import '../../shared/widgets/listenable_selector.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../integrations/platform/editor_window_chrome.dart';
@@ -38,6 +44,8 @@ class ProjectSidebar extends ConsumerStatefulWidget {
super.key,
required this.agent,
this.navigationOnly = false,
this.resourcesSelected = false,
this.externalWindowFrame = false,
this.experience = DeviceExperience.desktop,
this.onNavigationComplete,
required this.mode,
@@ -58,6 +66,8 @@ class ProjectSidebar extends ConsumerStatefulWidget {
final Widget agent;
final bool navigationOnly;
final bool resourcesSelected;
final bool externalWindowFrame;
final DeviceExperience experience;
final VoidCallback? onNavigationComplete;
final ProjectState state;
@@ -80,6 +90,7 @@ class ProjectSidebar extends ConsumerStatefulWidget {
}
class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
bool _resourcesVisited = false;
bool get _touch => widget.experience != DeviceExperience.desktop;
bool _projectHeaderHovered = false;
String? _hoveredProjectId;
@@ -87,6 +98,30 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
final Set<String> _expandedConversationProjects = {};
final Set<String> _collapsedProjects = {};
bool _showTrash = false;
late final ValueNotifier<String?> _projectSelection;
final _groupWidgets = <String, (Object, Widget)>{};
@override
void initState() {
super.initState();
_resourcesVisited = widget.resourcesSelected;
_projectSelection = ValueNotifier(widget.selectedProjectId);
}
@override
void didUpdateWidget(covariant ProjectSidebar oldWidget) {
super.didUpdateWidget(oldWidget);
_resourcesVisited |= widget.resourcesSelected;
_projectSelection.value = widget.selectedProjectId;
final ids = widget.state.recent.map((project) => project.id).toSet();
_groupWidgets.removeWhere((id, _) => !ids.contains(id));
}
@override
void dispose() {
_projectSelection.dispose();
super.dispose();
}
ConversationSidebar get _conversations =>
ref.read(conversationSidebarProvider.notifier);
@@ -98,11 +133,8 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
}
Map<String, List<ConversationMetadata>> get _conversationsByProject =>
_snapshot.groups;
ref.read(conversationSidebarProvider).value?.groups ?? const {};
List<ConversationMetadata> get _trashed => _snapshot.trashed;
String? get _selectedConversationId => ref
.read(conversationSelectionProvider(widget.state.activeProject?.id))
.selectedId;
String? get _conversationError =>
(ref.read(conversationSidebarProvider).hasError || _snapshot.reloadFailed)
? context.l10n.agentSessionRestoreFailed
@@ -253,9 +285,9 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
await _conversations.delete(item);
} catch (_) {
if (mounted) {
ScaffoldMessenger.of(
ErrorNotificationHost.of(
context,
).showSnackBar(SnackBar(content: Text(context.l10n.operationFailed)));
).show(ErrorNotification(content: Text(context.l10n.operationFailed)));
}
}
}
@@ -293,74 +325,84 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
) ==
true;
Widget _conversationRow(ConversationMetadata item) {
final selected =
widget.state.activeProject?.id == item.projectId &&
_selectedConversationId == item.id;
List<Widget> actions(BuildContext context) => [
AppMenuItem(
label: context.l10n.rename,
onPressed: () => _renameConversation(item),
),
AppMenuItem(
label: context.l10n.agentMoveToTrash,
onPressed: () => _trashConversation(item),
),
AppMenuItem(
label: context.l10n.agentRelinkProvider,
onPressed: () => _relinkProvider(item),
),
const AppMenuSeparator(),
AppMenuItem(
label: '${context.l10n.agentDeleteForever}…',
destructive: true,
onPressed: () => _deleteForever(item),
),
];
if (_touch) {
return TouchConversationTile(
id: item.id,
title: item.title,
selected: selected,
onSelect: () => _selectConversation(item),
actions: actions,
Widget _conversationRow(ConversationMetadata item) => Consumer(
builder: (context, ref, _) {
final active = ref.watch(
projectsProvider.select(
(value) => value.value?.activeProject?.id == item.projectId,
),
);
}
return Padding(
padding: AppSidebarMetrics.rowPadding,
child: AppContextMenu(
itemsBuilder: actions,
child: Material(
color: selected
? AppSidebarColors.of(context).hover
: Colors.transparent,
borderRadius: BorderRadius.circular(AppSidebarMetrics.radius),
child: InkWell(
key: ValueKey('sidebar-conversation-${item.id}'),
hoverColor: selected
? Colors.transparent
: AppSidebarColors.of(context).hover,
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
final selected =
ref.watch(
conversationSelectionProvider(item.projectId)
.select((value) => value.selectedId == item.id),
) &&
active;
List<Widget> actions(BuildContext context) => [
AppMenuItem(
label: context.l10n.rename,
onPressed: () => _renameConversation(item),
),
AppMenuItem(
label: context.l10n.agentMoveToTrash,
onPressed: () => _trashConversation(item),
),
AppMenuItem(
label: context.l10n.agentRelinkProvider,
onPressed: () => _relinkProvider(item),
),
const AppMenuSeparator(),
AppMenuItem(
label: '${context.l10n.agentDeleteForever}…',
destructive: true,
onPressed: () => _deleteForever(item),
),
];
if (_touch) {
return TouchConversationTile(
id: item.id,
title: item.title,
selected: selected,
onSelect: () => _selectConversation(item),
actions: actions,
);
}
return Padding(
padding: AppSidebarMetrics.rowPadding,
child: AppContextMenu(
itemsBuilder: actions,
child: Material(
color: selected
? AppSidebarColors.of(context).hover
: Colors.transparent,
borderRadius: BorderRadius.circular(AppSidebarMetrics.radius),
onTap: () => _selectConversation(item),
child: SizedBox(
height: AppSidebarMetrics.rowHeight,
child: Align(
alignment: AlignmentDirectional.centerStart,
child: Padding(
padding: const EdgeInsetsDirectional.only(
start: AppSidebarMetrics.textInset,
end: AppSidebarMetrics.cellPadding,
),
child: Text(
item.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: AppSidebarTypography.style(
context,
fontSize: AppSidebarMetrics.conversationFontSize,
height: AppSidebarMetrics.conversationLineHeight,
child: InkWell(
key: ValueKey('sidebar-conversation-${item.id}'),
hoverColor: selected
? Colors.transparent
: AppSidebarColors.of(context).hover,
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
borderRadius: BorderRadius.circular(AppSidebarMetrics.radius),
onTap: () => _selectConversation(item),
child: SizedBox(
height: AppSidebarMetrics.rowHeight,
child: Align(
alignment: AlignmentDirectional.centerStart,
child: Padding(
padding: const EdgeInsetsDirectional.only(
start: AppSidebarMetrics.textInset,
end: AppSidebarMetrics.cellPadding,
),
child: Text(
item.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: AppSidebarTypography.style(
context,
fontSize: AppSidebarMetrics.conversationFontSize,
height: AppSidebarMetrics.conversationLineHeight,
),
),
),
),
@@ -368,11 +410,39 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
),
),
),
),
);
}
);
},
);
Widget _projectGroup(RecentProject project) {
final configuration = (
project,
_touch,
Localizations.localeOf(context),
Theme.of(context),
_expandedConversationProjects.contains(project.id),
_collapsedProjects.contains(project.id),
_hoveredProjectId == project.id,
widget.state.projectBusy,
);
final cached = _groupWidgets[project.id];
if (cached?.$1 == configuration) return cached!.$2;
final group = Consumer(
key: ValueKey('sidebar-project-binding-${project.id}'),
builder: (context, ref, _) {
ref.watch(
conversationSidebarProvider.select(
(value) => value.value?.groups[project.id],
),
);
return _buildProjectGroup(project);
},
);
_groupWidgets[project.id] = (configuration, group);
return group;
}
Widget _buildProjectGroup(RecentProject project) {
final conversations = _conversationsByProject[project.id] ?? const [];
final expanded = _expandedConversationProjects.contains(project.id);
final collapsed = _collapsedProjects.contains(project.id);
@@ -382,6 +452,7 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
? conversations
: conversations.take(5);
return Column(
key: ValueKey('sidebar-project-group-${project.id}'),
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
MouseRegion(
@@ -391,65 +462,70 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
setState(() => _hoveredProjectId = null);
}
},
child: _touch
? TouchProjectTile(
project: project,
selected: widget.selectedProjectId == project.id,
expanded: !collapsed,
availabilityLabel: _availabilityLabel(
context,
project.availability,
),
onSelect: () => _selectProjectFromNavigation(project),
onToggle: () => setState(() {
if (collapsed) {
_collapsedProjects.remove(project.id);
} else {
_collapsedProjects.add(project.id);
}
}),
onNewConversation:
widget.state.projectBusy || !project.availability.canOpen
? null
: () => _newConversationForProject(project),
onRename: project.availability.canOpen
? () => widget.onRenameProject(project)
: null,
onRemove: widget.state.projectBusy
? null
: () => _removeProject(project),
)
: Padding(
padding: AppSidebarMetrics.rowPadding,
child: _ProjectTile(
child: ListenableSelector(
listenable: _projectSelection,
select: () => _projectSelection.value == project.id,
builder: (context, selected) => _touch
? TouchProjectTile(
project: project,
active: widget.selectedProjectId == project.id,
selected: selected,
expanded: !collapsed,
availabilityLabel: _availabilityLabel(
context,
project.availability,
),
onSelect: () {
_cutProjectsMenu.close();
_selectProjectFromNavigation(project);
},
onRename: () => widget.onRenameProject(project),
onRemove: widget.state.projectBusy
? null
: () => _removeProject(project),
expanded: !collapsed,
onToggleExpanded: () => setState(() {
onSelect: () => _selectProjectFromNavigation(project),
onToggle: () => setState(() {
if (collapsed) {
_collapsedProjects.remove(project.id);
} else {
_collapsedProjects.add(project.id);
}
}),
sidebarStyle: true,
hovered: _hoveredProjectId == project.id,
onNewConversation: () =>
_newConversationForProject(project),
onNewConversation:
widget.state.projectBusy ||
!project.availability.canOpen
? null
: () => _newConversationForProject(project),
onRename: project.availability.canOpen
? () => widget.onRenameProject(project)
: null,
onRemove: widget.state.projectBusy
? null
: () => _removeProject(project),
)
: Padding(
padding: AppSidebarMetrics.rowPadding,
child: _ProjectTile(
project: project,
active: selected,
availabilityLabel: _availabilityLabel(
context,
project.availability,
),
onSelect: () {
_cutProjectsMenu.close();
_selectProjectFromNavigation(project);
},
onRename: () => widget.onRenameProject(project),
onRemove: widget.state.projectBusy
? null
: () => _removeProject(project),
expanded: !collapsed,
onToggleExpanded: () => setState(() {
if (collapsed) {
_collapsedProjects.remove(project.id);
} else {
_collapsedProjects.add(project.id);
}
}),
sidebarStyle: true,
hovered: _hoveredProjectId == project.id,
onNewConversation: () =>
_newConversationForProject(project),
),
),
),
),
),
for (final item in visible) ...[
const SizedBox(height: AppSidebarMetrics.rowGap),
@@ -516,18 +592,21 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
@override
Widget build(BuildContext context) {
ref.watch(conversationSidebarProvider);
ref.watch(conversationSelectionProvider(widget.state.activeProject?.id));
final compact = MediaQuery.sizeOf(context).height < 520;
final headerHeight = widget.navigationOnly
final headerHeight = widget.externalWindowFrame
? 0.0
: widget.navigationOnly
? 48.0
: widget.integratedTitlebar
? AppControlSize.panelHeader
: AppControlSize.headerButton;
final modeTop = headerHeight;
final modeHeader = SizedBox(
key: const Key('project-content-header'),
height:
modeTop + AppSidebarMetrics.modeHeight + AppSidebarMetrics.sectionGap,
modeTop +
(_touch ? AppSidebarMetrics.modeHeight : 0) +
(widget.externalWindowFrame ? 0 : AppSidebarMetrics.sectionGap),
child: Stack(
children: [
Positioned(
@@ -554,94 +633,95 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
),
),
),
Positioned(
top: modeTop,
left: AppSidebarMetrics.outerPadding,
right: AppSidebarMetrics.outerPadding,
height: AppSidebarMetrics.modeHeight,
child: Align(
alignment: AlignmentDirectional.topStart,
child: AppPopover(
width: AppMenuMetrics.modeMenuWidth,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
for (final mode in WorkspaceMode.values)
AppMenuItem(
key: ValueKey('sidebar-mode-${mode.name}'),
label: mode == WorkspaceMode.agent
? context.l10n.workspaceAgent
: context.l10n.workspaceCut,
selected: widget.mode == mode,
description: mode == WorkspaceMode.agent
? context.l10n.agentLayoutDescription
: context.l10n.editingLayoutDescription,
onPressed: () {
widget.onModeChanged(mode);
if (widget.navigationOnly) _finishNavigation();
},
),
],
),
builder: (context, toggle) => TextButton(
key: const Key('sidebar-mode-trigger'),
onPressed: toggle,
style: ButtonStyle(
foregroundColor: sidebarActionButtonStyle(context)
.foregroundColor,
padding: const WidgetStatePropertyAll(
EdgeInsets.symmetric(horizontal: 8),
),
minimumSize: const WidgetStatePropertyAll(
Size(0, AppSidebarMetrics.modeHeight),
),
alignment: AlignmentDirectional.centerStart,
backgroundColor: WidgetStateProperty.resolveWith(
(states) =>
states.contains(WidgetState.hovered) ||
states.contains(WidgetState.focused) ||
states.contains(WidgetState.pressed)
? AppSidebarColors.of(context).hover
: Colors.transparent,
),
overlayColor: const WidgetStatePropertyAll(
Colors.transparent,
),
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
),
child: Row(
if (_touch)
Positioned(
top: modeTop,
left: AppSidebarMetrics.outerPadding,
right: AppSidebarMetrics.outerPadding,
height: AppSidebarMetrics.modeHeight,
child: Align(
alignment: AlignmentDirectional.topStart,
child: AppPopover(
width: AppMenuMetrics.modeMenuWidth,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: Text(
widget.mode == WorkspaceMode.agent
for (final mode in WorkspaceMode.values)
AppMenuItem(
key: ValueKey('sidebar-mode-${mode.name}'),
label: mode == WorkspaceMode.agent
? context.l10n.workspaceAgent
: context.l10n.workspaceCut,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: AppSidebarTypography.style(
context,
fontSize: AppSidebarMetrics.titleFontSize,
height: AppSidebarMetrics.titleLineHeight,
weight: FontWeight.w600,
),
selected: widget.mode == mode,
description: mode == WorkspaceMode.agent
? context.l10n.agentLayoutDescription
: context.l10n.editingLayoutDescription,
onPressed: () {
widget.onModeChanged(mode);
if (widget.navigationOnly) _finishNavigation();
},
),
],
),
builder: (context, toggle) => TextButton(
key: const Key('sidebar-mode-trigger'),
onPressed: toggle,
style: ButtonStyle(
foregroundColor: sidebarActionButtonStyle(context)
.foregroundColor,
padding: const WidgetStatePropertyAll(
EdgeInsets.symmetric(horizontal: 8),
),
minimumSize: const WidgetStatePropertyAll(
Size(0, AppSidebarMetrics.modeHeight),
),
alignment: AlignmentDirectional.centerStart,
backgroundColor: WidgetStateProperty.resolveWith(
(states) =>
states.contains(WidgetState.hovered) ||
states.contains(WidgetState.focused) ||
states.contains(WidgetState.pressed)
? AppSidebarColors.of(context).hover
: Colors.transparent,
),
overlayColor: const WidgetStatePropertyAll(
Colors.transparent,
),
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
const SizedBox(width: AppSpacing.small),
const Icon(
Icons.keyboard_arrow_down,
size: AppSidebarMetrics.iconSize,
),
],
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: Text(
widget.mode == WorkspaceMode.agent
? context.l10n.workspaceAgent
: context.l10n.workspaceCut,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: AppSidebarTypography.style(
context,
fontSize: AppSidebarMetrics.titleFontSize,
height: AppSidebarMetrics.titleLineHeight,
weight: FontWeight.w600,
),
),
),
const SizedBox(width: AppSpacing.small),
const Icon(
Icons.keyboard_arrow_down,
size: AppSidebarMetrics.iconSize,
),
],
),
),
),
),
),
),
],
),
);
@@ -656,9 +736,9 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
onEnter: (_) => setState(() => _projectHeaderHovered = true),
onExit: (_) => setState(() => _projectHeaderHovered = false),
child: Padding(
padding: const EdgeInsets.fromLTRB(
padding: EdgeInsets.fromLTRB(
AppSidebarMetrics.outerPadding,
0,
_touch ? 0 : AppSpacing.gap,
AppSidebarMetrics.outerPadding,
AppSidebarMetrics.sectionGap,
),
@@ -692,79 +772,102 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
if (index > 0) const SizedBox(height: AppSidebarMetrics.projectGap),
_projectGroup(widget.state.recent[index]),
],
if (_conversationError != null)
Padding(
padding: const EdgeInsets.all(AppSpacing.small),
child: Text(
_conversationError!,
style: Theme.of(context).textTheme.bodySmall,
),
),
if (widget.state.activeProject != null &&
(_trashed.isNotEmpty || _showTrash))
ExpansionTile(
title: Text(
context.l10n.agentTrash,
style: AppSidebarTypography.style(
context,
color: AppSidebarColors.of(context).tertiary,
weight: FontWeight.w500,
Consumer(
builder: (context, ref, _) {
ref.watch(
conversationSidebarProvider.select(
(value) => (value.hasError, value.value?.reloadFailed),
),
),
initiallyExpanded: _showTrash,
onExpansionChanged: (value) => setState(() => _showTrash = value),
trailing: _trashed.isEmpty
? null
: TextButton(
onPressed: _emptyTrash,
child: Text(context.l10n.agentEmptyTrash),
),
children: [
ListView.builder(
primary: false,
shrinkWrap: true,
itemCount: _trashed.length,
itemBuilder: (context, index) {
final item = _trashed[index];
return ListTile(
dense: true,
title: Text(
item.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: AppSidebarTypography.style(
context,
fontSize: AppSidebarMetrics.fontSize,
height: AppSidebarMetrics.lineHeight,
color: AppSidebarColors.of(context).secondary,
),
),
trailing: PopupMenuButton<String>(
tooltip: context.l10n.agentConversationActions,
onSelected: (value) {
if (value == 'restore') {
_restoreConversation(item);
}
if (value == 'delete') _deleteForever(item);
},
itemBuilder: (context) => [
PopupMenuItem(
height: AppMenuMetrics.rowHeight,
value: 'restore',
child: Text(context.l10n.agentRestore),
),
PopupMenuItem(
height: AppMenuMetrics.rowHeight,
value: 'delete',
child: Text(context.l10n.agentDeleteForever),
),
],
);
return _conversationError == null
? const SizedBox.shrink()
: Padding(
padding: const EdgeInsets.all(AppSpacing.small),
child: Text(
_conversationError!,
style: Theme.of(context).textTheme.bodySmall,
),
);
},
},
),
Consumer(
builder: (context, ref, _) {
ref.watch(
conversationSidebarProvider.select(
(value) => (value.value?.projectId, value.value?.trashed),
),
],
),
);
return widget.state.activeProject == null ||
(_trashed.isEmpty && !_showTrash)
? const SizedBox.shrink()
: ExpansionTile(
title: Text(
context.l10n.agentTrash,
style: AppSidebarTypography.style(
context,
color: AppSidebarColors.of(context).tertiary,
weight: FontWeight.w500,
),
),
initiallyExpanded: _showTrash,
onExpansionChanged: (value) =>
setState(() => _showTrash = value),
trailing: _trashed.isEmpty
? null
: TextButton(
onPressed: _emptyTrash,
child: Text(context.l10n.agentEmptyTrash),
),
children: [
ListView.builder(
primary: false,
shrinkWrap: true,
itemCount: _trashed.length,
itemBuilder: (context, index) {
final item = _trashed[index];
return ListTile(
dense: true,
title: Text(
item.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: AppSidebarTypography.style(
context,
fontSize: AppSidebarMetrics.fontSize,
height: AppSidebarMetrics.lineHeight,
color: AppSidebarColors.of(context).secondary,
),
),
trailing: PopupMenuButton<String>(
tooltip: context.l10n.agentConversationActions,
onSelected: (value) {
if (value == 'restore') {
_restoreConversation(item);
}
if (value == 'delete') _deleteForever(item);
},
itemBuilder: (context) => [
PopupMenuItem(
height: AppMenuMetrics.rowHeight,
value: 'restore',
child: Text(context.l10n.agentRestore),
),
PopupMenuItem(
height: AppMenuMetrics.rowHeight,
value: 'delete',
child: Text(
context.l10n.agentDeleteForever,
),
),
],
),
);
},
),
],
);
},
),
],
),
);
@@ -776,7 +879,28 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
modeHeader,
Expanded(child: projectList),
Expanded(
child: _touch
? projectList
: IndexedStack(
index: widget.resourcesSelected ? 1 : 0,
children: [
TickerMode(
enabled: !widget.resourcesSelected,
child: projectList,
),
TickerMode(
enabled: widget.resourcesSelected,
child: _resourcesVisited
? MediaPanel(
projectId: widget.state.activeProject?.id,
onSelectProject: widget.onSelectProject,
)
: Center(child: Text(context.l10n.projectsNone)),
),
],
),
),
],
),
);
@@ -0,0 +1,60 @@
import 'dart:async';
import 'package:flutter/widgets.dart';
/// Keeps the current content during short switches without delaying completion.
class ProjectSwitchRegion extends StatefulWidget {
const ProjectSwitchRegion({
super.key,
required this.pendingProjectId,
required this.builder,
});
final String? pendingProjectId;
final Widget Function(BuildContext context, bool showDefaults) builder;
@override
State<ProjectSwitchRegion> createState() => _ProjectSwitchRegionState();
}
class _ProjectSwitchRegionState extends State<ProjectSwitchRegion> {
Timer? _timer;
bool _showDefaults = false;
@override
void initState() {
super.initState();
_reset();
}
@override
void didUpdateWidget(covariant ProjectSwitchRegion oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.pendingProjectId != widget.pendingProjectId) _reset();
}
void _reset() {
_timer?.cancel();
_showDefaults = false;
if (widget.pendingProjectId != null) {
_timer = Timer(const Duration(milliseconds: 150), () {
if (mounted) setState(() => _showDefaults = true);
});
}
}
@override
Widget build(BuildContext context) => ExcludeFocus(
excluding: widget.pendingProjectId != null,
child: IgnorePointer(
ignoring: widget.pendingProjectId != null,
child: widget.builder(context, _showDefaults),
),
);
@override
void dispose() {
_timer?.cancel();
super.dispose();
}
}
+360 -278
View File
@@ -1,3 +1,4 @@
import 'package:cutdex/shared/widgets/error_notification_host.dart';
import 'package:cutdex/errors/app_failure.dart';
import 'dart:async';
@@ -7,9 +8,12 @@ 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';
@@ -30,8 +34,9 @@ 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_dialog.dart';
import '../settings/settings_page.dart';
import 'editor_loading_region.dart';
import 'project_switch_region.dart';
import 'project_sidebar.dart';
import 'widgets/name_dialog.dart';
@@ -103,7 +108,7 @@ class _EditingPageState extends ConsumerState<EditingPage> {
if (!created && context.mounted) {
final error = ref.read(projectsProvider).value?.error;
if (error?.requiresProjectLocation == true) {
await showSettingsDialog(context);
await showSettingsPage(context);
}
}
return;
@@ -113,10 +118,13 @@ class _EditingPageState extends ConsumerState<EditingPage> {
.pickDirectory(confirmButtonText: context.l10n.openProject);
if (directory == null || !context.mounted) return;
await ref.read(projectsProvider.notifier).open(directory);
} catch (_) {
} catch (error) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(context.l10n.selectDirectoryFailed)),
ErrorNotificationHost.of(context).show(
ErrorNotification(
content: Text(context.l10n.selectDirectoryFailed),
details: error.toString(),
),
);
}
}
@@ -174,10 +182,11 @@ class _EditingPageState extends ConsumerState<EditingPage> {
ref.watch(workspaceNavigationProvider);
final experience = ref.watch(deviceExperienceProvider);
final desktop = experience == DeviceExperience.desktop;
final contentSelection = ref.watch(desktopContentProvider);
final projects = ref.watch(projectsProvider);
final state = projects.value ?? const ProjectState();
return EditorWindowChrome(
headerHeight: desktop ? AppControlSize.panelHeader : 48,
headerHeight: desktop ? DesktopWindowFrame.headerHeight : 48,
builder: (context, integrated) => Scaffold(
body: SafeArea(
top: !integrated,
@@ -195,120 +204,138 @@ class _EditingPageState extends ConsumerState<EditingPage> {
final navigationHiddenBySpace =
desktop &&
!WorkspaceLayoutPolicy.desktopNavigationFits(
constraints.maxWidth,
constraints.maxWidth -
DesktopWindowFrame.railWidth -
DesktopWindowFrame.contentInset,
);
final navigationCollapsed =
_sidebarCollapsed || navigationHiddenBySpace;
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: Row(
mainAxisSize: MainAxisSize.min,
spacing: AppSpacing.tiny,
children: [
if (navigationToggle)
SizedBox.square(
dimension: AppControlSize.headerButton,
child: IconButton(
key: const Key(
'project-sidebar-toggle',
),
tooltip: navigationCollapsed
? context.l10n.expandSidebar
: context.l10n.collapseSidebar,
onPressed: () {
if (navigationHiddenBySpace) {
_desktopScaffoldKey.currentState
?.openDrawer();
} else {
_sidebarCollapsed =
!_sidebarCollapsed;
_saveViewState();
}
},
style: sidebarActionButtonStyle(
context,
),
icon: const Icon(
Icons.view_sidebar_outlined,
size: AppIconSize.header,
),
),
),
if (desktop &&
navigationCollapsed &&
navigationToggle)
PopupMenuButton<WorkspaceMode>(
key: const Key('desktop-workspace-mode'),
initialValue: _mode,
onSelected: _setMode,
itemBuilder: (context) => [
for (final mode in WorkspaceMode.values)
PopupMenuItem(
key: ValueKey(
'desktop-mode-${mode.name}',
),
value: mode,
child: Text(
mode == WorkspaceMode.agent
? context.l10n.workspaceAgent
: context.l10n.workspaceCut,
),
child: Padding(
padding: EdgeInsets.only(
left: desktop
? (DesktopWindowFrame.railWidth -
AppControlSize.headerButton) /
2
: 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: () {
if (navigationHiddenBySpace) {
_desktopScaffoldKey.currentState
?.openDrawer();
} else {
_sidebarCollapsed =
!_sidebarCollapsed;
_saveViewState();
}
},
style: sidebarActionButtonStyle(
context,
),
icon: const Icon(
Icons.view_sidebar_outlined,
size: AppIconSize.header,
),
],
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 6,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
_mode == WorkspaceMode.agent
? context.l10n.workspaceAgent
: context.l10n.workspaceCut,
),
const Icon(
Icons.keyboard_arrow_down,
size: 16,
),
],
),
),
),
SizedBox.square(
dimension: desktop
? AppControlSize.headerButton
: 48,
child: IconButton(
key: const Key('project-settings-button'),
tooltip: context.l10n.settings,
onPressed: () =>
showSettingsDialog(context),
style: sidebarActionButtonStyle(context),
icon: const Icon(
Icons.settings_outlined,
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(
Icons.settings_outlined,
size: AppIconSize.header,
),
),
),
),
),
SizedBox.square(
dimension: desktop
? AppControlSize.headerButton
: 48,
child: const BackgroundTasksButton(),
),
],
controlSlot(const BackgroundTasksButton()),
],
),
),
);
Widget leading() => Row(
mainAxisSize: MainAxisSize.min,
children: [
if (navigationCollapsed && integrated)
if (!desktop &&
navigationCollapsed &&
integrated)
SizedBox(
width: EditorWindowChrome.leadingWidth,
),
if (navigationCollapsed) controls(),
if (!desktop && navigationCollapsed) controls(),
const SizedBox(width: AppSpacing.compact),
],
);
@@ -330,19 +357,43 @@ class _EditingPageState extends ConsumerState<EditingPage> {
onCreateProject: () =>
_selectProject(context, ref, create: true),
);
void selectSidebar(bool resources) {
ref
.read(desktopContentProvider.notifier)
.select(
resources
? DesktopContent.library
: DesktopContent.workspace,
);
setState(() => _sidebarCollapsed = false);
_saveViewState();
if (navigationHiddenBySpace) {
WidgetsBinding.instance.addPostFrameCallback((
_,
) {
if (mounted) {
_desktopScaffoldKey.currentState
?.openDrawer();
}
});
}
}
Widget navigation({
DesktopWorkspaceGeometry? geometry,
VoidCallback? expandEditor,
bool drawer = false,
}) => ProjectSidebar(
experience: experience,
resourcesSelected:
desktop && contentSelection.resourcesSelected,
key: drawer
? _drawerNavigationKey
: _navigationKey,
agent: desktop && !drawer
? agent
: const SizedBox.shrink(),
navigationOnly: !desktop || drawer,
navigationOnly: true,
onNavigationComplete: desktop && !drawer
? null
: () => Navigator.of(context).maybePop(),
@@ -359,14 +410,15 @@ class _EditingPageState extends ConsumerState<EditingPage> {
state: state,
selectedProjectId:
_selectedProjectId ?? state.activeProject?.id,
integratedTitlebar: integrated,
integratedTitlebar: !desktop && integrated,
externalWindowFrame: desktop && !drawer,
onCreateProject: () =>
_selectProject(context, ref, create: true),
onSelectProject: selectProject,
onRenameProject: (project) =>
_renameProject(context, ref, project),
headerControls: desktop && !drawer
? controls()
? const SizedBox.shrink()
: HeaderControlRegion(
child: Row(
mainAxisSize: MainAxisSize.min,
@@ -386,61 +438,210 @@ class _EditingPageState extends ConsumerState<EditingPage> {
),
),
);
final editor = ProjectLoadingRegion(
loading: _switchingProject,
child:
state.activeProject != null &&
state.timeline != null
? EditorWorkspace(
key: _editorKey,
experience: experience,
projectId: state.activeProject!.id,
timelineId: state.timeline!.id,
projectName: state.activeProject!.name,
showProjectName:
desktop && _mode == WorkspaceMode.cut,
integratedTitlebar: desktop && integrated,
headerLeading:
desktop && _mode == WorkspaceMode.cut
? leading()
: const SizedBox(
width: AppSpacing.compact,
),
)
: EmptyEditor(
state: state,
showProjectName:
desktop && _mode == WorkspaceMode.cut,
headerLeading:
desktop && _mode == WorkspaceMode.cut
? leading()
: const SizedBox(
width: AppSpacing.compact,
),
),
final pendingProject = _switchingProject
? state.recent
.where(
(item) => item.id == _selectedProjectId,
)
.firstOrNull
: null;
final projectLoading =
pendingProject != null &&
pendingProject.id != state.activeProject?.id;
final editor = ProjectSwitchRegion(
pendingProjectId: projectLoading
? pendingProject.id
: null,
builder: (context, showDefaults) {
final displayDefaults =
projectLoading && showDefaults;
final visibleProject = displayDefaults
? pendingProject
: state.activeProject;
return visibleProject != null &&
(displayDefaults ||
state.timeline != null)
? EditorWorkspace(
key: _editorKey,
experience: experience,
projectId: visibleProject.id,
timelineId: displayDefaults
? ''
: state.timeline!.id,
projectName: visibleProject.name,
projectLoading: displayDefaults,
showProjectName:
desktop &&
_mode == WorkspaceMode.cut,
integratedTitlebar: false,
headerLeading: desktop
? const SizedBox.shrink()
: const SizedBox(
width: AppSpacing.compact,
),
)
: EmptyEditor(
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,
initialTab:
contentSelection.settingsTab,
navigationRequest: contentSelection
.settingsRequest,
workspace:
contentSelection.workspace,
),
)
: const SizedBox.shrink(),
),
],
);
return switch (experience) {
DeviceExperience.desktop => DesktopWorkspaceShell(
controller: _desktopSplits,
scaffoldKey: _desktopScaffoldKey,
navigationDrawer: navigation(drawer: true),
mode: _mode,
sidebarCollapsed: navigationCollapsed,
sidebarWidth: _sidebarWidthOverride,
onSidebarCollapsedChanged: (value) {
_sidebarCollapsed = value;
_saveViewState();
DeviceExperience.desktop => DesktopWindowFrame(
integratedTitlebar: integrated,
headerControls: controls(),
librarySelected:
contentSelection.surface ==
DesktopContent.library,
settingsSelected:
contentSelection.surface ==
DesktopContent.settings,
onModeChanged: (mode) {
selectSidebar(false);
_setMode(mode);
},
onSidebarWidthChanged: (value) {
_sidebarWidthOverride = value;
_saveViewState();
},
sidebarBuilder: (geometry, expand) =>
navigation(
geometry: geometry,
expandEditor: expand,
onLibraryPressed: () => selectSidebar(true),
onSettingsPressed: () =>
showSettingsPage(context),
child: desktopContents(
DesktopWorkspaceShell(
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) => Column(
children: [
SizedBox(
key: const Key(
'agent-content-header',
),
height: AppControlSize.panelToolbar,
child: Padding(
padding: const EdgeInsets.all(
AppSpacing.gap,
),
child: Row(
children: [
const Spacer(),
HeaderControlRegion(
child: SizedBox.square(
dimension: AppControlSize
.headerButton,
child: IconButton(
key: const Key(
'agent-fullscreen-button',
),
isSelected:
geometry.editorHidden,
tooltip:
geometry.editorHidden
? context
.l10n
.exitPreviewFullscreen
: context
.l10n
.agentFullscreen,
onPressed:
geometry.editorHidden
? expand
: () => _desktopSplits
.setAgentFullscreen(
true,
),
icon: Icon(
size:
AppIconSize.header,
geometry.editorHidden
? Icons
.fullscreen_exit
: Icons.fullscreen,
),
),
),
),
],
),
),
),
Expanded(child: agent),
],
),
editor: editor,
editor: editor,
),
),
),
DeviceExperience.tablet => TabletWorkspaceShell(
mode: _mode,
@@ -472,10 +673,11 @@ class _EditingPageState extends ConsumerState<EditingPage> {
PositionedDirectional(
top: AppSpacing.compact,
end: AppSpacing.compact,
child: _SonnerErrorToast(
child: ErrorFailureListener(
message: projects.hasError
? const AppFailure(
? AppFailure(
AppErrorCode.loadProjectsFailed,
diagnostic: projects.error.toString(),
)
: state.error,
),
@@ -542,123 +744,3 @@ class _StartupLoadingState extends State<_StartupLoading>
),
);
}
class _SonnerErrorToast extends StatefulWidget {
const _SonnerErrorToast({required this.message});
final AppFailure? message;
@override
State<_SonnerErrorToast> createState() => _SonnerErrorToastState();
}
class _SonnerErrorToastState extends State<_SonnerErrorToast> {
static const _displayDuration = Duration(seconds: 6);
Timer? _timer;
AppFailure? _displayedMessage;
bool _visible = false;
@override
void initState() {
super.initState();
_show(widget.message);
}
@override
void didUpdateWidget(covariant _SonnerErrorToast oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.message != null &&
(oldWidget.message == null || widget.message != oldWidget.message)) {
_show(widget.message);
}
}
void _show(AppFailure? message) {
if (message == null) return;
_timer?.cancel();
_displayedMessage = message;
_visible = true;
_timer = Timer(_displayDuration, _hide);
}
void _hide() {
if (mounted) setState(() => _visible = false);
}
@override
void dispose() {
_timer?.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
final message = _displayedMessage;
if (message == null) return const SizedBox.shrink();
final theme = Theme.of(context);
return IgnorePointer(
ignoring: !_visible,
child: AnimatedSlide(
offset: _visible ? Offset.zero : const Offset(0.08, 0),
duration: const Duration(milliseconds: 180),
curve: Curves.easeOutCubic,
child: AnimatedOpacity(
opacity: _visible ? 1 : 0,
duration: const Duration(milliseconds: 160),
child: Semantics(
liveRegion: true,
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 360),
child: DecoratedBox(
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHigh,
border: Border.all(color: theme.colorScheme.outlineVariant),
borderRadius: BorderRadius.circular(AppRadius.large),
boxShadow: [
BoxShadow(
color: theme.colorScheme.shadow.withValues(alpha: .25),
blurRadius: 16,
offset: const Offset(0, 6),
),
],
),
child: Padding(
padding: const EdgeInsetsDirectional.only(
start: AppSpacing.compact,
top: AppSpacing.small,
bottom: AppSpacing.small,
end: AppSpacing.tiny,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.error_outline,
size: AppIconSize.small,
color: theme.colorScheme.error,
),
const SizedBox(width: AppSpacing.small),
Flexible(
child: Text(
context.l10n.failureMessage(message),
style: theme.textTheme.bodyMedium,
),
),
IconButton(
tooltip: MaterialLocalizations.of(context)
.closeButtonTooltip,
onPressed: _hide,
icon: const Icon(Icons.close, size: AppIconSize.small),
),
],
),
),
),
),
),
),
),
);
}
}