Remove Cupertino branches from shown transcript

Keep the Material transcript path while preserving public Cupertino parameters for callers that will be removed in a later change.
This commit is contained in:
2026-11-11 11:13:58 +00:00
parent 1c2bb8733a
commit 3ba124f250
6 changed files with 38 additions and 97 deletions
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -100,22 +99,12 @@ class ChatShownFileCard extends StatelessWidget {
), ),
], ],
); );
final cupertino = chatShownCupertino(context);
return ChatShownSurface( return ChatShownSurface(
label: image ? 'Shown image $title' : 'Shown file $title', label: image ? 'Shown image $title' : 'Shown file $title',
child: Semantics( child: Semantics(
button: true, button: true,
onTap: open, onTap: open,
child: cupertino child: InkWell(onTap: open, child: body),
? CupertinoButton(
padding: EdgeInsets.zero,
onPressed: open,
child: DefaultTextStyle.merge(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: body,
),
)
: InkWell(onTap: open, child: body),
), ),
); );
} }
@@ -1,8 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../../../core/api_gateway.dart'; import '../../../../../core/api_gateway.dart';
import '../../../../../ui/adaptive/host.dart';
import '../../../../artifacts/ui/artifact_fullscreen.dart'; import '../../../../artifacts/ui/artifact_fullscreen.dart';
import '../../../../artifacts/ui/artifact_html_view.dart'; import '../../../../artifacts/ui/artifact_html_view.dart';
import '../../../../artifacts/ui/artifact_viewer_scaffold.dart'; import '../../../../artifacts/ui/artifact_viewer_scaffold.dart';
@@ -42,12 +40,13 @@ class ChatShownHtmlCard extends StatelessWidget {
final expired = item['expired'] == true || html.isEmpty; final expired = item['expired'] == true || html.isEmpty;
final bytes = item['html_bytes']; final bytes = item['html_bytes'];
final size = bytes is num ? fileSizeLabel(bytes.toInt()) : null; final size = bytes is num ? fileSizeLabel(bytes.toInt()) : null;
final cupertino = chatShownCupertino(context);
final open = expired final open = expired
? null ? null
: () => Navigator.of(context, rootNavigator: true).push( : () => Navigator.of(context, rootNavigator: true).push(
// The Material host: the route is a MaterialPageRoute whatever
// this flag says, so the flag is always false here.
artifactFullscreenRoute( artifactFullscreenRoute(
cupertino: usesCupertinoHost(context), cupertino: false,
builder: (_) => ChatShownHtmlPage( builder: (_) => ChatShownHtmlPage(
title: title, title: title,
html: html, html: html,
@@ -57,13 +56,6 @@ class ChatShownHtmlCard extends StatelessWidget {
); );
final action = open == null final action = open == null
? null ? null
: cupertino
? CupertinoButton(
key: const Key('chat-shown-html-open'),
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: open,
child: const Text('Open'),
)
: TextButton( : TextButton(
key: const Key('chat-shown-html-open'), key: const Key('chat-shown-html-open'),
onPressed: open, onPressed: open,
@@ -76,10 +68,7 @@ class ChatShownHtmlCard extends StatelessWidget {
subtitle: expired subtitle: expired
? 'This view is no longer retained' ? 'This view is no longer retained'
: ['View', ?size].join(' · '), : ['View', ?size].join(' · '),
leading: Icon( leading: Icon(Icons.web_asset, color: chatShownSecondary(context)),
cupertino ? CupertinoIcons.chart_bar_square : Icons.web_asset,
color: chatShownSecondary(context),
),
trailing: action, trailing: action,
), ),
); );
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../../../core/api_gateway.dart'; import '../../../../../core/api_gateway.dart';
@@ -84,16 +83,7 @@ class ChatShownLinkImage extends StatelessWidget {
button: true, button: true,
link: true, link: true,
onTap: open, onTap: open,
child: chatShownCupertino(context) child: InkWell(onTap: open, child: body),
? CupertinoButton(
padding: EdgeInsets.zero,
onPressed: open,
child: DefaultTextStyle.merge(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: body,
),
)
: InkWell(onTap: open, child: body),
), ),
); );
} }
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../../../core/api_gateway.dart'; import '../../../../../core/api_gateway.dart';
@@ -24,24 +23,15 @@ class ChatShownNotifyRow extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final cupertino = chatShownCupertino(context);
final delivered = item['delivered'] == true; final delivered = item['delivered'] == true;
final secondary = chatShownSecondary(context); final secondary = chatShownSecondary(context);
final color = delivered final color = delivered ? secondary : Theme.of(context).colorScheme.error;
? secondary final base = Theme.of(context).textTheme.bodySmall;
: (cupertino
? CupertinoColors.systemRed.resolveFrom(context)
: Theme.of(context).colorScheme.error);
final base = cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.bodySmall;
final text = chatShownNotifyText(item); final text = chatShownNotifyText(item);
final message = '${item['message'] ?? ''}'.trim(); final message = '${item['message'] ?? ''}'.trim();
final icon = delivered final icon = delivered
? (cupertino ? CupertinoIcons.bell : Icons.notifications_outlined) ? Icons.notifications_outlined
: (cupertino : Icons.notifications_off_outlined;
? CupertinoIcons.bell_slash
: Icons.notifications_off_outlined);
return Semantics( return Semantics(
container: true, container: true,
label: text, label: text,
@@ -1,17 +1,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../../../core/api_gateway.dart'; import '../../../../../core/api_gateway.dart';
import '../../sessions/chat_adaptive.dart';
/// Whether the transcript draws Cupertino controls. /// The secondary text colour of a shown entry.
bool chatShownCupertino(BuildContext context) => Color chatShownSecondary(BuildContext context) =>
chatControlsStyleOf(context) == ChatControlsStyle.cupertino; Theme.of(context).colorScheme.onSurfaceVariant;
/// The secondary text colour of either host.
Color chatShownSecondary(BuildContext context) => chatShownCupertino(context)
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
/// The item's title, else [fallback]. /// The item's title, else [fallback].
String chatShownTitle(JsonMap item, String fallback) { String chatShownTitle(JsonMap item, String fallback) {
@@ -36,25 +29,11 @@ class ChatShownSurface extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final cupertino = chatShownCupertino(context); final card = Card.outlined(
const radius = BorderRadius.all(Radius.circular(12)); margin: EdgeInsets.zero,
final card = cupertino clipBehavior: Clip.antiAlias,
? DecoratedBox( child: child,
decoration: BoxDecoration( );
color: CupertinoColors.secondarySystemGroupedBackground
.resolveFrom(context),
border: Border.all(
color: CupertinoColors.separator.resolveFrom(context),
),
borderRadius: radius,
),
child: ClipRRect(borderRadius: radius, child: child),
)
: Card.outlined(
margin: EdgeInsets.zero,
clipBehavior: Clip.antiAlias,
child: child,
);
return Semantics( return Semantics(
container: true, container: true,
explicitChildNodes: true, explicitChildNodes: true,
@@ -90,22 +69,10 @@ class ChatShownHeading extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final cupertino = chatShownCupertino(context); final titleStyle = Theme.of(context).textTheme.titleSmall;
final titleStyle = cupertino final subtitleStyle = Theme.of(
? CupertinoTheme.of( context,
context, ).textTheme.bodySmall?.copyWith(color: chatShownSecondary(context));
).textTheme.textStyle.copyWith(fontWeight: FontWeight.w600)
: Theme.of(context).textTheme.titleSmall;
// Cupertino has no caption role; the body style at a smaller size keeps
// the line secondary while still following text scaling.
final cupertinoBody = CupertinoTheme.of(context).textTheme.textStyle;
final subtitleStyle =
(cupertino
? cupertinoBody.copyWith(
fontSize: (cupertinoBody.fontSize ?? 17) * 0.8,
)
: Theme.of(context).textTheme.bodySmall)
?.copyWith(color: chatShownSecondary(context));
final sub = subtitle; final sub = subtitle;
return Row( return Row(
children: [ children: [
@@ -212,4 +212,20 @@ void main() {
findsOneWidget, findsOneWidget,
); );
}); });
testWidgets('an undelivered notify row draws the error icon in the theme', (
tester,
) async {
await pump(tester, {
'id': 'n3',
'kind': 'notify',
'title': 'Build done',
'delivered': false,
});
final icon = find.byIcon(Icons.notifications_off_outlined);
expect(icon, findsOneWidget);
final theme = Theme.of(tester.element(icon));
expect(tester.widget<Icon>(icon).color, theme.colorScheme.error);
expect(find.byIcon(Icons.notifications_outlined), findsNothing);
});
} }