Files
meshcore-open/lib/widgets/mesh_nav_tile.dart
T
tthandClaude Opus 5.5 e939932cef
build / build (push) Successful in 17m24s
Terminal theme: flat lists, compact settings, one-line reply quote
In the terminal theme only:
- MeshCard becomes a flat row with a rule underneath: no margin, no
  corners, 8/4 padding. Channel and contact lists, settings groups and
  every other card shrink to about half their height.
- AvatarCircle is just the glyph (icon or initials, at most 20 px), the
  contact emoji avatar likewise.
- MeshNavTile and SectionHeader: smaller icons, padding and type.
- Text line height 1.2 instead of Material's 1.4-1.5.
- A reply in a channel is one dim line above the message,
  "↳ <nick> quoted text…", instead of the boxed preview; the
  "replying to" banner above the composer loses its padding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 12:28:24 +02:00

137 lines
4.0 KiB
Dart

import 'package:flutter/material.dart';
import '../theme/terminal_theme.dart';
/// Settings-style navigation row: leading icon, bold title, secondary
/// subtitle and an optional trailing chevron.
///
/// Sized for readability (24px icons, `bodyLarge` titles, `bodyMedium`
/// subtitles). When [onTap] is null the row is rendered dimmed and reported
/// as disabled to accessibility services, so a tile that cannot be used never
/// looks identical to one that can.
class MeshNavTile extends StatelessWidget {
final IconData icon;
final String title;
final String? subtitle;
final VoidCallback? onTap;
final Color? titleColor;
final Color? iconColor;
final bool showChevron;
final Widget? trailing;
final int? subtitleMaxLines;
final EdgeInsetsGeometry padding;
const MeshNavTile({
super.key,
required this.icon,
required this.title,
this.subtitle,
this.onTap,
this.titleColor,
this.iconColor,
this.showChevron = true,
this.trailing,
this.subtitleMaxLines,
this.padding = const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final textTheme = theme.textTheme;
final enabled = onTap != null;
final effectiveIconColor = iconColor ?? scheme.onSurfaceVariant;
final terminal = MeshStyle.of(context).terminal;
final iconSize = terminal ? 18.0 : 24.0;
final row = Row(
children: [
Icon(icon, size: iconSize, color: effectiveIconColor),
SizedBox(width: terminal ? 10 : 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: (terminal ? textTheme.bodyMedium : textTheme.bodyLarge)
?.copyWith(fontWeight: FontWeight.w600, color: titleColor),
),
if (subtitle != null) ...[
const SizedBox(height: 2),
Text(
subtitle!,
maxLines: subtitleMaxLines,
overflow: subtitleMaxLines == null
? null
: TextOverflow.ellipsis,
style: (terminal ? textTheme.bodySmall : textTheme.bodyMedium)
?.copyWith(
color: titleColor != null
? titleColor!.withValues(alpha: 0.8)
: scheme.onSurfaceVariant,
),
),
],
],
),
),
?trailing,
if (showChevron && trailing == null)
Icon(
Icons.chevron_right,
color: scheme.onSurfaceVariant,
size: iconSize,
),
],
);
return MergeSemantics(
child: Semantics(
button: true,
enabled: enabled,
child: InkWell(
onTap: onTap,
child: Padding(
padding: terminal
? const EdgeInsets.symmetric(horizontal: 8, vertical: 5)
: padding,
// Dimmed rather than recoloured so warn/alert tints still read as
// such while clearly unavailable.
child: Opacity(opacity: enabled ? 1 : 0.5, child: row),
),
),
),
);
}
}
/// One radio-style option row inside a bottom sheet picker.
class MeshSheetOption extends StatelessWidget {
final String label;
final bool selected;
final VoidCallback onTap;
const MeshSheetOption({
super.key,
required this.label,
required this.selected,
required this.onTap,
});
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
return ListTile(
leading: Icon(
selected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
size: 24,
color: selected ? scheme.primary : scheme.onSurfaceVariant,
),
title: Text(label),
onTap: onTap,
);
}
}