Files
cutdex/lib/features/projects/touch_project_navigation.dart
T
lingjhf 2e0033ce2d
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
feat(workspace): refresh desktop editing experience and prepare 0.1.2
2026-10-09 01:56:01 +08:00

139 lines
4.2 KiB
Dart

import 'package:flutter/material.dart';
import '../../l10n/l10n.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/widgets.dart';
import '../../workspace/project_state.dart';
class TouchProjectsHeader extends StatelessWidget {
const TouchProjectsHeader({super.key, required this.onCreate});
final VoidCallback? onCreate;
@override
Widget build(BuildContext context) => Row(
children: [
Expanded(child: Text(context.l10n.projects)),
SizedBox.square(
dimension: 48,
child: IconButton(
key: const Key('create-project'),
tooltip: context.l10n.newProject,
onPressed: onCreate,
icon: const Icon(AppIcons.add),
),
),
],
);
}
/// Touch navigation keeps its actions visible and uses finger-sized targets.
class TouchProjectTile extends StatelessWidget {
const TouchProjectTile({
super.key,
required this.project,
required this.selected,
required this.expanded,
required this.availabilityLabel,
required this.onSelect,
required this.onToggle,
required this.onNewConversation,
required this.onRename,
required this.onRemove,
});
final RecentProject project;
final bool selected;
final bool expanded;
final String availabilityLabel;
final VoidCallback onSelect;
final VoidCallback onToggle;
final VoidCallback? onNewConversation;
final VoidCallback? onRename;
final VoidCallback? onRemove;
@override
Widget build(BuildContext context) => ListTile(
key: ValueKey('sidebar-project-${project.id}'),
contentPadding: EdgeInsets.zero,
minTileHeight: 56,
selected: selected,
leading: IconButton(
key: ValueKey('sidebar-project-toggle-${project.id}'),
constraints: const BoxConstraints.tightFor(width: 48, height: 48),
tooltip: expanded
? context.l10n.collapseProject
: context.l10n.expandProject,
onPressed: onToggle,
icon: Icon(expanded ? AppIcons.expandMore : AppIcons.chevronRight),
),
title: Text(project.name, maxLines: 1, overflow: TextOverflow.ellipsis),
subtitle: project.availability.canOpen ? null : Text(availabilityLabel),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
key: ValueKey('new-agent-conversation-${project.id}'),
constraints: const BoxConstraints.tightFor(width: 48, height: 48),
tooltip: context.l10n.agentNewConversation,
onPressed: onNewConversation,
icon: const Icon(AppIcons.edit),
),
AppPopover(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
AppMenuItem(label: context.l10n.rename, onPressed: onRename),
AppMenuItem(
label: context.l10n.removeProjectFromSidebar,
onPressed: onRemove,
),
],
),
builder: (context, toggle) => IconButton(
key: ValueKey('sidebar-project-more-${project.id}'),
constraints: const BoxConstraints.tightFor(width: 48, height: 48),
onPressed: toggle,
icon: const Icon(AppIcons.more),
),
),
],
),
onTap: onSelect,
);
}
class TouchConversationTile extends StatelessWidget {
const TouchConversationTile({
super.key,
required this.id,
required this.title,
required this.selected,
required this.onSelect,
required this.actions,
});
final String id;
final String title;
final bool selected;
final VoidCallback onSelect;
final List<Widget> Function(BuildContext) actions;
@override
Widget build(BuildContext context) => ListTile(
key: ValueKey('sidebar-conversation-$id'),
minTileHeight: 48,
selected: selected,
title: Text(title, maxLines: 1, overflow: TextOverflow.ellipsis),
onTap: onSelect,
trailing: AppPopover(
child: Column(mainAxisSize: MainAxisSize.min, children: actions(context)),
builder: (context, toggle) => IconButton(
key: ValueKey('sidebar-conversation-more-$id'),
constraints: const BoxConstraints.tightFor(width: 48, height: 48),
onPressed: toggle,
icon: const Icon(AppIcons.more),
),
),
);
}