App: chat colours, Ctrl+1-9 opens the Nth list item, starred chats alphabetical
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.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../domain/chat_colors.dart';
|
||||
import '../ui/sessions/chat_color_palette.dart';
|
||||
|
||||
/// The open chat's colour as a faint wash behind the top of the page: it
|
||||
/// shows through the glass bar and fades out just below it, so even without
|
||||
/// the list beside it the chat carries a gentle reminder of which one it is.
|
||||
/// It sits under the transcript and takes no taps, so text contrast and
|
||||
/// hit-testing are untouched. Nothing is drawn for a chat with no colour.
|
||||
class ChatColorWash extends StatelessWidget {
|
||||
const ChatColorWash({super.key, required this.session});
|
||||
|
||||
final JsonMap? session;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = chatColorShade(context, chatSessionColor(session));
|
||||
if (color == null) return const SizedBox.shrink();
|
||||
final strength = chatColorDarkSurface(context) ? 0.20 : 0.14;
|
||||
// The bar's height arrives as top padding; the wash reaches a little
|
||||
// past it so the fade reads under the bar, not as an edge at it.
|
||||
final height = MediaQuery.paddingOf(context).top + 72;
|
||||
return Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: height,
|
||||
child: IgnorePointer(
|
||||
child: DecoratedBox(
|
||||
key: const Key('chat-color-wash'),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
color.withValues(alpha: strength),
|
||||
color.withValues(alpha: 0),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,17 @@ import '../data/chat_repository.dart';
|
||||
import '../domain/chat_activity_detail.dart';
|
||||
import '../domain/chat_notice.dart';
|
||||
import '../domain/chat_attachment_picker.dart';
|
||||
import '../domain/chat_colors.dart';
|
||||
import '../domain/chat_transcript.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import '../ui/sessions/chat_color_picker.dart';
|
||||
import '../ui/sessions/session_actions.dart';
|
||||
import '../ui/transcript/chat_markdown_view.dart';
|
||||
import '../ui/transcript/chat_message_view.dart';
|
||||
import '../ui/transcript/chat_injected_rows.dart';
|
||||
import 'chat_account_usage_section.dart';
|
||||
import 'chat_background_tasks.dart';
|
||||
import 'chat_color_wash.dart';
|
||||
import 'chat_command_actions.dart';
|
||||
import 'chat_composer_bar.dart';
|
||||
import 'chat_composer_controller.dart';
|
||||
@@ -75,9 +78,14 @@ class ChatThreadView extends StatefulWidget {
|
||||
this.onCreatedSession,
|
||||
this.onSessionRenamed,
|
||||
this.onSessionClosed,
|
||||
this.onColorSelected,
|
||||
});
|
||||
|
||||
final ApiGateway gateway;
|
||||
|
||||
/// Sets the chat's shared colour (a palette name, null for none) from the
|
||||
/// information sheet; null leaves the sheet without the Colour choice.
|
||||
final ValueChanged<String?>? onColorSelected;
|
||||
final String sessionId;
|
||||
final VoidCallback onBack;
|
||||
|
||||
@@ -337,11 +345,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
context: context,
|
||||
builder: (sheetContext) => Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: SafeArea(
|
||||
child: CupertinoPopupSurface(
|
||||
child: _ChatInfoSheet(controller: _controller),
|
||||
),
|
||||
),
|
||||
child: SafeArea(child: CupertinoPopupSurface(child: _infoSheet())),
|
||||
),
|
||||
);
|
||||
return;
|
||||
@@ -351,10 +355,16 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
showDragHandle: true,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
builder: (sheetContext) => _ChatInfoSheet(controller: _controller),
|
||||
builder: (sheetContext) => _infoSheet(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _infoSheet() => _ChatInfoSheet(
|
||||
controller: _controller,
|
||||
color: chatSessionColor(widget.session),
|
||||
onColorSelected: widget.onColorSelected,
|
||||
);
|
||||
|
||||
/// The transcript in recorded order; a sent turn is part of it from the
|
||||
/// moment it is sent (ChatThreadController.insertLocal).
|
||||
List<JsonMap> _visibleMessages() => _controller.messages;
|
||||
@@ -927,6 +937,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
_rowWidgets.prune();
|
||||
return Stack(
|
||||
children: [
|
||||
// Behind everything: the chat's colour under the bar.
|
||||
ChatColorWash(session: widget.session),
|
||||
// At rest the first item starts below the floating bar
|
||||
// and the last one ends above the floating composer.
|
||||
// Bottom-anchored at the split row, the newest rows are
|
||||
@@ -1541,9 +1553,15 @@ String _chatInfoDollars(num value) {
|
||||
/// The "Chat information" panel. It rebuilds from the controller, so metrics
|
||||
/// that arrive while it is open replace the displayed snapshot.
|
||||
class _ChatInfoSheet extends StatelessWidget {
|
||||
const _ChatInfoSheet({required this.controller});
|
||||
const _ChatInfoSheet({
|
||||
required this.controller,
|
||||
this.color,
|
||||
this.onColorSelected,
|
||||
});
|
||||
|
||||
final ChatThreadController controller;
|
||||
final String? color;
|
||||
final ValueChanged<String?>? onColorSelected;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -1562,6 +1580,8 @@ class _ChatInfoSheet extends StatelessWidget {
|
||||
cupertino: cupertino,
|
||||
doneKey: const Key('chat-info-close'),
|
||||
),
|
||||
if (onColorSelected case final onSelected?)
|
||||
ChatColorSection(selected: color, onSelected: onSelected),
|
||||
for (final metric in _chatInfoMetrics(controller.usage))
|
||||
_ChatInfoRow(metric: metric, cupertino: cupertino),
|
||||
ChatAccountUsageSection(
|
||||
|
||||
Reference in New Issue
Block a user