Remove Cupertino chat conversation branches
Keep the Material-only conversation implementation while preserving public Cupertino parameters for callers. Narrow affected tests to Material hosts so the dead platform paths are no longer exercised.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'chat_bar_tint.dart';
|
||||
@@ -25,12 +24,13 @@ ButtonStyle chatBarTextButtonStyle(
|
||||
/// Horizontal padding inside the bar's text buttons (model, mode).
|
||||
const EdgeInsets chatBarButtonPadding = EdgeInsets.symmetric(horizontal: 12);
|
||||
|
||||
/// Cupertino: [content] (a [CupertinoButton]'s child) in the label colour
|
||||
/// instead of the button's tint.
|
||||
/// Puts [content] (a button's child) in the bar's foreground colour: the
|
||||
/// chat's tint if it has one, else `onSurfaceVariant`. Kept for existing
|
||||
/// callers; the Material path colours buttons with [chatBarTextButtonStyle].
|
||||
Widget chatBarCupertinoContent(BuildContext context, Widget content) {
|
||||
final color =
|
||||
ChatBarTintScope.foregroundOf(context) ??
|
||||
CupertinoColors.label.resolveFrom(context);
|
||||
Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
return IconTheme.merge(
|
||||
data: IconThemeData(color: color),
|
||||
child: DefaultTextStyle.merge(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Host-native typography and colour for the approval and question cards.
|
||||
@@ -6,24 +5,21 @@ import 'package:flutter/material.dart';
|
||||
/// The cards share one hierarchy: the card title uses the host's title style,
|
||||
/// field/answer labels sit visibly below it, and recorded prose uses the body
|
||||
/// style. Keeping the styles here stops each card file from inventing its own
|
||||
/// size and colour; everything still comes from the active Material/Cupertino
|
||||
/// theme, so light, dark and text scaling follow the host.
|
||||
TextStyle? chatCardTitleStyle(BuildContext context, bool cupertino) => cupertino
|
||||
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
|
||||
: Theme.of(context).textTheme.titleMedium;
|
||||
/// size and colour; everything still comes from the active Material theme, so
|
||||
/// light, dark and text scaling follow the host.
|
||||
///
|
||||
/// The `cupertino` parameters are kept for existing callers; the app is
|
||||
/// Material-only, so every helper returns its Material value.
|
||||
TextStyle? chatCardTitleStyle(BuildContext context, bool cupertino) =>
|
||||
Theme.of(context).textTheme.titleMedium;
|
||||
|
||||
TextStyle? chatCardBodyStyle(BuildContext context, bool cupertino) => cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium;
|
||||
TextStyle? chatCardBodyStyle(BuildContext context, bool cupertino) =>
|
||||
Theme.of(context).textTheme.bodyMedium;
|
||||
|
||||
/// A field or recorded-answer label. Under Cupertino the system tab-label style
|
||||
/// (the same subordinate style the rest of the app uses for secondary copy)
|
||||
/// keeps labels from reading as extra headings; Material keeps `titleSmall`.
|
||||
TextStyle? chatCardLabelStyle(BuildContext context, bool cupertino) => cupertino
|
||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
color: chatCardSecondaryColor(context, true),
|
||||
)
|
||||
: Theme.of(context).textTheme.titleSmall;
|
||||
/// A field or recorded-answer label: `titleSmall`, so labels sit visibly
|
||||
/// below the card title without reading as extra headings.
|
||||
TextStyle? chatCardLabelStyle(BuildContext context, bool cupertino) =>
|
||||
Theme.of(context).textTheme.titleSmall;
|
||||
|
||||
/// Body text that supports a control, such as a field description.
|
||||
TextStyle? chatCardSecondaryStyle(BuildContext context, bool cupertino) =>
|
||||
@@ -31,25 +27,19 @@ TextStyle? chatCardSecondaryStyle(BuildContext context, bool cupertino) =>
|
||||
color: chatCardSecondaryColor(context, cupertino),
|
||||
);
|
||||
|
||||
Color chatCardSecondaryColor(BuildContext context, bool cupertino) => cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
Color chatCardSecondaryColor(BuildContext context, bool cupertino) =>
|
||||
Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
|
||||
Color chatCardErrorColor(BuildContext context, bool cupertino) => cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error;
|
||||
Color chatCardErrorColor(BuildContext context, bool cupertino) =>
|
||||
Theme.of(context).colorScheme.error;
|
||||
|
||||
/// The amber risk hue: the host's warning role, never a bespoke palette.
|
||||
Color chatCardWarningColor(BuildContext context, bool cupertino) => cupertino
|
||||
? CupertinoColors.systemOrange.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.tertiary;
|
||||
Color chatCardWarningColor(BuildContext context, bool cupertino) =>
|
||||
Theme.of(context).colorScheme.tertiary;
|
||||
|
||||
/// A quiet inset surface for resource blocks and risk panels.
|
||||
Color chatCardFillColor(BuildContext context, bool cupertino) => cupertino
|
||||
? CupertinoColors.secondarySystemFill.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
Color chatCardFillColor(BuildContext context, bool cupertino) =>
|
||||
Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
|
||||
Color chatCardWarningFillColor(BuildContext context, bool cupertino) =>
|
||||
cupertino
|
||||
? CupertinoColors.secondarySystemFill.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.tertiaryContainer;
|
||||
Theme.of(context).colorScheme.tertiaryContainer;
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../domain/chat_commands.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
|
||||
/// The command palette above the composer: the recorded commands matching the
|
||||
/// slash word, each with its own `/name` and summary.
|
||||
///
|
||||
/// Rows are standard host controls (Material's selected `ListTile`, Cupertino's
|
||||
/// own button on a popup surface), so typography, colours and text scaling stay
|
||||
/// the platform's. The list is content-sized and never imposes a fixed height;
|
||||
/// Rows are standard Material `ListTile`s, so typography, colours and text
|
||||
/// scaling stay the theme's. The list is content-sized and never imposes a fixed height;
|
||||
/// a viewport-bound scroll keeps a tall text scale reachable.
|
||||
class ChatCommandPalette extends StatelessWidget {
|
||||
const ChatCommandPalette({
|
||||
@@ -29,9 +26,6 @@ class ChatCommandPalette extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (commands.isEmpty) return const SizedBox.shrink();
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final list = cupertino ? _cupertinoRows(context) : _materialRows(context);
|
||||
return ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.4,
|
||||
@@ -40,7 +34,7 @@ class ChatCommandPalette extends StatelessWidget {
|
||||
child: Semantics(
|
||||
container: true,
|
||||
label: 'Command suggestions',
|
||||
child: list,
|
||||
child: _materialRows(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -66,62 +60,4 @@ class ChatCommandPalette extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Cupertino has no list tile that keeps a wrapping summary, so each row is
|
||||
/// the host's own button, with the name and summary at the native text style
|
||||
/// and the selected row on the host's semantic fill.
|
||||
Widget _cupertinoRows(BuildContext context) {
|
||||
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
|
||||
final selectedFill = CupertinoColors.systemFill.resolveFrom(context);
|
||||
final textStyle = CupertinoTheme.of(context).textTheme.textStyle;
|
||||
return CupertinoPopupSurface(
|
||||
key: const Key('chat-command-palette'),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (var index = 0; index < commands.length; index += 1)
|
||||
Semantics(
|
||||
selected: index == selectedIndex,
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: CupertinoButton(
|
||||
key: ValueKey<String>('chat-command-${commands[index].name}'),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () => onSelected(commands[index]),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: index == selectedIndex ? selectedFill : null,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||
16,
|
||||
10,
|
||||
16,
|
||||
10,
|
||||
),
|
||||
child: DefaultTextStyle.merge(
|
||||
style: textStyle,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('/${commands[index].name}'),
|
||||
Text(
|
||||
commands[index].summary,
|
||||
style: TextStyle(color: secondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -19,7 +17,6 @@ import '../domain/chat_attachment_picker.dart';
|
||||
import '../domain/chat_attachment_wire.dart';
|
||||
import '../domain/chat_clipboard_paste.dart';
|
||||
import '../domain/chat_commands.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'chat_command_actions.dart';
|
||||
import 'chat_command_palette.dart';
|
||||
import 'chat_composer_controller.dart';
|
||||
@@ -821,8 +818,6 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
return ListenableBuilder(
|
||||
listenable: widget.composer,
|
||||
builder: (context, _) {
|
||||
@@ -837,12 +832,11 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
// command palette, a separate menu, floats above it.
|
||||
final extras = <Widget>[
|
||||
if (chatDraftIsShell(composer.draft))
|
||||
ChatShellModeIndicator(cupertino: cupertino),
|
||||
if (!_attachments.isEmpty) _attachmentStrip(context, cupertino),
|
||||
ChatShellModeIndicator(cupertino: false),
|
||||
if (!_attachments.isEmpty) _attachmentStrip(context),
|
||||
if (_uploading)
|
||||
_notice(
|
||||
context,
|
||||
cupertino,
|
||||
key: const Key('chat-composer-uploading'),
|
||||
text: _attachments.attachments.length == 1
|
||||
? 'Uploading 1 file…'
|
||||
@@ -851,23 +845,20 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
if (_attachmentError != null)
|
||||
_notice(
|
||||
context,
|
||||
cupertino,
|
||||
key: const Key('chat-composer-attachment-error'),
|
||||
text: _attachmentError!,
|
||||
failed: true,
|
||||
),
|
||||
if (_commandNotice != null) _commandReport(context, cupertino),
|
||||
if (_commandNotice != null) _commandReport(context),
|
||||
if (composer.queued)
|
||||
_notice(
|
||||
context,
|
||||
cupertino,
|
||||
key: const Key('chat-composer-queued'),
|
||||
text: chatQueuedNotice,
|
||||
),
|
||||
if (error != null)
|
||||
_notice(
|
||||
context,
|
||||
cupertino,
|
||||
key: const Key('chat-composer-error'),
|
||||
text: error,
|
||||
failed: true,
|
||||
@@ -911,7 +902,6 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
key: const ValueKey('chat-composer-entrance'),
|
||||
child: _pill(
|
||||
context,
|
||||
cupertino,
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -935,13 +925,13 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
builder: (context, constraints) => Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
_attach(context, cupertino),
|
||||
_attach(context),
|
||||
Expanded(
|
||||
child: Focus(
|
||||
canRequestFocus: false,
|
||||
includeSemantics: false,
|
||||
onKeyEvent: _onKey,
|
||||
child: _field(cupertino),
|
||||
child: _field(),
|
||||
),
|
||||
),
|
||||
// Shown only while tasks run (or their list
|
||||
@@ -955,10 +945,10 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
child: widget.backgroundTasks!,
|
||||
),
|
||||
if (widget.running) ...[
|
||||
_primary(context, cupertino, stop: true),
|
||||
_primary(context, stop: true),
|
||||
const SizedBox(width: 4),
|
||||
],
|
||||
_primary(context, cupertino),
|
||||
_primary(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -984,45 +974,28 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
/// the transcript, so the composer reads as a single input rather than a
|
||||
/// row of separate controls, and the conversation shows through it. While
|
||||
/// the field has focus a ring in the chat's colour runs along its edge.
|
||||
Widget _pill(BuildContext context, bool cupertino, Widget child) =>
|
||||
ComposerFocusRing(
|
||||
focus: _focus,
|
||||
accent: chatFocusRingColor(context, widget.chatColor),
|
||||
shape: _pillShape,
|
||||
child: GlassPill(
|
||||
key: const Key('chat-composer-pill'),
|
||||
cupertino: cupertino,
|
||||
shape: _pillShape,
|
||||
// The end controls keep the same gap from the pill's sides as from
|
||||
// its bottom (and its top while the field is one line).
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(GlassBarMetrics.fieldEdgeGap),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
);
|
||||
Widget _pill(BuildContext context, Widget child) => ComposerFocusRing(
|
||||
focus: _focus,
|
||||
accent: chatFocusRingColor(context, widget.chatColor),
|
||||
shape: _pillShape,
|
||||
child: GlassPill(
|
||||
key: const Key('chat-composer-pill'),
|
||||
cupertino: false,
|
||||
shape: _pillShape,
|
||||
// The end controls keep the same gap from the pill's sides as from
|
||||
// its bottom (and its top while the field is one line).
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(GlassBarMetrics.fieldEdgeGap),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/// The attach control: a host button that opens the picker, disabled when the
|
||||
/// host has no picker or one prompt is already awaiting its reply.
|
||||
Widget _attach(BuildContext context, bool cupertino) {
|
||||
Widget _attach(BuildContext context) {
|
||||
final enabled = _picker.isSupported && !widget.composer.sending;
|
||||
final onPressed = enabled ? () => unawaited(_pickAttachments()) : null;
|
||||
if (cupertino) {
|
||||
return Semantics(
|
||||
label: chatAttachLabel,
|
||||
button: true,
|
||||
enabled: enabled,
|
||||
child: ExcludeSemantics(
|
||||
child: CupertinoButton(
|
||||
key: const Key('chat-composer-attach'),
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: GlassBarMetrics.cupertinoMinimumSize(),
|
||||
onPressed: onPressed,
|
||||
child: const Icon(CupertinoIcons.add),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return IconButton(
|
||||
key: const Key('chat-composer-attach'),
|
||||
tooltip: chatAttachLabel,
|
||||
@@ -1033,7 +1006,7 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
|
||||
/// The files attached to the next message. Each chip carries only the
|
||||
/// operator's recorded name and a native remove action.
|
||||
Widget _attachmentStrip(BuildContext context, bool cupertino) {
|
||||
Widget _attachmentStrip(BuildContext context) {
|
||||
final attachments = _attachments.attachments;
|
||||
return Padding(
|
||||
key: const Key('chat-composer-attachments'),
|
||||
@@ -1045,8 +1018,6 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
for (var index = 0; index < attachments.length; index += 1)
|
||||
if (_imageBytes(index) case final bytes?)
|
||||
_imageThumbnail(context, attachments[index], bytes, index)
|
||||
else if (cupertino)
|
||||
_cupertinoChip(context, attachments[index], index)
|
||||
else
|
||||
_materialChip(attachments[index], index),
|
||||
],
|
||||
@@ -1071,8 +1042,6 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
Uint8List bytes,
|
||||
int index,
|
||||
) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
return Semantics(
|
||||
key: ValueKey<String>('chat-composer-attachment-$index'),
|
||||
container: true,
|
||||
@@ -1094,13 +1063,8 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
bytes,
|
||||
key: ValueKey<String>('chat-composer-thumbnail-$index'),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, _, _) => Center(
|
||||
child: Icon(
|
||||
cupertino
|
||||
? CupertinoIcons.photo
|
||||
: Icons.image_outlined,
|
||||
),
|
||||
),
|
||||
errorBuilder: (_, _, _) =>
|
||||
const Center(child: Icon(Icons.image_outlined)),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1123,10 +1087,10 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: Icon(
|
||||
cupertino ? CupertinoIcons.xmark : Icons.close,
|
||||
child: const Icon(
|
||||
Icons.close,
|
||||
size: 14,
|
||||
color: const Color(0xFFFFFFFF),
|
||||
color: Color(0xFFFFFFFF),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1159,80 +1123,6 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
deleteButtonTooltipMessage: 'Remove ${attachment.name}',
|
||||
);
|
||||
|
||||
/// Cupertino has no chip control, so the host's capsule fill and its own
|
||||
/// button carry the same name and remove action.
|
||||
Widget _cupertinoChip(
|
||||
BuildContext context,
|
||||
ChatAttachment attachment,
|
||||
int index,
|
||||
) {
|
||||
return Semantics(
|
||||
container: true,
|
||||
explicitChildNodes: true,
|
||||
child: DefaultTextStyle.merge(
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
child: DecoratedBox(
|
||||
key: ValueKey<String>('chat-composer-attachment-$index'),
|
||||
decoration: ShapeDecoration(
|
||||
shape: const StadiumBorder(),
|
||||
color: CupertinoColors.secondarySystemFill.resolveFrom(context),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(12, 4, 4, 4),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(attachment.name, overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Semantics(
|
||||
container: true,
|
||||
button: true,
|
||||
label: 'Remove ${attachment.name}',
|
||||
onTap: () => _removeAttachmentAt(index),
|
||||
child: ExcludeSemantics(
|
||||
child: CupertinoButton(
|
||||
key: ValueKey<String>(
|
||||
'chat-composer-attachment-remove-$index',
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () => _removeAttachmentAt(index),
|
||||
child: Icon(
|
||||
CupertinoIcons.xmark_circle_fill,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(
|
||||
context,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// The lines the composer placeholder needs at [width] (the field's
|
||||
/// default 7px side padding excluded), capped at 3.
|
||||
int _placeholderLines(BuildContext context, double width) {
|
||||
if (!width.isFinite) return 1;
|
||||
final painter = TextPainter(
|
||||
text: TextSpan(
|
||||
text: widget.placeholder,
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
),
|
||||
textDirection: Directionality.of(context),
|
||||
textScaler: MediaQuery.textScalerOf(context),
|
||||
maxLines: 3,
|
||||
)..layout(maxWidth: math.max(0, width - 14));
|
||||
final lines = painter.computeLineMetrics().length;
|
||||
painter.dispose();
|
||||
return lines.clamp(1, 3);
|
||||
}
|
||||
|
||||
/// The most lines the field grows to before it scrolls: up to
|
||||
/// [_composerMaxLines], but never more than about 40% of the visible
|
||||
/// height (the keyboard excluded), so the conversation stays in view.
|
||||
@@ -1250,49 +1140,8 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
return fit.clamp(3, _composerMaxLines);
|
||||
}
|
||||
|
||||
Widget _field(bool cupertino) {
|
||||
Widget _field() {
|
||||
final maxLines = _maxLines(context);
|
||||
if (cupertino) {
|
||||
// CupertinoTextField lays its placeholder out with up to maxLines lines
|
||||
// but sizes an empty field by minLines, so a wrapped placeholder was
|
||||
// clipped on a narrow pane. While empty the field is exactly as tall as
|
||||
// its placeholder (at most 3 lines, then ellipsised); typing restores
|
||||
// the normal range (see _maxLines).
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final empty = _text.text.isEmpty;
|
||||
final lines = empty
|
||||
? _placeholderLines(context, constraints.maxWidth)
|
||||
: 1;
|
||||
return CupertinoTextField(
|
||||
key: const Key('chat-composer-field'),
|
||||
controller: _text,
|
||||
focusNode: _focus,
|
||||
scrollController: _fieldScroll,
|
||||
placeholder: widget.placeholder,
|
||||
// The pill draws the field's surface; the field adds no border.
|
||||
decoration: null,
|
||||
// The contextual prompt must stay readable on the glass fill;
|
||||
// placeholderText falls below normal-text contrast here.
|
||||
placeholderStyle: TextStyle(
|
||||
color: CupertinoColors.label.resolveFrom(context),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
minLines: lines,
|
||||
// Keep the empty field multiline too: a single-line web editor
|
||||
// strips Shift+Enter's newline on the next text edit.
|
||||
maxLines: empty && lines > 1 ? lines : maxLines,
|
||||
keyboardType: TextInputType.multiline,
|
||||
textInputAction: _enterSends
|
||||
? TextInputAction.send
|
||||
: TextInputAction.newline,
|
||||
onEditingComplete: () {},
|
||||
onSubmitted: (_) => _submitDraft(),
|
||||
onChanged: _onDraftEdited,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return TextField(
|
||||
key: const Key('chat-composer-field'),
|
||||
controller: _text,
|
||||
@@ -1320,7 +1169,7 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _primary(BuildContext context, bool cupertino, {bool stop = false}) {
|
||||
Widget _primary(BuildContext context, {bool stop = false}) {
|
||||
final composer = widget.composer;
|
||||
final enabled = stop
|
||||
? !composer.stopping
|
||||
@@ -1356,42 +1205,6 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
// A coloured chat's send button takes the chat's colour (its seeded
|
||||
// primary, like the focus ring); stop stays the host's error red.
|
||||
final tinted = chatSchemeOf(context, widget.chatColor);
|
||||
if (cupertino) {
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: label,
|
||||
excludeSemantics: true,
|
||||
// A filled circle centred in a full touch target, like Material's
|
||||
// filled icon button, so it keeps the pill's edge gap on every side.
|
||||
child: SizedBox.square(
|
||||
dimension: GlassBarMetrics.controlExtent(true),
|
||||
child: Center(
|
||||
child: CupertinoButton.filled(
|
||||
key: key,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: Size.square(GlassBarMetrics.filledExtent(true)),
|
||||
borderRadius: BorderRadius.circular(
|
||||
GlassBarMetrics.filledExtent(true) / 2,
|
||||
),
|
||||
color: stop
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: tinted?.primary,
|
||||
onPressed: enabled ? press : null,
|
||||
child: stop
|
||||
? const ChatStopIcon(
|
||||
child: Icon(CupertinoIcons.stop_fill, size: 18),
|
||||
)
|
||||
: Icon(
|
||||
CupertinoIcons.arrow_up,
|
||||
size: 18,
|
||||
color: enabled ? tinted?.onPrimary : null,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
return IconButton.filled(
|
||||
key: key,
|
||||
@@ -1418,7 +1231,7 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
/// shape, plus the offer's two host controls when an unknown command can be
|
||||
/// sent as a message. Neither action is a prompt until the operator chooses
|
||||
/// "Send as message".
|
||||
Widget _commandReport(BuildContext context, bool cupertino) {
|
||||
Widget _commandReport(BuildContext context) {
|
||||
final offer = _commandOffer;
|
||||
return Column(
|
||||
key: const Key('chat-composer-command-notice'),
|
||||
@@ -1433,36 +1246,21 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
: chatCommandNoticeLabel,
|
||||
style: TextStyle(
|
||||
color: _commandFailed
|
||||
? (cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error)
|
||||
? Theme.of(context).colorScheme.error
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (cupertino)
|
||||
Semantics(
|
||||
button: true,
|
||||
label: chatCommandDismissLabel,
|
||||
child: CupertinoButton(
|
||||
key: const Key('chat-command-dismiss'),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () => setState(_dismissCommandReport),
|
||||
child: const Text('Dismiss'),
|
||||
),
|
||||
)
|
||||
else
|
||||
IconButton(
|
||||
key: const Key('chat-command-dismiss'),
|
||||
tooltip: chatCommandDismissLabel,
|
||||
onPressed: () => setState(_dismissCommandReport),
|
||||
icon: const Icon(Icons.close),
|
||||
),
|
||||
IconButton(
|
||||
key: const Key('chat-command-dismiss'),
|
||||
tooltip: chatCommandDismissLabel,
|
||||
onPressed: () => setState(_dismissCommandReport),
|
||||
icon: const Icon(Icons.close),
|
||||
),
|
||||
],
|
||||
),
|
||||
_notice(
|
||||
context,
|
||||
cupertino,
|
||||
key: const Key('chat-composer-command-text'),
|
||||
text: _commandNotice!,
|
||||
failed: _commandFailed,
|
||||
@@ -1476,13 +1274,11 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
_commandAction(
|
||||
cupertino,
|
||||
key: const Key('chat-command-send-as-message'),
|
||||
label: chatCommandSendAsMessageLabel,
|
||||
onPressed: () => unawaited(_sendOffered()),
|
||||
),
|
||||
_commandAction(
|
||||
cupertino,
|
||||
key: const Key('chat-command-cancel'),
|
||||
label: chatCommandCancelLabel,
|
||||
onPressed: () => setState(_dismissCommandReport),
|
||||
@@ -1494,45 +1290,27 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _commandAction(
|
||||
bool cupertino, {
|
||||
Widget _commandAction({
|
||||
required Key key,
|
||||
required String label,
|
||||
required VoidCallback onPressed,
|
||||
}) {
|
||||
if (cupertino) {
|
||||
return CupertinoButton(
|
||||
key: key,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: Text(label),
|
||||
);
|
||||
}
|
||||
return TextButton(key: key, onPressed: onPressed, child: Text(label));
|
||||
}
|
||||
|
||||
/// A polite, secondary line for queued/refused state. The error uses the
|
||||
/// host's own semantic error tint, never a bespoke palette.
|
||||
Widget _notice(
|
||||
BuildContext context,
|
||||
bool cupertino, {
|
||||
BuildContext context, {
|
||||
required Key key,
|
||||
required String text,
|
||||
bool failed = false,
|
||||
}) {
|
||||
final theme = Theme.of(context);
|
||||
final color = failed
|
||||
? (cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: theme.colorScheme.error)
|
||||
: (cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: theme.colorScheme.onSurfaceVariant);
|
||||
final style =
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: theme.textTheme.bodyMedium)
|
||||
?.copyWith(color: color);
|
||||
? theme.colorScheme.error
|
||||
: theme.colorScheme.onSurfaceVariant;
|
||||
final style = theme.textTheme.bodyMedium?.copyWith(color: color);
|
||||
return Semantics(
|
||||
liveRegion: true,
|
||||
child: Padding(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'chat_deliveries.dart';
|
||||
@@ -41,12 +40,8 @@ class ChatDeliveryIndicator extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final failed = state == ChatDelivery.failed;
|
||||
final color = failed
|
||||
? (cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error)
|
||||
: (cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant);
|
||||
? Theme.of(context).colorScheme.error
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final style = DefaultTextStyle.of(
|
||||
context,
|
||||
).style.merge(TextStyle(fontSize: 12, color: color));
|
||||
@@ -75,13 +70,11 @@ class ChatDeliveryIndicator extends StatelessWidget {
|
||||
}
|
||||
|
||||
IconData get _icon => switch (state) {
|
||||
ChatDelivery.sending => cupertino ? CupertinoIcons.clock : Icons.schedule,
|
||||
ChatDelivery.sent => cupertino ? CupertinoIcons.checkmark : Icons.done,
|
||||
ChatDelivery.queued =>
|
||||
cupertino ? CupertinoIcons.hourglass : Icons.hourglass_empty,
|
||||
ChatDelivery.steered => cupertino ? CupertinoIcons.checkmark : Icons.done,
|
||||
ChatDelivery.failed =>
|
||||
cupertino ? CupertinoIcons.exclamationmark_circle : Icons.error_outline,
|
||||
ChatDelivery.sending => Icons.schedule,
|
||||
ChatDelivery.sent => Icons.done,
|
||||
ChatDelivery.queued => Icons.hourglass_empty,
|
||||
ChatDelivery.steered => Icons.done,
|
||||
ChatDelivery.failed => Icons.error_outline,
|
||||
};
|
||||
|
||||
Widget _action(
|
||||
@@ -90,15 +83,6 @@ class ChatDeliveryIndicator extends StatelessWidget {
|
||||
VoidCallback onPressed,
|
||||
TextStyle style,
|
||||
) {
|
||||
if (cupertino) {
|
||||
return CupertinoButton(
|
||||
key: Key(key),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
minimumSize: Size.zero,
|
||||
onPressed: onPressed,
|
||||
child: Text(text, style: style.copyWith(fontWeight: FontWeight.w600)),
|
||||
);
|
||||
}
|
||||
return TextButton(
|
||||
key: Key(key),
|
||||
style: TextButton.styleFrom(
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
import '../../../ui/adaptive/app_menu_anchor.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../core/error_reason.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import '../../../ui/adaptive/app_menu_anchor.dart';
|
||||
import 'chat_bar_control_style.dart';
|
||||
import 'chat_effort_sheet.dart';
|
||||
import 'chat_efforts.dart';
|
||||
import 'chat_models.dart';
|
||||
|
||||
/// The conversation bar's thinking-level control ("Thinking: High").
|
||||
///
|
||||
/// It shows the levels the session row names for the chat's model without a
|
||||
/// request of its own. Material opens a menu and Cupertino an action sheet of
|
||||
/// those levels; choosing one sends `chat_effort` through the chat's own
|
||||
/// request of its own. It opens a menu of those levels; choosing one sends `chat_effort` through the chat's own
|
||||
/// gateway. The level applies from the next turn: while a turn runs, the
|
||||
/// choices say so and the label marks the new level "next turn". A model with
|
||||
/// no levels (or a harness without them) shows no control. After the model
|
||||
@@ -114,20 +110,9 @@ class _ChatEffortControlState extends State<ChatEffortControl> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _openSheet() => showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (_) => ChatEffortSheet(
|
||||
state: _state,
|
||||
running: widget.running,
|
||||
choose: _choose,
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!_state.supported) return const SizedBox.shrink();
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final label =
|
||||
'${chatEffortLabel(_state)}${_nextTurn ? ' · next turn' : ''}';
|
||||
final iconOnly =
|
||||
@@ -135,7 +120,7 @@ class _ChatEffortControlState extends State<ChatEffortControl> {
|
||||
final content = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(cupertino ? CupertinoIcons.lightbulb : Icons.psychology_outlined),
|
||||
const Icon(Icons.psychology_outlined),
|
||||
if (!iconOnly) ...[
|
||||
const SizedBox(width: 4),
|
||||
Flexible(child: Text(label, overflow: TextOverflow.ellipsis)),
|
||||
@@ -143,22 +128,6 @@ class _ChatEffortControlState extends State<ChatEffortControl> {
|
||||
],
|
||||
);
|
||||
const key = Key('chat-effort');
|
||||
if (cupertino) {
|
||||
return Semantics(
|
||||
container: true,
|
||||
button: true,
|
||||
label: 'Change thinking level, currently ${_state.currentName}',
|
||||
onTap: _openSheet,
|
||||
child: ExcludeSemantics(
|
||||
child: CupertinoButton(
|
||||
key: key,
|
||||
padding: chatBarButtonPadding,
|
||||
onPressed: _openSheet,
|
||||
child: chatBarCupertinoContent(context, content),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return AppMenuAnchor(
|
||||
menuChildren: [
|
||||
Padding(
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/error_reason.dart';
|
||||
import 'chat_efforts.dart';
|
||||
|
||||
/// The Cupertino action sheet of a chat's thinking levels, the current one
|
||||
/// checked. It stays open with the server's reason when a choice is refused
|
||||
/// and closes once one is accepted.
|
||||
/// The thinking-level chooser of a chat: the levels with the current one
|
||||
/// checked, in a Material dialog. It stays open with the server's reason when
|
||||
/// a choice is refused and closes once one is accepted.
|
||||
///
|
||||
/// Nothing opens it now: the effort control shows its levels in an anchored
|
||||
/// menu. The class stays so existing references keep compiling.
|
||||
class ChatEffortSheet extends StatefulWidget {
|
||||
const ChatEffortSheet({
|
||||
super.key,
|
||||
@@ -53,49 +56,40 @@ class _ChatEffortSheetState extends State<ChatEffortSheet> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final error = _error;
|
||||
return CupertinoActionSheet(
|
||||
return AlertDialog(
|
||||
key: const Key('chat-effort-sheet'),
|
||||
title: const Text('Thinking'),
|
||||
message: Text(
|
||||
error ?? chatEffortNote(running: widget.running),
|
||||
key: const Key('chat-effort-note'),
|
||||
style: error == null
|
||||
? null
|
||||
: TextStyle(color: CupertinoColors.systemRed.resolveFrom(context)),
|
||||
content: SingleChildScrollView(
|
||||
child: ListBody(
|
||||
children: [
|
||||
Text(
|
||||
error ?? chatEffortNote(running: widget.running),
|
||||
key: const Key('chat-effort-note'),
|
||||
style: error == null ? null : TextStyle(color: scheme.error),
|
||||
),
|
||||
for (final level in widget.state.levels)
|
||||
ListTile(
|
||||
key: ValueKey<String>('chat-effort-option-${level.id}'),
|
||||
title: Text(level.name),
|
||||
subtitle: level.description.isEmpty
|
||||
? null
|
||||
: Text(level.description),
|
||||
trailing: level.id == widget.state.current
|
||||
? const Icon(Icons.check)
|
||||
: null,
|
||||
onTap: () => _choose(level),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
for (final level in widget.state.levels)
|
||||
CupertinoActionSheetAction(
|
||||
key: ValueKey<String>('chat-effort-option-${level.id}'),
|
||||
onPressed: () => _choose(level),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(child: Text(level.name)),
|
||||
if (level.id == widget.state.current) ...[
|
||||
const SizedBox(width: 6),
|
||||
const Icon(CupertinoIcons.checkmark_alt),
|
||||
],
|
||||
],
|
||||
),
|
||||
if (level.description.isNotEmpty)
|
||||
Text(
|
||||
level.description,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 13, color: secondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
@@ -141,11 +140,7 @@ class _ChatModelChooserState extends State<ChatModelChooser> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) =>
|
||||
widget.cupertino ? _cupertinoChooser(context) : _materialChooser(context);
|
||||
|
||||
/// Whether the catalog loaded far enough to search it.
|
||||
bool get _hasCatalog => !_loading && _error == null && _models.isNotEmpty;
|
||||
Widget build(BuildContext context) => _materialChooser(context);
|
||||
|
||||
Widget _materialChooser(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
@@ -210,7 +205,7 @@ class _ChatModelChooserState extends State<ChatModelChooser> {
|
||||
SimpleDialogOption(
|
||||
key: _optionKey(model),
|
||||
onPressed: _busy ? null : () => _choose(model),
|
||||
child: _optionRow(context, model, cupertino: false),
|
||||
child: _optionRow(context, model),
|
||||
),
|
||||
if (matches.isEmpty && needle.isNotEmpty)
|
||||
Padding(
|
||||
@@ -237,111 +232,10 @@ class _ChatModelChooserState extends State<ChatModelChooser> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoChooser(BuildContext context) {
|
||||
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
|
||||
final error = CupertinoColors.systemRed.resolveFrom(context);
|
||||
final matches = filterChatModels(_models, _search.text);
|
||||
final needle = _search.text.trim();
|
||||
return CupertinoActionSheet(
|
||||
key: const Key('chat-model-chooser'),
|
||||
title: const Text('Change model'),
|
||||
message: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
chatModelSelectionNote(widget.backend),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
if (_hasCatalog)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(top: 12),
|
||||
// The search field sits in the sheet's message slot: a native
|
||||
// search field is the only way to type here, and the sheet's own
|
||||
// scroll keeps a long catalog reachable.
|
||||
child: CupertinoSearchTextField(
|
||||
key: const Key('chat-model-search'),
|
||||
controller: _search,
|
||||
placeholder: 'Search models',
|
||||
onChanged: (_) => setState(() {}),
|
||||
),
|
||||
),
|
||||
if (_loading)
|
||||
const Padding(
|
||||
padding: EdgeInsetsDirectional.only(top: 12),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CupertinoActivityIndicator(),
|
||||
SizedBox(width: 8),
|
||||
Flexible(child: Text('Loading models…')),
|
||||
],
|
||||
),
|
||||
)
|
||||
else if (_error != null)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(top: 8),
|
||||
child: Text(
|
||||
_error!,
|
||||
key: const Key('chat-model-error'),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: error),
|
||||
),
|
||||
)
|
||||
else if (_models.isEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(top: 8),
|
||||
child: Text(
|
||||
'No models are available for this chat.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: secondary),
|
||||
),
|
||||
)
|
||||
else if (matches.isEmpty && needle.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(top: 8),
|
||||
child: Text(
|
||||
'No models match "$needle".',
|
||||
key: const Key('chat-model-no-match'),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: secondary),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: _hasCatalog
|
||||
? [
|
||||
for (final model in matches)
|
||||
CupertinoActionSheetAction(
|
||||
key: _optionKey(model),
|
||||
isDefaultAction: _isCurrent(model),
|
||||
onPressed: () {
|
||||
if (!_busy) _choose(model);
|
||||
},
|
||||
child: _optionRow(context, model, cupertino: true),
|
||||
),
|
||||
]
|
||||
: null,
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
key: const Key('chat-model-cancel'),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _optionRow(
|
||||
BuildContext context,
|
||||
JsonMap model, {
|
||||
required bool cupertino,
|
||||
}) {
|
||||
Widget _optionRow(BuildContext context, JsonMap model) {
|
||||
final selected = _isCurrent(model);
|
||||
final secondary = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final accent = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final secondary = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final accent = Theme.of(context).colorScheme.primary;
|
||||
final provider = '${model['provider'] ?? ''}'.trim();
|
||||
return Semantics(
|
||||
selected: selected,
|
||||
@@ -358,11 +252,7 @@ class _ChatModelChooserState extends State<ChatModelChooser> {
|
||||
],
|
||||
),
|
||||
),
|
||||
if (selected)
|
||||
Icon(
|
||||
cupertino ? CupertinoIcons.check_mark : Icons.check,
|
||||
color: accent,
|
||||
),
|
||||
if (selected) Icon(Icons.check, color: accent),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'chat_bar_control_style.dart';
|
||||
import 'chat_model_chooser.dart';
|
||||
import 'chat_models.dart';
|
||||
@@ -75,24 +73,15 @@ class _ChatModelControlState extends State<ChatModelControl> {
|
||||
}
|
||||
|
||||
Future<void> _open() async {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final chooser = ChatModelChooser(
|
||||
gateway: widget.gateway,
|
||||
sessionId: widget.sessionId,
|
||||
backend: '${widget.session['backend'] ?? ''}'.trim(),
|
||||
currentProvider: _provider,
|
||||
currentModel: _model,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onAccepted: _accept,
|
||||
);
|
||||
if (cupertino) {
|
||||
await showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (_) => chooser,
|
||||
);
|
||||
return;
|
||||
}
|
||||
await showDialog<void>(context: context, builder: (_) => chooser);
|
||||
}
|
||||
|
||||
@@ -110,8 +99,6 @@ class _ChatModelControlState extends State<ChatModelControl> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final backend = '${widget.session['backend'] ?? ''}'.trim();
|
||||
final label = _model.isNotEmpty
|
||||
? chatModelLabel(_model, _selection)
|
||||
@@ -126,26 +113,10 @@ class _ChatModelControlState extends State<ChatModelControl> {
|
||||
children: [
|
||||
Flexible(child: Text(label, overflow: TextOverflow.ellipsis)),
|
||||
const SizedBox(width: 4),
|
||||
Icon(cupertino ? CupertinoIcons.chevron_down : Icons.expand_more),
|
||||
const Icon(Icons.expand_more),
|
||||
],
|
||||
);
|
||||
const key = Key('chat-model');
|
||||
if (cupertino) {
|
||||
return Semantics(
|
||||
container: true,
|
||||
button: true,
|
||||
label: 'Change model, currently $label',
|
||||
onTap: _open,
|
||||
child: ExcludeSemantics(
|
||||
child: CupertinoButton(
|
||||
key: key,
|
||||
padding: chatBarButtonPadding,
|
||||
onPressed: _open,
|
||||
child: chatBarCupertinoContent(context, content),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Semantics(
|
||||
container: true,
|
||||
button: true,
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
|
||||
/// The open chat's Next chat button: the platform's icon button, labelled
|
||||
/// "Next chat", that opens the chat after this one in the list.
|
||||
///
|
||||
@@ -18,17 +15,6 @@ class ChatNextChatButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
return Semantics(
|
||||
label: label,
|
||||
button: true,
|
||||
child: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: const Icon(CupertinoIcons.arrow_right_to_line),
|
||||
),
|
||||
);
|
||||
}
|
||||
return IconButton(
|
||||
tooltip: label,
|
||||
onPressed: onPressed,
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
|
||||
/// Selects a retained pane when the window cannot show every chat at once.
|
||||
Future<void> showChatPanePicker(
|
||||
BuildContext context, {
|
||||
@@ -11,45 +8,23 @@ Future<void> showChatPanePicker(
|
||||
required ValueChanged<String> onSelected,
|
||||
String title = 'Open chats',
|
||||
}) async {
|
||||
final String? selected;
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
selected = await showCupertinoModalPopup<String>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoActionSheet(
|
||||
title: Text(title),
|
||||
actions: [
|
||||
for (final pane in panes)
|
||||
CupertinoActionSheetAction(
|
||||
isDefaultAction: pane.id == activeId,
|
||||
onPressed: () => Navigator.pop(context, pane.id),
|
||||
child: Text(pane.title),
|
||||
final selected = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => SimpleDialog(
|
||||
title: Text(title),
|
||||
children: [
|
||||
for (final pane in panes)
|
||||
SimpleDialogOption(
|
||||
onPressed: () => Navigator.pop(context, pane.id),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text(pane.title)),
|
||||
if (pane.id == activeId) const Icon(Icons.check),
|
||||
],
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
selected = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => SimpleDialog(
|
||||
title: Text(title),
|
||||
children: [
|
||||
for (final pane in panes)
|
||||
SimpleDialogOption(
|
||||
onPressed: () => Navigator.pop(context, pane.id),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text(pane.title)),
|
||||
if (pane.id == activeId) const Icon(Icons.check),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (selected != null && context.mounted) onSelected(selected);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import '../ui/transcript/native_disclosure.dart';
|
||||
import 'chat_card_styles.dart';
|
||||
import 'chat_permission_card_model.dart';
|
||||
@@ -25,105 +22,93 @@ class ChatPermissionCard extends StatelessWidget {
|
||||
final Future<void> Function(String decision) onDecision;
|
||||
final String? error;
|
||||
|
||||
/// The card-style helpers keep their `cupertino` flag for existing callers;
|
||||
/// the card is always Material, so every call passes `false`.
|
||||
@override
|
||||
Widget build(BuildContext context) =>
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? _cupertino(context)
|
||||
: _material(context);
|
||||
Widget build(BuildContext context) => Card(
|
||||
// Consecutive cards must read as separate surfaces; the row itself adds only
|
||||
// the horizontal inset.
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
child: Padding(padding: const EdgeInsets.all(16), child: _body(context)),
|
||||
);
|
||||
|
||||
Widget _body(BuildContext context, {required bool cupertino}) {
|
||||
final body = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(end: 12),
|
||||
child: Icon(
|
||||
cupertino
|
||||
? CupertinoIcons.exclamationmark_shield
|
||||
: Icons.shield_outlined,
|
||||
color: chatCardWarningColor(context, cupertino),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
card.headline,
|
||||
style: chatCardTitleStyle(context, cupertino),
|
||||
),
|
||||
Text(
|
||||
card.statusLine,
|
||||
style: chatCardSecondaryStyle(context, cupertino),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (card.resourceText.isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: chatCardFillColor(context, cupertino),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Text(
|
||||
card.resourceText,
|
||||
maxLines: chatApprovalMaxResourceLines,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Widget _body(BuildContext context) => Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(end: 12),
|
||||
child: Icon(
|
||||
Icons.shield_outlined,
|
||||
color: chatCardWarningColor(context, false),
|
||||
),
|
||||
),
|
||||
if (card.resources.join('\n') != card.resourceText)
|
||||
NativeDisclosure(
|
||||
label: 'Show full request',
|
||||
childBuilder: (context) =>
|
||||
SelectableText(card.resources.join('\n')),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(card.headline, style: chatCardTitleStyle(context, false)),
|
||||
Text(
|
||||
card.statusLine,
|
||||
style: chatCardSecondaryStyle(context, false),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
if (card.showRisk && card.risk.trim().isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
_risk(context, cupertino),
|
||||
],
|
||||
if (error != null && error!.trim().isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
Semantics(
|
||||
liveRegion: true,
|
||||
),
|
||||
if (card.resourceText.isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: chatCardFillColor(context, false),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Text(
|
||||
error!,
|
||||
style: chatCardBodyStyle(
|
||||
context,
|
||||
cupertino,
|
||||
)?.copyWith(color: chatCardErrorColor(context, cupertino)),
|
||||
card.resourceText,
|
||||
maxLines: chatApprovalMaxResourceLines,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (card.actionable) ...[
|
||||
const SizedBox(height: 12),
|
||||
_controls(context, cupertino),
|
||||
],
|
||||
),
|
||||
if (card.resources.join('\n') != card.resourceText)
|
||||
NativeDisclosure(
|
||||
label: 'Show full request',
|
||||
childBuilder: (context) =>
|
||||
SelectableText(card.resources.join('\n')),
|
||||
),
|
||||
],
|
||||
);
|
||||
return cupertino
|
||||
? DefaultTextStyle.merge(
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
child: body,
|
||||
)
|
||||
: body;
|
||||
}
|
||||
if (card.showRisk && card.risk.trim().isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
_risk(context),
|
||||
],
|
||||
if (error != null && error!.trim().isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
Semantics(
|
||||
liveRegion: true,
|
||||
child: Text(
|
||||
error!,
|
||||
style: chatCardBodyStyle(
|
||||
context,
|
||||
false,
|
||||
)?.copyWith(color: chatCardErrorColor(context, false)),
|
||||
),
|
||||
),
|
||||
],
|
||||
if (card.actionable) ...[const SizedBox(height: 12), _controls(context)],
|
||||
],
|
||||
);
|
||||
|
||||
Widget _risk(BuildContext context, bool cupertino) {
|
||||
final tint = chatCardWarningColor(context, cupertino);
|
||||
Widget _risk(BuildContext context) {
|
||||
final tint = chatCardWarningColor(context, false);
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: chatCardWarningFillColor(context, cupertino),
|
||||
color: chatCardWarningFillColor(context, false),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
@@ -133,105 +118,45 @@ class ChatPermissionCard extends StatelessWidget {
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
cupertino
|
||||
? CupertinoIcons.exclamationmark_shield
|
||||
: Icons.shield_outlined,
|
||||
size: 16,
|
||||
color: tint,
|
||||
),
|
||||
Icon(Icons.shield_outlined, size: 16, color: tint),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Text(
|
||||
chatRiskReviewLabel,
|
||||
style: chatCardLabelStyle(
|
||||
context,
|
||||
cupertino,
|
||||
false,
|
||||
)?.copyWith(color: tint),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(card.risk, style: chatCardBodyStyle(context, cupertino)),
|
||||
Text(card.risk, style: chatCardBodyStyle(context, false)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _controls(BuildContext context, bool cupertino) {
|
||||
final always = card.alwaysLabel;
|
||||
if (cupertino) {
|
||||
return Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
CupertinoButton.filled(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
onPressed: () => onDecision(chatDecisionOnce),
|
||||
child: const Text(chatApprovalOnceLabel),
|
||||
),
|
||||
CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
onPressed: () => onDecision(chatDecisionAlways),
|
||||
child: Text(always),
|
||||
),
|
||||
CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
onPressed: () => onDecision(chatDecisionReject),
|
||||
child: Text(
|
||||
chatApprovalRejectLabel,
|
||||
style: TextStyle(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
FilledButton(
|
||||
onPressed: () => onDecision(chatDecisionOnce),
|
||||
child: const Text(chatApprovalOnceLabel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => onDecision(chatDecisionAlways),
|
||||
child: Text(always),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => onDecision(chatDecisionReject),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
child: const Text(chatApprovalRejectLabel),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _material(BuildContext context) => Card(
|
||||
// Consecutive cards must read as separate surfaces; the row itself adds only
|
||||
// the horizontal inset.
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: _body(context, cupertino: false),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _cupertino(BuildContext context) => CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
// As the Material card: the transcript row owns the horizontal inset, so
|
||||
// the card lines up with the message bubbles.
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
Widget _controls(BuildContext context) => Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: _body(context, cupertino: true),
|
||||
FilledButton(
|
||||
onPressed: () => onDecision(chatDecisionOnce),
|
||||
child: const Text(chatApprovalOnceLabel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => onDecision(chatDecisionAlways),
|
||||
child: Text(card.alwaysLabel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => onDecision(chatDecisionReject),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
child: const Text(chatApprovalRejectLabel),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/text/monospace.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import '../ui/transcript/chat_turn_chip.dart';
|
||||
import '../ui/transcript/native_disclosure.dart';
|
||||
import 'chat_permission_card_model.dart';
|
||||
@@ -101,24 +99,14 @@ class ChatPermissionsChip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final rejected = permissions.any((p) => p.decision == chatDecisionReject);
|
||||
final color = rejected
|
||||
? (cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error)
|
||||
: (cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant);
|
||||
? Theme.of(context).colorScheme.error
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final label = chatPermissionsLabel(permissions.length);
|
||||
return ChatTurnChip(
|
||||
chipKey: const Key('chat-permission-chip'),
|
||||
leading: Icon(
|
||||
cupertino ? CupertinoIcons.checkmark_shield : Icons.shield_outlined,
|
||||
size: 14,
|
||||
color: color,
|
||||
),
|
||||
leading: Icon(Icons.shield_outlined, size: 14, color: color),
|
||||
label: label,
|
||||
color: color,
|
||||
semanticsLabel: permissions.length == 1
|
||||
@@ -136,11 +124,7 @@ class _PermissionsSheet extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final style = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium;
|
||||
final style = Theme.of(context).textTheme.bodyMedium;
|
||||
return DefaultTextStyle.merge(
|
||||
style: style,
|
||||
child: ConstrainedBox(
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'chat_card_styles.dart';
|
||||
import 'chat_question_card_controls.dart';
|
||||
import 'chat_question_card_fields.dart';
|
||||
@@ -125,34 +122,14 @@ class _ChatQuestionCardState extends State<ChatQuestionCard> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final body = _body(context, cupertino);
|
||||
final wrapped = cupertino
|
||||
? DefaultTextStyle.merge(
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
child: body,
|
||||
)
|
||||
: body;
|
||||
if (cupertino) {
|
||||
return CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
// As the Material card: the transcript row owns the horizontal inset,
|
||||
// so the card lines up with the message bubbles.
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
children: [Padding(padding: const EdgeInsets.all(16), child: wrapped)],
|
||||
);
|
||||
}
|
||||
return Card(
|
||||
// Keep consecutive cards visually separate; the transcript row only
|
||||
// supplies the horizontal inset.
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
child: Padding(padding: const EdgeInsets.all(16), child: wrapped),
|
||||
);
|
||||
}
|
||||
Widget build(BuildContext context) => Card(
|
||||
// Keep consecutive cards visually separate; the transcript row only
|
||||
// supplies the horizontal inset.
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
child: Padding(padding: const EdgeInsets.all(16), child: _body(context)),
|
||||
);
|
||||
|
||||
Widget _body(BuildContext context, bool cupertino) {
|
||||
Widget _body(BuildContext context) {
|
||||
final actions = widget.form['actions'];
|
||||
final error = widget.error?.trim().isNotEmpty == true
|
||||
? widget.error!.trim()
|
||||
@@ -165,9 +142,9 @@ class _ChatQuestionCardState extends State<ChatQuestionCard> {
|
||||
'${widget.form['title'] ?? ''}'.trim().isEmpty
|
||||
? 'Question'
|
||||
: '${widget.form['title']}'.trim(),
|
||||
style: chatCardTitleStyle(context, cupertino),
|
||||
style: chatCardTitleStyle(context, false),
|
||||
),
|
||||
Text(_statusLine(), style: chatCardSecondaryStyle(context, cupertino)),
|
||||
Text(_statusLine(), style: chatCardSecondaryStyle(context, false)),
|
||||
if (error.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
@@ -177,8 +154,8 @@ class _ChatQuestionCardState extends State<ChatQuestionCard> {
|
||||
error,
|
||||
style: chatCardBodyStyle(
|
||||
context,
|
||||
cupertino,
|
||||
)?.copyWith(color: chatCardErrorColor(context, cupertino)),
|
||||
false,
|
||||
)?.copyWith(color: chatCardErrorColor(context, false)),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -187,7 +164,7 @@ class _ChatQuestionCardState extends State<ChatQuestionCard> {
|
||||
context: context,
|
||||
fields: _fields,
|
||||
answers: _answers,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
controllers: _controllers,
|
||||
onChanged: _changed,
|
||||
)
|
||||
@@ -195,13 +172,13 @@ class _ChatQuestionCardState extends State<ChatQuestionCard> {
|
||||
...chatQuestionRecordedAnswers(
|
||||
context: context,
|
||||
form: widget.form,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
),
|
||||
if (_pending) ...[
|
||||
const SizedBox(height: 12),
|
||||
chatQuestionControls(
|
||||
context: context,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
actions: actions,
|
||||
submitLabel: _submitLabel,
|
||||
sending: _sending,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Submit and optional decline/cancel controls for a pending question.
|
||||
///
|
||||
/// The web shows `Confirm completion` when every field is external, otherwise
|
||||
/// `Send answer`, and offers only the actions the form records. The labels are
|
||||
/// passed in so this file stays layout only.
|
||||
/// passed in so this file stays layout only. `cupertino` is kept for existing
|
||||
/// callers; the controls are always Material.
|
||||
Widget chatQuestionControls({
|
||||
required BuildContext context,
|
||||
required bool cupertino,
|
||||
@@ -17,31 +17,6 @@ Widget chatQuestionControls({
|
||||
}) {
|
||||
final canDecline = actions is List && actions.contains('decline');
|
||||
final canCancel = actions is List && actions.contains('cancel');
|
||||
if (cupertino) {
|
||||
return Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
CupertinoButton.filled(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
onPressed: sending ? null : onSubmit,
|
||||
child: Text(sending ? 'Sending…' : submitLabel),
|
||||
),
|
||||
if (canDecline)
|
||||
CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
onPressed: sending ? null : () => onAction('decline'),
|
||||
child: const Text('Decline'),
|
||||
),
|
||||
if (canCancel)
|
||||
CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
onPressed: sending ? null : () => onAction('cancel'),
|
||||
child: const Text('Cancel question'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
@@ -91,7 +90,6 @@ Widget _field({
|
||||
label: label,
|
||||
keyName: keyName,
|
||||
controller: controllers[keyName]!,
|
||||
cupertino: cupertino,
|
||||
hasOptions: chatQuestionOptions(field).isNotEmpty,
|
||||
onChanged: (value) => onChanged(
|
||||
keyName,
|
||||
@@ -110,7 +108,6 @@ Widget _input({
|
||||
required String label,
|
||||
required String keyName,
|
||||
required TextEditingController controller,
|
||||
required bool cupertino,
|
||||
required bool hasOptions,
|
||||
required ValueChanged<String> onChanged,
|
||||
}) {
|
||||
@@ -131,24 +128,14 @@ Widget _input({
|
||||
: TextInputType.text;
|
||||
// The visual label sits above the input; the same words must also reach the
|
||||
// input's own semantics node, as the web's `aria-label` does.
|
||||
final input = cupertino
|
||||
? CupertinoTextField(
|
||||
key: ValueKey<String>('chat-question-input-$keyName'),
|
||||
controller: controller,
|
||||
placeholder: placeholder,
|
||||
obscureText: secret,
|
||||
keyboardType: keyboard,
|
||||
padding: const EdgeInsets.all(8),
|
||||
onChanged: onChanged,
|
||||
)
|
||||
: TextField(
|
||||
key: ValueKey<String>('chat-question-input-$keyName'),
|
||||
controller: controller,
|
||||
obscureText: secret,
|
||||
keyboardType: keyboard,
|
||||
decoration: InputDecoration(hintText: placeholder),
|
||||
onChanged: onChanged,
|
||||
);
|
||||
final input = TextField(
|
||||
key: ValueKey<String>('chat-question-input-$keyName'),
|
||||
controller: controller,
|
||||
obscureText: secret,
|
||||
keyboardType: keyboard,
|
||||
decoration: InputDecoration(hintText: placeholder),
|
||||
onChanged: onChanged,
|
||||
);
|
||||
return Semantics(label: label, child: input);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import '../ui/transcript/chat_turn_chip.dart';
|
||||
import 'chat_card_styles.dart';
|
||||
import 'chat_question_card_model.dart';
|
||||
@@ -122,19 +120,11 @@ class ChatQuestionChip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final color = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final color = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final label = chatQuestionSummary(form);
|
||||
return ChatTurnChip(
|
||||
chipKey: ValueKey<String>('chat-question-chip-${form['id']}'),
|
||||
leading: Icon(
|
||||
cupertino ? CupertinoIcons.question_circle : Icons.help_outline,
|
||||
size: 14,
|
||||
color: color,
|
||||
),
|
||||
leading: Icon(Icons.help_outline, size: 14, color: color),
|
||||
label: label,
|
||||
color: color,
|
||||
ellipsizeLabel: true,
|
||||
@@ -173,11 +163,7 @@ class _QuestionSheet extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final style = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium;
|
||||
final style = Theme.of(context).textTheme.bodyMedium;
|
||||
final title = '${form['title'] ?? ''}'.trim();
|
||||
return DefaultTextStyle.merge(
|
||||
style: style,
|
||||
@@ -192,16 +178,16 @@ class _QuestionSheet extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
title.isEmpty ? 'Question' : title,
|
||||
style: chatCardTitleStyle(context, cupertino),
|
||||
style: chatCardTitleStyle(context, false),
|
||||
),
|
||||
Text(
|
||||
chatQuestionSettledStatus(form),
|
||||
style: chatCardSecondaryStyle(context, cupertino),
|
||||
style: chatCardSecondaryStyle(context, false),
|
||||
),
|
||||
...chatQuestionRecordedAnswers(
|
||||
context: context,
|
||||
form: form,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import 'chat_card_styles.dart';
|
||||
import 'chat_question_card_model.dart';
|
||||
|
||||
/// Native option controls for one question field. Single-select uses the host's
|
||||
@@ -23,43 +21,6 @@ Widget chatQuestionOptionsField({
|
||||
final selected = multi
|
||||
? (value is List ? value.map((entry) => '$entry').toSet() : <String>{})
|
||||
: <String>{if (value is String) value};
|
||||
if (cupertino) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
for (final option in options)
|
||||
CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
onPressed: () => onChanged(
|
||||
keyName,
|
||||
multi
|
||||
? _toggle(selected, chatQuestionOptionValue(option))
|
||||
: chatQuestionOptionValue(option),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(chatQuestionOptionLabel(option)),
|
||||
if ('${option['description'] ?? ''}'.trim().isNotEmpty)
|
||||
Text(
|
||||
'${option['description']}'.trim(),
|
||||
style: chatCardSecondaryStyle(context, cupertino),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (selected.contains(chatQuestionOptionValue(option)))
|
||||
const Icon(CupertinoIcons.checkmark),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
if (multi) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -102,8 +63,7 @@ Widget chatQuestionOptionsField({
|
||||
);
|
||||
}
|
||||
|
||||
/// Yes/No for a boolean field: native checkmarks under Cupertino, the web's
|
||||
/// explicit "Choose Yes or No" menu under Material.
|
||||
/// Yes/No for a boolean field: the web's explicit "Choose Yes or No" menu.
|
||||
Widget chatQuestionBooleanField({
|
||||
required BuildContext context,
|
||||
required JsonMap field,
|
||||
@@ -113,24 +73,6 @@ Widget chatQuestionBooleanField({
|
||||
required void Function(String key, Object? value) onChanged,
|
||||
}) {
|
||||
final value = answers[keyName];
|
||||
if (cupertino) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final entry in const [('Yes', true), ('No', false)])
|
||||
CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
onPressed: () => onChanged(keyName, entry.$2),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text(entry.$1)),
|
||||
if (value == entry.$2) const Icon(CupertinoIcons.checkmark),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return DropdownButtonFormField<String>(
|
||||
initialValue: value is bool ? '$value' : null,
|
||||
hint: const Text('Choose Yes or No'),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
@@ -12,6 +11,8 @@ import 'chat_export_controller.dart';
|
||||
/// The info sheet's "Session" section: the harness's native session id with a
|
||||
/// copy control, the harness and the working directory, the verified terminal
|
||||
/// command that resumes the session, and the export actions.
|
||||
///
|
||||
/// `cupertino` is kept for existing callers; the section is always Material.
|
||||
class ChatSessionSection extends StatefulWidget {
|
||||
const ChatSessionSection({
|
||||
super.key,
|
||||
@@ -51,24 +52,13 @@ class _ChatSessionSectionState extends State<ChatSessionSection> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = widget.cupertino;
|
||||
final handoff = widget.handoff;
|
||||
final secondary = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final body = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyLarge;
|
||||
final title = cupertino
|
||||
? CupertinoTheme.of(
|
||||
context,
|
||||
).textTheme.textStyle.copyWith(fontWeight: FontWeight.w600)
|
||||
: Theme.of(context).textTheme.titleSmall;
|
||||
final label =
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodySmall)
|
||||
?.copyWith(color: secondary);
|
||||
final secondary = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final body = Theme.of(context).textTheme.bodyLarge;
|
||||
final title = Theme.of(context).textTheme.titleSmall;
|
||||
final label = Theme.of(
|
||||
context,
|
||||
).textTheme.bodySmall?.copyWith(color: secondary);
|
||||
final mono = body?.copyWith(fontFamily: appMonospaceFamily);
|
||||
final muted = body?.copyWith(color: secondary);
|
||||
|
||||
@@ -111,16 +101,11 @@ class _ChatSessionSectionState extends State<ChatSessionSection> {
|
||||
),
|
||||
_ActionButton(
|
||||
key: const Key('chat-session-copy-id'),
|
||||
cupertino: cupertino,
|
||||
label: _copied == 'id' ? 'Copied' : 'Copy',
|
||||
semanticsLabel: _copied == 'id'
|
||||
? 'Copied'
|
||||
: 'Copy session ID',
|
||||
icon: _copied == 'id'
|
||||
? (cupertino ? CupertinoIcons.checkmark : Icons.check)
|
||||
: (cupertino
|
||||
? CupertinoIcons.doc_on_doc
|
||||
: Icons.copy_outlined),
|
||||
icon: _copied == 'id' ? Icons.check : Icons.copy_outlined,
|
||||
onPressed: handoff.id.isEmpty
|
||||
? null
|
||||
: () => _copy('id', handoff.id),
|
||||
@@ -144,37 +129,27 @@ class _ChatSessionSectionState extends State<ChatSessionSection> {
|
||||
if (handoff.resumeCommand.isNotEmpty)
|
||||
_ActionButton(
|
||||
key: const Key('chat-session-copy-resume'),
|
||||
cupertino: cupertino,
|
||||
label: _copied == 'resume'
|
||||
? 'Copied'
|
||||
: 'Copy resume command',
|
||||
icon: _copied == 'resume'
|
||||
? (cupertino ? CupertinoIcons.checkmark : Icons.check)
|
||||
: (cupertino
|
||||
? CupertinoIcons
|
||||
.chevron_left_slash_chevron_right
|
||||
: Icons.terminal),
|
||||
icon: _copied == 'resume' ? Icons.check : Icons.terminal,
|
||||
onPressed: () => _copy('resume', handoff.resumeCommand),
|
||||
),
|
||||
_exportButton(
|
||||
ChatExportFormat.markdown,
|
||||
'Export conversation',
|
||||
cupertino
|
||||
? CupertinoIcons.square_arrow_up
|
||||
: Icons.ios_share,
|
||||
Icons.ios_share,
|
||||
),
|
||||
_exportButton(
|
||||
ChatExportFormat.json,
|
||||
'Export JSON',
|
||||
cupertino ? CupertinoIcons.doc_text : Icons.data_object,
|
||||
Icons.data_object,
|
||||
),
|
||||
if (handoff.nativeExport)
|
||||
_exportButton(
|
||||
ChatExportFormat.native,
|
||||
'Export native session',
|
||||
cupertino
|
||||
? CupertinoIcons.doc
|
||||
: Icons.description_outlined,
|
||||
Icons.description_outlined,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -201,7 +176,6 @@ class _ChatSessionSectionState extends State<ChatSessionSection> {
|
||||
final exporter = widget.exporter;
|
||||
return _ActionButton(
|
||||
key: Key('chat-session-export-${format.wire}'),
|
||||
cupertino: widget.cupertino,
|
||||
label: label,
|
||||
icon: icon,
|
||||
busy: exporter.active == format,
|
||||
@@ -214,7 +188,6 @@ class _ChatSessionSectionState extends State<ChatSessionSection> {
|
||||
class _ActionButton extends StatelessWidget {
|
||||
const _ActionButton({
|
||||
super.key,
|
||||
required this.cupertino,
|
||||
required this.label,
|
||||
required this.icon,
|
||||
required this.onPressed,
|
||||
@@ -222,7 +195,6 @@ class _ActionButton extends StatelessWidget {
|
||||
this.busy = false,
|
||||
});
|
||||
|
||||
final bool cupertino;
|
||||
final String label;
|
||||
final String? semanticsLabel;
|
||||
final IconData icon;
|
||||
@@ -232,12 +204,10 @@ class _ActionButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Widget leading = busy
|
||||
? (cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const SizedBox.square(
|
||||
dimension: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
))
|
||||
? const SizedBox.square(
|
||||
dimension: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: Icon(icon, size: 18);
|
||||
final child = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -247,13 +217,6 @@ class _ActionButton extends StatelessWidget {
|
||||
Flexible(child: Text(label, semanticsLabel: semanticsLabel)),
|
||||
],
|
||||
);
|
||||
final button = cupertino
|
||||
? CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||
onPressed: onPressed,
|
||||
child: child,
|
||||
)
|
||||
: TextButton(onPressed: onPressed, child: child);
|
||||
return button;
|
||||
return TextButton(onPressed: onPressed, child: child);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
|
||||
enum ChatSidebarMode { expanded, compact, hidden }
|
||||
@@ -31,46 +30,24 @@ class ChatSidebarButton extends StatelessWidget
|
||||
);
|
||||
|
||||
Future<void> _choose(BuildContext context) async {
|
||||
final ChatSidebarMode? choice;
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
choice = await showCupertinoModalPopup<ChatSidebarMode>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoActionSheet(
|
||||
title: const Text('Chat list'),
|
||||
actions: [
|
||||
for (final value in ChatSidebarMode.values)
|
||||
CupertinoActionSheetAction(
|
||||
isDefaultAction: mode == value,
|
||||
onPressed: () => Navigator.pop(context, value),
|
||||
child: Text(_label(value)),
|
||||
final choice = await showDialog<ChatSidebarMode>(
|
||||
context: context,
|
||||
builder: (context) => SimpleDialog(
|
||||
title: const Text('Chat list'),
|
||||
children: [
|
||||
for (final value in ChatSidebarMode.values)
|
||||
SimpleDialogOption(
|
||||
onPressed: () => Navigator.pop(context, value),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text(_label(value))),
|
||||
if (value == mode) const Icon(Icons.check),
|
||||
],
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
choice = await showDialog<ChatSidebarMode>(
|
||||
context: context,
|
||||
builder: (context) => SimpleDialog(
|
||||
title: const Text('Chat list'),
|
||||
children: [
|
||||
for (final value in ChatSidebarMode.values)
|
||||
SimpleDialogOption(
|
||||
onPressed: () => Navigator.pop(context, value),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text(_label(value))),
|
||||
if (value == mode) const Icon(Icons.check),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (choice != null && context.mounted) onChanged(choice);
|
||||
}
|
||||
|
||||
@@ -80,20 +57,9 @@ class ChatSidebarButton extends StatelessWidget
|
||||
ChatSidebarMode.hidden => 'Hide chat list',
|
||||
};
|
||||
@override
|
||||
Widget build(BuildContext context) =>
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? Semantics(
|
||||
label: 'Chat list layout',
|
||||
button: true,
|
||||
child: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () => _choose(context),
|
||||
child: const Icon(CupertinoIcons.sidebar_left),
|
||||
),
|
||||
)
|
||||
: IconButton(
|
||||
tooltip: 'Chat list layout',
|
||||
onPressed: () => _choose(context),
|
||||
icon: const Icon(Icons.view_sidebar_outlined),
|
||||
);
|
||||
Widget build(BuildContext context) => IconButton(
|
||||
tooltip: 'Chat list layout',
|
||||
onPressed: () => _choose(context),
|
||||
icon: const Icon(Icons.view_sidebar_outlined),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
@@ -28,7 +27,7 @@ class ChatTaskMetadataView extends StatelessWidget {
|
||||
final facts = <Widget>[
|
||||
if (!detail)
|
||||
ChatTaskFact(
|
||||
icon: taskCupertino(context) ? CupertinoIcons.clock : Icons.schedule,
|
||||
icon: Icons.schedule,
|
||||
label: 'Started',
|
||||
value: start == null
|
||||
? 'Start time unavailable'
|
||||
@@ -36,49 +35,37 @@ class ChatTaskMetadataView extends StatelessWidget {
|
||||
),
|
||||
if (!detail && start != null && start.isAfter(now))
|
||||
ChatTaskFact(
|
||||
icon: taskCupertino(context)
|
||||
? CupertinoIcons.exclamationmark_circle
|
||||
: Icons.info_outline,
|
||||
icon: Icons.info_outline,
|
||||
label: 'Device clock',
|
||||
value: 'Start time is ahead of this device’s clock',
|
||||
),
|
||||
if (!detail && start == null && duration != null)
|
||||
ChatTaskFact(
|
||||
icon: taskCupertino(context)
|
||||
? CupertinoIcons.timer
|
||||
: Icons.timer_outlined,
|
||||
icon: Icons.timer_outlined,
|
||||
label: 'Reported runtime',
|
||||
value: taskDuration(Duration(milliseconds: duration)),
|
||||
),
|
||||
if (!detail && tools != null)
|
||||
ChatTaskFact(
|
||||
icon: taskCupertino(context)
|
||||
? CupertinoIcons.wrench
|
||||
: Icons.build_outlined,
|
||||
icon: Icons.build_outlined,
|
||||
label: 'Tool calls',
|
||||
value: formatTaskCount(tools),
|
||||
),
|
||||
if (!detail && tokens != null)
|
||||
ChatTaskFact(
|
||||
icon: taskCupertino(context)
|
||||
? CupertinoIcons.number
|
||||
: Icons.token_outlined,
|
||||
icon: Icons.token_outlined,
|
||||
label: 'Tokens',
|
||||
value: formatTaskCount(tokens),
|
||||
),
|
||||
if (detail && lastTool != null)
|
||||
ChatTaskFact(
|
||||
icon: taskCupertino(context)
|
||||
? CupertinoIcons.wrench
|
||||
: Icons.build_outlined,
|
||||
icon: Icons.build_outlined,
|
||||
label: 'Last tool',
|
||||
value: lastTool,
|
||||
),
|
||||
if (detail && updated != null)
|
||||
ChatTaskFact(
|
||||
icon: taskCupertino(context)
|
||||
? CupertinoIcons.arrow_clockwise
|
||||
: Icons.update,
|
||||
icon: Icons.update,
|
||||
label: 'Last update',
|
||||
value: formatTaskDate(context, updated),
|
||||
),
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../domain/chat_task_metadata.dart';
|
||||
import '../../../ui/text/monospace.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
|
||||
bool taskCupertino(BuildContext context) =>
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
/// Always false: the app is Material-only. Kept so existing callers compile;
|
||||
/// a later run removes it with its callers.
|
||||
bool taskCupertino(BuildContext context) => false;
|
||||
|
||||
Color taskSecondary(BuildContext context) => taskCupertino(context)
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
Color taskSecondary(BuildContext context) =>
|
||||
Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
|
||||
TextStyle taskHeading(BuildContext context) => taskCupertino(context)
|
||||
? CupertinoTheme.of(
|
||||
context,
|
||||
).textTheme.textStyle.copyWith(fontWeight: FontWeight.w600)
|
||||
: Theme.of(context).textTheme.titleMedium ?? const TextStyle();
|
||||
TextStyle taskHeading(BuildContext context) =>
|
||||
Theme.of(context).textTheme.titleMedium ?? const TextStyle();
|
||||
|
||||
String taskDisplayTitle(Map<String, dynamic> shell) =>
|
||||
taskText(shell, 'description') ??
|
||||
@@ -65,12 +60,11 @@ String formatTaskDate(BuildContext context, DateTime time) {
|
||||
MaterialLocalizations,
|
||||
);
|
||||
final monthYear =
|
||||
material?.formatMonthYear(time) ??
|
||||
'${CupertinoLocalizations.of(context).datePickerMonth(time.month)} ${time.year}';
|
||||
material?.formatMonthYear(time) ?? '${time.month}/${time.year}';
|
||||
return '${time.day} $monthYear · ${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
/// Native grouped surface; callers supply content that grows with text scaling.
|
||||
/// A Material filled card; callers supply content that grows with text scaling.
|
||||
class ChatTaskSurface extends StatelessWidget {
|
||||
const ChatTaskSurface({
|
||||
super.key,
|
||||
@@ -81,16 +75,10 @@ class ChatTaskSurface extends StatelessWidget {
|
||||
final EdgeInsetsGeometry padding;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => taskCupertino(context)
|
||||
? CupertinoListSection.insetGrouped(
|
||||
margin: EdgeInsets.zero,
|
||||
backgroundColor: CupertinoColors.transparent,
|
||||
children: [Padding(padding: padding, child: child)],
|
||||
)
|
||||
: Card.filled(
|
||||
margin: EdgeInsets.zero,
|
||||
child: Padding(padding: padding, child: child),
|
||||
);
|
||||
Widget build(BuildContext context) => Card.filled(
|
||||
margin: EdgeInsets.zero,
|
||||
child: Padding(padding: padding, child: child),
|
||||
);
|
||||
}
|
||||
|
||||
class ChatTaskFact extends StatelessWidget {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import '../../../core/servers/server_context.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/servers/server_context.dart';
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'chat_bar_tint.dart';
|
||||
import '../workspace/chat_workspace_pane_scope.dart';
|
||||
|
||||
@@ -60,8 +58,6 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final tint = chatBarTintOf(context, chatColor);
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
@@ -73,7 +69,7 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
if (action is! SegmentedOverflowable) action,
|
||||
if (moreActions.whereType<SegmentedOverflowable>().isNotEmpty)
|
||||
SegmentedMoreButton(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
entries: [
|
||||
for (final action
|
||||
in moreActions.whereType<SegmentedOverflowable>())
|
||||
@@ -82,7 +78,7 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
),
|
||||
];
|
||||
final Widget bar = SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
pillColor: tint?.fill,
|
||||
foregroundColor: tint?.foreground,
|
||||
automaticallyImplyLeading: false,
|
||||
@@ -91,16 +87,14 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
leading: showBack
|
||||
? SegmentedBackButton(
|
||||
key: const Key('chat-back'),
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onPressed: onBack,
|
||||
)
|
||||
: null,
|
||||
title: title.isEmpty ? 'Chat' : title,
|
||||
titleLeading: identity,
|
||||
subtitle: ServerContext.metadata(context, folder),
|
||||
subtitleIcon: cupertino
|
||||
? CupertinoIcons.folder
|
||||
: Icons.folder_outlined,
|
||||
subtitleIcon: Icons.folder_outlined,
|
||||
onTitlePressed: onInfo,
|
||||
titleSemanticLabel: 'Chat information',
|
||||
titleKey: const Key('chat-info'),
|
||||
@@ -131,15 +125,13 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
bottomPadding: compact ? 8 : 16,
|
||||
);
|
||||
return ColoredBox(
|
||||
color: cupertino
|
||||
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: tint == null
|
||||
? bar
|
||||
: ChatBarTintScope(
|
||||
key: const Key('chat-bar-tint'),
|
||||
tint: tint,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
child: bar,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -21,10 +21,10 @@ import '../../../core/transport/pipelines_client.dart'
|
||||
import '../domain/chat_shown_items.dart';
|
||||
import '../domain/chat_transcript.dart';
|
||||
import '../domain/chat_turn_diffs.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import '../ui/sessions/chat_color_picker.dart';
|
||||
import '../ui/sessions/session_actions.dart';
|
||||
import '../ui/sessions/session_row_content.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import '../ui/transcript/chat_markdown_view.dart';
|
||||
import '../ui/transcript/chat_message_bubble.dart';
|
||||
import '../ui/transcript/chat_message_view.dart';
|
||||
@@ -300,8 +300,6 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
return;
|
||||
}
|
||||
_filesSheetOpen = true;
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
// In a floating window the explorer is a page of that window, so a file
|
||||
// it opens stays in the window too.
|
||||
final sheet = WindowScope.maybeOf(context) != null
|
||||
@@ -313,21 +311,6 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
),
|
||||
),
|
||||
)
|
||||
: cupertino
|
||||
? showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (_) => Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: SafeArea(
|
||||
child: CupertinoPopupSurface(
|
||||
child: SizedBox(
|
||||
height: MediaQuery.sizeOf(context).height * .85,
|
||||
child: FilesPanel(controller: _files),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
@@ -999,8 +982,6 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
_shellRuns.membership,
|
||||
]),
|
||||
builder: (context, _) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final messages = _visibleMessages();
|
||||
final cards = chatCardRows(
|
||||
permissions: _controller.permissionFrames,
|
||||
@@ -1209,10 +1190,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
Padding(
|
||||
key: const Key('chat-thread-loading'),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Center(
|
||||
child: cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(),
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
if (_controller.hasMore)
|
||||
@@ -1223,20 +1202,12 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: _controller.loading
|
||||
? null
|
||||
: _controller.loadOlder,
|
||||
child: const Text('Load older'),
|
||||
)
|
||||
: TextButton(
|
||||
onPressed: _controller.loading
|
||||
? null
|
||||
: _controller.loadOlder,
|
||||
child: const Text('Load older'),
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: _controller.loading
|
||||
? null
|
||||
: _controller.loadOlder,
|
||||
child: const Text('Load older'),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (historyNotice != null)
|
||||
@@ -1276,7 +1247,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
),
|
||||
child: _queuedRow(prompt, cupertino),
|
||||
child: _queuedRow(prompt),
|
||||
),
|
||||
// Messages the server has not accepted follow the
|
||||
// transcript until they are retried or edited.
|
||||
@@ -1288,7 +1259,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
),
|
||||
child: _unsentRow(send, cupertino),
|
||||
child: _unsentRow(send),
|
||||
),
|
||||
// The conversation's own command lines sit after the
|
||||
// turns, as on the web; they are never bubbles.
|
||||
@@ -1310,7 +1281,6 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
child: _ChatJumpToLatest(
|
||||
key: const Key('chat-jump-to-latest'),
|
||||
label: chatJumpToLatestLabel(newMessages),
|
||||
cupertino: cupertino,
|
||||
onPressed: _followLatest,
|
||||
),
|
||||
),
|
||||
@@ -1487,7 +1457,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
runChatShellFromMenu(
|
||||
context,
|
||||
_shellRuns,
|
||||
cupertino: chatControlsStyleOf(context) == ChatControlsStyle.cupertino,
|
||||
cupertino: false,
|
||||
showNotice: _showCommandNotice,
|
||||
),
|
||||
);
|
||||
@@ -1497,7 +1467,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
context,
|
||||
_shellRuns,
|
||||
_shellRuns.finishedIds,
|
||||
cupertino: chatControlsStyleOf(context) == ChatControlsStyle.cupertino,
|
||||
cupertino: false,
|
||||
onRefused: (refusal) => _showCommandNotice(
|
||||
"Couldn't dismiss the commands: $refusal",
|
||||
failed: true,
|
||||
@@ -1612,8 +1582,6 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
final delivery = message != null
|
||||
? _composer.deliveries.stateFor(message)
|
||||
: null;
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final onRemove = _removeAction('${message?['operation_id'] ?? ''}');
|
||||
// An unchanged finished row hands back its previous widget, so a streamed
|
||||
// delta rebuilds only the live turn. Transcript snapshots are copied on
|
||||
@@ -1623,15 +1591,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
return _rowWidgets.widgetFor(
|
||||
key,
|
||||
row,
|
||||
[
|
||||
delivery,
|
||||
cupertino,
|
||||
onRemove != null,
|
||||
_images,
|
||||
_controller,
|
||||
_composer,
|
||||
_shellRuns,
|
||||
],
|
||||
[delivery, onRemove != null, _images, _controller, _composer, _shellRuns],
|
||||
() => ChatMessageView(
|
||||
row: row,
|
||||
textBuilder: chatMarkdownText,
|
||||
@@ -1640,7 +1600,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
if (delivery != null)
|
||||
ChatDeliveryIndicator(
|
||||
state: delivery,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onRemove: onRemove,
|
||||
),
|
||||
],
|
||||
@@ -1671,7 +1631,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
|
||||
/// One prompt the server holds queued that the transcript does not show,
|
||||
/// as the sender's bubble with "Queued" and its Remove.
|
||||
Widget _queuedRow(JsonMap prompt, bool cupertino) {
|
||||
Widget _queuedRow(JsonMap prompt) {
|
||||
final message = ChatServerQueue.message(prompt);
|
||||
return ChatMessageView(
|
||||
row: {'kind': 'user', 'key': message['id'], 'message': message},
|
||||
@@ -1680,7 +1640,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
footer: [
|
||||
ChatDeliveryIndicator(
|
||||
state: ChatDelivery.queued,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onRemove: _removeAction('${prompt['operation_id'] ?? ''}'),
|
||||
),
|
||||
],
|
||||
@@ -1689,7 +1649,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
|
||||
/// One message the server has not accepted, as the operator's bubble with
|
||||
/// "Not sent" and its Retry and Edit.
|
||||
Widget _unsentRow(ChatComposerSend send, bool cupertino) {
|
||||
Widget _unsentRow(ChatComposerSend send) {
|
||||
final composer = _composer;
|
||||
return ChatMessageView(
|
||||
row: {
|
||||
@@ -1702,7 +1662,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
footer: [
|
||||
ChatDeliveryIndicator(
|
||||
state: ChatDelivery.failed,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onRetry: send.canRetry && !composer.sending
|
||||
? () => unawaited(composer.retry(send.operationId))
|
||||
: null,
|
||||
@@ -1722,38 +1682,17 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
}
|
||||
|
||||
/// The native dismiss control shared by a local notice and a running
|
||||
/// compaction's activity line. Material uses a tooltip; Cupertino carries the
|
||||
/// same accessible name on the wrapping node, since its button has none.
|
||||
/// compaction's activity line: an icon button whose tooltip is its label.
|
||||
Widget _noticeDismissControl({
|
||||
required bool cupertino,
|
||||
required String label,
|
||||
required Key key,
|
||||
required VoidCallback onPressed,
|
||||
}) {
|
||||
final icon = Icon(cupertino ? CupertinoIcons.xmark_circle_fill : Icons.close);
|
||||
if (!cupertino) {
|
||||
return IconButton(
|
||||
key: key,
|
||||
tooltip: label,
|
||||
onPressed: onPressed,
|
||||
icon: icon,
|
||||
);
|
||||
}
|
||||
return Semantics(
|
||||
container: true,
|
||||
button: true,
|
||||
label: label,
|
||||
onTap: onPressed,
|
||||
child: ExcludeSemantics(
|
||||
child: CupertinoButton(
|
||||
key: key,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: icon,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}) => IconButton(
|
||||
key: key,
|
||||
tooltip: label,
|
||||
onPressed: onPressed,
|
||||
icon: const Icon(Icons.close),
|
||||
);
|
||||
|
||||
/// One local notice beside the conversation: a recorded failure or a slash
|
||||
/// command's outcome.
|
||||
@@ -1777,27 +1716,13 @@ class _ChatNoticeLine extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final theme = Theme.of(context);
|
||||
final failed = notice.failed;
|
||||
final color = failed
|
||||
? (cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: theme.colorScheme.error)
|
||||
: (cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: theme.colorScheme.onSurfaceVariant);
|
||||
final style =
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: theme.textTheme.bodyMedium)
|
||||
?.copyWith(color: color);
|
||||
final icon = failed
|
||||
? (cupertino
|
||||
? CupertinoIcons.exclamationmark_circle
|
||||
: Icons.error_outline)
|
||||
: (cupertino ? CupertinoIcons.info_circle : Icons.info_outline);
|
||||
? theme.colorScheme.error
|
||||
: theme.colorScheme.onSurfaceVariant;
|
||||
final style = theme.textTheme.bodyMedium?.copyWith(color: color);
|
||||
final icon = failed ? Icons.error_outline : Icons.info_outline;
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 8, 4),
|
||||
child: Column(
|
||||
@@ -1820,33 +1745,24 @@ class _ChatNoticeLine extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
_dismissControl(cupertino),
|
||||
_dismissControl(),
|
||||
],
|
||||
),
|
||||
if (onRetry != null)
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onRetry,
|
||||
child: const Text('Retry'),
|
||||
)
|
||||
: TextButton(onPressed: onRetry, child: const Text('Retry')),
|
||||
child: TextButton(onPressed: onRetry, child: const Text('Retry')),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _dismissControl(bool cupertino) {
|
||||
return _noticeDismissControl(
|
||||
cupertino: cupertino,
|
||||
label: chatNoticeDismissLabel(notice.kind),
|
||||
key: ValueKey<String>('chat-notice-dismiss-${notice.kind.name}'),
|
||||
onPressed: () => onDismiss(notice),
|
||||
);
|
||||
}
|
||||
Widget _dismissControl() => _noticeDismissControl(
|
||||
label: chatNoticeDismissLabel(notice.kind),
|
||||
key: ValueKey<String>('chat-notice-dismiss-${notice.kind.name}'),
|
||||
onPressed: () => onDismiss(notice),
|
||||
);
|
||||
}
|
||||
|
||||
/// One reported usage metric: its web label, whether the harness reported it,
|
||||
@@ -1966,8 +1882,6 @@ class _ChatInfoSheet extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
return AnimatedBuilder(
|
||||
animation: controller,
|
||||
builder: (context, _) {
|
||||
@@ -1978,76 +1892,53 @@ class _ChatInfoSheet extends StatelessWidget {
|
||||
children: [
|
||||
AppSheetHeader(
|
||||
title: 'Chat information',
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
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),
|
||||
_ChatInfoRow(metric: metric),
|
||||
ChatAccountUsageSection(
|
||||
usage: controller.accountUsage,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(24, 8, 24, 16),
|
||||
child: Text(
|
||||
'Last reported by the harness. '
|
||||
'Unavailable values are not estimated.',
|
||||
style:
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodySmall)
|
||||
?.copyWith(
|
||||
color: cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(
|
||||
context,
|
||||
)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
ChatSessionSection(
|
||||
handoff: handoff,
|
||||
exporter: exporter,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
);
|
||||
if (!cupertino) return SingleChildScrollView(child: content);
|
||||
// A tall text scale must scroll inside the popup rather than push its
|
||||
// heading off-screen. The height follows the viewport, not a fixed size.
|
||||
return ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.8,
|
||||
),
|
||||
child: SingleChildScrollView(child: content),
|
||||
);
|
||||
return SingleChildScrollView(child: content);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ChatInfoRow extends StatelessWidget {
|
||||
const _ChatInfoRow({required this.metric, required this.cupertino});
|
||||
const _ChatInfoRow({required this.metric});
|
||||
|
||||
final _ChatInfoMetric metric;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final secondary = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final labelStyle =
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodySmall)
|
||||
?.copyWith(color: secondary);
|
||||
final valueStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyLarge;
|
||||
final secondary = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final labelStyle = Theme.of(
|
||||
context,
|
||||
).textTheme.bodySmall?.copyWith(color: secondary);
|
||||
final valueStyle = Theme.of(context).textTheme.bodyLarge;
|
||||
return Padding(
|
||||
key: Key('chat-info-metric-${metric.key}'),
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(24, 6, 24, 6),
|
||||
@@ -2075,37 +1966,19 @@ class _ChatJumpToLatest extends StatelessWidget {
|
||||
const _ChatJumpToLatest({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.cupertino,
|
||||
required this.onPressed,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final bool cupertino;
|
||||
final VoidCallback onPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final button = cupertino
|
||||
? CupertinoButton.filled(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
onPressed: onPressed,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
CupertinoIcons.arrow_down,
|
||||
color: CupertinoTheme.of(context).primaryContrastingColor,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(child: Text(label, textAlign: TextAlign.center)),
|
||||
],
|
||||
),
|
||||
)
|
||||
: FilledButton.tonalIcon(
|
||||
onPressed: onPressed,
|
||||
icon: const Icon(Icons.arrow_downward),
|
||||
label: Text(label, textAlign: TextAlign.center),
|
||||
);
|
||||
final button = FilledButton.tonalIcon(
|
||||
onPressed: onPressed,
|
||||
icon: const Icon(Icons.arrow_downward),
|
||||
label: Text(label, textAlign: TextAlign.center),
|
||||
);
|
||||
// A long count at a large text scale wraps inside the pane instead of
|
||||
// pushing the control past the transcript's edge.
|
||||
return ConstrainedBox(
|
||||
@@ -2157,35 +2030,21 @@ class _ChatActivityLineState extends State<_ChatActivityLine> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final state = '${widget.row['state'] ?? ''}'.trim().toLowerCase();
|
||||
final failed = state == 'failed' || state == 'error';
|
||||
final running = state == 'running';
|
||||
final completed =
|
||||
state == 'completed' || state == 'ended' || state == 'succeeded';
|
||||
final secondary = _secondary(context, cupertino);
|
||||
final color = failed
|
||||
? (cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error)
|
||||
: secondary;
|
||||
final style =
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodySmall)
|
||||
?.copyWith(color: color);
|
||||
final secondary = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final color = failed ? Theme.of(context).colorScheme.error : secondary;
|
||||
final style = Theme.of(context).textTheme.bodySmall?.copyWith(color: color);
|
||||
final icon = failed
|
||||
? (cupertino
|
||||
? CupertinoIcons.exclamationmark_circle
|
||||
: Icons.error_outline)
|
||||
? Icons.error_outline
|
||||
: running
|
||||
? (cupertino ? CupertinoIcons.arrow_2_circlepath : Icons.sync)
|
||||
? Icons.sync
|
||||
: completed
|
||||
? (cupertino
|
||||
? CupertinoIcons.check_mark_circled
|
||||
: Icons.check_circle_outline)
|
||||
: (cupertino ? CupertinoIcons.circle : Icons.circle_outlined);
|
||||
? Icons.check_circle_outline
|
||||
: Icons.circle_outlined;
|
||||
final label = '${widget.row['label'] ?? ''}'.trim();
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
@@ -2213,65 +2072,39 @@ class _ChatActivityLineState extends State<_ChatActivityLine> {
|
||||
),
|
||||
),
|
||||
),
|
||||
_toggleControl(cupertino),
|
||||
_toggleControl(),
|
||||
if (widget.onDismiss != null)
|
||||
_noticeDismissControl(
|
||||
cupertino: cupertino,
|
||||
label: chatNoticeDismissLabel(ChatNoticeKind.compaction),
|
||||
key: const ValueKey<String>('chat-notice-dismiss-compaction'),
|
||||
onPressed: widget.onDismiss!,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_expanded) _detail(context, cupertino, secondary),
|
||||
if (_expanded) _detail(context, secondary),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// The host's own disclosure control, with an action label that states what a
|
||||
/// tap does. Cupertino's button has no built-in label, so the wrapping node
|
||||
/// carries it and the button keeps the pointer handling.
|
||||
Widget _toggleControl(bool cupertino) {
|
||||
/// The disclosure control, with an action label that states what a tap does.
|
||||
Widget _toggleControl() {
|
||||
const key = ValueKey<String>('chat-activity-toggle');
|
||||
final label = _expanded ? 'Collapse activity' : 'Expand activity';
|
||||
final icon = Icon(
|
||||
_expanded
|
||||
? (cupertino ? CupertinoIcons.chevron_up : Icons.expand_less)
|
||||
: (cupertino ? CupertinoIcons.chevron_down : Icons.expand_more),
|
||||
);
|
||||
if (!cupertino) {
|
||||
return IconButton(
|
||||
key: key,
|
||||
tooltip: label,
|
||||
onPressed: _toggle,
|
||||
icon: icon,
|
||||
);
|
||||
}
|
||||
return Semantics(
|
||||
container: true,
|
||||
button: true,
|
||||
label: label,
|
||||
onTap: _toggle,
|
||||
child: ExcludeSemantics(
|
||||
child: CupertinoButton(
|
||||
key: key,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: _toggle,
|
||||
child: icon,
|
||||
),
|
||||
),
|
||||
return IconButton(
|
||||
key: key,
|
||||
tooltip: label,
|
||||
onPressed: _toggle,
|
||||
icon: Icon(_expanded ? Icons.expand_less : Icons.expand_more),
|
||||
);
|
||||
}
|
||||
|
||||
/// The expanded section: every recorded field, with the exact absence sentence
|
||||
/// for one the record did not carry. Only [ChatActivityDetail] reads the
|
||||
/// record, so the line and its details cannot disagree about a field.
|
||||
Widget _detail(BuildContext context, bool cupertino, Color secondary) {
|
||||
Widget _detail(BuildContext context, Color secondary) {
|
||||
final detail = chatActivityDetail(_record());
|
||||
final baseStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium;
|
||||
final baseStyle = Theme.of(context).textTheme.bodyMedium;
|
||||
final labelStyle = TextStyle(color: secondary, fontWeight: FontWeight.w600);
|
||||
Widget field(String label, String value) {
|
||||
final absent =
|
||||
@@ -2315,8 +2148,4 @@ class _ChatActivityLineState extends State<_ChatActivityLine> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Color _secondary(BuildContext context, bool cupertino) => cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user