f7b5958d64
A chat's colour is picked from its row menu (Colour...), a long-press or the chat information sheet. The list shows it as a leading bar, a faint row tint and a coloured avatar; the open chat shows a faint wash under its top bar. Shades are Cupertino's dynamic system colours and Material swatches tuned per brightness. Changes from other devices apply live. Ctrl+1...Ctrl+9 open the Nth item of the open tab's list (chats, runs, pipelines) in on-screen order, also while typing. Starred chats are sorted by name, case-insensitively, as one alphabetical group.
63 lines
2.0 KiB
Dart
63 lines
2.0 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
|
|
import '../../../../core/api_gateway.dart';
|
|
import '../../../../ui/layout/memo_subtree.dart';
|
|
import '../../domain/chat_sessions.dart';
|
|
import 'session_actions.dart';
|
|
import 'session_row_content.dart';
|
|
|
|
/// A chat row that rebuilds only when its own session or state changes, so a
|
|
/// running-state change in one chat does not rebuild every row of the list.
|
|
///
|
|
/// The list's callbacks are part of the memo: the screen passes its own
|
|
/// methods, so they compare equal from one build to the next.
|
|
Widget memoChatSessionRow({
|
|
required JsonMap session,
|
|
required bool selected,
|
|
required Set<String> duplicateTitles,
|
|
required bool unseen,
|
|
required bool divider,
|
|
required ValueChanged<JsonMap> onOpen,
|
|
required ValueChanged<JsonMap> onStar,
|
|
required ValueChanged<JsonMap>? onColor,
|
|
required ValueChanged<JsonMap> onRename,
|
|
required ValueChanged<JsonMap> onClose,
|
|
required ValueChanged<JsonMap> onReopen,
|
|
required ValueChanged<JsonMap> onHide,
|
|
}) => MemoSubtree(
|
|
key: ValueKey('chat-row-memo-${session['id'] ?? ''}'),
|
|
memo: (
|
|
MemoMap(session),
|
|
selected,
|
|
// The row reads the set only for its own title.
|
|
duplicateTitles.contains(chatSessionTitle(session)),
|
|
unseen,
|
|
divider,
|
|
onOpen,
|
|
onStar,
|
|
onColor,
|
|
onRename,
|
|
onClose,
|
|
onReopen,
|
|
onHide,
|
|
),
|
|
builder: (_) => ChatSessionRow(
|
|
session: session,
|
|
selected: selected,
|
|
duplicateTitles: duplicateTitles,
|
|
unseen: unseen,
|
|
divider: divider,
|
|
onOpen: onOpen,
|
|
// A long-press is the touch way to the colour, the row's quick mark.
|
|
onLongPress: onColor == null ? null : () => onColor(session),
|
|
onAction: (action) => switch (action) {
|
|
SessionAction.star => onStar(session),
|
|
SessionAction.color => onColor?.call(session),
|
|
SessionAction.rename => onRename(session),
|
|
SessionAction.close => onClose(session),
|
|
SessionAction.reopen => onReopen(session),
|
|
SessionAction.hide => onHide(session),
|
|
},
|
|
),
|
|
);
|