diff --git a/app/lib/features/chat/conversation/chat_bar_control_style.dart b/app/lib/features/chat/conversation/chat_bar_control_style.dart index bc681626..2536c089 100644 --- a/app/lib/features/chat/conversation/chat_bar_control_style.dart +++ b/app/lib/features/chat/conversation/chat_bar_control_style.dart @@ -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( diff --git a/app/lib/features/chat/conversation/chat_card_styles.dart b/app/lib/features/chat/conversation/chat_card_styles.dart index d2b12f58..033ac891 100644 --- a/app/lib/features/chat/conversation/chat_card_styles.dart +++ b/app/lib/features/chat/conversation/chat_card_styles.dart @@ -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; diff --git a/app/lib/features/chat/conversation/chat_command_palette.dart b/app/lib/features/chat/conversation/chat_command_palette.dart index 5cd2acff..6d865b3c 100644 --- a/app/lib/features/chat/conversation/chat_command_palette.dart +++ b/app/lib/features/chat/conversation/chat_command_palette.dart @@ -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('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), - ), - ], - ), - ), - ), - ), - ), - ), - ), - ), - ], - ), - ); - } } diff --git a/app/lib/features/chat/conversation/chat_composer_bar.dart b/app/lib/features/chat/conversation/chat_composer_bar.dart index 093d109d..6e10357e 100644 --- a/app/lib/features/chat/conversation/chat_composer_bar.dart +++ b/app/lib/features/chat/conversation/chat_composer_bar.dart @@ -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 { @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 { // command palette, a separate menu, floats above it. final extras = [ 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 { 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 { 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 { 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 { 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 { /// 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 { /// 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 { 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 { Uint8List bytes, int index, ) { - final cupertino = - chatControlsStyleOf(context) == ChatControlsStyle.cupertino; return Semantics( key: ValueKey('chat-composer-attachment-$index'), container: true, @@ -1094,13 +1063,8 @@ class _ChatComposerBarState extends State { bytes, key: ValueKey('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 { 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 { 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('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( - '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 { 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 { ); } - 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 { // 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 { /// 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 { : 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 { 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 { ); } - 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( diff --git a/app/lib/features/chat/conversation/chat_delivery_indicator.dart b/app/lib/features/chat/conversation/chat_delivery_indicator.dart index b11e59cb..fb6facd5 100644 --- a/app/lib/features/chat/conversation/chat_delivery_indicator.dart +++ b/app/lib/features/chat/conversation/chat_delivery_indicator.dart @@ -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( diff --git a/app/lib/features/chat/conversation/chat_effort_control.dart b/app/lib/features/chat/conversation/chat_effort_control.dart index ff86f1de..226cafc3 100644 --- a/app/lib/features/chat/conversation/chat_effort_control.dart +++ b/app/lib/features/chat/conversation/chat_effort_control.dart @@ -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 { } } - Future _openSheet() => showCupertinoModalPopup( - 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 { 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 { ], ); 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( diff --git a/app/lib/features/chat/conversation/chat_effort_sheet.dart b/app/lib/features/chat/conversation/chat_effort_sheet.dart index 47075397..79f8e9a7 100644 --- a/app/lib/features/chat/conversation/chat_effort_sheet.dart +++ b/app/lib/features/chat/conversation/chat_effort_sheet.dart @@ -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 { @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('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('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'), - ), ); } } diff --git a/app/lib/features/chat/conversation/chat_model_chooser.dart b/app/lib/features/chat/conversation/chat_model_chooser.dart index 215db7ec..81bd112d 100644 --- a/app/lib/features/chat/conversation/chat_model_chooser.dart +++ b/app/lib/features/chat/conversation/chat_model_chooser.dart @@ -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 { } @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 { 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 { ); } - 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 { ], ), ), - if (selected) - Icon( - cupertino ? CupertinoIcons.check_mark : Icons.check, - color: accent, - ), + if (selected) Icon(Icons.check, color: accent), ], ), ); diff --git a/app/lib/features/chat/conversation/chat_model_control.dart b/app/lib/features/chat/conversation/chat_model_control.dart index af00a81d..0df4eb3f 100644 --- a/app/lib/features/chat/conversation/chat_model_control.dart +++ b/app/lib/features/chat/conversation/chat_model_control.dart @@ -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 { } Future _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( - context: context, - builder: (_) => chooser, - ); - return; - } await showDialog(context: context, builder: (_) => chooser); } @@ -110,8 +99,6 @@ class _ChatModelControlState extends State { @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 { 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, diff --git a/app/lib/features/chat/conversation/chat_next_chat_button.dart b/app/lib/features/chat/conversation/chat_next_chat_button.dart index f481bef9..98b9014a 100644 --- a/app/lib/features/chat/conversation/chat_next_chat_button.dart +++ b/app/lib/features/chat/conversation/chat_next_chat_button.dart @@ -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, diff --git a/app/lib/features/chat/conversation/chat_pane_picker.dart b/app/lib/features/chat/conversation/chat_pane_picker.dart index 03eec591..e917d2fd 100644 --- a/app/lib/features/chat/conversation/chat_pane_picker.dart +++ b/app/lib/features/chat/conversation/chat_pane_picker.dart @@ -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 showChatPanePicker( BuildContext context, { @@ -11,45 +8,23 @@ Future showChatPanePicker( required ValueChanged onSelected, String title = 'Open chats', }) async { - final String? selected; - if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) { - selected = await showCupertinoModalPopup( - 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( + 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( - 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); } diff --git a/app/lib/features/chat/conversation/chat_permission_card.dart b/app/lib/features/chat/conversation/chat_permission_card.dart index c872fe73..25ddb86c 100644 --- a/app/lib/features/chat/conversation/chat_permission_card.dart +++ b/app/lib/features/chat/conversation/chat_permission_card.dart @@ -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 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), ), ], ); diff --git a/app/lib/features/chat/conversation/chat_permission_group.dart b/app/lib/features/chat/conversation/chat_permission_group.dart index 3cddad15..17a83c69 100644 --- a/app/lib/features/chat/conversation/chat_permission_group.dart +++ b/app/lib/features/chat/conversation/chat_permission_group.dart @@ -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( diff --git a/app/lib/features/chat/conversation/chat_question_card.dart b/app/lib/features/chat/conversation/chat_question_card.dart index baf28c38..79c0cb60 100644 --- a/app/lib/features/chat/conversation/chat_question_card.dart +++ b/app/lib/features/chat/conversation/chat_question_card.dart @@ -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 { } @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 { '${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 { error, style: chatCardBodyStyle( context, - cupertino, - )?.copyWith(color: chatCardErrorColor(context, cupertino)), + false, + )?.copyWith(color: chatCardErrorColor(context, false)), ), ), ), @@ -187,7 +164,7 @@ class _ChatQuestionCardState extends State { context: context, fields: _fields, answers: _answers, - cupertino: cupertino, + cupertino: false, controllers: _controllers, onChanged: _changed, ) @@ -195,13 +172,13 @@ class _ChatQuestionCardState extends State { ...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, diff --git a/app/lib/features/chat/conversation/chat_question_card_controls.dart b/app/lib/features/chat/conversation/chat_question_card_controls.dart index 874ce839..67e3e1fd 100644 --- a/app/lib/features/chat/conversation/chat_question_card_controls.dart +++ b/app/lib/features/chat/conversation/chat_question_card_controls.dart @@ -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, diff --git a/app/lib/features/chat/conversation/chat_question_card_fields.dart b/app/lib/features/chat/conversation/chat_question_card_fields.dart index c227f5a1..1d37ad0a 100644 --- a/app/lib/features/chat/conversation/chat_question_card_fields.dart +++ b/app/lib/features/chat/conversation/chat_question_card_fields.dart @@ -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 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('chat-question-input-$keyName'), - controller: controller, - placeholder: placeholder, - obscureText: secret, - keyboardType: keyboard, - padding: const EdgeInsets.all(8), - onChanged: onChanged, - ) - : TextField( - key: ValueKey('chat-question-input-$keyName'), - controller: controller, - obscureText: secret, - keyboardType: keyboard, - decoration: InputDecoration(hintText: placeholder), - onChanged: onChanged, - ); + final input = TextField( + key: ValueKey('chat-question-input-$keyName'), + controller: controller, + obscureText: secret, + keyboardType: keyboard, + decoration: InputDecoration(hintText: placeholder), + onChanged: onChanged, + ); return Semantics(label: label, child: input); } diff --git a/app/lib/features/chat/conversation/chat_question_group.dart b/app/lib/features/chat/conversation/chat_question_group.dart index 7e12abb0..880ddd0d 100644 --- a/app/lib/features/chat/conversation/chat_question_group.dart +++ b/app/lib/features/chat/conversation/chat_question_group.dart @@ -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('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, ), ], ), diff --git a/app/lib/features/chat/conversation/chat_question_option_controls.dart b/app/lib/features/chat/conversation/chat_question_option_controls.dart index 938690c4..efc8ceb4 100644 --- a/app/lib/features/chat/conversation/chat_question_option_controls.dart +++ b/app/lib/features/chat/conversation/chat_question_option_controls.dart @@ -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() : {}) : {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( initialValue: value is bool ? '$value' : null, hint: const Text('Choose Yes or No'), diff --git a/app/lib/features/chat/conversation/chat_question_recorded_answers.dart b/app/lib/features/chat/conversation/chat_question_recorded_answers.dart index b060eca8..5cea2d72 100644 --- a/app/lib/features/chat/conversation/chat_question_recorded_answers.dart +++ b/app/lib/features/chat/conversation/chat_question_recorded_answers.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; diff --git a/app/lib/features/chat/conversation/chat_session_section.dart b/app/lib/features/chat/conversation/chat_session_section.dart index ba226c40..d0a5b3d0 100644 --- a/app/lib/features/chat/conversation/chat_session_section.dart +++ b/app/lib/features/chat/conversation/chat_session_section.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 { @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 { ), _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 { 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 { 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 { 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); } } diff --git a/app/lib/features/chat/conversation/chat_sidebar_controls.dart b/app/lib/features/chat/conversation/chat_sidebar_controls.dart index e5a75a0b..401e4742 100644 --- a/app/lib/features/chat/conversation/chat_sidebar_controls.dart +++ b/app/lib/features/chat/conversation/chat_sidebar_controls.dart @@ -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 _choose(BuildContext context) async { - final ChatSidebarMode? choice; - if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) { - choice = await showCupertinoModalPopup( - 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( + 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( - 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), + ); } diff --git a/app/lib/features/chat/conversation/chat_task_metadata_view.dart b/app/lib/features/chat/conversation/chat_task_metadata_view.dart index d3f48aa2..2b066fe0 100644 --- a/app/lib/features/chat/conversation/chat_task_metadata_view.dart +++ b/app/lib/features/chat/conversation/chat_task_metadata_view.dart @@ -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 = [ 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), ), diff --git a/app/lib/features/chat/conversation/chat_task_presentation.dart b/app/lib/features/chat/conversation/chat_task_presentation.dart index 309a0397..01a649db 100644 --- a/app/lib/features/chat/conversation/chat_task_presentation.dart +++ b/app/lib/features/chat/conversation/chat_task_presentation.dart @@ -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 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 { diff --git a/app/lib/features/chat/conversation/chat_thread_header.dart b/app/lib/features/chat/conversation/chat_thread_header.dart index 709c9396..68956371 100644 --- a/app/lib/features/chat/conversation/chat_thread_header.dart +++ b/app/lib/features/chat/conversation/chat_thread_header.dart @@ -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().isNotEmpty) SegmentedMoreButton( - cupertino: cupertino, + cupertino: false, entries: [ for (final action in moreActions.whereType()) @@ -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, ), ); diff --git a/app/lib/features/chat/conversation/chat_thread_view.dart b/app/lib/features/chat/conversation/chat_thread_view.dart index 6f050df0..fd27edb7 100644 --- a/app/lib/features/chat/conversation/chat_thread_view.dart +++ b/app/lib/features/chat/conversation/chat_thread_view.dart @@ -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 { 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 { ), ), ) - : cupertino - ? showCupertinoModalPopup( - context: context, - builder: (_) => Align( - alignment: Alignment.bottomCenter, - child: SafeArea( - child: CupertinoPopupSurface( - child: SizedBox( - height: MediaQuery.sizeOf(context).height * .85, - child: FilesPanel(controller: _files), - ), - ), - ), - ), - ) : showModalBottomSheet( context: context, isScrollControlled: true, @@ -999,8 +982,6 @@ class _ChatThreadViewState extends State { _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 { 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 { ), 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 { 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 { 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 { child: _ChatJumpToLatest( key: const Key('chat-jump-to-latest'), label: chatJumpToLatestLabel(newMessages), - cupertino: cupertino, onPressed: _followLatest, ), ), @@ -1487,7 +1457,7 @@ class _ChatThreadViewState extends State { runChatShellFromMenu( context, _shellRuns, - cupertino: chatControlsStyleOf(context) == ChatControlsStyle.cupertino, + cupertino: false, showNotice: _showCommandNotice, ), ); @@ -1497,7 +1467,7 @@ class _ChatThreadViewState extends State { 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 { 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 { 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 { if (delivery != null) ChatDeliveryIndicator( state: delivery, - cupertino: cupertino, + cupertino: false, onRemove: onRemove, ), ], @@ -1671,7 +1631,7 @@ class _ChatThreadViewState extends State { /// 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 { footer: [ ChatDeliveryIndicator( state: ChatDelivery.queued, - cupertino: cupertino, + cupertino: false, onRemove: _removeAction('${prompt['operation_id'] ?? ''}'), ), ], @@ -1689,7 +1649,7 @@ class _ChatThreadViewState extends State { /// 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 { 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 { } /// 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('chat-notice-dismiss-${notice.kind.name}'), - onPressed: () => onDismiss(notice), - ); - } + Widget _dismissControl() => _noticeDismissControl( + label: chatNoticeDismissLabel(notice.kind), + key: ValueKey('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('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('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; } diff --git a/app/test/application/chat_registration_test.dart b/app/test/application/chat_registration_test.dart index c2e7cde8..c80eb9f5 100644 --- a/app/test/application/chat_registration_test.dart +++ b/app/test/application/chat_registration_test.dart @@ -226,124 +226,115 @@ Future replyChatHistory( } void main() { - for (final cupertino in [false, true]) { - testWidgets( - 'a wide /chat/s1 deep link shows that thread beside the list and route Back returns to /chat ($cupertino)', - (tester) async { - tester.view.physicalSize = const Size(900, 900); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); - if (cupertino) { - tester.platformDispatcher.platformBrightnessTestValue = - Brightness.dark; - addTearDown( - tester.platformDispatcher.clearPlatformBrightnessTestValue, - ); - } + testWidgets( + 'a wide /chat/s1 deep link shows that thread beside the list and route Back returns to /chat', + (tester) async { + tester.view.physicalSize = const Size(900, 900); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); - final channel = FakeChannel()..readyCompleter.complete(); - final client = PipelinesClient(channelFactory: (_) => channel); - final provider = PlatformRouteInformationProvider( - initialRouteInformation: RouteInformation(uri: Uri.parse('/chat/s1')), - ); - addTearDown(provider.dispose); + final channel = FakeChannel()..readyCompleter.complete(); + final client = PipelinesClient(channelFactory: (_) => channel); + final provider = PlatformRouteInformationProvider( + initialRouteInformation: RouteInformation(uri: Uri.parse('/chat/s1')), + ); + addTearDown(provider.dispose); - await tester.pumpWidget( - PipelinesApp( - androidSupported: false, - server: webServer(), - client: client, - cupertino: cupertino, - routeInformationProvider: provider, - ), - ); - await tester.pump(); + await tester.pumpWidget( + PipelinesApp( + androidSupported: false, + server: webServer(), + client: client, + cupertino: false, + routeInformationProvider: provider, + ), + ); + await tester.pump(); - await replySessions(tester, channel); - await replySubscribe(tester, channel); - await replyHistory(tester, channel); - await tester.pumpAndSettle(); + await replySessions(tester, channel); + await replySubscribe(tester, channel); + await replyHistory(tester, channel); + await tester.pumpAndSettle(); - expect(provider.value.uri.path, '/chat/s1'); - expect(find.byType(ChatThreadView), findsOneWidget); - // The exact route names the session; the request carries the same id. - expect(requestOf(channel, 'chat_subscribe')!['chat_subscribe'], { - 'session_id': 's1', - }); - expect(requestOf(channel, 'chat_messages')!['chat_query'], { - 'session_id': 's1', - 'limit': 200, - 'cursor': '', - }); - expect(find.text('The stored reply stays readable.'), findsOneWidget); - expect(find.text('Ran 1 command'), findsOneWidget); - expect(find.byKey(const Key('chat-turn-activity')), findsOneWidget); - expect(find.text('Kept behind a native disclosure.'), findsNothing); + expect(provider.value.uri.path, '/chat/s1'); + expect(find.byType(ChatThreadView), findsOneWidget); + // The exact route names the session; the request carries the same id. + expect(requestOf(channel, 'chat_subscribe')!['chat_subscribe'], { + 'session_id': 's1', + }); + expect(requestOf(channel, 'chat_messages')!['chat_query'], { + 'session_id': 's1', + 'limit': 200, + 'cursor': '', + }); + expect(find.text('The stored reply stays readable.'), findsOneWidget); + expect(find.text('Ran 1 command'), findsOneWidget); + expect(find.byKey(const Key('chat-turn-activity')), findsOneWidget); + expect(find.text('Kept behind a native disclosure.'), findsNothing); - // The shell bar stays over the list and tabs; the open chat draws its - // own floating bar in its pane, with no Back: the list beside it is the - // way out. - expect(find.byType(ChatSessionsScreen), findsOneWidget); - expect(find.byType(NavigationRail), findsNothing); - expect(find.byType(FloatingDestinationBar), findsOneWidget); - // The shell's bar and the conversation's own header. - expect(find.byType(SegmentedBar), findsNWidgets(2)); - expect(find.byType(AppBar), findsNothing); - expect(find.byType(CupertinoNavigationBar), findsNothing); - expect(find.byKey(const Key('chat-thread-header')), findsOneWidget); - expect(findNativeBack(), findsNothing); + // The shell bar stays over the list and tabs; the open chat draws its + // own floating bar in its pane, with no Back: the list beside it is the + // way out. + expect(find.byType(ChatSessionsScreen), findsOneWidget); + expect(find.byType(NavigationRail), findsNothing); + expect(find.byType(FloatingDestinationBar), findsOneWidget); + // The shell's bar and the conversation's own header. + expect(find.byType(SegmentedBar), findsNWidgets(2)); + expect(find.byType(AppBar), findsNothing); + expect(find.byType(CupertinoNavigationBar), findsNothing); + expect(find.byKey(const Key('chat-thread-header')), findsOneWidget); + expect(findNativeBack(), findsNothing); - // A live frame updates the held thread. - channel.incoming.add( - jsonEncode({ - 'type': 'chat_event', - 'chat_event': { - 'session_id': 's1', - 'message_id': 'a1', - 'kind': 'text', - 'part': {'id': 'p2', 'type': 'text'}, - 'delta': 'A live line arrived.', - }, - }), - ); - await tester.pump(); - await tester.pump(); - expect(find.text('A live line arrived.'), findsOneWidget); + // A live frame updates the held thread. + channel.incoming.add( + jsonEncode({ + 'type': 'chat_event', + 'chat_event': { + 'session_id': 's1', + 'message_id': 'a1', + 'kind': 'text', + 'part': {'id': 'p2', 'type': 'text'}, + 'delta': 'A live line arrived.', + }, + }), + ); + await tester.pump(); + await tester.pump(); + expect(find.text('A live line arrived.'), findsOneWidget); - // The thread's own bar carries its controls once: no second bar. - expect(find.byKey(const Key('chat-thread-header')), findsOneWidget); - // Browser Back to /chat clears the open pane and keeps the list. - await provider.didPushRouteInformation( - RouteInformation(uri: Uri.parse('/chat')), - ); - await tester.pumpAndSettle(); - expect(provider.value.uri.path, '/chat'); - expect(find.byType(ChatThreadView), findsNothing); - expect(find.byType(ChatSessionsScreen), findsOneWidget); - expect(find.text('Wire chat'), findsOneWidget); - expect(find.text('Select a chat to open it here.'), findsOneWidget); + // The thread's own bar carries its controls once: no second bar. + expect(find.byKey(const Key('chat-thread-header')), findsOneWidget); + // Browser Back to /chat clears the open pane and keeps the list. + await provider.didPushRouteInformation( + RouteInformation(uri: Uri.parse('/chat')), + ); + await tester.pumpAndSettle(); + expect(provider.value.uri.path, '/chat'); + expect(find.byType(ChatThreadView), findsNothing); + expect(find.byType(ChatSessionsScreen), findsOneWidget); + expect(find.text('Wire chat'), findsOneWidget); + expect(find.text('Select a chat to open it here.'), findsOneWidget); - // Browser Forward re-opens the same session through its route. - await provider.didPushRouteInformation( - RouteInformation(uri: Uri.parse('/chat/s1')), - ); - await tester.pump(); - expect(provider.value.uri.path, '/chat/s1'); - await replySubscribe(tester, channel, index: 1); - await replyHistory( - tester, - channel, - index: 1, - text: 'Reopened from the route.', - ); - expect(find.text('Reopened from the route.'), findsOneWidget); + // Browser Forward re-opens the same session through its route. + await provider.didPushRouteInformation( + RouteInformation(uri: Uri.parse('/chat/s1')), + ); + await tester.pump(); + expect(provider.value.uri.path, '/chat/s1'); + await replySubscribe(tester, channel, index: 1); + await replyHistory( + tester, + channel, + index: 1, + text: 'Reopened from the route.', + ); + expect(find.text('Reopened from the route.'), findsOneWidget); - await tester.pumpWidget(const SizedBox.shrink()); - await tester.pump(); - }, - ); - } + await tester.pumpWidget(const SizedBox.shrink()); + await tester.pump(); + }, + ); testWidgets( 'mobile Chats retap reopens the retained multi-pane workspace after tabs', diff --git a/app/test/features/chat/chat_list_shortcuts_test.dart b/app/test/features/chat/chat_list_shortcuts_test.dart index 7ea36540..47589116 100644 --- a/app/test/features/chat/chat_list_shortcuts_test.dart +++ b/app/test/features/chat/chat_list_shortcuts_test.dart @@ -64,7 +64,7 @@ Future<_Gateway> _pumpShell( MaterialApp( theme: ThemeData(platform: platform, brightness: brightness), home: AdaptiveShell( - cupertino: platform == TargetPlatform.iOS, + cupertino: false, destination: AppDestination.chat, destinationBodies: { AppDestination.chat: (_) => ChatScreen(gateway: gateway), @@ -234,55 +234,50 @@ void main() { await tester.pumpWidget(const SizedBox.shrink()); }); - for (final platform in [TargetPlatform.android, TargetPlatform.iOS]) { - for (final brightness in Brightness.values) { - final host = - '${platform == TargetPlatform.iOS ? 'Cupertino' : 'Material'} ' - '${brightness.name}'; - testWidgets('$host: a coloured chat tints its bar, with no wash; the ' - 'info sheet changes the colour', (tester) async { - final gateway = await _pumpShell( - tester, - const Size(1280, 800), - platform: platform, - brightness: brightness, - ); - await _ctrl(tester, LogicalKeyboardKey.digit1); - expect(_thread('a'), findsOneWidget); - // The colour lives in the bar's pieces; the page has no wash. - expect(find.byKey(const Key('chat-bar-tint')), findsOneWidget); - expect(find.byKey(const Key('chat-color-wash')), findsNothing); - expect(find.byKey(const Key('chat-color-wash-below')), findsNothing); - final tint = tester.widget( - find.byKey(const Key('chat-bar-tint')), - ); - final pill = tester.widget( - find - .ancestor( - of: find.byKey(const Key('chat-info')), - matching: find.byType(GlassPill), - ) - .first, - ); - expect(pill.fill, tint.tint.fill); + for (final brightness in Brightness.values) { + final host = 'Material ${brightness.name}'; + testWidgets('$host: a coloured chat tints its bar, with no wash; the ' + 'info sheet changes the colour', (tester) async { + final gateway = await _pumpShell( + tester, + const Size(1280, 800), + brightness: brightness, + ); + await _ctrl(tester, LogicalKeyboardKey.digit1); + expect(_thread('a'), findsOneWidget); + // The colour lives in the bar's pieces; the page has no wash. + expect(find.byKey(const Key('chat-bar-tint')), findsOneWidget); + expect(find.byKey(const Key('chat-color-wash')), findsNothing); + expect(find.byKey(const Key('chat-color-wash-below')), findsNothing); + final tint = tester.widget( + find.byKey(const Key('chat-bar-tint')), + ); + final pill = tester.widget( + find + .ancestor( + of: find.byKey(const Key('chat-info')), + matching: find.byType(GlassPill), + ) + .first, + ); + expect(pill.fill, tint.tint.fill); - // A plain chat keeps the neutral bar. - await _ctrl(tester, LogicalKeyboardKey.digit3); - expect(find.byKey(const Key('chat-bar-tint')), findsNothing); + // A plain chat keeps the neutral bar. + await _ctrl(tester, LogicalKeyboardKey.digit3); + expect(find.byKey(const Key('chat-bar-tint')), findsNothing); - await tester.tap(find.byKey(const Key('chat-info'))); - await tester.pumpAndSettle(); - expect(find.byKey(const Key('chat-color-section')), findsOneWidget); - await tester.tap(find.byKey(const Key('chat-color-blue'))); - await tester.pumpAndSettle(); - expect(gateway.calls.last.fields, { - 'chat_query': {'session_id': 'r', 'color': 'blue'}, - }); - await tester.tap(find.byKey(const Key('chat-info-close'))); - await tester.pumpAndSettle(); - expect(find.byKey(const Key('chat-bar-tint')), findsOneWidget); - await tester.pumpWidget(const SizedBox.shrink()); + await tester.tap(find.byKey(const Key('chat-info'))); + await tester.pumpAndSettle(); + expect(find.byKey(const Key('chat-color-section')), findsOneWidget); + await tester.tap(find.byKey(const Key('chat-color-blue'))); + await tester.pumpAndSettle(); + expect(gateway.calls.last.fields, { + 'chat_query': {'session_id': 'r', 'color': 'blue'}, }); - } + await tester.tap(find.byKey(const Key('chat-info-close'))); + await tester.pumpAndSettle(); + expect(find.byKey(const Key('chat-bar-tint')), findsOneWidget); + await tester.pumpWidget(const SizedBox.shrink()); + }); } } diff --git a/app/test/features/chat/conversation/chat_composer_attachment_test.dart b/app/test/features/chat/conversation/chat_composer_attachment_test.dart index 8a432ae8..3f30d557 100644 --- a/app/test/features/chat/conversation/chat_composer_attachment_test.dart +++ b/app/test/features/chat/conversation/chat_composer_attachment_test.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:typed_data'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/core/api_gateway.dart'; @@ -31,9 +30,7 @@ class _FakePicker { ChatPickedFile _file(String name, {int size = 3, String mime = 'text/plain'}) => ChatPickedFile(name: name, mime: mime, bytes: Uint8List(size)); -Widget _host(Widget bar, {required bool cupertino}) => cupertino - ? CupertinoApp(home: CupertinoPageScaffold(child: bar)) - : materialHost(bar); +Widget _host(Widget bar) => materialHost(bar); void main() { late ComposerBarGateway gateway; @@ -68,49 +65,37 @@ void main() { Future pumpBar( WidgetTester tester, { ChatAttachmentPicker? picker, - bool cupertino = false, }) async { newComposer(); await tester.pumpWidget( _host( ChatComposerBar(composer: composer, running: false, picker: picker), - cupertino: cupertino, ), ); await tester.pump(); } - for (final cupertino in [false, true]) { - testWidgets('picking a file shows its recorded name and removes it ' - '(${cupertino ? 'cupertino' : 'material'})', (tester) async { - final fake = _FakePicker([ - [_file('notes.txt')], - ]); - await pumpBar(tester, picker: fake.picker, cupertino: cupertino); + testWidgets('picking a file shows its recorded name and removes it', ( + tester, + ) async { + final fake = _FakePicker([ + [_file('notes.txt')], + ]); + await pumpBar(tester, picker: fake.picker); - await tester.tap(find.byKey(const Key('chat-composer-attach'))); - await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('chat-composer-attach'))); + await tester.pumpAndSettle(); - expect(fake.calls, 1); - expect( - find.byKey(const Key('chat-composer-attachments')), - findsOneWidget, - ); - expect(find.text('notes.txt'), findsOneWidget); + expect(fake.calls, 1); + expect(find.byKey(const Key('chat-composer-attachments')), findsOneWidget); + expect(find.text('notes.txt'), findsOneWidget); - if (cupertino) { - await tester.tap( - find.byKey(const Key('chat-composer-attachment-remove-0')), - ); - } else { - await tester.tap(find.byTooltip('Remove notes.txt')); - } - await tester.pump(); + await tester.tap(find.byTooltip('Remove notes.txt')); + await tester.pump(); - expect(find.text('notes.txt'), findsNothing); - expect(find.byKey(const Key('chat-composer-attachments')), findsNothing); - }); - } + expect(find.text('notes.txt'), findsNothing); + expect(find.byKey(const Key('chat-composer-attachments')), findsNothing); + }); testWidgets('a file over the draft budget shows the draft refusal line', ( tester, @@ -218,32 +203,28 @@ void main() { expect(attach.onPressed, isNull); }); - for (final cupertino in [false, true]) { - testWidgets('a long attachment name fits a narrow 2x composer ' - '(${cupertino ? 'cupertino' : 'material'})', (tester) async { - tester.view.physicalSize = const Size(640, 1200); - tester.view.devicePixelRatio = 2; - tester.platformDispatcher.textScaleFactorTestValue = 2; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); - addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue); + testWidgets('a long attachment name fits a narrow 2x composer', ( + tester, + ) async { + tester.view.physicalSize = const Size(640, 1200); + tester.view.devicePixelRatio = 2; + tester.platformDispatcher.textScaleFactorTestValue = 2; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue); - final name = - 'a-very-long-recorded-attachment-name-that-must-not-overflow.pdf'; - final fake = _FakePicker([ - [_file(name)], - ]); - await pumpBar(tester, picker: fake.picker, cupertino: cupertino); + final name = + 'a-very-long-recorded-attachment-name-that-must-not-overflow.pdf'; + final fake = _FakePicker([ + [_file(name)], + ]); + await pumpBar(tester, picker: fake.picker); - await tester.tap(find.byKey(const Key('chat-composer-attach'))); - await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('chat-composer-attach'))); + await tester.pumpAndSettle(); - expect(tester.takeException(), isNull); - expect(find.text(name), findsOneWidget); - expect( - find.byKey(const Key('chat-composer-attachments')), - findsOneWidget, - ); - }); - } + expect(tester.takeException(), isNull); + expect(find.text(name), findsOneWidget); + expect(find.byKey(const Key('chat-composer-attachments')), findsOneWidget); + }); } diff --git a/app/test/features/chat/conversation/chat_effort_control_test.dart b/app/test/features/chat/conversation/chat_effort_control_test.dart index 669b62b3..e31b2625 100644 --- a/app/test/features/chat/conversation/chat_effort_control_test.dart +++ b/app/test/features/chat/conversation/chat_effort_control_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/core/api_gateway.dart'; @@ -185,42 +184,4 @@ void main() { expect(find.text('Thinking: Max'), findsOneWidget); expect(changes.single.defaultEffort, 'max'); }); - - testWidgets('Cupertino uses an action sheet that reports a refusal', ( - tester, - ) async { - Widget app(ApiGateway gateway) => CupertinoApp( - home: CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - trailing: ChatEffortControl( - gateway: gateway, - sessionId: 's', - session: _row(), - ), - ), - child: const SizedBox.shrink(), - ), - ); - final refusing = _EffortGateway(refuse: 'level refused'); - await tester.pumpWidget(app(refusing)); - await tester.tap(find.byKey(const Key('chat-effort'))); - await tester.pumpAndSettle(); - expect(find.byType(CupertinoActionSheet), findsOneWidget); - await tester.tap(find.byKey(const ValueKey('chat-effort-option-low'))); - await tester.pumpAndSettle(); - expect(find.byType(CupertinoActionSheet), findsOneWidget); - expect(find.textContaining('level refused'), findsOneWidget); - - final gateway = _EffortGateway(); - await tester.pumpWidget(app(gateway)); - await tester.pumpAndSettle(); - await tester.tapAt(const Offset(10, 10)); - await tester.pumpAndSettle(); - await tester.tap(find.byKey(const Key('chat-effort'))); - await tester.pumpAndSettle(); - await tester.tap(find.byKey(const ValueKey('chat-effort-option-xhigh'))); - await tester.pumpAndSettle(); - expect(find.byType(CupertinoActionSheet), findsNothing); - expect(gateway.requests.single['type'], 'chat_effort'); - }); } diff --git a/app/test/features/chat/conversation/chat_question_card_test.dart b/app/test/features/chat/conversation/chat_question_card_test.dart index 4ba1084b..7f4d43b0 100644 --- a/app/test/features/chat/conversation/chat_question_card_test.dart +++ b/app/test/features/chat/conversation/chat_question_card_test.dart @@ -1,6 +1,5 @@ import 'dart:async'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/core/api_gateway.dart'; @@ -19,16 +18,6 @@ Widget materialHost(Widget child) => MaterialApp( Widget scrollHost(Widget child) => materialHost(SingleChildScrollView(child: child)); -Widget cupertinoHost(Widget child) => CupertinoApp( - theme: const CupertinoThemeData(brightness: Brightness.dark), - home: CupertinoPageScaffold( - child: SingleChildScrollView( - padding: const EdgeInsets.all(16), - child: child, - ), - ), -); - List fields() => [ { 'key': 'colour', @@ -235,19 +224,6 @@ void main() { expect(find.text('Send answer'), findsNothing); }); - testWidgets('Cupertino field labels stay subordinate to the card title', ( - tester, - ) async { - await tester.pumpWidget( - cupertinoHost( - ChatQuestionCard(form: question(), onSubmit: (_, _) async {}), - ), - ); - final title = tester.widget(find.text('A demo question')); - final label = tester.widget(find.text('Colour')); - expect(label.style!.fontSize, lessThan(title.style!.fontSize!)); - }); - testWidgets('a free-text input carries its visual label in semantics', ( tester, ) async { @@ -424,29 +400,6 @@ void main() { expect(find.text('kept'), findsOneWidget); }); - testWidgets('320px at 2x in dark Cupertino keeps native controls', ( - tester, - ) async { - tester.view.physicalSize = const Size(640, 1600); - tester.view.devicePixelRatio = 2; - tester.platformDispatcher.textScaleFactorTestValue = 2; - tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); - addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue); - addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue); - - await tester.pumpWidget( - cupertinoHost( - ChatQuestionCard(form: question(), onSubmit: (_, _) async {}), - ), - ); - expect(tester.takeException(), isNull); - expect(find.text('A demo question'), findsOneWidget); - expect(find.text('Send answer'), findsOneWidget); - expect(find.byType(Material), findsNothing); - }); - testWidgets('a pushed form renders and sends one exact chat_answer', ( tester, ) async { diff --git a/app/test/features/chat/conversation/chat_stop_icon_test.dart b/app/test/features/chat/conversation/chat_stop_icon_test.dart index bddcf1f6..fdd467f0 100644 --- a/app/test/features/chat/conversation/chat_stop_icon_test.dart +++ b/app/test/features/chat/conversation/chat_stop_icon_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/chat/conversation/chat_stop_icon.dart'; @@ -121,61 +120,55 @@ void main() { await tester.pumpWidget(const SizedBox.shrink()); }); - for (final cupertino in [false, true]) { - testWidgets( - 'rotating Stop keeps its target and interrupt action; Send stays available ($cupertino)', - (tester) async { - final gateway = ComposerBarGateway(); - addTearDown(gateway.close); - final composer = ChatComposerController( - gateway, - 's', - drafts: MemoryChatDraftStore(), - ); - addTearDown(composer.dispose); - final running = ValueNotifier(true); - addTearDown(running.dispose); - final bar = ValueListenableBuilder( - valueListenable: running, - builder: (_, value, _) => - ChatComposerBar(composer: composer, running: value), - ); - await tester.pumpWidget( - cupertino - ? CupertinoApp( - home: CupertinoPageScaffold(child: Center(child: bar)), - ) - : MaterialApp( - home: Scaffold(body: Center(child: bar)), - ), - ); - // The composer pops in first; Stop's target is measured once it has. - await tester.pump(Motion.tabEntranceDuration); - final stop = find.byKey(const Key('chat-composer-stop')); - final target = tester.getRect(stop); - await tester.pump(const Duration(seconds: 3)); - expect(tester.getRect(stop), target); - expect(find.byKey(const Key('chat-composer-primary')), findsOneWidget); - expect( - tester - .widget( - find.byKey(const Key('chat-stop-rotation')), - ) - .turns - .value, - greaterThan(0), - ); - await tester.tap(stop); - await tester.pump(); - await tester.pump(); - expect(gateway.interruptBodies, [ - {'session_id': 's'}, - ]); - running.value = false; - await tester.pumpAndSettle(); - expect(find.byType(ChatStopIcon), findsNothing); - expect(tester.binding.transientCallbackCount, 0); - }, - ); - } + testWidgets( + 'rotating Stop keeps its target and interrupt action; Send stays available', + (tester) async { + final gateway = ComposerBarGateway(); + addTearDown(gateway.close); + final composer = ChatComposerController( + gateway, + 's', + drafts: MemoryChatDraftStore(), + ); + addTearDown(composer.dispose); + final running = ValueNotifier(true); + addTearDown(running.dispose); + final bar = ValueListenableBuilder( + valueListenable: running, + builder: (_, value, _) => + ChatComposerBar(composer: composer, running: value), + ); + await tester.pumpWidget( + MaterialApp( + home: Scaffold(body: Center(child: bar)), + ), + ); + // The composer pops in first; Stop's target is measured once it has. + await tester.pump(Motion.tabEntranceDuration); + final stop = find.byKey(const Key('chat-composer-stop')); + final target = tester.getRect(stop); + await tester.pump(const Duration(seconds: 3)); + expect(tester.getRect(stop), target); + expect(find.byKey(const Key('chat-composer-primary')), findsOneWidget); + expect( + tester + .widget( + find.byKey(const Key('chat-stop-rotation')), + ) + .turns + .value, + greaterThan(0), + ); + await tester.tap(stop); + await tester.pump(); + await tester.pump(); + expect(gateway.interruptBodies, [ + {'session_id': 's'}, + ]); + running.value = false; + await tester.pumpAndSettle(); + expect(find.byType(ChatStopIcon), findsNothing); + expect(tester.binding.transientCallbackCount, 0); + }, + ); } diff --git a/app/test/features/chat/conversation/chat_thread_header_test.dart b/app/test/features/chat/conversation/chat_thread_header_test.dart index f2b96d18..7a54fc00 100644 --- a/app/test/features/chat/conversation/chat_thread_header_test.dart +++ b/app/test/features/chat/conversation/chat_thread_header_test.dart @@ -19,15 +19,10 @@ const _session = { 'model_provider': 'p1', }; -Widget _host(Widget child, {required bool cupertino}) => cupertino - ? CupertinoApp( - theme: const CupertinoThemeData(brightness: Brightness.dark), - home: CupertinoPageScaffold(child: child), - ) - : MaterialApp( - theme: ThemeData(platform: TargetPlatform.android), - home: Scaffold(body: child), - ); +Widget _host(Widget child) => MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: Scaffold(body: child), +); void _useNarrowText(WidgetTester tester) { tester.view.physicalSize = const Size(320, 640); @@ -39,58 +34,49 @@ void _useNarrowText(WidgetTester tester) { } void main() { - for (final cupertino in [false, true]) { - testWidgets( - '${cupertino ? 'Cupertino' : 'Material'} wide header uses one explicit control gap', - (tester) async { - tester.view.physicalSize = const Size(1440, 900); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); + testWidgets('wide header uses one explicit control gap', (tester) async { + tester.view.physicalSize = const Size(1440, 900); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); - Widget control(String key) => - SizedBox(key: Key(key), width: 48, height: 48); + Widget control(String key) => + SizedBox(key: Key(key), width: 48, height: 48); - await tester.pumpWidget( - _host( - ChatThreadHeader( - title: 'Chat', - folder: 'demo', - onInfo: () {}, - controls: [ - control('header-control-1'), - control('header-control-2'), - ], - actions: [control('header-action-1'), control('header-action-2')], - moreActions: [ - ChatBarAction( - label: 'More action', - onPressed: () {}, - materialIcon: Icons.more_horiz, - cupertinoIcon: CupertinoIcons.ellipsis, - ), - ], + await tester.pumpWidget( + _host( + ChatThreadHeader( + title: 'Chat', + folder: 'demo', + onInfo: () {}, + controls: [control('header-control-1'), control('header-control-2')], + actions: [control('header-action-1'), control('header-action-2')], + moreActions: [ + ChatBarAction( + label: 'More action', + onPressed: () {}, + materialIcon: Icons.more_horiz, + cupertinoIcon: CupertinoIcons.ellipsis, ), - cupertino: cupertino, - ), - ); - await tester.pumpAndSettle(); - - double gap(String left, String right) => - tester.getTopLeft(find.byKey(Key(right))).dx - - tester.getTopRight(find.byKey(Key(left))).dx; - - expect(gap('header-control-1', 'header-control-2'), 8); - expect(gap('header-control-2', 'header-action-1'), 8); - expect(gap('header-action-1', 'header-action-2'), 8); - expect( - tester.getTopLeft(find.byKey(segmentedMoreKey).first).dx - - tester.getTopRight(find.byKey(const Key('header-action-2'))).dx, - 8, - ); - }, + ], + ), + ), ); - } + await tester.pumpAndSettle(); + + double gap(String left, String right) => + tester.getTopLeft(find.byKey(Key(right))).dx - + tester.getTopRight(find.byKey(Key(left))).dx; + + expect(gap('header-control-1', 'header-control-2'), 8); + expect(gap('header-control-2', 'header-action-1'), 8); + expect(gap('header-action-1', 'header-action-2'), 8); + expect( + tester.getTopLeft(find.byKey(segmentedMoreKey).first).dx - + tester.getTopRight(find.byKey(const Key('header-action-2'))).dx, + 8, + ); + }); testWidgets('short large-text header keeps controls in its single row', ( tester, @@ -116,7 +102,6 @@ void main() { ), ), ), - cupertino: false, ), ); await tester.pumpAndSettle(); @@ -148,7 +133,6 @@ void main() { session: _session, onBack: () => backed++, ), - cupertino: false, ), ); await tester.pumpAndSettle(); @@ -194,157 +178,134 @@ void main() { ); // The mode control is Material only. - for (final cupertino in [false]) { - for (final width in [320.0, 390.0, 1280.0]) { - testWidgets( - '${cupertino ? 'Cupertino' : 'Material'} grouped actions at $width and text scale 2', - (tester) async { - _useNarrowText(tester); - tester.view.physicalSize = Size(width, 800); - final gateway = FakeChatGateway(); - addTearDown(gateway.close); - gateway.history = (_) async => chatPage(const []); - gateway.subscribe = () async => const {}; - var sidebar = 0; - var pane = 0; - var next = 0; - await tester.pumpWidget( - _host( - ChatThreadView( - gateway: gateway, - sessionId: 's', - title: _title, - session: { - ..._session, - 'mode': 'safe', - 'mode_name': 'Ask before making changes', - }, - onBack: () {}, - onNextChat: () => next++, - sidebarControl: ChatBarAction( - label: 'Sidebar action', - onPressed: () => sidebar++, - materialIcon: Icons.menu, - cupertinoIcon: CupertinoIcons.sidebar_left, - ), - paneControls: [ - ChatBarAction( - label: 'Pane action', - onPressed: () => pane++, - materialIcon: Icons.add_box, - cupertinoIcon: CupertinoIcons.plus_square, - ), - ], - ), - cupertino: cupertino, + for (final width in [320.0, 390.0, 1280.0]) { + testWidgets('grouped actions at $width and text scale 2', (tester) async { + _useNarrowText(tester); + tester.view.physicalSize = Size(width, 800); + final gateway = FakeChatGateway(); + addTearDown(gateway.close); + gateway.history = (_) async => chatPage(const []); + gateway.subscribe = () async => const {}; + var sidebar = 0; + var pane = 0; + var next = 0; + await tester.pumpWidget( + _host( + ChatThreadView( + gateway: gateway, + sessionId: 's', + title: _title, + session: { + ..._session, + 'mode': 'safe', + 'mode_name': 'Ask before making changes', + }, + onBack: () {}, + onNextChat: () => next++, + sidebarControl: ChatBarAction( + label: 'Sidebar action', + onPressed: () => sidebar++, + materialIcon: Icons.menu, + cupertinoIcon: CupertinoIcons.sidebar_left, ), - ); - await tester.pumpAndSettle(); - final selectors = find.byKey( - const Key('chat-model-permission-island'), - ); - final actions = find.byKey(const Key('chat-actions-island')); - expect(selectors, findsOneWidget); - expect(actions, findsOneWidget); - expect( - (tester.getCenter(selectors).dy - tester.getCenter(actions).dy) - .abs(), - lessThan(16), - ); - expect(find.byKey(const Key('chat-next')), findsNothing); - expect(find.text('Next chat'), findsNothing); - expect(find.byKey(const Key('chat-model')), findsOneWidget); - expect(find.byKey(const Key('chat-mode')), findsOneWidget); - if (width < 600) { - expect(find.text('model-a'), findsNothing); - expect(find.text('Ask before making changes'), findsNothing); - expect(find.byIcon(Icons.memory_outlined), findsOneWidget); - expect( - find.byIcon( - cupertino - ? CupertinoIcons.shield_lefthalf_fill - : Icons.shield_outlined, + paneControls: [ + ChatBarAction( + label: 'Pane action', + onPressed: () => pane++, + materialIcon: Icons.add_box, + cupertinoIcon: CupertinoIcons.plus_square, ), - findsOneWidget, - ); - if (!cupertino) { - expect( - tester.getSemantics(find.byKey(const Key('chat-model'))).label, - contains('Change model, currently'), - ); - expect( - tester.getSemantics(find.byKey(const Key('chat-mode'))).label, - contains('Change mode, currently'), - ); - } - expect( - (tester.getCenter(selectors).dy - tester.getCenter(actions).dy) - .abs(), - lessThan(16), - ); - } - for (final key in ['chat-model', 'chat-mode']) { - expect( - tester.getSize(find.byKey(Key(key))).width, - greaterThanOrEqualTo(cupertino ? 44 : 48), - ); - } - expect(find.text('Sidebar action'), findsNothing); - expect(find.text('Pane action'), findsNothing); - expect(tester.takeException(), isNull); - // Both More entries retain their original callbacks in native menus. - await tester.tap(find.byKey(segmentedMoreKey).hitTestable()); - await tester.pumpAndSettle(); - await tester.tap(find.text('Sidebar action')); - await tester.pumpAndSettle(); - expect(sidebar, 1); - await tester.tap(find.byKey(segmentedMoreKey).hitTestable()); - await tester.pumpAndSettle(); - await tester.tap(find.text('Pane action')); - await tester.pumpAndSettle(); - expect(pane, 1); - expect(next, 0); - expect(tester.takeException(), isNull); - }, + ], + ), + ), ); - } + await tester.pumpAndSettle(); + final selectors = find.byKey(const Key('chat-model-permission-island')); + final actions = find.byKey(const Key('chat-actions-island')); + expect(selectors, findsOneWidget); + expect(actions, findsOneWidget); + expect( + (tester.getCenter(selectors).dy - tester.getCenter(actions).dy).abs(), + lessThan(16), + ); + expect(find.byKey(const Key('chat-next')), findsNothing); + expect(find.text('Next chat'), findsNothing); + expect(find.byKey(const Key('chat-model')), findsOneWidget); + expect(find.byKey(const Key('chat-mode')), findsOneWidget); + if (width < 600) { + expect(find.text('model-a'), findsNothing); + expect(find.text('Ask before making changes'), findsNothing); + expect(find.byIcon(Icons.memory_outlined), findsOneWidget); + expect(find.byIcon(Icons.shield_outlined), findsOneWidget); + expect( + tester.getSemantics(find.byKey(const Key('chat-model'))).label, + contains('Change model, currently'), + ); + expect( + tester.getSemantics(find.byKey(const Key('chat-mode'))).label, + contains('Change mode, currently'), + ); + expect( + (tester.getCenter(selectors).dy - tester.getCenter(actions).dy).abs(), + lessThan(16), + ); + } + for (final key in ['chat-model', 'chat-mode']) { + expect( + tester.getSize(find.byKey(Key(key))).width, + greaterThanOrEqualTo(48), + ); + } + expect(find.text('Sidebar action'), findsNothing); + expect(find.text('Pane action'), findsNothing); + expect(tester.takeException(), isNull); + // Both More entries retain their original callbacks in native menus. + await tester.tap(find.byKey(segmentedMoreKey).hitTestable()); + await tester.pumpAndSettle(); + await tester.tap(find.text('Sidebar action')); + await tester.pumpAndSettle(); + expect(sidebar, 1); + await tester.tap(find.byKey(segmentedMoreKey).hitTestable()); + await tester.pumpAndSettle(); + await tester.tap(find.text('Pane action')); + await tester.pumpAndSettle(); + expect(pane, 1); + expect(next, 0); + expect(tester.takeException(), isNull); + }); } - for (final cupertino in [false, true]) { - testWidgets( - 'sidebar layout submenu retains callback on ${cupertino ? 'Cupertino' : 'Material'}', - (tester) async { - ChatSidebarMode? picked; - await tester.pumpWidget( - _host( - ChatThreadHeader( - title: 'Chat', - folder: 'demo', - onInfo: () {}, - actions: const [Icon(Icons.folder_outlined)], - moreActions: [ - ChatSidebarButton( - mode: ChatSidebarMode.expanded, - onChanged: (value) => picked = value, - ), - ], + testWidgets('sidebar layout submenu retains callback on Material', ( + tester, + ) async { + ChatSidebarMode? picked; + await tester.pumpWidget( + _host( + ChatThreadHeader( + title: 'Chat', + folder: 'demo', + onInfo: () {}, + actions: const [Icon(Icons.folder_outlined)], + moreActions: [ + ChatSidebarButton( + mode: ChatSidebarMode.expanded, + onChanged: (value) => picked = value, ), - cupertino: cupertino, - ), - ); - await tester.pumpAndSettle(); - expect(find.byType(ChatSidebarButton), findsNothing); - await tester.tap(find.byKey(segmentedMoreKey).hitTestable()); - await tester.pumpAndSettle(); - await tester.tap(find.text('Chat list layout')); - await tester.pumpAndSettle(); - await tester.tap(find.text('Hide chat list')); - await tester.pumpAndSettle(); - expect(picked, ChatSidebarMode.hidden); - expect(tester.takeException(), isNull); - }, + ], + ), + ), ); - } + await tester.pumpAndSettle(); + expect(find.byType(ChatSidebarButton), findsNothing); + await tester.tap(find.byKey(segmentedMoreKey).hitTestable()); + await tester.pumpAndSettle(); + await tester.tap(find.text('Chat list layout')); + await tester.pumpAndSettle(); + await tester.tap(find.text('Hide chat list')); + await tester.pumpAndSettle(); + expect(picked, ChatSidebarMode.hidden); + expect(tester.takeException(), isNull); + }); testWidgets('a conversation without a model keeps the same compact row', ( tester, @@ -364,7 +325,6 @@ void main() { session: {..._session, 'backend': 'other'}, onBack: () {}, ), - cupertino: false, ), ); await tester.pumpAndSettle();