Fix repeater settings grey box, nameless discovered nodes and chip contrast

Repeater settings:
- The Advanced and Identity Keys cards store their expanded flag in
  PageStorage. Their TextFields' inner Scrollables shared that identifier,
  read the bool as a scroll offset and failed to build, which showed as a
  large grey box in release builds. Give each card's body its own storage
  scope. Regression test added.

Discovered contacts:
- Adverts parse the two optional 16-bit feature fields before the name,
  as MeshCore's AdvertDataParser does, so their bytes are no longer read
  as the name (a zero byte gave an empty name).
- A nameless advert or removal no longer wipes a known name.
- The discovery tile gives the name the full width (the type chip beside
  it squeezed it to nothing at large text sizes); the type moves to the
  key line as plain text, and an unnamed node shows its key prefix.
- The node scan sheet's type chip can shrink instead of the name.

Contrast:
- StatusChip draws its label in the normal text color; the icon or dot
  keeps the accent, adjusted to 3:1 against its tint. Avatar icons and
  initials get the same adjustment. Amber on its tint in the light theme
  was about 2:1.

Channel chat:
- Hashtag channels drop the redundant "Hashtag" subtitle label, and the
  region action moves into the overflow menu (tapping the title still
  opens it) so the channel name keeps its room.
This commit is contained in:
zjs81 committed 2026-10-31 12:09:42 -07:00
1 parent ac28dac575
commit 821479742d
8 files changed
+265 -68

No files matched your search

+26 -13
View File
@@ -357,17 +357,19 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
),
Consumer<MeshCoreConnector>(
builder: (context, connector, _) {
// Hashtag channels get no type label: the # icon
// and name already say it, and the title needs the
// room.
final privacy = switch (Channel.getChannelType(
widget.channel,
_communityIndex,
)) {
ChannelType.public => context.l10n.channels_public,
ChannelType.hashtag => context.l10n.channels_hashtag,
ChannelType.hashtag => null,
ChannelType.private => context.l10n.channels_private,
ChannelType.communityPublic =>
context.l10n.community_publicChannel,
ChannelType.communityHashtag =>
context.l10n.community_hashtagChannel,
ChannelType.communityHashtag => null,
};
final ownRegion = connector.getChannelRegion(
widget.channel.index,
@@ -380,15 +382,17 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
: '';
final radioDefault = connector.defaultFloodScopeName;
final regionText = region.isNotEmpty
? ' • ${context.l10n.channels_regionSetTo(region)}$defaultSuffix'
? '${context.l10n.channels_regionSetTo(region)}$defaultSuffix'
: radioDefault != null &&
connector.channelUsesRadioDefaultScope(
widget.channel.index,
)
? ' • ${context.l10n.channels_regionSetTo(radioDefault)} ${context.l10n.channels_regionRadioDefaultSuffix}'
: '';
? '${context.l10n.channels_regionSetTo(radioDefault)} ${context.l10n.channels_regionRadioDefaultSuffix}'
: null;
final subtitle = [?privacy, ?regionText].join(' • ');
if (subtitle.isEmpty) return const SizedBox.shrink();
return Text(
'$privacy$regionText',
subtitle,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 12),
);
@@ -425,20 +429,29 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
);
},
),
IconButton(
tooltip: context.l10n.channels_regionSelect_Title,
icon: const Icon(Icons.landscape),
onPressed: () => openRegionSelectDialog(widget.channel),
),
const RadioStatsIconButton(),
PopupMenuButton<String>(
icon: const Icon(Icons.more_vert),
onSelected: (value) {
if (value == 'clearChat') {
if (value == 'region') {
openRegionSelectDialog(widget.channel);
} else if (value == 'clearChat') {
_confirmClearChat();
}
},
// Region lives here (and on a tap of the title) so the channel
// name keeps its room in the app bar.
itemBuilder: (context) => [
PopupMenuItem(
value: 'region',
child: Row(
children: [
const Icon(Icons.landscape, size: 20),
const SizedBox(width: 12),
Text(context.l10n.channels_regionSelect_Title),
],
),
),
PopupMenuItem(
value: 'clearChat',
child: Row(
+18 -23
View File
@@ -203,35 +203,30 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
// Name + type chip
Row(
children: [
Expanded(
child: Text(
contact.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontWeight: FontWeight.w500,
fontSize: 15,
),
),
),
const SizedBox(width: 6),
StatusChip(
label: contact.typeLabel(context.l10n).toUpperCase(),
color: contactTypeColor(contact.type),
icon: contactTypeIcon(contact.type),
),
],
// The name gets the full width; a type chip beside it
// squeezed it to nothing on narrow screens or large text.
// The avatar icon already shows the type.
Text(
// Nodes can advertise without a name; show the key
// prefix rather than a blank title.
contact.name.isNotEmpty
? contact.name
: contact.publicKeyHex.substring(0, 8),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontWeight: FontWeight.w500,
fontSize: 15,
),
),
const SizedBox(height: 3),
// Short pub key
// Type and short pub key
Row(
children: [
Expanded(
child: Text(
contact.shortPubKeyHex,
'${contact.typeLabel(context.l10n)} · '
'${contact.shortPubKeyHex}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: MeshTheme.mono(
+22 -3
View File
@@ -1464,6 +1464,22 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
);
}
/// Wraps an [ExpansionTile]'s children in their own [PageStorage] scope.
///
/// The tile saves its expanded flag (a bool) under its [PageStorageKey].
/// A TextField's inner Scrollable has no key, so without this it shares
/// that identifier, reads the bool back as its scroll offset and throws
/// while building (a grey box in release builds).
List<Widget> _ownPageStorage(String id, List<Widget> children) => [
KeyedSubtree(
key: PageStorageKey(id),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: children,
),
),
];
Widget _buildAdvancedCard() {
final l10n = context.l10n;
return MeshCard(
@@ -1476,7 +1492,10 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
),
subtitle: Text(l10n.repeater_advancedSettingsSubtitle),
childrenPadding: const EdgeInsets.fromLTRB(0, 8, 0, 4),
children: _buildSpecControls(RepeaterSettingSection.advanced),
children: _ownPageStorage(
'repeater_settings_advanced_body',
_buildSpecControls(RepeaterSettingSection.advanced),
),
),
);
}
@@ -1545,7 +1564,7 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
),
subtitle: Text(l10n.repeater_keySettingsSubtitle),
childrenPadding: const EdgeInsets.fromLTRB(0, 8, 0, 4),
children: [
children: _ownPageStorage('repeater_settings_keys_body', [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -1659,7 +1678,7 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
const SizedBox(width: 48),
],
),
],
]),
),
);
}