Files
openchamber-android-native/lib/screens/sessions_screen.dart
T
blumia 511c3b006b feat: write the UI in English, select only conversation content
- source strings are English again; Chinese comes from lib/l10n/zh.dart
  through tr()/trArgs() and AppText, and a language without a table
  (Spanish, ...) reads English instead of Chinese
- server and user data (titles, messages, file names, notes, task names)
  is drawn with plain Text, so it is never looked up in the table
- SelectionArea moved from the whole message list to the messages, the
  answer text, an opened tool call's details and the turn footer; status
  lines and folded tool rows no longer start a selection
- a message the transcript does not know (its start event was lost while
  the stream was down) fetches the tail once, so a turn continued from
  another client comes in with its prompt
- bump to 0.5.3
2026-11-26 11:48:16 +08:00

938 lines
31 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import '../api/models.dart';
import '../state.dart';
import '../widgets/project_icon.dart';
import 'features_screen.dart';
import 'servers_screen.dart';
import 'settings_screen.dart';
import '../l10n.dart';
/// The session list: a drawer on a phone, a persistent column on a wide
/// layout. Sessions are grouped by project, dated within it, and a row swipes
/// to pin, archive or delete.
class SessionListPane extends StatefulWidget {
final AppState app;
/// Called after a session (or the draft) was opened, so the drawer closes.
final VoidCallback? onOpened;
const SessionListPane({super.key, required this.app, this.onOpened});
@override
State<SessionListPane> createState() => _SessionListPaneState();
}
class _SessionListPaneState extends State<SessionListPane> {
bool _searchOpen = false;
Timer? _timer;
late final TextEditingController _searchCtrl;
final Set<String> _collapsed = {};
bool _showArchived = false;
/// Parents whose subagents are expanded. Collapsed is the default; the
/// parent of the open child expands once so its child is visible.
final Set<String> _expandedChildren = {};
String? _activeChildParent;
@override
void initState() {
super.initState();
_searchCtrl = TextEditingController();
}
@override
void dispose() {
_timer?.cancel();
_searchCtrl.dispose();
super.dispose();
}
AppState get _app => widget.app;
void _onSearchChanged(String v) {
_timer?.cancel();
_timer = Timer(const Duration(milliseconds: 350), () {
if (v.isEmpty) {
_app.refreshSessions();
} else {
_app.searchSessions(v);
}
});
}
@override
Widget build(BuildContext context) {
return ListenableBuilder(
listenable: _app,
builder: (context, _) {
_syncActiveParent();
final scheme = Theme.of(context).colorScheme;
return SafeArea(
child: Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(4, 6, 4, 0),
child: Row(
children: [
const SizedBox(width: 12),
const Expanded(
child: AppText('Sessions',
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.w600)),
),
IconButton(
icon: Icon(_searchOpen ? Icons.close : Icons.search),
tooltip: tr('Search'),
onPressed: () {
setState(() {
_searchOpen = !_searchOpen;
if (!_searchOpen) {
_searchCtrl.clear();
_app.refreshSessions();
}
});
},
),
IconButton(
icon: const Icon(Icons.add),
tooltip: tr('New session'),
onPressed: () => _newSession(),
),
],
),
),
if (_searchOpen)
Padding(
padding: const EdgeInsets.fromLTRB(12, 2, 12, 4),
child: TextField(
controller: _searchCtrl,
autofocus: true,
onChanged: _onSearchChanged,
decoration: InputDecoration(
hintText: tr('Search sessions'),
prefixIcon: const Icon(Icons.search),
border: const OutlineInputBorder(),
isDense: true,
),
),
),
if (_app.error != null)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
Expanded(
child: Text(_app.error!,
style: TextStyle(
color: scheme.error, fontSize: 13)),
),
TextButton(
onPressed: _app.refreshSessions,
child: const AppText('Retry')),
],
),
),
Expanded(child: _body(scheme)),
_serverFooter(scheme),
],
),
);
},
);
}
/// The bottom bar: the connected server on the left (tap to switch), the
/// settings key on the right, as the first-party phone sidebar has it.
Widget _serverFooter(ColorScheme scheme) {
return DecoratedBox(
decoration: BoxDecoration(
border: Border(
top: BorderSide(color: scheme.outlineVariant.withValues(alpha: 0.6)),
),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(8, 4, 4, 4),
child: Row(
children: [
Expanded(
child: InkWell(
borderRadius: BorderRadius.circular(10),
onTap: _instancesSheet,
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 6, vertical: 8),
child: Row(
children: [
Icon(Icons.dns_outlined,
size: 18, color: scheme.onSurfaceVariant),
const SizedBox(width: 8),
Expanded(
child: AppText(
_app.connectionName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 13,
color: scheme.onSurfaceVariant,
),
),
),
],
),
),
),
),
IconButton(
icon: const Icon(Icons.widgets_outlined),
tooltip: tr('All features'),
onPressed: _openFeatures,
),
IconButton(
icon: const Icon(Icons.settings_outlined),
tooltip: tr('Settings'),
onPressed: _openSettings,
),
],
),
),
);
}
void _openFeatures() {
widget.onOpened?.call();
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => FeaturesScreen(app: _app),
));
}
void _openSettings() {
// A phone's list is a drawer: close it before the settings page covers
// the shell.
widget.onOpened?.call();
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => SettingsScreen(app: _app),
));
}
Widget _body(ColorScheme scheme) {
final app = _app;
if (app.sessionsLoading && app.sessions.isEmpty) {
return const Center(child: CircularProgressIndicator());
}
final draft = app.draft;
final topLevel = [
for (final s in app.sessions)
if (!s.isChild) s
];
final pinned = [
for (final s in topLevel)
if (s.isPinned) s
]..sort((a, b) => b.pinnedAt.compareTo(a.pinnedAt));
final unpinned = [
for (final s in topLevel)
if (!s.isPinned) s
];
if (topLevel.isEmpty && draft == null) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
AppText(_searchCtrl.text.isEmpty ? 'No sessions' : 'No matching sessions'),
const SizedBox(height: 8),
FilledButton(
onPressed: () => _newSession(), child: const AppText('New session')),
],
),
);
}
return RefreshIndicator(
onRefresh: () async {
await app.refreshSessions();
if (app.archivedLoaded) await app.refreshArchived();
},
child: ListView(
padding: const EdgeInsets.only(bottom: 16),
children: [
if (draft != null) _draftRow(draft),
if (pinned.isNotEmpty) ..._pinnedSection(pinned),
for (final group in _groups(unpinned)) ..._groupSection(group),
_footer(scheme),
],
),
);
}
// --------------------------------------------------------------- groups
List<_SessionGroup> _groups(List<Session> sessions) {
final map = <String, List<Session>>{};
for (final session in sessions) {
// Group on a separator-normalised key so a Windows server's mix of
// `\` and `/` does not split one project into two.
final key = _app.isChatDirectory(session.directory)
? AppState.chatTarget
: slashPath(session.directory);
map.putIfAbsent(key, () => []).add(session);
}
final groups = [
for (final entry in map.entries)
_SessionGroup(
key: entry.key,
label: entry.key == AppState.chatTarget
? tr('Chat')
: _app.projectLabelFor(entry.value.first.directory),
// The first session's own path: the server knows that spelling.
path: entry.key == AppState.chatTarget
? ''
: entry.value.first.directory,
sessions: entry.value
..sort((a, b) => b.updated.compareTo(a.updated)),
),
];
groups.sort((a, b) {
final aTime = a.sessions.isEmpty ? 0 : a.sessions.first.updated;
final bTime = b.sessions.isEmpty ? 0 : b.sessions.first.updated;
return bTime.compareTo(aTime);
});
return groups;
}
List<Widget> _groupSection(_SessionGroup group) {
final collapsed = _collapsed.contains(group.key);
return [
_groupHeader(group, collapsed: collapsed),
if (!collapsed)
for (final entry in _dated(group.sessions)) ...[
_caption(entry.key),
for (final session in entry.value) ..._rowsWithChildren(session),
],
];
}
Widget _groupHeader(_SessionGroup group, {required bool collapsed}) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
// A ListTile with a title and a subtitle has the session rows' height and
// trailing slot; only the tinted band and the folder mark it as a project.
return Padding(
padding: const EdgeInsets.fromLTRB(8, 8, 8, 2),
child: Material(
color: scheme.surfaceContainerHighest.withValues(alpha: 0.5),
borderRadius: BorderRadius.circular(10),
clipBehavior: Clip.antiAlias,
child: ListTile(
// Compact like a session row: two dense lines in a 56px band.
dense: true,
minTileHeight: 56,
// The band already insets by 8, the same as a session row's
// content padding. No padding inside it then makes the folder
// chevron and the + share one vertical line with the session rows'
// chevron and ⋮.
contentPadding: EdgeInsets.zero,
leading: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(collapsed ? Icons.chevron_right : Icons.expand_more,
size: 18, color: scheme.onSurfaceVariant),
const SizedBox(width: 2),
ProjectIcon(
app: _app,
project: group.key == AppState.chatTarget
? null
: _app.projectFor(group.path),
chat: group.key == AppState.chatTarget,
size: 16,
),
],
),
title: Text(
group.label.isEmpty ? tr('Untitled project') : group.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.5,
fontWeight: FontWeight.w700,
color: scheme.onSurface,
),
),
subtitle: group.path.isEmpty
? null
: Text(
group.path,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 11.5, color: theme.hintColor),
),
// A fixed 48 slot, like the session rows' menu: both keys then sit
// on the same vertical line.
trailing: SizedBox(
width: 48,
height: 48,
child: IconButton(
icon: const Icon(Icons.add, size: 20),
padding: EdgeInsets.zero,
tooltip: group.key == AppState.chatTarget
? tr('New chat')
: tr('New session in this project'),
onPressed: () => _newSession(
directory: group.key == AppState.chatTarget
? AppState.chatTarget
: group.path),
),
),
onTap: () => setState(() {
if (collapsed) {
_collapsed.remove(group.key);
} else {
_collapsed.add(group.key);
}
}),
),
),
);
}
Widget _caption(String label) {
return Padding(
padding: const EdgeInsets.fromLTRB(28, 6, 12, 2),
child: AppText(label,
style: TextStyle(
fontSize: 11, color: Theme.of(context).hintColor)),
);
}
/// 今天 / 昨天 / 本周早些时候 / 更早, in that order.
List<MapEntry<String, List<Session>>> _dated(List<Session> sessions) {
final now = DateTime.now();
final today = DateTime(now.year, now.month, now.day);
final yesterday = today.subtract(const Duration(days: 1));
final weekAgo = today.subtract(const Duration(days: 7));
final buckets = <String, List<Session>>{
'Today': [],
'Yesterday': [],
'Earlier this week': [],
'Earlier': [],
};
for (final session in sessions) {
final time = session.updated > 0
? DateTime.fromMillisecondsSinceEpoch(session.updated)
: DateTime.fromMillisecondsSinceEpoch(session.created);
final day = DateTime(time.year, time.month, time.day);
final key = day == today
? 'Today'
: day == yesterday
? 'Yesterday'
: day.isAfter(weekAgo)
? 'Earlier this week'
: 'Earlier';
buckets[key]!.add(session);
}
return [
for (final entry in buckets.entries)
if (entry.value.isNotEmpty) entry,
];
}
// ----------------------------------------------------------------- rows
List<Widget> _pinnedSection(List<Session> pinned) {
final collapsed = _collapsed.contains('pinned');
return [
InkWell(
onTap: () => setState(() {
if (collapsed) {
_collapsed.remove('pinned');
} else {
_collapsed.add('pinned');
}
}),
child: Padding(
padding: const EdgeInsets.fromLTRB(14, 10, 4, 4),
child: Row(
children: [
Icon(Icons.push_pin,
size: 13, color: Theme.of(context).hintColor),
const SizedBox(width: 5),
Expanded(
child: AppText('Pinned',
style: TextStyle(
fontSize: 12.5,
fontWeight: FontWeight.w700,
color: Theme.of(context).hintColor)),
),
Icon(collapsed ? Icons.chevron_right : Icons.expand_more,
size: 16, color: Theme.of(context).hintColor),
],
),
),
),
if (!collapsed)
for (final session in pinned) ..._rowsWithChildren(session),
];
}
Widget _draftRow(SessionDraft draft) {
final theme = Theme.of(context);
final label = draft.firstLine.isEmpty ? tr('New session') : draft.firstLine;
final project = _app.projectLabelFor(draft.directory);
return ListTile(
selected: _app.draftOpen,
leading: Icon(Icons.edit_outlined, size: 18, color: theme.hintColor),
title: Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontStyle: FontStyle.italic),
),
subtitle: AppText(
project.isEmpty ? 'Draft' : trArgs('Draft · {0}', [project]),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
trailing: IconButton(
icon: const Icon(Icons.close, size: 18),
tooltip: tr('Discard draft'),
onPressed: () => _app.discardDraft(),
),
onTap: () {
_app.showDraft();
widget.onOpened?.call();
},
);
}
bool _isActive(Session session) {
if (_app.active.contains(session.id)) return true;
return _app.sessions
.any((s) => s.parentID == session.id && _app.active.contains(s.id));
}
/// The session's worker sessions (subagents). The API lists them among the
/// sessions, so they are drawn nested right below their parent.
List<Session> _childrenOf(Session parent, {bool archived = false}) {
final source = archived ? _app.archivedSessions : _app.sessions;
return [
for (final session in source)
if (session.parentID == parent.id) session,
]..sort((a, b) => a.created.compareTo(b.created));
}
List<Widget> _rowsWithChildren(Session session, {bool archived = false}) {
final rows = <Widget>[_row(session, archived: archived)];
if (!_expandedChildren.contains(session.id)) return rows;
final theme = Theme.of(context);
for (final child in _childrenOf(session, archived: archived)) {
rows.add(Container(
margin: const EdgeInsets.only(left: 24),
decoration: BoxDecoration(
border: Border(
left: BorderSide(color: theme.dividerColor, width: 1),
),
),
child: _row(child, archived: archived, child: true),
));
}
return rows;
}
/// Expands the parent of the open subagent once, so the sidebar shows where
/// the child is. Collapsing it by hand stays collapsed until another child
/// is opened.
void _syncActiveParent() {
final parent = _app.chat?.session.parentID;
if (parent == _activeChildParent) return;
_activeChildParent = parent;
if (parent != null) _expandedChildren.add(parent);
}
Widget _row(Session session,
{bool archived = false, bool child = false}) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final running = _isActive(session);
final selected =
!_app.draftOpen && _app.chat?.session.id == session.id;
final children = child ? const <Session>[] : _childrenOf(session, archived: archived);
final expanded = _expandedChildren.contains(session.id);
return Slidable(
key: ValueKey('${archived ? 'a' : 's'}-${session.id}'),
endActionPane: ActionPane(
motion: const DrawerMotion(),
extentRatio: 0.62,
children: [
if (!archived)
SlidableAction(
onPressed: (_) => _app.togglePin(session),
icon: Icons.push_pin_outlined,
label: session.isPinned ? tr('Unpin') : tr('Pin'),
backgroundColor: scheme.secondaryContainer,
foregroundColor: scheme.onSecondaryContainer,
),
SlidableAction(
onPressed: (_) => _archive(session, archived),
icon: archived ? Icons.unarchive_outlined : Icons.archive_outlined,
label: archived ? tr('Unarchive') : tr('Archive'),
backgroundColor: scheme.surfaceContainerHighest,
foregroundColor: scheme.onSurface,
),
SlidableAction(
onPressed: (_) => _confirmDelete(session),
icon: Icons.delete_outline,
label: tr('Delete'),
backgroundColor: scheme.errorContainer,
foregroundColor: scheme.onErrorContainer,
),
],
),
child: ListTile(
// Compact: both the project band and a session row are 56 high.
dense: true,
minTileHeight: 56,
// A fixed chevron column for every session row: rows without
// subagents keep the same title start as rows with them. A short gap
// after it keeps the title space wide.
contentPadding: child
? const EdgeInsets.only(left: 32, right: 8)
: const EdgeInsets.only(left: 8, right: 8),
horizontalTitleGap: 8,
selected: selected,
selectedTileColor: scheme.primary.withValues(alpha: 0.10),
leading: child
? null
: children.isEmpty
? const SizedBox(width: 18)
: SizedBox(
width: 18,
height: 40,
child: IconButton(
icon: Icon(
expanded
? Icons.expand_more
: Icons.chevron_right,
size: 18),
tooltip: expanded ? tr('Collapse subagents') : tr('Expand subagents'),
padding: EdgeInsets.zero,
visualDensity: VisualDensity.compact,
constraints:
const BoxConstraints(minWidth: 18, minHeight: 40),
onPressed: () => setState(() {
if (expanded) {
_expandedChildren.remove(session.id);
} else {
_expandedChildren.add(session.id);
}
}),
),
),
title: Text(
session.title.isEmpty ? tr('(Untitled session)') : session.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14,
fontWeight: selected ? FontWeight.w600 : FontWeight.w400,
),
),
subtitle: Text(
child ? trArgs('Subagent · {0}', [_subtitle(session)]) : _subtitle(session),
maxLines: 1,
overflow: TextOverflow.ellipsis),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (session.isPinned)
Padding(
padding: const EdgeInsets.only(right: 6),
child: Icon(Icons.push_pin,
size: 13, color: scheme.primary),
),
if (running)
Padding(
padding: const EdgeInsets.only(right: 6),
child: SizedBox(
width: 12,
height: 12,
child: CircularProgressIndicator(
strokeWidth: 1.8, color: scheme.primary),
),
),
_menu(session, archived: archived),
],
),
onTap: () {
_app.openChat(session);
widget.onOpened?.call();
},
),
);
}
Widget _menu(Session session, {required bool archived}) {
// The same 48 slot as the project header's +, so the keys line up.
return SizedBox(
width: 48,
height: 48,
child: PopupMenuButton<String>(
icon: const Icon(Icons.more_vert, size: 18),
onSelected: (value) {
switch (value) {
case 'rename':
_rename(session);
break;
case 'pin':
_app.togglePin(session);
break;
case 'archive':
_archive(session, archived);
break;
case 'delete':
_confirmDelete(session);
break;
case 'copy':
Clipboard.setData(ClipboardData(text: session.id));
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: AppText('Session ID copied')));
break;
}
},
itemBuilder: (_) => [
if (!archived) ...[
const PopupMenuItem(value: 'rename', child: AppText('Rename')),
PopupMenuItem(
value: 'pin',
child: AppText(session.isPinned ? 'Unpin' : 'Pin')),
],
PopupMenuItem(
value: 'archive',
child: AppText(archived ? 'Unarchive' : 'Archive')),
const PopupMenuItem(value: 'delete', child: AppText('Delete')),
const PopupMenuItem(value: 'copy', child: AppText('Copy session ID')),
],
),
);
}
Widget _footer(ColorScheme scheme) {
final app = _app;
final archivedCount =
app.archivedLoaded ? app.archivedSessions.length : null;
return Column(
children: [
if (app.hasMoreSessions)
TextButton(
onPressed: app.loadingMoreSessions ? null : app.loadMoreSessions,
child: app.loadingMoreSessions
? const SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(strokeWidth: 2))
: const AppText('Load more'),
),
TextButton.icon(
icon: Icon(
_showArchived
? Icons.expand_less
: Icons.archive_outlined,
size: 16),
label: AppText(
_showArchived
? 'Hide archived'
: archivedCount == null
? 'Show archived'
: trArgs('Show archived ({0})', [archivedCount]),
style: const TextStyle(fontSize: 12.5),
),
onPressed: app.archivedLoading ? null : _toggleArchived,
),
if (app.archivedLoading)
const Padding(
padding: EdgeInsets.only(bottom: 8),
child: SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(strokeWidth: 2)),
),
if (_showArchived)
for (final session in app.archivedSessions)
_row(session, archived: true, child: session.isChild),
if (_showArchived &&
app.archivedLoaded &&
app.archivedSessions.isEmpty)
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: AppText('No archived sessions',
style: TextStyle(fontSize: 12, color: scheme.outline)),
),
],
);
}
Future<void> _toggleArchived() async {
if (_showArchived) {
setState(() => _showArchived = false);
return;
}
if (!_app.archivedLoaded) await _app.refreshArchived();
if (mounted) setState(() => _showArchived = true);
}
String _subtitle(Session s) {
final parts = <String>[];
if (s.agent.isNotEmpty) parts.add(s.agent);
final children = _childrenOf(s).length;
if (children > 0) parts.add(trArgs('{0} subagents', [children]));
if (s.model != null) parts.add(_app.modelName(s.model));
if (s.updated > 0) {
final t = DateTime.fromMillisecondsSinceEpoch(s.updated);
parts.add(
'${t.month.toString().padLeft(2, '0')}-${t.day.toString().padLeft(2, '0')} '
'${t.hour.toString().padLeft(2, '0')}:${t.minute.toString().padLeft(2, '0')}');
}
return parts.join(' · ');
}
// -------------------------------------------------------------- actions
void _newSession({String? directory}) {
_app.openDraft(directory: directory ?? _app.chat?.session.directory);
widget.onOpened?.call();
}
Future<void> _archive(Session session, bool archived) async {
await _app.setArchived(session, !archived);
}
void _rename(Session s) {
final ctrl = TextEditingController(text: s.title);
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const AppText('Rename'),
content: TextField(controller: ctrl, autofocus: true),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const AppText('Cancel')),
FilledButton(
onPressed: () {
Navigator.pop(context);
_app.client?.updateSession(s.id, title: ctrl.text);
},
child: const AppText('Save'),
),
],
),
);
}
void _confirmDelete(Session s) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const AppText('Delete session?'),
content: AppText(trArgs('“{0}” and its subagent sessions will be deleted permanently.', [s.title])),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const AppText('Cancel')),
FilledButton(
onPressed: () {
Navigator.pop(context);
_app.client?.deleteSession(s.id);
_app.sessions.removeWhere((x) => x.id == s.id);
_app.archivedSessions.removeWhere((x) => x.id == s.id);
_app.touch();
},
child: const AppText('Delete'),
),
],
),
);
}
void _instancesSheet() {
final app = _app;
showModalBottomSheet(
context: context,
builder: (context) => SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Padding(
padding: EdgeInsets.all(12),
child: AppText('Servers',
style:
TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
),
for (final c in app.connections) ...[
ListTile(
title: Text(c.label),
subtitle: Text(c.isRelay
? trArgs('Via Relay · {0}', [c.serverId])
: (c.proxy.isEmpty
? c.url
: trArgs('{0}\nvia {1}', [c.url, c.proxy]))),
trailing: app.conn?.id == c.id
? AppText('Connected',
style: TextStyle(
color: Theme.of(context).colorScheme.primary))
: null,
onTap: () {
Navigator.pop(context);
if (app.conn?.id != c.id) app.switchTo(c);
},
),
],
ListTile(
leading: const Icon(Icons.add),
title: const AppText('Add server'),
onTap: () {
Navigator.pop(context);
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => ServersScreen(app: app, startEditing: true),
));
},
),
ListTile(
leading: const Icon(Icons.qr_code_2),
title: const AppText('Pairing link'),
subtitle: const AppText('Direct address or OpenChamber Relay'),
onTap: () {
Navigator.pop(context);
showPairingDialog(context, app);
},
),
if (app.client != null)
ListTile(
leading: const Icon(Icons.link_off),
title: const AppText('Disconnect'),
onTap: () {
Navigator.pop(context);
app.disconnect();
},
),
const SizedBox(height: 8),
],
),
),
);
}
}
class _SessionGroup {
final String key;
final String label;
final String path;
final List<Session> sessions;
const _SessionGroup({
required this.key,
required this.label,
required this.path,
required this.sessions,
});
}