Fix layouts on small screens and large text, and test every screen

Contact rows give the name its own line (wrapping to two) with route and
last seen below, right-aligned on wide windows. Fixes overflows found by a
new widget test that renders every screen at 320x568 with text scales up to
2.0 and on a desktop window: region dropdown, contacts list, repeater CLI,
status grid and settings card, map cache buttons, and empty states.
Dropdowns truncate long labels, and option sheets and dialogs scroll.
This commit is contained in:
zjs81 committed 2026-10-25 11:10:27 -07:00
1 parent f0144ca959
commit 979e1a7d2a
21 files changed
+1512 -979

No files matched your search

+287 -261
View File
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -544,46 +545,48 @@ class _ContactsScreenState extends State<ContactsScreen>
showMeshSheet(
context,
builder: (sheetContext) => SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
BottomSheetHeader(title: context.l10n.contacts_title),
ListTile(
leading: const Icon(Icons.paste),
title: Text(context.l10n.contacts_addContactFromClipboard),
onTap: () {
Navigator.pop(sheetContext);
_contactImport();
},
),
ListTile(
leading: const Icon(Icons.qr_code_scanner),
title: Text(context.l10n.contacts_scanQrCode),
onTap: () {
Navigator.pop(sheetContext);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ContactQrScannerScreen(),
),
);
},
),
ListTile(
leading: const Icon(Icons.person_add_rounded),
title: Text(context.l10n.discoveredContacts_Title),
onTap: () {
Navigator.pop(sheetContext);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const DiscoveryScreen(),
),
);
},
),
const SizedBox(height: 8),
],
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
BottomSheetHeader(title: context.l10n.contacts_title),
ListTile(
leading: const Icon(Icons.paste),
title: Text(context.l10n.contacts_addContactFromClipboard),
onTap: () {
Navigator.pop(sheetContext);
_contactImport();
},
),
ListTile(
leading: const Icon(Icons.qr_code_scanner),
title: Text(context.l10n.contacts_scanQrCode),
onTap: () {
Navigator.pop(sheetContext);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ContactQrScannerScreen(),
),
);
},
),
ListTile(
leading: const Icon(Icons.person_add_rounded),
title: Text(context.l10n.discoveredContacts_Title),
onTap: () {
Navigator.pop(sheetContext);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const DiscoveryScreen(),
),
);
},
),
const SizedBox(height: 8),
],
),
),
),
);
@@ -915,6 +918,23 @@ class _ContactsScreenState extends State<ContactsScreen>
120.0,
); //two 48px icon buttons + 1px divider
// Scrolls with the list rather than staying pinned above it, so large
// text or an open keyboard on a short screen can't squeeze the list out.
final discoveredTile = ListTile(
dense: true,
leading: const Icon(Icons.person_add_rounded),
title: Text(
context.l10n.contacts_discoveredNearby(
connector.discoveredContacts.where((c) => !c.isActive).length,
),
),
trailing: const Icon(Icons.chevron_right),
onTap: () => Navigator.push(
context,
MaterialPageRoute(builder: (context) => const DiscoveryScreen()),
),
);
return Column(
children: [
Padding(
@@ -1038,20 +1058,6 @@ class _ContactsScreenState extends State<ContactsScreen>
],
),
),
ListTile(
dense: true,
leading: const Icon(Icons.person_add_rounded),
title: Text(
context.l10n.contacts_discoveredNearby(
connector.discoveredContacts.where((c) => !c.isActive).length,
),
),
trailing: const Icon(Icons.chevron_right),
onTap: () => Navigator.push(
context,
MaterialPageRoute(builder: (context) => const DiscoveryScreen()),
),
),
Expanded(
child: RefreshIndicator(
onRefresh: () => connector.getContacts(),
@@ -1060,9 +1066,13 @@ class _ContactsScreenState extends State<ContactsScreen>
builder: (context, constraints) => ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: [
discoveredTile,
ConstrainedBox(
constraints: BoxConstraints(
minHeight: constraints.maxHeight,
minHeight: math.max(
0,
constraints.maxHeight - kMinInteractiveDimension,
),
),
child: EmptyState(
icon: Icons.search_off,
@@ -1076,8 +1086,10 @@ class _ContactsScreenState extends State<ContactsScreen>
)
: ListView.builder(
padding: const EdgeInsets.only(bottom: 88),
itemCount: filteredAndSorted.length,
itemBuilder: (context, index) {
itemCount: filteredAndSorted.length + 1,
itemBuilder: (context, row) {
if (row == 0) return discoveredTile;
final index = row - 1;
final contact = filteredAndSorted[index];
final unreadCount = connector.getUnreadCountForContact(
contact,
@@ -1561,98 +1573,18 @@ class _ContactsScreenState extends State<ContactsScreen>
showMeshSheet(
context,
builder: (sheetContext) => SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
BottomSheetHeader(
title: contact.name,
subtitle: contact.typeLabel(context.l10n),
),
if (isRepeater) ...[
ListTile(
leading: Icon(Icons.radar, color: MeshPalette.signal),
title: Text(context.l10n.contacts_ping),
onTap: () {
Navigator.pop(sheetContext);
final hw = context
.read<MeshCoreConnector>()
.pathHashByteWidth;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PathTraceMapScreen(
title: context.l10n.contacts_repeaterPing,
path: contact.pathBytesForDisplay.isNotEmpty
? contact.pathBytesForDisplay
: _contactPathPrefix(contact, hw),
flipPathAround: true,
targetContact: contact,
pathHashByteWidth: hw,
),
),
);
},
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
BottomSheetHeader(
title: contact.name,
subtitle: contact.typeLabel(context.l10n),
),
ListTile(
leading: Icon(Icons.cell_tower, color: MeshPalette.warn),
title: Text(context.l10n.contacts_manageRepeater),
onTap: () {
Navigator.pop(sheetContext);
_showRepeaterLogin(context, contact);
},
),
] else if (isRoom) ...[
ListTile(
leading: Icon(Icons.radar, color: MeshPalette.signal),
title: Text(context.l10n.contacts_pathTrace),
onTap: () {
Navigator.pop(sheetContext);
final hw = context
.read<MeshCoreConnector>()
.pathHashByteWidth;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PathTraceMapScreen(
title: contact.pathBytesForDisplay.isNotEmpty
? context.l10n.contacts_roomPathTrace
: context.l10n.contacts_roomPing,
path: contact.pathBytesForDisplay.isNotEmpty
? contact.pathBytesForDisplay
: _contactPathPrefix(contact, hw),
flipPathAround: true,
targetContact: contact,
pathHashByteWidth: hw,
),
),
);
},
),
ListTile(
leading: Icon(Icons.meeting_room, color: MeshPalette.blue),
title: Text(context.l10n.contacts_roomLogin),
onTap: () {
Navigator.pop(sheetContext);
_showRoomLogin(context, contact, RoomLoginDestination.chat);
},
),
ListTile(
leading: Icon(Icons.room_preferences, color: MeshPalette.warn),
title: Text(context.l10n.room_management),
onTap: () {
Navigator.pop(sheetContext);
_showRoomLogin(
context,
contact,
RoomLoginDestination.management,
);
},
),
] else ...[
if (contact.pathLength > 0)
if (isRepeater) ...[
ListTile(
leading: Icon(Icons.radar, color: MeshPalette.signal),
title: Text(context.l10n.contacts_chatTraceRoute),
title: Text(context.l10n.contacts_ping),
onTap: () {
Navigator.pop(sheetContext);
final hw = context
@@ -1662,10 +1594,10 @@ class _ContactsScreenState extends State<ContactsScreen>
context,
MaterialPageRoute(
builder: (context) => PathTraceMapScreen(
title: context.l10n.contacts_pathTraceTo(
contact.name,
),
path: contact.pathBytesForDisplay,
title: context.l10n.contacts_repeaterPing,
path: contact.pathBytesForDisplay.isNotEmpty
? contact.pathBytesForDisplay
: _contactPathPrefix(contact, hw),
flipPathAround: true,
targetContact: contact,
pathHashByteWidth: hw,
@@ -1674,57 +1606,142 @@ class _ContactsScreenState extends State<ContactsScreen>
);
},
),
ListTile(
leading: Icon(Icons.cell_tower, color: MeshPalette.warn),
title: Text(context.l10n.contacts_manageRepeater),
onTap: () {
Navigator.pop(sheetContext);
_showRepeaterLogin(context, contact);
},
),
] else if (isRoom) ...[
ListTile(
leading: Icon(Icons.radar, color: MeshPalette.signal),
title: Text(context.l10n.contacts_pathTrace),
onTap: () {
Navigator.pop(sheetContext);
final hw = context
.read<MeshCoreConnector>()
.pathHashByteWidth;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PathTraceMapScreen(
title: contact.pathBytesForDisplay.isNotEmpty
? context.l10n.contacts_roomPathTrace
: context.l10n.contacts_roomPing,
path: contact.pathBytesForDisplay.isNotEmpty
? contact.pathBytesForDisplay
: _contactPathPrefix(contact, hw),
flipPathAround: true,
targetContact: contact,
pathHashByteWidth: hw,
),
),
);
},
),
ListTile(
leading: Icon(Icons.meeting_room, color: MeshPalette.blue),
title: Text(context.l10n.contacts_roomLogin),
onTap: () {
Navigator.pop(sheetContext);
_showRoomLogin(context, contact, RoomLoginDestination.chat);
},
),
ListTile(
leading: Icon(
Icons.room_preferences,
color: MeshPalette.warn,
),
title: Text(context.l10n.room_management),
onTap: () {
Navigator.pop(sheetContext);
_showRoomLogin(
context,
contact,
RoomLoginDestination.management,
);
},
),
] else ...[
if (contact.pathLength > 0)
ListTile(
leading: Icon(Icons.radar, color: MeshPalette.signal),
title: Text(context.l10n.contacts_chatTraceRoute),
onTap: () {
Navigator.pop(sheetContext);
final hw = context
.read<MeshCoreConnector>()
.pathHashByteWidth;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PathTraceMapScreen(
title: context.l10n.contacts_pathTraceTo(
contact.name,
),
path: contact.pathBytesForDisplay,
flipPathAround: true,
targetContact: contact,
pathHashByteWidth: hw,
),
),
);
},
),
],
ListTile(
leading: Icon(
isFavorite ? Icons.star : Icons.star_border,
color: MeshPalette.warn,
),
title: Text(
isFavorite
? context.l10n.listFilter_removeFromFavorites
: context.l10n.listFilter_addToFavorites,
),
onTap: () async {
Navigator.pop(sheetContext);
await connector.setContactFlags(
contact,
isFavorite: !isFavorite,
);
},
),
ListTile(
leading: const Icon(Icons.copy),
title: Text(context.l10n.contacts_ShareContact),
onTap: () {
Navigator.pop(sheetContext);
_contactExport(contact.publicKey);
},
),
ListTile(
leading: const Icon(Icons.connect_without_contact),
title: Text(context.l10n.contacts_ShareContactZeroHop),
onTap: () {
Navigator.pop(sheetContext);
_contactZeroHop(contact.publicKey);
},
),
ListTile(
leading: Icon(
Icons.delete,
color: Theme.of(context).colorScheme.error,
),
title: Text(
context.l10n.contacts_removeFromContacts,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
onTap: () {
Navigator.pop(sheetContext);
_confirmDelete(context, connector, contact);
},
),
const SizedBox(height: 8),
],
ListTile(
leading: Icon(
isFavorite ? Icons.star : Icons.star_border,
color: MeshPalette.warn,
),
title: Text(
isFavorite
? context.l10n.listFilter_removeFromFavorites
: context.l10n.listFilter_addToFavorites,
),
onTap: () async {
Navigator.pop(sheetContext);
await connector.setContactFlags(
contact,
isFavorite: !isFavorite,
);
},
),
ListTile(
leading: const Icon(Icons.copy),
title: Text(context.l10n.contacts_ShareContact),
onTap: () {
Navigator.pop(sheetContext);
_contactExport(contact.publicKey);
},
),
ListTile(
leading: const Icon(Icons.connect_without_contact),
title: Text(context.l10n.contacts_ShareContactZeroHop),
onTap: () {
Navigator.pop(sheetContext);
_contactZeroHop(contact.publicKey);
},
),
ListTile(
leading: Icon(
Icons.delete,
color: Theme.of(context).colorScheme.error,
),
title: Text(
context.l10n.contacts_removeFromContacts,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
onTap: () {
Navigator.pop(sheetContext);
_confirmDelete(context, connector, contact);
},
),
const SizedBox(height: 8),
],
),
),
),
);
@@ -1750,6 +1767,7 @@ class _ContactsScreenState extends State<ContactsScreen>
context: context,
builder: (dialogContext) => StatefulBuilder(
builder: (dialogContext, setDialogState) => AlertDialog(
scrollable: true,
title: Text(context.l10n.contacts_removeFromContacts),
content: Column(
mainAxisSize: MainAxisSize.min,
@@ -1871,45 +1889,61 @@ class _ContactTile extends StatelessWidget {
icon: contactTypeIcon(contact.type),
),
const SizedBox(width: 12),
// Main content
// Main content. The name owns the whole first row (wrapping to
// a second line if needed); last-seen and the route share the row
// below so long names stay readable on narrow screens and large
// text scales.
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
// Name row + route chip
Row(
children: [
Expanded(
child: Text(
contact.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: unreadCount > 0
? FontWeight.w700
: FontWeight.w500,
fontSize: 15,
color: scheme.onSurface,
Text.rich(
TextSpan(
text: contact.name,
children: [
if (isFavorite)
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Padding(
padding: const EdgeInsetsDirectional.only(
start: 4,
),
child: Icon(
Icons.star,
size: 16,
color: MeshPalette.warn,
),
),
),
if (contact.hasLocation)
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Padding(
padding: const EdgeInsetsDirectional.only(
start: 4,
),
child: Icon(
Icons.location_on,
size: 16,
color: scheme.onSurfaceVariant,
),
),
),
),
),
if (isFavorite) ...[
const SizedBox(width: 4),
Icon(Icons.star, size: 16, color: MeshPalette.warn),
],
if (contact.hasLocation) ...[
const SizedBox(width: 4),
Icon(
Icons.location_on,
size: 16,
color: scheme.onSurfaceVariant,
),
],
],
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: unreadCount > 0
? FontWeight.w700
: FontWeight.w500,
fontSize: 15,
color: scheme.onSurface,
),
),
const SizedBox(height: 3),
// Key prefix + path / subtitle row
// Key prefix + path + last seen
Row(
children: [
_KeyPrefixBadge(
@@ -1917,6 +1951,7 @@ class _ContactTile extends StatelessWidget {
),
const SizedBox(width: 8),
Expanded(
flex: 3,
child: Text(
contact.pathLabel(
context.l10n,
@@ -1930,42 +1965,33 @@ class _ContactTile extends StatelessWidget {
),
),
),
const SizedBox(width: 8),
// Fills its share and right-aligns, so the time sits at
// the row's end on wide screens too.
Expanded(
flex: 2,
child: Text(
formatContactLastSeen(context.l10n, lastSeen),
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.end,
style: MeshTheme.mono(
fontSize: 12.5,
color: unreadCount > 0
? MeshPalette.blue
: scheme.onSurfaceVariant,
),
),
),
],
),
],
),
),
const SizedBox(width: 10),
// Trailing: time + unread badge. A width cap + wrapping keeps
// large text scales from overflowing without clamping them.
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: MediaQuery.sizeOf(context).width * 0.25,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
if (unreadCount > 0) ...[
UnreadBadge(count: unreadCount),
const SizedBox(height: 4),
],
Text(
formatContactLastSeen(context.l10n, lastSeen),
maxLines: 2,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.right,
style: MeshTheme.mono(
fontSize: 12.5,
color: unreadCount > 0
? MeshPalette.blue
: scheme.onSurfaceVariant,
),
),
],
),
),
if (unreadCount > 0) ...[
const SizedBox(width: 10),
UnreadBadge(count: unreadCount),
],
if (onManage != null)
IconButton(
icon: const Icon(Icons.admin_panel_settings_outlined),