Terminal theme: pure black, square, monospace, IRC-style chat lines
build / build (push) Successful in 16m14s
build / build (push) Successful in 16m14s
A fourth theme choice "Term" next to System/Light/Dark: - black surfaces, green accent, JetBrains Mono, no rounded corners, compact density and paddings, no ink splash (lib/theme/terminal_theme.dart, built on MeshTheme's dark theme with the shapes overridden); - channel and direct chats render each message as one IRC line across the whole width: "14:02 <nick> text [2 hops] ✓", no avatar, no bubble, own messages on the left too. Route, region, repeat and delivery status follow the text inline; the tracing path stays on its own line. The upstream bubble code is untouched: both chat screens branch to a separate builder when MeshStyle.of(context).terminal, so the nightly upstream merge does not collide with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b519922d51
commit
55386df69f
9 files changed
+762
-6
No files matched your search
@@ -0,0 +1,152 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_linkify/flutter_linkify.dart';
|
||||
|
||||
import '../helpers/link_handler.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../utils/platform_info.dart';
|
||||
|
||||
/// One chat message as an IRC line for the terminal theme:
|
||||
///
|
||||
/// 14:02 <tth-x1> text that wraps under the whole width [2 hops] ✓
|
||||
///
|
||||
/// [trailing] widgets (route, delivery status) follow the text inline, so a
|
||||
/// plain message stays a single line. [text] may be null for messages whose
|
||||
/// body is not text (GIF, POI) — the line is then just the time and the nick.
|
||||
class TerminalMessageLine extends StatelessWidget {
|
||||
final String time;
|
||||
final String nick;
|
||||
final Color nickColor;
|
||||
final String? text;
|
||||
|
||||
/// Text before translation, shown dimmed on its own line.
|
||||
final String? originalText;
|
||||
final Color textColor;
|
||||
final Color metaColor;
|
||||
final double textScale;
|
||||
final List<Widget> trailing;
|
||||
final VoidCallback? onSecondaryTap;
|
||||
|
||||
const TerminalMessageLine({
|
||||
super.key,
|
||||
required this.time,
|
||||
required this.nick,
|
||||
required this.nickColor,
|
||||
required this.textColor,
|
||||
required this.metaColor,
|
||||
required this.textScale,
|
||||
this.text,
|
||||
this.originalText,
|
||||
this.trailing = const [],
|
||||
this.onSecondaryTap,
|
||||
});
|
||||
|
||||
static const _linkifyOptions = LinkifyOptions(
|
||||
humanize: false,
|
||||
defaultToHttps: false,
|
||||
);
|
||||
static const _linkifiers = [UrlLinkifier(), EmailLinkifier()];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final style = MeshTheme.mono(
|
||||
fontSize: 14 * textScale,
|
||||
color: textColor,
|
||||
letterSpacing: 0,
|
||||
);
|
||||
final metaStyle = style.copyWith(color: metaColor);
|
||||
final body = text?.trim();
|
||||
final original = originalText?.trim();
|
||||
|
||||
TextSpan linkified(String value, TextStyle base) {
|
||||
// What linkify() from package:linkify does; flutter_linkify does not
|
||||
// re-export the function, only the linkifiers.
|
||||
var elements = <LinkifyElement>[TextElement(value)];
|
||||
for (final linkifier in _linkifiers) {
|
||||
elements = linkifier.parse(elements, _linkifyOptions);
|
||||
}
|
||||
return buildTextSpan(
|
||||
elements,
|
||||
style: base,
|
||||
linkStyle: LinkHandler.defaultLinkStyle(context, base),
|
||||
onOpen: (link) => LinkHandler.handleLinkTap(context, link.url),
|
||||
);
|
||||
}
|
||||
|
||||
final line = TextSpan(
|
||||
children: [
|
||||
TextSpan(text: '$time ', style: metaStyle),
|
||||
TextSpan(
|
||||
text: '<$nick>',
|
||||
style: style.copyWith(color: nickColor, fontWeight: FontWeight.w700),
|
||||
),
|
||||
if (body != null && body.isNotEmpty) ...[
|
||||
TextSpan(text: ' ', style: style),
|
||||
linkified(body, style),
|
||||
],
|
||||
for (final widget in trailing) ...[
|
||||
TextSpan(text: ' ', style: style),
|
||||
WidgetSpan(alignment: PlaceholderAlignment.middle, child: widget),
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
final showOriginal =
|
||||
original != null && original.isNotEmpty && original != body;
|
||||
final rich = TextSpan(
|
||||
children: [
|
||||
line,
|
||||
if (showOriginal) ...[
|
||||
TextSpan(text: '\n', style: style),
|
||||
linkified(original, metaStyle.copyWith(fontStyle: FontStyle.italic)),
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
if (!PlatformInfo.isDesktop) return Text.rich(rich);
|
||||
final selectable = SelectableText.rich(rich);
|
||||
if (onSecondaryTap == null) return selectable;
|
||||
return Listener(
|
||||
onPointerDown: (event) {
|
||||
if (event.buttons & kSecondaryMouseButton != 0) onSecondaryTap!();
|
||||
},
|
||||
behavior: HitTestBehavior.translucent,
|
||||
child: selectable,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// [RouteChip] as plain text for a terminal line, e.g. `[2 hops]`, `[flood]`.
|
||||
class TerminalRouteTag extends StatelessWidget {
|
||||
final bool isDirect;
|
||||
final int? hops;
|
||||
final Color color;
|
||||
final double textScale;
|
||||
|
||||
const TerminalRouteTag({
|
||||
super.key,
|
||||
required this.isDirect,
|
||||
required this.hops,
|
||||
required this.color,
|
||||
required this.textScale,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final label = isDirect
|
||||
? (hops == null || hops == 0
|
||||
? l10n.chat_direct
|
||||
: l10n.chat_hopsCount(hops!))
|
||||
: l10n.routing_modeFlood;
|
||||
return Text(
|
||||
'[${label.toLowerCase()}]',
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 12 * textScale,
|
||||
color: color,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user