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:
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -100,22 +99,12 @@ class ChatShownFileCard extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
);
|
||||
final cupertino = chatShownCupertino(context);
|
||||
return ChatShownSurface(
|
||||
label: image ? 'Shown image $title' : 'Shown file $title',
|
||||
child: Semantics(
|
||||
button: true,
|
||||
onTap: open,
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: open,
|
||||
child: DefaultTextStyle.merge(
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
child: body,
|
||||
),
|
||||
)
|
||||
: InkWell(onTap: open, child: body),
|
||||
child: InkWell(onTap: open, child: body),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../core/api_gateway.dart';
|
||||
import '../../../../../ui/adaptive/host.dart';
|
||||
import '../../../../artifacts/ui/artifact_fullscreen.dart';
|
||||
import '../../../../artifacts/ui/artifact_html_view.dart';
|
||||
import '../../../../artifacts/ui/artifact_viewer_scaffold.dart';
|
||||
@@ -42,12 +40,13 @@ class ChatShownHtmlCard extends StatelessWidget {
|
||||
final expired = item['expired'] == true || html.isEmpty;
|
||||
final bytes = item['html_bytes'];
|
||||
final size = bytes is num ? fileSizeLabel(bytes.toInt()) : null;
|
||||
final cupertino = chatShownCupertino(context);
|
||||
final open = expired
|
||||
? null
|
||||
: () => 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(
|
||||
cupertino: usesCupertinoHost(context),
|
||||
cupertino: false,
|
||||
builder: (_) => ChatShownHtmlPage(
|
||||
title: title,
|
||||
html: html,
|
||||
@@ -57,13 +56,6 @@ class ChatShownHtmlCard extends StatelessWidget {
|
||||
);
|
||||
final action = open == null
|
||||
? null
|
||||
: cupertino
|
||||
? CupertinoButton(
|
||||
key: const Key('chat-shown-html-open'),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
onPressed: open,
|
||||
child: const Text('Open'),
|
||||
)
|
||||
: TextButton(
|
||||
key: const Key('chat-shown-html-open'),
|
||||
onPressed: open,
|
||||
@@ -76,10 +68,7 @@ class ChatShownHtmlCard extends StatelessWidget {
|
||||
subtitle: expired
|
||||
? 'This view is no longer retained'
|
||||
: ['View', ?size].join(' · '),
|
||||
leading: Icon(
|
||||
cupertino ? CupertinoIcons.chart_bar_square : Icons.web_asset,
|
||||
color: chatShownSecondary(context),
|
||||
),
|
||||
leading: Icon(Icons.web_asset, color: chatShownSecondary(context)),
|
||||
trailing: action,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../core/api_gateway.dart';
|
||||
@@ -84,16 +83,7 @@ class ChatShownLinkImage extends StatelessWidget {
|
||||
button: true,
|
||||
link: true,
|
||||
onTap: open,
|
||||
child: chatShownCupertino(context)
|
||||
? CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: open,
|
||||
child: DefaultTextStyle.merge(
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
child: body,
|
||||
),
|
||||
)
|
||||
: InkWell(onTap: open, child: body),
|
||||
child: InkWell(onTap: open, child: body),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../core/api_gateway.dart';
|
||||
@@ -24,24 +23,15 @@ class ChatShownNotifyRow extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = chatShownCupertino(context);
|
||||
final delivered = item['delivered'] == true;
|
||||
final secondary = chatShownSecondary(context);
|
||||
final color = delivered
|
||||
? secondary
|
||||
: (cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error);
|
||||
final base = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodySmall;
|
||||
final color = delivered ? secondary : Theme.of(context).colorScheme.error;
|
||||
final base = Theme.of(context).textTheme.bodySmall;
|
||||
final text = chatShownNotifyText(item);
|
||||
final message = '${item['message'] ?? ''}'.trim();
|
||||
final icon = delivered
|
||||
? (cupertino ? CupertinoIcons.bell : Icons.notifications_outlined)
|
||||
: (cupertino
|
||||
? CupertinoIcons.bell_slash
|
||||
: Icons.notifications_off_outlined);
|
||||
? Icons.notifications_outlined
|
||||
: Icons.notifications_off_outlined;
|
||||
return Semantics(
|
||||
container: true,
|
||||
label: text,
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../core/api_gateway.dart';
|
||||
import '../../sessions/chat_adaptive.dart';
|
||||
|
||||
/// Whether the transcript draws Cupertino controls.
|
||||
bool chatShownCupertino(BuildContext context) =>
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
|
||||
/// The secondary text colour of either host.
|
||||
Color chatShownSecondary(BuildContext context) => chatShownCupertino(context)
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
/// The secondary text colour of a shown entry.
|
||||
Color chatShownSecondary(BuildContext context) =>
|
||||
Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
|
||||
/// The item's title, else [fallback].
|
||||
String chatShownTitle(JsonMap item, String fallback) {
|
||||
@@ -36,25 +29,11 @@ class ChatShownSurface extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = chatShownCupertino(context);
|
||||
const radius = BorderRadius.all(Radius.circular(12));
|
||||
final card = cupertino
|
||||
? DecoratedBox(
|
||||
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,
|
||||
);
|
||||
final card = Card.outlined(
|
||||
margin: EdgeInsets.zero,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: child,
|
||||
);
|
||||
return Semantics(
|
||||
container: true,
|
||||
explicitChildNodes: true,
|
||||
@@ -90,22 +69,10 @@ class ChatShownHeading extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = chatShownCupertino(context);
|
||||
final titleStyle = cupertino
|
||||
? CupertinoTheme.of(
|
||||
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 titleStyle = Theme.of(context).textTheme.titleSmall;
|
||||
final subtitleStyle = Theme.of(
|
||||
context,
|
||||
).textTheme.bodySmall?.copyWith(color: chatShownSecondary(context));
|
||||
final sub = subtitle;
|
||||
return Row(
|
||||
children: [
|
||||
|
||||
@@ -212,4 +212,20 @@ void main() {
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user