Chat: code blocks and inline code use the monospace font
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/semantics.dart';
|
||||
|
||||
import '../../../../ui/layout/wheel_scroll_forwarding.dart';
|
||||
import '../../../../ui/text/monospace.dart';
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
import 'chat_link_launcher.dart';
|
||||
import 'chat_link_spans.dart';
|
||||
@@ -209,7 +210,12 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
decoration: BoxDecoration(color: _codeFill(context, cupertino)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: HorizontalScrollView(child: Text(code)),
|
||||
child: HorizontalScrollView(
|
||||
child: Text(
|
||||
code,
|
||||
style: const TextStyle(fontFamily: appMonospaceFamily),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -262,9 +268,12 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
MarkdownPlain(text: final text) => TextSpan(text: text),
|
||||
MarkdownInlineCode(text: final text) => TextSpan(
|
||||
text: text,
|
||||
// The same host-theme surface as a fenced block marks the run as
|
||||
// code without a font, size or literal colour override.
|
||||
style: TextStyle(backgroundColor: _codeFill(context, cupertino)),
|
||||
// The same host-theme surface and monospace family as a fenced
|
||||
// block mark the run as code; the size stays the surrounding text's.
|
||||
style: TextStyle(
|
||||
fontFamily: appMonospaceFamily,
|
||||
backgroundColor: _codeFill(context, cupertino),
|
||||
),
|
||||
),
|
||||
MarkdownStrong(spans: final inner) => TextSpan(
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/semantics.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/transcript/chat_markdown_view.dart';
|
||||
import 'package:pipelines_app/ui/text/monospace.dart';
|
||||
|
||||
import 'chat_markdown_test_support.dart';
|
||||
|
||||
@@ -126,7 +127,7 @@ void main() {
|
||||
expect(code.style?.backgroundColor, fill, reason: '$cupertino');
|
||||
expect(plain.style?.backgroundColor, isNull, reason: '$cupertino');
|
||||
expect(code.style?.fontSize, isNull, reason: '$cupertino');
|
||||
expect(code.style?.fontFamily, isNull, reason: '$cupertino');
|
||||
expect(code.style?.fontFamily, appMonospaceFamily, reason: '$cupertino');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user