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

+1
View File
@@ -77,6 +77,7 @@ class LinkHandler {
final shouldOpen = await showDialog<bool>( final shouldOpen = await showDialog<bool>(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
scrollable: true,
title: Text(context.l10n.chat_openLink), title: Text(context.l10n.chat_openLink),
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
+45 -40
View File
@@ -26,46 +26,51 @@ class ReviewModeBanner extends StatelessWidget {
minimumSize: const Size(48, 48), minimumSize: const Size(48, 48),
); );
return Container( // A status strip on every main screen: capped so that at the largest
width: double.infinity, // text sizes it can't take over a small phone's screen.
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), return MediaQuery.withClampedTextScaling(
decoration: const BoxDecoration( maxScaleFactor: 1.3,
color: MeshPalette.bg3, child: Container(
border: Border(bottom: BorderSide(color: MeshPalette.warnLine)), width: double.infinity,
), padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: Column( decoration: const BoxDecoration(
crossAxisAlignment: CrossAxisAlignment.start, color: MeshPalette.bg3,
children: [ border: Border(bottom: BorderSide(color: MeshPalette.warnLine)),
Row( ),
children: [ child: Column(
const Icon(Icons.science, color: MeshPalette.warn, size: 24), crossAxisAlignment: CrossAxisAlignment.start,
const SizedBox(width: 8), children: [
Expanded(child: Text(l10n.reviewMode_banner, style: textStyle)), Row(
], children: [
), const Icon(Icons.science, color: MeshPalette.warn, size: 24),
Wrap( const SizedBox(width: 8),
spacing: 8, Expanded(child: Text(l10n.reviewMode_banner, style: textStyle)),
children: [ ],
TextButton( ),
style: buttonStyle, Wrap(
onPressed: () { spacing: 8,
connector.sendReviewTestMessage(); children: [
ScaffoldMessenger.of(context).showSnackBar( TextButton(
SnackBar(content: Text(l10n.reviewMode_testSent)), style: buttonStyle,
); onPressed: () {
}, connector.sendReviewTestMessage();
child: Text(l10n.reviewMode_sendTest), ScaffoldMessenger.of(context).showSnackBar(
), SnackBar(content: Text(l10n.reviewMode_testSent)),
TextButton( );
style: buttonStyle, },
// The screens hosting the banner return to the Connect screen child: Text(l10n.reviewMode_sendTest),
// themselves once disconnected. ),
onPressed: () => connector.disconnect(manual: true), TextButton(
child: Text(l10n.reviewMode_exit), style: buttonStyle,
), // The screens hosting the banner return to the Connect screen
], // themselves once disconnected.
), onPressed: () => connector.disconnect(manual: true),
], child: Text(l10n.reviewMode_exit),
),
],
),
],
),
), ),
); );
} }
+79 -73
View File
@@ -1418,56 +1418,58 @@ class AppSettingsScreen extends StatelessWidget {
) { ) {
showMeshSheet( showMeshSheet(
context, context,
builder: (ctx) => Column( builder: (ctx) => SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
BottomSheetHeader(title: context.l10n.appSettings_mapTimeFilter), children: [
Padding( BottomSheetHeader(title: context.l10n.appSettings_mapTimeFilter),
padding: const EdgeInsets.fromLTRB(16, 4, 16, 8), Padding(
child: Text(context.l10n.appSettings_showNodesDiscoveredWithin), padding: const EdgeInsets.fromLTRB(16, 4, 16, 8),
), child: Text(context.l10n.appSettings_showNodesDiscoveredWithin),
MeshSheetOption( ),
label: context.l10n.appSettings_allTime, MeshSheetOption(
selected: settingsService.settings.mapTimeFilterHours == 0, label: context.l10n.appSettings_allTime,
onTap: () { selected: settingsService.settings.mapTimeFilterHours == 0,
settingsService.setMapTimeFilterHours(0); onTap: () {
Navigator.pop(ctx); settingsService.setMapTimeFilterHours(0);
}, Navigator.pop(ctx);
), },
MeshSheetOption( ),
label: context.l10n.appSettings_lastHour, MeshSheetOption(
selected: settingsService.settings.mapTimeFilterHours == 1, label: context.l10n.appSettings_lastHour,
onTap: () { selected: settingsService.settings.mapTimeFilterHours == 1,
settingsService.setMapTimeFilterHours(1); onTap: () {
Navigator.pop(ctx); settingsService.setMapTimeFilterHours(1);
}, Navigator.pop(ctx);
), },
MeshSheetOption( ),
label: context.l10n.appSettings_last6Hours, MeshSheetOption(
selected: settingsService.settings.mapTimeFilterHours == 6, label: context.l10n.appSettings_last6Hours,
onTap: () { selected: settingsService.settings.mapTimeFilterHours == 6,
settingsService.setMapTimeFilterHours(6); onTap: () {
Navigator.pop(ctx); settingsService.setMapTimeFilterHours(6);
}, Navigator.pop(ctx);
), },
MeshSheetOption( ),
label: context.l10n.appSettings_last24Hours, MeshSheetOption(
selected: settingsService.settings.mapTimeFilterHours == 24, label: context.l10n.appSettings_last24Hours,
onTap: () { selected: settingsService.settings.mapTimeFilterHours == 24,
settingsService.setMapTimeFilterHours(24); onTap: () {
Navigator.pop(ctx); settingsService.setMapTimeFilterHours(24);
}, Navigator.pop(ctx);
), },
MeshSheetOption( ),
label: context.l10n.appSettings_lastWeek, MeshSheetOption(
selected: settingsService.settings.mapTimeFilterHours == 168, label: context.l10n.appSettings_lastWeek,
onTap: () { selected: settingsService.settings.mapTimeFilterHours == 168,
settingsService.setMapTimeFilterHours(168); onTap: () {
Navigator.pop(ctx); settingsService.setMapTimeFilterHours(168);
}, Navigator.pop(ctx);
), },
SizedBox(height: MediaQuery.paddingOf(ctx).bottom + 8), ),
], SizedBox(height: MediaQuery.paddingOf(ctx).bottom + 8),
],
),
), ),
); );
} }
@@ -1478,29 +1480,32 @@ class AppSettingsScreen extends StatelessWidget {
) { ) {
showMeshSheet( showMeshSheet(
context, context,
builder: (ctx) => Column( builder: (ctx) => SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
BottomSheetHeader(title: context.l10n.appSettings_unitsTitle), children: [
MeshSheetOption( BottomSheetHeader(title: context.l10n.appSettings_unitsTitle),
label: context.l10n.appSettings_unitsMetric, MeshSheetOption(
selected: settingsService.settings.unitSystem == UnitSystem.metric, label: context.l10n.appSettings_unitsMetric,
onTap: () { selected:
settingsService.setUnitSystem(UnitSystem.metric); settingsService.settings.unitSystem == UnitSystem.metric,
Navigator.pop(ctx); onTap: () {
}, settingsService.setUnitSystem(UnitSystem.metric);
), Navigator.pop(ctx);
MeshSheetOption( },
label: context.l10n.appSettings_unitsImperial, ),
selected: MeshSheetOption(
settingsService.settings.unitSystem == UnitSystem.imperial, label: context.l10n.appSettings_unitsImperial,
onTap: () { selected:
settingsService.setUnitSystem(UnitSystem.imperial); settingsService.settings.unitSystem == UnitSystem.imperial,
Navigator.pop(ctx); onTap: () {
}, settingsService.setUnitSystem(UnitSystem.imperial);
), Navigator.pop(ctx);
SizedBox(height: MediaQuery.paddingOf(ctx).bottom + 8), },
], ),
SizedBox(height: MediaQuery.paddingOf(ctx).bottom + 8),
],
),
), ),
); );
} }
@@ -1917,6 +1922,7 @@ class _MapApiKeyDialogState extends State<_MapApiKeyDialog> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final l10n = context.l10n; final l10n = context.l10n;
return AlertDialog( return AlertDialog(
scrollable: true,
title: Text(l10n.appSettings_stadiaApiKey), title: Text(l10n.appSettings_stadiaApiKey),
content: SizedBox( content: SizedBox(
width: 420, width: 420,
+139 -134
View File
@@ -1775,57 +1775,59 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
showMeshSheet( showMeshSheet(
context, context,
builder: (sheetContext) => SafeArea( builder: (sheetContext) => SafeArea(
child: Column( child: SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
BottomSheetHeader( children: [
title: l10n.receivedImage_awaiting( BottomSheetHeader(
entry.bitstreamByteCount, title: l10n.receivedImage_awaiting(
entry.totalChunks, entry.bitstreamByteCount,
entry.totalChunks,
),
subtitle: _imageSenderLabel(entry),
), ),
subtitle: _imageSenderLabel(entry), if (canSave)
), ListTile(
if (canSave) leading: const Icon(Icons.save_alt),
title: Text(l10n.receivedImage_save),
onTap: () {
Navigator.pop(sheetContext);
_saveImage(entry);
},
),
ListTile( ListTile(
leading: const Icon(Icons.save_alt), leading: const Icon(Icons.info_outline),
title: Text(l10n.receivedImage_save), title: Text(l10n.receivedImage_packetInfo),
onTap: () { onTap: () {
Navigator.pop(sheetContext); Navigator.pop(sheetContext);
_saveImage(entry); _showImagePacketInfo(entry);
}, },
), ),
ListTile( const Divider(height: 1),
leading: const Icon(Icons.info_outline), ListTile(
title: Text(l10n.receivedImage_packetInfo), leading: Icon(
onTap: () { Icons.delete_outline,
Navigator.pop(sheetContext); color: Theme.of(context).colorScheme.error,
_showImagePacketInfo(entry); ),
}, title: Text(
), l10n.common_delete,
const Divider(height: 1), style: TextStyle(color: Theme.of(context).colorScheme.error),
ListTile( ),
leading: Icon( onTap: () async {
Icons.delete_outline, Navigator.pop(sheetContext);
color: Theme.of(context).colorScheme.error, await context.read<ReceivedImageStore>().deleteImage(
entry.streamId,
);
if (!mounted) return;
showDismissibleSnackBar(
context,
content: Text(l10n.chat_messageDeleted),
);
},
), ),
title: Text( const SizedBox(height: 8),
l10n.common_delete, ],
style: TextStyle(color: Theme.of(context).colorScheme.error), ),
),
onTap: () async {
Navigator.pop(sheetContext);
await context.read<ReceivedImageStore>().deleteImage(
entry.streamId,
);
if (!mounted) return;
showDismissibleSnackBar(
context,
content: Text(l10n.chat_messageDeleted),
);
},
),
const SizedBox(height: 8),
],
), ),
), ),
); );
@@ -1860,6 +1862,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
showDialog<void>( showDialog<void>(
context: context, context: context,
builder: (dialogContext) => AlertDialog( builder: (dialogContext) => AlertDialog(
scrollable: true,
title: Text(l10n.receivedImage_packetInfo), title: Text(l10n.receivedImage_packetInfo),
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -2234,109 +2237,111 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
showMeshSheet( showMeshSheet(
context, context,
builder: (sheetContext) => SafeArea( builder: (sheetContext) => SafeArea(
child: Column( child: SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
BottomSheetHeader( children: [
title: message.text.characters.length > 40 BottomSheetHeader(
? '${message.text.characters.take(40)}…' title: message.text.characters.length > 40
: message.text, ? '${message.text.characters.take(40)}…'
subtitle: message.senderName.isNotEmpty : message.text,
? message.senderName subtitle: message.senderName.isNotEmpty
: null, ? message.senderName
), : null,
ListTile( ),
leading: const Icon(Icons.reply),
title: Text(context.l10n.chat_reply),
onTap: () {
Navigator.pop(sheetContext);
_setReplyingTo(message);
},
),
ListTile(
leading: const Icon(Icons.route),
title: Text(context.l10n.chat_path),
onTap: () {
Navigator.pop(sheetContext);
_showMessagePathInfo(message);
},
),
if (message.pathBytes.isNotEmpty)
ListTile( ListTile(
leading: const Icon(Icons.map_outlined), leading: const Icon(Icons.reply),
title: Text(context.l10n.chat_viewPathOnMap), title: Text(context.l10n.chat_reply),
onTap: () { onTap: () {
Navigator.pop(sheetContext); Navigator.pop(sheetContext);
Navigator.push( _setReplyingTo(message);
context, },
MaterialPageRoute( ),
builder: (context) => ChannelMessagePathMapScreen( ListTile(
message: message, leading: const Icon(Icons.route),
channelMessage: true, title: Text(context.l10n.chat_path),
onTap: () {
Navigator.pop(sheetContext);
_showMessagePathInfo(message);
},
),
if (message.pathBytes.isNotEmpty)
ListTile(
leading: const Icon(Icons.map_outlined),
title: Text(context.l10n.chat_viewPathOnMap),
onTap: () {
Navigator.pop(sheetContext);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ChannelMessagePathMapScreen(
message: message,
channelMessage: true,
),
), ),
), );
); },
}, ),
), // Can't react to your own messages
// Can't react to your own messages if (!message.isOutgoing)
if (!message.isOutgoing) ListTile(
leading: const Icon(Icons.add_reaction_outlined),
title: Text(context.l10n.chat_addReaction),
onTap: () {
Navigator.pop(sheetContext);
_showEmojiPicker(message);
},
),
ListTile( ListTile(
leading: const Icon(Icons.add_reaction_outlined), leading: const Icon(Icons.copy),
title: Text(context.l10n.chat_addReaction), title: Text(context.l10n.common_copy),
onTap: () { onTap: () {
Navigator.pop(sheetContext); Navigator.pop(sheetContext);
_showEmojiPicker(message); copyChatMessageText(context, message.text);
}, },
), ),
ListTile( if (canTranslateMessage)
leading: const Icon(Icons.copy), ListTile(
title: Text(context.l10n.common_copy), leading: const Icon(Icons.translate),
onTap: () { title: Text(context.l10n.translation_translateMessage),
Navigator.pop(sheetContext); onTap: () {
copyChatMessageText(context, message.text); Navigator.pop(sheetContext);
}, unawaited(
), context.read<MeshCoreConnector>().translateChannelMessage(
if (canTranslateMessage) widget.channel.index,
message,
manualTranslation: true,
),
);
},
),
if (!message.isOutgoing)
ListTile(
leading: const Icon(Icons.mark_chat_unread_outlined),
title: Text(context.l10n.chat_markAsUnread),
onTap: () {
Navigator.pop(sheetContext);
_markAsUnread(message);
},
),
const Divider(height: 1),
ListTile( ListTile(
leading: const Icon(Icons.translate), leading: Icon(
title: Text(context.l10n.translation_translateMessage), Icons.delete_outline,
onTap: () { color: Theme.of(context).colorScheme.error,
),
title: Text(
context.l10n.common_delete,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
onTap: () async {
Navigator.pop(sheetContext); Navigator.pop(sheetContext);
unawaited( await _deleteMessage(message);
context.read<MeshCoreConnector>().translateChannelMessage(
widget.channel.index,
message,
manualTranslation: true,
),
);
}, },
), ),
if (!message.isOutgoing) const SizedBox(height: 8),
ListTile( ],
leading: const Icon(Icons.mark_chat_unread_outlined), ),
title: Text(context.l10n.chat_markAsUnread),
onTap: () {
Navigator.pop(sheetContext);
_markAsUnread(message);
},
),
const Divider(height: 1),
ListTile(
leading: Icon(
Icons.delete_outline,
color: Theme.of(context).colorScheme.error,
),
title: Text(
context.l10n.common_delete,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
onTap: () async {
Navigator.pop(sheetContext);
await _deleteMessage(message);
},
),
const SizedBox(height: 8),
],
), ),
), ),
); );
+58 -48
View File
@@ -631,56 +631,58 @@ class _ChannelsScreenState extends State<ChannelsScreen>
showMeshSheet( showMeshSheet(
parentContext, parentContext,
builder: (sheetContext) => SafeArea( builder: (sheetContext) => SafeArea(
child: Column( child: SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
ListTile( children: [
leading: const Icon(Icons.edit_outlined), ListTile(
title: Text(sheetContext.l10n.channels_editChannel), leading: const Icon(Icons.edit_outlined),
onTap: () async { title: Text(sheetContext.l10n.channels_editChannel),
Navigator.pop(sheetContext); onTap: () async {
await Future.delayed(const Duration(milliseconds: 100)); Navigator.pop(sheetContext);
if (parentContext.mounted) { await Future.delayed(const Duration(milliseconds: 100));
_showEditChannelDialog(parentContext, connector, channel); if (parentContext.mounted) {
} _showEditChannelDialog(parentContext, connector, channel);
}, }
), },
// Notification mode selection
ListTile(
leading: const Icon(Icons.notifications_outlined),
title: Text(sheetContext.l10n.channels_notificationSettings),
trailing: const Icon(Icons.chevron_right),
onTap: () async {
Navigator.pop(sheetContext);
await Future.delayed(const Duration(milliseconds: 100));
if (parentContext.mounted) {
showChannelNotificationModeSheet(
parentContext,
channel.muteKey,
);
}
},
),
ListTile(
leading: Icon(
Icons.delete_outline,
color: Theme.of(sheetContext).colorScheme.error,
), ),
title: Text( // Notification mode selection
sheetContext.l10n.channels_deleteChannel, ListTile(
style: TextStyle( leading: const Icon(Icons.notifications_outlined),
title: Text(sheetContext.l10n.channels_notificationSettings),
trailing: const Icon(Icons.chevron_right),
onTap: () async {
Navigator.pop(sheetContext);
await Future.delayed(const Duration(milliseconds: 100));
if (parentContext.mounted) {
showChannelNotificationModeSheet(
parentContext,
channel.muteKey,
);
}
},
),
ListTile(
leading: Icon(
Icons.delete_outline,
color: Theme.of(sheetContext).colorScheme.error, color: Theme.of(sheetContext).colorScheme.error,
), ),
title: Text(
sheetContext.l10n.channels_deleteChannel,
style: TextStyle(
color: Theme.of(sheetContext).colorScheme.error,
),
),
onTap: () async {
Navigator.pop(sheetContext);
await Future.delayed(const Duration(milliseconds: 100));
if (parentContext.mounted) {
_confirmDeleteChannel(parentContext, connector, channel);
}
},
), ),
onTap: () async { ],
Navigator.pop(sheetContext); ),
await Future.delayed(const Duration(milliseconds: 100));
if (parentContext.mounted) {
_confirmDeleteChannel(parentContext, connector, channel);
}
},
),
],
), ),
), ),
); );
@@ -1191,12 +1193,16 @@ class _ChannelsScreenState extends State<ChannelsScreen>
vertical: 8, vertical: 8,
), ),
child: DropdownButtonFormField<Community>( child: DropdownButtonFormField<Community>(
isExpanded: true,
initialValue: selectedCommunity, initialValue: selectedCommunity,
items: _communities items: _communities
.map( .map(
(c) => DropdownMenuItem( (c) => DropdownMenuItem(
value: c, value: c,
child: Text(c.name), child: Text(
c.name,
overflow: TextOverflow.ellipsis,
),
), ),
) )
.toList(), .toList(),
@@ -1751,6 +1757,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
Padding( Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 0, 8), padding: const EdgeInsets.fromLTRB(0, 8, 0, 8),
child: DropdownButtonFormField<String>( child: DropdownButtonFormField<String>(
isExpanded: true,
initialValue: selectedCyr2LatProfileId, initialValue: selectedCyr2LatProfileId,
decoration: InputDecoration( decoration: InputDecoration(
labelText: sheetContext labelText: sheetContext
@@ -1762,7 +1769,10 @@ class _ChannelsScreenState extends State<ChannelsScreen>
.map((profile) { .map((profile) {
return DropdownMenuItem( return DropdownMenuItem(
value: profile.id, value: profile.id,
child: Text(profile.name), child: Text(
profile.name,
overflow: TextOverflow.ellipsis,
),
); );
}) })
.toList(), .toList(),
+96 -90
View File
@@ -870,6 +870,7 @@ class _ChatScreenState extends State<ChatScreen> {
Padding( Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 0, 8), padding: const EdgeInsets.fromLTRB(0, 8, 0, 8),
child: DropdownButtonFormField<String>( child: DropdownButtonFormField<String>(
isExpanded: true,
initialValue: selectedCyr2LatProfileId, initialValue: selectedCyr2LatProfileId,
decoration: InputDecoration( decoration: InputDecoration(
labelText: labelText:
@@ -881,7 +882,10 @@ class _ChatScreenState extends State<ChatScreen> {
) { ) {
return DropdownMenuItem( return DropdownMenuItem(
value: profile.id, value: profile.id,
child: Text(profile.name), child: Text(
profile.name,
overflow: TextOverflow.ellipsis,
),
); );
}).toList(), }).toList(),
onChanged: (value) { onChanged: (value) {
@@ -1071,109 +1075,111 @@ class _ChatScreenState extends State<ChatScreen> {
showMeshSheet( showMeshSheet(
context, context,
builder: (sheetContext) => SafeArea( builder: (sheetContext) => SafeArea(
child: Column( child: SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
BottomSheetHeader( children: [
title: message.text.characters.length > 40 BottomSheetHeader(
? '${message.text.characters.take(40)}…' title: message.text.characters.length > 40
: message.text, ? '${message.text.characters.take(40)}…'
), : message.text,
// Can't react to your own messages ),
if (!message.isOutgoing) // Can't react to your own messages
if (!message.isOutgoing)
ListTile(
leading: const Icon(Icons.add_reaction_outlined),
title: Text(context.l10n.chat_addReaction),
onTap: () {
Navigator.pop(sheetContext);
_showEmojiPicker(message, contact);
},
),
ListTile( ListTile(
leading: const Icon(Icons.add_reaction_outlined), leading: const Icon(Icons.route),
title: Text(context.l10n.chat_addReaction), title: Text(context.l10n.chat_path),
onTap: () { onTap: () {
Navigator.pop(sheetContext); Navigator.pop(sheetContext);
_showEmojiPicker(message, contact); _openMessagePath(message, contact);
}, },
), ),
ListTile( if (message.pathBytes.isNotEmpty)
leading: const Icon(Icons.route), ListTile(
title: Text(context.l10n.chat_path), leading: const Icon(Icons.map_outlined),
onTap: () { title: Text(context.l10n.chat_viewPathOnMap),
Navigator.pop(sheetContext); onTap: () {
_openMessagePath(message, contact); Navigator.pop(sheetContext);
}, _openMessagePath(message, contact, openMap: true);
), },
if (message.pathBytes.isNotEmpty) ),
ListTile( ListTile(
leading: const Icon(Icons.map_outlined), leading: const Icon(Icons.copy),
title: Text(context.l10n.chat_viewPathOnMap), title: Text(context.l10n.common_copy),
onTap: () { onTap: () {
Navigator.pop(sheetContext); Navigator.pop(sheetContext);
_openMessagePath(message, contact, openMap: true); copyChatMessageText(context, message.text);
}, },
), ),
ListTile( if (canTranslateMessage)
leading: const Icon(Icons.copy), ListTile(
title: Text(context.l10n.common_copy), leading: const Icon(Icons.translate),
onTap: () { title: Text(context.l10n.translation_translateMessage),
Navigator.pop(sheetContext); onTap: () {
copyChatMessageText(context, message.text); Navigator.pop(sheetContext);
}, unawaited(
), context.read<MeshCoreConnector>().translateContactMessage(
if (canTranslateMessage) widget.contact.publicKeyHex,
message,
manualTranslation: true,
),
);
},
),
if (!message.isOutgoing)
ListTile(
leading: const Icon(Icons.mark_chat_unread_outlined),
title: Text(context.l10n.chat_markAsUnread),
onTap: () {
Navigator.pop(sheetContext);
_markAsUnread(message);
},
),
if (message.isOutgoing && message.status == MessageStatus.failed)
ListTile(
leading: const Icon(Icons.refresh),
title: Text(context.l10n.common_retry),
onTap: () {
Navigator.pop(sheetContext);
_retryMessage(message);
},
),
if (_resolveContact(context.read<MeshCoreConnector>()).type ==
advTypeRoom)
ListTile(
leading: const Icon(Icons.chat),
title: Text(context.l10n.contacts_openChat),
onTap: () {
Navigator.pop(sheetContext);
_openChat(context, contact);
},
),
const Divider(height: 1),
ListTile( ListTile(
leading: const Icon(Icons.translate), leading: Icon(
title: Text(context.l10n.translation_translateMessage), Icons.delete_outline,
onTap: () { color: Theme.of(context).colorScheme.error,
),
title: Text(
context.l10n.common_delete,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
onTap: () async {
Navigator.pop(sheetContext); Navigator.pop(sheetContext);
unawaited( await _deleteMessage(message);
context.read<MeshCoreConnector>().translateContactMessage(
widget.contact.publicKeyHex,
message,
manualTranslation: true,
),
);
}, },
), ),
if (!message.isOutgoing) const SizedBox(height: 8),
ListTile( ],
leading: const Icon(Icons.mark_chat_unread_outlined), ),
title: Text(context.l10n.chat_markAsUnread),
onTap: () {
Navigator.pop(sheetContext);
_markAsUnread(message);
},
),
if (message.isOutgoing && message.status == MessageStatus.failed)
ListTile(
leading: const Icon(Icons.refresh),
title: Text(context.l10n.common_retry),
onTap: () {
Navigator.pop(sheetContext);
_retryMessage(message);
},
),
if (_resolveContact(context.read<MeshCoreConnector>()).type ==
advTypeRoom)
ListTile(
leading: const Icon(Icons.chat),
title: Text(context.l10n.contacts_openChat),
onTap: () {
Navigator.pop(sheetContext);
_openChat(context, contact);
},
),
const Divider(height: 1),
ListTile(
leading: Icon(
Icons.delete_outline,
color: Theme.of(context).colorScheme.error,
),
title: Text(
context.l10n.common_delete,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
onTap: () async {
Navigator.pop(sheetContext);
await _deleteMessage(message);
},
),
const SizedBox(height: 8),
],
), ),
), ),
); );
+188 -182
View File
@@ -168,61 +168,63 @@ class _CommunityQrScannerScreenState extends State<CommunityQrScannerScreen> {
context, context,
builder: (sheetContext) { builder: (sheetContext) {
final sheetScheme = Theme.of(sheetContext).colorScheme; final sheetScheme = Theme.of(sheetContext).colorScheme;
return Column( return SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min,
children: [ crossAxisAlignment: CrossAxisAlignment.stretch,
BottomSheetHeader(title: context.l10n.channels_joinChannelTitle), children: [
Padding( BottomSheetHeader(title: context.l10n.channels_joinChannelTitle),
padding: const EdgeInsets.fromLTRB(20, 0, 20, 4), Padding(
child: Text( padding: const EdgeInsets.fromLTRB(20, 0, 20, 4),
context.l10n.channels_joinChannelConfirm(name), child: Text(
style: TextStyle(color: sheetScheme.onSurfaceVariant), context.l10n.channels_joinChannelConfirm(name),
style: TextStyle(color: sheetScheme.onSurfaceVariant),
),
), ),
), MeshCard(
MeshCard( child: Row(
child: Row( children: [
children: [ AvatarCircle(
AvatarCircle( name: name,
name: name, icon: Icons.lock,
icon: Icons.lock, color: MeshPalette.blue,
color: MeshPalette.blue, size: 44,
size: 44, ),
), const SizedBox(width: 14),
const SizedBox(width: 14), Expanded(
Expanded( child: Text(
child: Text( name,
name, style: const TextStyle(
style: const TextStyle( fontWeight: FontWeight.w600,
fontWeight: FontWeight.w600, fontSize: 15,
fontSize: 15, ),
), ),
), ),
), ],
], ),
), ),
), Padding(
Padding( padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16), child: Row(
child: Row( children: [
children: [ Expanded(
Expanded( child: OutlinedButton(
child: OutlinedButton( onPressed: () => Navigator.pop(sheetContext, false),
onPressed: () => Navigator.pop(sheetContext, false), child: Text(context.l10n.common_cancel),
child: Text(context.l10n.common_cancel), ),
), ),
), const SizedBox(width: 12),
const SizedBox(width: 12), Expanded(
Expanded( child: FilledButton(
child: FilledButton( onPressed: () => Navigator.pop(sheetContext, true),
onPressed: () => Navigator.pop(sheetContext, true), child: Text(context.l10n.common_add),
child: Text(context.l10n.common_add), ),
), ),
), ],
], ),
), ),
), ],
], ),
); );
}, },
); );
@@ -271,61 +273,63 @@ class _CommunityQrScannerScreenState extends State<CommunityQrScannerScreen> {
context, context,
builder: (sheetContext) { builder: (sheetContext) {
final sheetScheme = Theme.of(sheetContext).colorScheme; final sheetScheme = Theme.of(sheetContext).colorScheme;
return Column( return SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min,
children: [ crossAxisAlignment: CrossAxisAlignment.stretch,
BottomSheetHeader(title: context.l10n.community_alreadyMember), children: [
Padding( BottomSheetHeader(title: context.l10n.community_alreadyMember),
padding: const EdgeInsets.fromLTRB(20, 0, 20, 4), Padding(
child: Text( padding: const EdgeInsets.fromLTRB(20, 0, 20, 4),
context.l10n.community_alreadyMemberMessage(community.name), child: Text(
style: TextStyle(color: sheetScheme.onSurfaceVariant), context.l10n.community_alreadyMemberMessage(community.name),
style: TextStyle(color: sheetScheme.onSurfaceVariant),
),
), ),
), MeshCard(
MeshCard( child: Row(
child: Row( children: [
children: [ const Icon(
const Icon( Icons.groups,
Icons.groups, color: MeshPalette.magenta,
color: MeshPalette.magenta, size: 32,
size: 32,
),
const SizedBox(width: 14),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
community.name,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 15,
),
),
Text(
context.l10n.community_shortId(
community.shortCommunityId,
),
style: MeshTheme.mono(
fontSize: 13,
color: sheetScheme.onSurfaceVariant,
),
),
],
), ),
), const SizedBox(width: 14),
], Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
community.name,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 15,
),
),
Text(
context.l10n.community_shortId(
community.shortCommunityId,
),
style: MeshTheme.mono(
fontSize: 13,
color: sheetScheme.onSurfaceVariant,
),
),
],
),
),
],
),
), ),
), Padding(
Padding( padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16), child: FilledButton(
child: FilledButton( onPressed: () => Navigator.pop(sheetContext, true),
onPressed: () => Navigator.pop(sheetContext, true), child: Text(context.l10n.common_ok),
child: Text(context.l10n.common_ok), ),
), ),
), ],
], ),
); );
}, },
); );
@@ -348,93 +352,95 @@ class _CommunityQrScannerScreenState extends State<CommunityQrScannerScreen> {
builder: (sheetContext) => StatefulBuilder( builder: (sheetContext) => StatefulBuilder(
builder: (sheetContext, setSheetState) { builder: (sheetContext, setSheetState) {
final joinScheme = Theme.of(sheetContext).colorScheme; final joinScheme = Theme.of(sheetContext).colorScheme;
return Column( return SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min,
children: [ crossAxisAlignment: CrossAxisAlignment.stretch,
BottomSheetHeader(title: context.l10n.community_joinTitle), children: [
Padding( BottomSheetHeader(title: context.l10n.community_joinTitle),
padding: const EdgeInsets.fromLTRB(20, 0, 20, 4), Padding(
child: Text( padding: const EdgeInsets.fromLTRB(20, 0, 20, 4),
context.l10n.community_joinConfirmation(community.name), child: Text(
style: TextStyle(color: joinScheme.onSurfaceVariant), context.l10n.community_joinConfirmation(community.name),
style: TextStyle(color: joinScheme.onSurfaceVariant),
),
), ),
), MeshCard(
MeshCard( child: Row(
child: Row( children: [
children: [ AvatarCircle(
AvatarCircle( name: community.name,
name: community.name, icon: Icons.groups,
icon: Icons.groups, color: MeshPalette.magenta,
color: MeshPalette.magenta, size: 44,
size: 44,
),
const SizedBox(width: 14),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
community.name,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 15,
),
),
Text(
context.l10n.community_shortId(
community.shortCommunityId,
),
style: MeshTheme.mono(
fontSize: 13,
color: joinScheme.onSurfaceVariant,
),
),
],
), ),
), const SizedBox(width: 14),
], Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
community.name,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 15,
),
),
Text(
context.l10n.community_shortId(
community.shortCommunityId,
),
style: MeshTheme.mono(
fontSize: 13,
color: joinScheme.onSurfaceVariant,
),
),
],
),
),
],
),
), ),
), CheckboxListTile(
CheckboxListTile( value: addPublicChannel,
value: addPublicChannel, onChanged: (value) {
onChanged: (value) { setSheetState(() {
setSheetState(() { addPublicChannel = value ?? true;
addPublicChannel = value ?? true; });
}); },
}, title: Text(context.l10n.community_addPublicChannel),
title: Text(context.l10n.community_addPublicChannel), subtitle: Text(context.l10n.community_addPublicChannelHint),
subtitle: Text(context.l10n.community_addPublicChannelHint), controlAffinity: ListTileControlAffinity.leading,
controlAffinity: ListTileControlAffinity.leading, contentPadding: const EdgeInsets.symmetric(horizontal: 16),
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
),
Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
child: Row(
children: [
Expanded(
child: OutlinedButton(
onPressed: () {
completer.complete(false);
Navigator.pop(sheetContext);
},
child: Text(context.l10n.common_cancel),
),
),
const SizedBox(width: 12),
Expanded(
child: FilledButton(
onPressed: () {
completer.complete(true);
Navigator.pop(sheetContext);
},
child: Text(context.l10n.community_join),
),
),
],
), ),
), Padding(
], padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
child: Row(
children: [
Expanded(
child: OutlinedButton(
onPressed: () {
completer.complete(false);
Navigator.pop(sheetContext);
},
child: Text(context.l10n.common_cancel),
),
),
const SizedBox(width: 12),
Expanded(
child: FilledButton(
onPressed: () {
completer.complete(true);
Navigator.pop(sheetContext);
},
child: Text(context.l10n.community_join),
),
),
],
),
),
],
),
); );
}, },
), ),
+287 -261
View File
@@ -1,4 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'dart:math' as math;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@@ -544,46 +545,48 @@ class _ContactsScreenState extends State<ContactsScreen>
showMeshSheet( showMeshSheet(
context, context,
builder: (sheetContext) => SafeArea( builder: (sheetContext) => SafeArea(
child: Column( child: SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
BottomSheetHeader(title: context.l10n.contacts_title), children: [
ListTile( BottomSheetHeader(title: context.l10n.contacts_title),
leading: const Icon(Icons.paste), ListTile(
title: Text(context.l10n.contacts_addContactFromClipboard), leading: const Icon(Icons.paste),
onTap: () { title: Text(context.l10n.contacts_addContactFromClipboard),
Navigator.pop(sheetContext); onTap: () {
_contactImport(); Navigator.pop(sheetContext);
}, _contactImport();
), },
ListTile( ),
leading: const Icon(Icons.qr_code_scanner), ListTile(
title: Text(context.l10n.contacts_scanQrCode), leading: const Icon(Icons.qr_code_scanner),
onTap: () { title: Text(context.l10n.contacts_scanQrCode),
Navigator.pop(sheetContext); onTap: () {
Navigator.push( Navigator.pop(sheetContext);
context, Navigator.push(
MaterialPageRoute( context,
builder: (context) => const ContactQrScannerScreen(), MaterialPageRoute(
), builder: (context) => const ContactQrScannerScreen(),
); ),
}, );
), },
ListTile( ),
leading: const Icon(Icons.person_add_rounded), ListTile(
title: Text(context.l10n.discoveredContacts_Title), leading: const Icon(Icons.person_add_rounded),
onTap: () { title: Text(context.l10n.discoveredContacts_Title),
Navigator.pop(sheetContext); onTap: () {
Navigator.push( Navigator.pop(sheetContext);
context, Navigator.push(
MaterialPageRoute( context,
builder: (context) => const DiscoveryScreen(), MaterialPageRoute(
), builder: (context) => const DiscoveryScreen(),
); ),
}, );
), },
const SizedBox(height: 8), ),
], const SizedBox(height: 8),
],
),
), ),
), ),
); );
@@ -915,6 +918,23 @@ class _ContactsScreenState extends State<ContactsScreen>
120.0, 120.0,
); //two 48px icon buttons + 1px divider ); //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( return Column(
children: [ children: [
Padding( 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( Expanded(
child: RefreshIndicator( child: RefreshIndicator(
onRefresh: () => connector.getContacts(), onRefresh: () => connector.getContacts(),
@@ -1060,9 +1066,13 @@ class _ContactsScreenState extends State<ContactsScreen>
builder: (context, constraints) => ListView( builder: (context, constraints) => ListView(
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
children: [ children: [
discoveredTile,
ConstrainedBox( ConstrainedBox(
constraints: BoxConstraints( constraints: BoxConstraints(
minHeight: constraints.maxHeight, minHeight: math.max(
0,
constraints.maxHeight - kMinInteractiveDimension,
),
), ),
child: EmptyState( child: EmptyState(
icon: Icons.search_off, icon: Icons.search_off,
@@ -1076,8 +1086,10 @@ class _ContactsScreenState extends State<ContactsScreen>
) )
: ListView.builder( : ListView.builder(
padding: const EdgeInsets.only(bottom: 88), padding: const EdgeInsets.only(bottom: 88),
itemCount: filteredAndSorted.length, itemCount: filteredAndSorted.length + 1,
itemBuilder: (context, index) { itemBuilder: (context, row) {
if (row == 0) return discoveredTile;
final index = row - 1;
final contact = filteredAndSorted[index]; final contact = filteredAndSorted[index];
final unreadCount = connector.getUnreadCountForContact( final unreadCount = connector.getUnreadCountForContact(
contact, contact,
@@ -1561,98 +1573,18 @@ class _ContactsScreenState extends State<ContactsScreen>
showMeshSheet( showMeshSheet(
context, context,
builder: (sheetContext) => SafeArea( builder: (sheetContext) => SafeArea(
child: Column( child: SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
BottomSheetHeader( children: [
title: contact.name, BottomSheetHeader(
subtitle: contact.typeLabel(context.l10n), 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,
),
),
);
},
), ),
ListTile( if (isRepeater) ...[
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( ListTile(
leading: Icon(Icons.radar, color: MeshPalette.signal), leading: Icon(Icons.radar, color: MeshPalette.signal),
title: Text(context.l10n.contacts_chatTraceRoute), title: Text(context.l10n.contacts_ping),
onTap: () { onTap: () {
Navigator.pop(sheetContext); Navigator.pop(sheetContext);
final hw = context final hw = context
@@ -1662,10 +1594,10 @@ class _ContactsScreenState extends State<ContactsScreen>
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => PathTraceMapScreen( builder: (context) => PathTraceMapScreen(
title: context.l10n.contacts_pathTraceTo( title: context.l10n.contacts_repeaterPing,
contact.name, path: contact.pathBytesForDisplay.isNotEmpty
), ? contact.pathBytesForDisplay
path: contact.pathBytesForDisplay, : _contactPathPrefix(contact, hw),
flipPathAround: true, flipPathAround: true,
targetContact: contact, targetContact: contact,
pathHashByteWidth: hw, 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, context: context,
builder: (dialogContext) => StatefulBuilder( builder: (dialogContext) => StatefulBuilder(
builder: (dialogContext, setDialogState) => AlertDialog( builder: (dialogContext, setDialogState) => AlertDialog(
scrollable: true,
title: Text(context.l10n.contacts_removeFromContacts), title: Text(context.l10n.contacts_removeFromContacts),
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -1871,45 +1889,61 @@ class _ContactTile extends StatelessWidget {
icon: contactTypeIcon(contact.type), icon: contactTypeIcon(contact.type),
), ),
const SizedBox(width: 12), 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( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
// Name row + route chip Text.rich(
Row( TextSpan(
children: [ text: contact.name,
Expanded( children: [
child: Text( if (isFavorite)
contact.name, WidgetSpan(
maxLines: 1, alignment: PlaceholderAlignment.middle,
overflow: TextOverflow.ellipsis, child: Padding(
style: TextStyle( padding: const EdgeInsetsDirectional.only(
fontWeight: unreadCount > 0 start: 4,
? FontWeight.w700 ),
: FontWeight.w500, child: Icon(
fontSize: 15, Icons.star,
color: scheme.onSurface, 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), maxLines: 2,
Icon( overflow: TextOverflow.ellipsis,
Icons.location_on, style: TextStyle(
size: 16, fontWeight: unreadCount > 0
color: scheme.onSurfaceVariant, ? FontWeight.w700
), : FontWeight.w500,
], fontSize: 15,
], color: scheme.onSurface,
),
), ),
const SizedBox(height: 3), const SizedBox(height: 3),
// Key prefix + path / subtitle row // Key prefix + path + last seen
Row( Row(
children: [ children: [
_KeyPrefixBadge( _KeyPrefixBadge(
@@ -1917,6 +1951,7 @@ class _ContactTile extends StatelessWidget {
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
Expanded( Expanded(
flex: 3,
child: Text( child: Text(
contact.pathLabel( contact.pathLabel(
context.l10n, 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), if (unreadCount > 0) ...[
// Trailing: time + unread badge. A width cap + wrapping keeps const SizedBox(width: 10),
// large text scales from overflowing without clamping them. UnreadBadge(count: unreadCount),
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 (onManage != null) if (onManage != null)
IconButton( IconButton(
icon: const Icon(Icons.admin_panel_settings_outlined), icon: const Icon(Icons.admin_panel_settings_outlined),
+21 -19
View File
@@ -345,25 +345,27 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
builder: (sheetContext) { builder: (sheetContext) {
final l10n = context.l10n; final l10n = context.l10n;
return SafeArea( return SafeArea(
child: Column( child: SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
BottomSheetHeader( children: [
title: contact.name, BottomSheetHeader(
subtitle: contact.typeLabel(l10n), title: contact.name,
), subtitle: contact.typeLabel(l10n),
ListTile( ),
leading: const Icon(Icons.copy), ListTile(
title: Text(l10n.discoveredContacts_copyContact), leading: const Icon(Icons.copy),
onTap: () => Navigator.of(sheetContext).pop('copy_contact'), title: Text(l10n.discoveredContacts_copyContact),
), onTap: () => Navigator.of(sheetContext).pop('copy_contact'),
ListTile( ),
leading: const Icon(Icons.delete), ListTile(
title: Text(l10n.discoveredContacts_deleteContact), leading: const Icon(Icons.delete),
onTap: () => Navigator.of(sheetContext).pop('delete_contact'), title: Text(l10n.discoveredContacts_deleteContact),
), onTap: () => Navigator.of(sheetContext).pop('delete_contact'),
const SizedBox(height: 8), ),
], const SizedBox(height: 8),
],
),
), ),
); );
}, },
+14 -7
View File
@@ -735,15 +735,22 @@ class _MapCacheScreenState extends State<MapCacheScreen> {
), ),
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
OutlinedButton( // Flexible lets the label wrap instead of pushing
style: OutlinedButton.styleFrom( // the row past the screen edge at large text sizes.
foregroundColor: MeshPalette.alert, Flexible(
side: const BorderSide( child: OutlinedButton(
color: MeshPalette.alertLine, style: OutlinedButton.styleFrom(
foregroundColor: MeshPalette.alert,
side: const BorderSide(
color: MeshPalette.alertLine,
),
),
onPressed: _isDownloading ? null : _clearCache,
child: Text(
l10n.mapCache_clearCacheButton,
textAlign: TextAlign.center,
), ),
), ),
onPressed: _isDownloading ? null : _clearCache,
child: Text(l10n.mapCache_clearCacheButton),
), ),
], ],
), ),
+20 -4
View File
@@ -180,9 +180,11 @@ class _RegionManagementScreenState extends State<RegionManagementScreen> {
child: DropdownButtonFormField<Region>( child: DropdownButtonFormField<Region>(
key: ValueKey(current), key: ValueKey(current),
initialValue: current, initialValue: current,
isExpanded: true,
decoration: InputDecoration( decoration: InputDecoration(
labelText: l10n.settings_regionDefault, labelText: l10n.settings_regionDefault,
helperText: l10n.settings_regionDefaultSubtitle, helperText: l10n.settings_regionDefaultSubtitle,
helperMaxLines: 3,
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
), ),
items: [ items: [
@@ -192,15 +194,22 @@ class _RegionManagementScreenState extends State<RegionManagementScreen> {
radioDefault == null radioDefault == null
? l10n.settings_regionDefaultNone ? l10n.settings_regionDefaultNone
: l10n.settings_regionUseRadioDefault(radioDefault), : l10n.settings_regionUseRadioDefault(radioDefault),
overflow: TextOverflow.ellipsis,
), ),
), ),
if (canForceUnscoped) if (canForceUnscoped)
DropdownMenuItem( DropdownMenuItem(
value: kUnscopedRegion, value: kUnscopedRegion,
child: Text(l10n.settings_regionNoRegion), child: Text(
l10n.settings_regionNoRegion,
overflow: TextOverflow.ellipsis,
),
), ),
for (final region in _regions) for (final region in _regions)
DropdownMenuItem(value: region, child: Text(region)), DropdownMenuItem(
value: region,
child: Text(region, overflow: TextOverflow.ellipsis),
),
], ],
onChanged: (value) => connector.setDefaultRegion(value ?? ''), onChanged: (value) => connector.setDefaultRegion(value ?? ''),
), ),
@@ -222,6 +231,7 @@ class _RegionManagementScreenState extends State<RegionManagementScreen> {
return Padding( return Padding(
padding: const EdgeInsets.only(top: 8, bottom: 8), padding: const EdgeInsets.only(top: 8, bottom: 8),
child: DropdownButtonFormField<Region>( child: DropdownButtonFormField<Region>(
isExpanded: true,
key: ValueKey('radio-default-$radioDefault'), key: ValueKey('radio-default-$radioDefault'),
initialValue: radioDefault, initialValue: radioDefault,
decoration: InputDecoration( decoration: InputDecoration(
@@ -233,10 +243,16 @@ class _RegionManagementScreenState extends State<RegionManagementScreen> {
items: [ items: [
DropdownMenuItem( DropdownMenuItem(
value: '', value: '',
child: Text(l10n.settings_regionDefaultNone), child: Text(
l10n.settings_regionDefaultNone,
overflow: TextOverflow.ellipsis,
),
), ),
for (final region in options) for (final region in options)
DropdownMenuItem(value: region, child: Text(region)), DropdownMenuItem(
value: region,
child: Text(region, overflow: TextOverflow.ellipsis),
),
], ],
onChanged: (value) => _setRadioDefaultRegion(connector, value ?? ''), onChanged: (value) => _setRadioDefaultRegion(connector, value ?? ''),
), ),
+24 -6
View File
@@ -471,7 +471,6 @@ class _RepeaterCliScreenState extends State<RepeaterCliScreen> {
), ),
body: Column( body: Column(
children: [ children: [
const RadioDisconnectedBanner(),
// Quick commands bar // Quick commands bar
Container( Container(
color: scheme.surfaceContainer, color: scheme.surfaceContainer,
@@ -506,10 +505,29 @@ class _RepeaterCliScreenState extends State<RepeaterCliScreen> {
Divider(height: 1, color: scheme.outlineVariant), Divider(height: 1, color: scheme.outlineVariant),
// Output area // Output area
// The disconnected banner lives in the output area and is capped at
// half of it, so large text or an open keyboard can't push the
// command input off screen.
Expanded( Expanded(
child: _commandHistory.isEmpty child: LayoutBuilder(
? _buildEmptyState() builder: (context, constraints) => Column(
: _buildCommandHistory(), children: [
ConstrainedBox(
constraints: BoxConstraints(
maxHeight: constraints.maxHeight / 2,
),
child: const SingleChildScrollView(
child: RadioDisconnectedBanner(),
),
),
Expanded(
child: _commandHistory.isEmpty
? _buildEmptyState()
: _buildCommandHistory(),
),
],
),
),
), ),
Divider(height: 1, color: scheme.outlineVariant), Divider(height: 1, color: scheme.outlineVariant),
@@ -616,10 +634,10 @@ class _RepeaterCliScreenState extends State<RepeaterCliScreen> {
final scheme = Theme.of(context).colorScheme; final scheme = Theme.of(context).colorScheme;
final textTheme = Theme.of(context).textTheme; final textTheme = Theme.of(context).textTheme;
return Center( return Center(
child: Padding( child: SingleChildScrollView(
padding: const EdgeInsets.all(24), padding: const EdgeInsets.all(24),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min,
children: [ children: [
Icon(Icons.terminal, size: 48, color: scheme.onSurfaceVariant), Icon(Icons.terminal, size: 48, color: scheme.onSurfaceVariant),
const SizedBox(height: 12), const SizedBox(height: 12),
+59 -17
View File
@@ -1411,14 +1411,21 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
Padding( Padding(
padding: const EdgeInsets.only(top: 16), padding: const EdgeInsets.only(top: 16),
child: MeshCard( child: MeshCard(
child: Row( // The button sits under the message so neither is
// squeezed on narrow screens or large text.
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
const Icon(Icons.info_outline, size: 20), Row(
const SizedBox(width: 12), children: [
Expanded( const Icon(Icons.info_outline, size: 20),
child: Text( const SizedBox(width: 12),
context.l10n.repeater_settingsNotLoaded, Expanded(
), child: Text(
context.l10n.repeater_settingsNotLoaded,
),
),
],
), ),
TextButton( TextButton(
onPressed: _isLoading || !connected onPressed: _isLoading || !connected
@@ -1626,12 +1633,16 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
DropdownButtonFormField<int>( DropdownButtonFormField<int>(
isExpanded: true,
initialValue: _bandwidth, initialValue: _bandwidth,
decoration: InputDecoration(labelText: l10n.repeater_bandwidth), decoration: InputDecoration(labelText: l10n.repeater_bandwidth),
items: _bandwidthOptions.map((bw) { items: _bandwidthOptions.map((bw) {
return DropdownMenuItem( return DropdownMenuItem(
value: bw, value: bw,
child: Text(_formatBandwidthLabel(bw)), child: Text(
_formatBandwidthLabel(bw),
overflow: TextOverflow.ellipsis,
),
); );
}).toList(), }).toList(),
onChanged: !_loaded('radio') onChanged: !_loaded('radio')
@@ -1647,12 +1658,16 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
DropdownButtonFormField<int>( DropdownButtonFormField<int>(
isExpanded: true,
initialValue: _spreadingFactor, initialValue: _spreadingFactor,
decoration: InputDecoration( decoration: InputDecoration(
labelText: l10n.repeater_spreadingFactor, labelText: l10n.repeater_spreadingFactor,
), ),
items: _spreadingFactorOptions.map((sf) { items: _spreadingFactorOptions.map((sf) {
return DropdownMenuItem(value: sf, child: Text('SF$sf')); return DropdownMenuItem(
value: sf,
child: Text('SF$sf', overflow: TextOverflow.ellipsis),
);
}).toList(), }).toList(),
onChanged: !_loaded('radio') onChanged: !_loaded('radio')
? null ? null
@@ -1667,12 +1682,16 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
DropdownButtonFormField<int>( DropdownButtonFormField<int>(
isExpanded: true,
initialValue: _codingRate, initialValue: _codingRate,
decoration: InputDecoration( decoration: InputDecoration(
labelText: l10n.repeater_codingRate, labelText: l10n.repeater_codingRate,
), ),
items: _codingRateOptions.map((cr) { items: _codingRateOptions.map((cr) {
return DropdownMenuItem(value: cr, child: Text('4/$cr')); return DropdownMenuItem(
value: cr,
child: Text('4/$cr', overflow: TextOverflow.ellipsis),
);
}).toList(), }).toList(),
onChanged: !_loaded('radio') onChanged: !_loaded('radio')
? null ? null
@@ -2122,6 +2141,7 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
children: [ children: [
Expanded( Expanded(
child: DropdownButtonFormField<String>( child: DropdownButtonFormField<String>(
isExpanded: true,
initialValue: _loaded('loop.detect') ? _loopDetect : null, initialValue: _loaded('loop.detect') ? _loopDetect : null,
decoration: InputDecoration( decoration: InputDecoration(
labelText: l10n.repeater_loopDetect, labelText: l10n.repeater_loopDetect,
@@ -2131,19 +2151,31 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
items: [ items: [
DropdownMenuItem( DropdownMenuItem(
value: 'off', value: 'off',
child: Text(l10n.repeater_loopDetectOff), child: Text(
l10n.repeater_loopDetectOff,
overflow: TextOverflow.ellipsis,
),
), ),
DropdownMenuItem( DropdownMenuItem(
value: 'minimal', value: 'minimal',
child: Text(l10n.repeater_loopDetectMinimal), child: Text(
l10n.repeater_loopDetectMinimal,
overflow: TextOverflow.ellipsis,
),
), ),
DropdownMenuItem( DropdownMenuItem(
value: 'moderate', value: 'moderate',
child: Text(l10n.repeater_loopDetectModerate), child: Text(
l10n.repeater_loopDetectModerate,
overflow: TextOverflow.ellipsis,
),
), ),
DropdownMenuItem( DropdownMenuItem(
value: 'strict', value: 'strict',
child: Text(l10n.repeater_loopDetectStrict), child: Text(
l10n.repeater_loopDetectStrict,
overflow: TextOverflow.ellipsis,
),
), ),
], ],
onChanged: !_loaded('loop.detect') onChanged: !_loaded('loop.detect')
@@ -2322,6 +2354,7 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
children: [ children: [
Expanded( Expanded(
child: DropdownButtonFormField<int>( child: DropdownButtonFormField<int>(
isExpanded: true,
initialValue: _loaded('path.hash.mode') initialValue: _loaded('path.hash.mode')
? _pathHashMode ? _pathHashMode
: null, : null,
@@ -2333,15 +2366,24 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
items: [ items: [
DropdownMenuItem( DropdownMenuItem(
value: 0, value: 0,
child: Text(l10n.repeater_pathHashModeOption0), child: Text(
l10n.repeater_pathHashModeOption0,
overflow: TextOverflow.ellipsis,
),
), ),
DropdownMenuItem( DropdownMenuItem(
value: 1, value: 1,
child: Text(l10n.repeater_pathHashModeOption1), child: Text(
l10n.repeater_pathHashModeOption1,
overflow: TextOverflow.ellipsis,
),
), ),
DropdownMenuItem( DropdownMenuItem(
value: 2, value: 2,
child: Text(l10n.repeater_pathHashModeOption2), child: Text(
l10n.repeater_pathHashModeOption2,
overflow: TextOverflow.ellipsis,
),
), ),
], ],
onChanged: !_loaded('path.hash.mode') onChanged: !_loaded('path.hash.mode')
+32 -19
View File
@@ -705,25 +705,38 @@ class _RepeaterStatusScreenState extends State<RepeaterStatusScreen> {
final columns = constraints.maxWidth / textScaler.scale(1) < 320 final columns = constraints.maxWidth / textScaler.scale(1) < 320
? 1 ? 1
: 2; : 2;
return GridView.builder( // Rows size to their tallest tile, so labels that wrap at large
shrinkWrap: true, // text scales grow the row instead of overflowing a fixed extent.
physics: const NeverScrollableScrollPhysics(), Widget tile(_StatItem item) => StatTile(
itemCount: items.length, icon: item.icon,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( label: item.label,
crossAxisCount: columns, value: item.value,
mainAxisSpacing: 8, color: item.color,
crossAxisSpacing: 8, );
mainAxisExtent: textScaler.scale(52) + 28, return Column(
), children: [
itemBuilder: (context, index) { for (var i = 0; i < items.length; i += columns)
final item = items[index]; Padding(
return StatTile( padding: EdgeInsets.only(
icon: item.icon, bottom: i + columns < items.length ? 8 : 0,
label: item.label, ),
value: item.value, child: IntrinsicHeight(
color: item.color, child: Row(
); crossAxisAlignment: CrossAxisAlignment.stretch,
}, children: [
for (var j = 0; j < columns; j++) ...[
if (j > 0) const SizedBox(width: 8),
Expanded(
child: i + j < items.length
? tile(items[i + j])
: const SizedBox.shrink(),
),
],
],
),
),
),
],
); );
}, },
); );
+14 -3
View File
@@ -805,12 +805,14 @@ class _SettingsScreenState extends State<SettingsScreen> {
context: context, context: context,
builder: (dialogContext) => StatefulBuilder( builder: (dialogContext) => StatefulBuilder(
builder: (builderContext, setDialogState) => AlertDialog( builder: (builderContext, setDialogState) => AlertDialog(
scrollable: true,
title: Text(l10n.repeater_pathHashMode), title: Text(l10n.repeater_pathHashMode),
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
DropdownButtonFormField<int>( DropdownButtonFormField<int>(
isExpanded: true,
initialValue: selectedMode, initialValue: selectedMode,
decoration: InputDecoration( decoration: InputDecoration(
labelText: l10n.repeater_pathHashMode, labelText: l10n.repeater_pathHashMode,
@@ -819,15 +821,24 @@ class _SettingsScreenState extends State<SettingsScreen> {
items: [ items: [
DropdownMenuItem( DropdownMenuItem(
value: 0, value: 0,
child: Text(l10n.repeater_pathHashModeOption0), child: Text(
l10n.repeater_pathHashModeOption0,
overflow: TextOverflow.ellipsis,
),
), ),
DropdownMenuItem( DropdownMenuItem(
value: 1, value: 1,
child: Text(l10n.repeater_pathHashModeOption1), child: Text(
l10n.repeater_pathHashModeOption1,
overflow: TextOverflow.ellipsis,
),
), ),
DropdownMenuItem( DropdownMenuItem(
value: 2, value: 2,
child: Text(l10n.repeater_pathHashModeOption2), child: Text(
l10n.repeater_pathHashModeOption2,
overflow: TextOverflow.ellipsis,
),
), ),
], ],
onChanged: (value) { onChanged: (value) {
@@ -36,28 +36,32 @@ void showChannelNotificationModeSheet(BuildContext context, String muteKey) {
builder: (sheetContext) { builder: (sheetContext) {
final scheme = Theme.of(sheetContext).colorScheme; final scheme = Theme.of(sheetContext).colorScheme;
return SafeArea( return SafeArea(
child: Column( child: SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
for (final mode in ChannelNotificationMode.values) children: [
ListTile( for (final mode in ChannelNotificationMode.values)
leading: Icon( ListTile(
channelNotificationModeIcon(mode), leading: Icon(
color: mode == currentMode channelNotificationModeIcon(mode),
? scheme.primary color: mode == currentMode
: scheme.onSurfaceVariant, ? scheme.primary
: scheme.onSurfaceVariant,
),
title: Text(channelNotificationModeLabel(sheetContext, mode)),
trailing: mode == currentMode
? const Icon(Icons.check)
: null,
onTap: () async {
Navigator.pop(sheetContext);
await settingsService.setChannelNotificationMode(
muteKey,
mode,
);
},
), ),
title: Text(channelNotificationModeLabel(sheetContext, mode)), ],
trailing: mode == currentMode ? const Icon(Icons.check) : null, ),
onTap: () async {
Navigator.pop(sheetContext);
await settingsService.setChannelNotificationMode(
muteKey,
mode,
);
},
),
],
), ),
); );
}, },
+62 -48
View File
@@ -55,56 +55,70 @@ class _EmptyStateState extends State<EmptyState>
begin: const Offset(0, 0.06), begin: const Offset(0, 0.06),
end: Offset.zero, end: Offset.zero,
).animate(_curve), ).animate(_curve),
child: Center( // Scrolls instead of overflowing when a short screen or a large text
child: Padding( // scale makes the content taller than the space it gets.
padding: const EdgeInsets.symmetric(horizontal: 40), child: LayoutBuilder(
child: Column( builder: (context, constraints) => SingleChildScrollView(
mainAxisAlignment: MainAxisAlignment.center, child: ConstrainedBox(
children: [ constraints: BoxConstraints(
Container( minHeight: constraints.hasBoundedHeight
width: 80, ? constraints.maxHeight
height: 80, : 0,
decoration: BoxDecoration( ),
shape: BoxShape.circle, child: Center(
color: scheme.primary.withValues(alpha: 0.08), child: Padding(
border: Border.all( padding: const EdgeInsets.symmetric(horizontal: 40),
color: scheme.primary.withValues(alpha: 0.18), child: Column(
width: 1.5, mainAxisSize: MainAxisSize.min,
), children: [
), Container(
child: Icon( width: 80,
widget.icon, height: 80,
size: 36, decoration: BoxDecoration(
color: scheme.onSurfaceVariant, shape: BoxShape.circle,
color: scheme.primary.withValues(alpha: 0.08),
border: Border.all(
color: scheme.primary.withValues(alpha: 0.18),
width: 1.5,
),
),
child: Icon(
widget.icon,
size: 36,
color: scheme.onSurfaceVariant,
),
),
const SizedBox(height: 20),
Text(
widget.title,
style: Theme.of(context).textTheme.titleMedium
?.copyWith(
fontWeight: FontWeight.w600,
color: scheme.onSurface,
letterSpacing: -0.1,
),
textAlign: TextAlign.center,
),
if (widget.subtitle != null) ...[
const SizedBox(height: 8),
Text(
widget.subtitle!,
style: TextStyle(
fontSize: 13.5,
color: scheme.onSurfaceVariant,
height: 1.45,
),
textAlign: TextAlign.center,
),
],
if (widget.action != null) ...[
const SizedBox(height: 28),
widget.action!,
],
],
), ),
), ),
const SizedBox(height: 20), ),
Text(
widget.title,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w600,
color: scheme.onSurface,
letterSpacing: -0.1,
),
textAlign: TextAlign.center,
),
if (widget.subtitle != null) ...[
const SizedBox(height: 8),
Text(
widget.subtitle!,
style: TextStyle(
fontSize: 13.5,
color: scheme.onSurfaceVariant,
height: 1.45,
),
textAlign: TextAlign.center,
),
],
if (widget.action != null) ...[
const SizedBox(height: 28),
widget.action!,
],
],
), ),
), ),
), ),
+4 -1
View File
@@ -1,3 +1,5 @@
import 'dart:math' as math;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart'; import '../l10n/app_localizations.dart';
@@ -55,7 +57,8 @@ void showLanguagePickerSheet(
children: [ children: [
BottomSheetHeader(title: l10n.appSettings_language), BottomSheetHeader(title: l10n.appSettings_language),
SizedBox( SizedBox(
height: 400, // Capped so the sheet still fits short screens and landscape.
height: math.min(400, MediaQuery.sizeOf(ctx).height * 0.6),
child: ListView( child: ListView(
children: [ children: [
for (final (code, label) in appLanguageOptions) for (final (code, label) in appLanguageOptions)
+28 -6
View File
@@ -645,6 +645,7 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
DropdownButtonFormField<LoRaBandwidth>( DropdownButtonFormField<LoRaBandwidth>(
isExpanded: true,
initialValue: _bandwidth, initialValue: _bandwidth,
decoration: InputDecoration( decoration: InputDecoration(
labelText: l10n.settings_bandwidth, labelText: l10n.settings_bandwidth,
@@ -652,7 +653,10 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
), ),
items: LoRaBandwidth.values items: LoRaBandwidth.values
.map( .map(
(bw) => DropdownMenuItem(value: bw, child: Text(bw.label)), (bw) => DropdownMenuItem(
value: bw,
child: Text(bw.label, overflow: TextOverflow.ellipsis),
),
) )
.toList(), .toList(),
onChanged: (value) { onChanged: (value) {
@@ -667,6 +671,7 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
DropdownButtonFormField<LoRaSpreadingFactor>( DropdownButtonFormField<LoRaSpreadingFactor>(
isExpanded: true,
initialValue: _spreadingFactor, initialValue: _spreadingFactor,
decoration: InputDecoration( decoration: InputDecoration(
labelText: l10n.settings_spreadingFactor, labelText: l10n.settings_spreadingFactor,
@@ -674,7 +679,10 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
), ),
items: LoRaSpreadingFactor.values items: LoRaSpreadingFactor.values
.map( .map(
(sf) => DropdownMenuItem(value: sf, child: Text(sf.label)), (sf) => DropdownMenuItem(
value: sf,
child: Text(sf.label, overflow: TextOverflow.ellipsis),
),
) )
.toList(), .toList(),
onChanged: (value) { onChanged: (value) {
@@ -691,6 +699,7 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
DropdownButtonFormField<LoRaCodingRate>( DropdownButtonFormField<LoRaCodingRate>(
isExpanded: true,
initialValue: _codingRate, initialValue: _codingRate,
decoration: InputDecoration( decoration: InputDecoration(
labelText: l10n.settings_codingRate, labelText: l10n.settings_codingRate,
@@ -698,7 +707,10 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
), ),
items: LoRaCodingRate.values items: LoRaCodingRate.values
.map( .map(
(cr) => DropdownMenuItem(value: cr, child: Text(cr.label)), (cr) => DropdownMenuItem(
value: cr,
child: Text(cr.label, overflow: TextOverflow.ellipsis),
),
) )
.toList(), .toList(),
onChanged: (value) { onChanged: (value) {
@@ -716,6 +728,7 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
// Values are path hash modes (0-2, byte width - 1), matching // Values are path hash modes (0-2, byte width - 1), matching
// the selectors in settings_screen and repeater_settings_screen. // the selectors in settings_screen and repeater_settings_screen.
DropdownButtonFormField<int>( DropdownButtonFormField<int>(
isExpanded: true,
initialValue: (_pathHashByteWidth - 1).clamp(0, 2).toInt(), initialValue: (_pathHashByteWidth - 1).clamp(0, 2).toInt(),
decoration: InputDecoration( decoration: InputDecoration(
labelText: l10n.repeater_pathHashMode, labelText: l10n.repeater_pathHashMode,
@@ -726,15 +739,24 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
items: [ items: [
DropdownMenuItem( DropdownMenuItem(
value: 0, value: 0,
child: Text(l10n.repeater_pathHashModeOption0), child: Text(
l10n.repeater_pathHashModeOption0,
overflow: TextOverflow.ellipsis,
),
), ),
DropdownMenuItem( DropdownMenuItem(
value: 1, value: 1,
child: Text(l10n.repeater_pathHashModeOption1), child: Text(
l10n.repeater_pathHashModeOption1,
overflow: TextOverflow.ellipsis,
),
), ),
DropdownMenuItem( DropdownMenuItem(
value: 2, value: 2,
child: Text(l10n.repeater_pathHashModeOption2), child: Text(
l10n.repeater_pathHashModeOption2,
overflow: TextOverflow.ellipsis,
),
), ),
], ],
onChanged: (value) { onChanged: (value) {
+1
View File
@@ -313,6 +313,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
showDialog( showDialog(
context: context, context: context,
builder: (dialogContext) => AlertDialog( builder: (dialogContext) => AlertDialog(
scrollable: true,
title: Text(l10n.chat_fullPath), title: Text(l10n.chat_fullPath),
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
+315
View File
@@ -0,0 +1,315 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:latlong2/latlong.dart';
import 'package:provider/provider.dart';
import 'package:provider/single_child_widget.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:meshcore_open/connector/meshcore_connector.dart';
import 'package:meshcore_open/connector/meshcore_protocol.dart';
import 'package:meshcore_open/l10n/app_localizations.dart';
import 'package:meshcore_open/models/contact.dart';
import 'package:meshcore_open/review_mode/review_radio.dart';
import 'package:meshcore_open/screens/app_debug_log_screen.dart';
import 'package:meshcore_open/screens/app_settings_screen.dart';
import 'package:meshcore_open/screens/ble_debug_log_screen.dart';
import 'package:meshcore_open/screens/channel_chat_screen.dart';
import 'package:meshcore_open/screens/channel_message_path_screen.dart';
import 'package:meshcore_open/screens/channels_screen.dart';
import 'package:meshcore_open/screens/chat_screen.dart';
import 'package:meshcore_open/screens/chrome_required_screen.dart';
import 'package:meshcore_open/screens/companion_radio_stats_screen.dart';
import 'package:meshcore_open/screens/contacts_screen.dart';
import 'package:meshcore_open/screens/discovery_screen.dart';
import 'package:meshcore_open/screens/line_of_sight_map_screen.dart';
import 'package:meshcore_open/screens/map_cache_screen.dart';
import 'package:meshcore_open/screens/map_screen.dart';
import 'package:meshcore_open/screens/neighbors_screen.dart';
import 'package:meshcore_open/screens/path_trace_map.dart';
import 'package:meshcore_open/screens/region_management_screen.dart';
import 'package:meshcore_open/screens/repeater_cli_screen.dart';
import 'package:meshcore_open/screens/repeater_hub_screen.dart';
import 'package:meshcore_open/screens/repeater_settings_screen.dart';
import 'package:meshcore_open/screens/repeater_status_screen.dart';
import 'package:meshcore_open/screens/scanner_screen.dart';
import 'package:meshcore_open/screens/settings_screen.dart';
import 'package:meshcore_open/screens/tcp_screen.dart';
import 'package:meshcore_open/screens/telemetry_screen.dart';
import 'package:meshcore_open/screens/usb_screen.dart';
import 'package:meshcore_open/services/app_debug_log_service.dart';
import 'package:meshcore_open/services/app_settings_service.dart';
import 'package:meshcore_open/services/ble_debug_log_service.dart';
import 'package:meshcore_open/services/chat_text_scale_service.dart';
import 'package:meshcore_open/services/image_codec_service.dart';
import 'package:meshcore_open/services/map_tile_cache_service.dart';
import 'package:meshcore_open/services/message_retry_service.dart';
import 'package:meshcore_open/services/network_map/network_map_upload_service.dart';
import 'package:meshcore_open/services/path_history_service.dart';
import 'package:meshcore_open/services/received_image_store.dart';
import 'package:meshcore_open/services/storage_service.dart';
import 'package:meshcore_open/services/timeout_prediction_service.dart';
import 'package:meshcore_open/services/translation_service.dart';
import 'package:meshcore_open/services/ui_view_state_service.dart';
import 'package:meshcore_open/storage/prefs_manager.dart';
import 'package:meshcore_open/theme/mesh_theme.dart';
/// Renders every screen on a small phone (320x568, the narrowest common
/// width) at several text scales, plus a desktop window, and fails on any
/// layout overflow.
const _layouts = [
(Size(320, 568), [1.0, 1.3, 2.0]),
(Size(1280, 800), [1.0]),
];
class _Env {
final MeshCoreConnector connector;
final List<SingleChildWidget> providers;
_Env(this.connector, this.providers);
}
Future<_Env> _connect(WidgetTester tester) async {
final storage = StorageService();
final connector = MeshCoreConnector();
final retry = MessageRetryService();
final settings = AppSettingsService();
final translation = TranslationService(settings);
final env = _Env(connector, [
ChangeNotifierProvider.value(value: connector),
ChangeNotifierProvider.value(value: retry),
ChangeNotifierProvider.value(value: PathHistoryService(storage)),
ChangeNotifierProvider.value(value: settings),
ChangeNotifierProvider.value(value: BleDebugLogService()),
ChangeNotifierProvider.value(value: AppDebugLogService()),
ChangeNotifierProvider.value(value: ChatTextScaleService()),
ChangeNotifierProvider.value(value: translation),
ChangeNotifierProvider.value(value: UiViewStateService()),
Provider.value(value: storage),
ChangeNotifierProvider.value(
value: MapTileCacheService(appSettingsService: settings),
),
ChangeNotifierProvider.value(value: TimeoutPredictionService(storage)),
ChangeNotifierProvider.value(value: ImageCodecService(settings)),
ChangeNotifierProvider.value(value: ReceivedImageStore()),
ChangeNotifierProvider.value(
value: NetworkMapUploadService(connector: connector, settings: settings),
),
]);
await tester.runAsync(() async {
await settings.loadSettings();
connector.initialize(
retryService: retry,
pathHistoryService: PathHistoryService(storage),
appSettingsService: settings,
translationService: translation,
);
connector.reviewRadioFactoryForTest = () => ReviewRadio(
scheduledMessageInterval: const Duration(hours: 1),
ackDelay: const Duration(hours: 1),
replyDelay: const Duration(hours: 1),
);
await connector.connectReview();
final end = DateTime.now().add(const Duration(seconds: 8));
while ((connector.contacts.isEmpty || connector.channels.isEmpty) &&
DateTime.now().isBefore(end)) {
await Future<void>.delayed(const Duration(milliseconds: 25));
}
});
return env;
}
Contact _contactOfType(MeshCoreConnector c, int type) => c.contacts.firstWhere(
(x) => x.type == type,
orElse: () => c.contacts.first,
);
_Env? _shared;
typedef _ScreenBuilder = Widget Function(MeshCoreConnector c);
/// Screens that open a sheet after the first frame, keyed like [_screens].
final Map<String, Future<void> Function(WidgetTester t, MeshCoreConnector c)>
_interactions = {
'Contacts options sheet': (t, _) async {
// At large text the first contact can start below the fold.
await t.drag(find.byType(RefreshIndicator), const Offset(0, -150));
await t.pump(const Duration(milliseconds: 500));
await t.longPress(
find
.byWidgetPredicate((w) => w.runtimeType.toString() == '_ContactTile')
.first,
);
},
'Contacts add sheet': (t, _) async {
await t.tap(find.byType(FloatingActionButton));
},
};
final Map<String, _ScreenBuilder> _screens = {
'Contacts options sheet': (_) => const ContactsScreen(),
'Contacts add sheet': (_) => const ContactsScreen(),
'Scanner': (_) => const ScannerScreen(),
'Tcp': (_) => const TcpScreen(),
'Usb': (_) => const UsbScreen(),
'ChromeRequired': (_) => const ChromeRequiredScreen(),
'Contacts': (_) => const ContactsScreen(),
'Channels': (_) => const ChannelsScreen(),
'Settings': (_) => const SettingsScreen(),
'AppSettings': (_) => const AppSettingsScreen(),
'Discovery': (_) => const DiscoveryScreen(),
'RegionManagement': (_) => const RegionManagementScreen(),
'MapCache': (_) => const MapCacheScreen(),
'CompanionRadioStats': (_) => const CompanionRadioStatsScreen(),
'AppDebugLog': (_) => const AppDebugLogScreen(),
'BleDebugLog': (_) => const BleDebugLogScreen(),
'Map': (_) => const MapScreen(),
'Chat': (c) => ChatScreen(contact: _contactOfType(c, advTypeChat)),
'ChannelChat': (c) => ChannelChatScreen(channel: c.channels.first),
'ChannelMessagePath': (c) {
final msgs = c.getChannelMessages(c.channels.first);
return ChannelMessagePathScreen(message: msgs.last);
},
'Telemetry': (c) => TelemetryScreen(contact: _contactOfType(c, advTypeChat)),
'RepeaterHub': (c) => RepeaterHubScreen(
repeater: _contactOfType(c, advTypeRepeater),
password: '',
isAdmin: true,
),
'RepeaterStatus': (c) => RepeaterStatusScreen(
repeater: _contactOfType(c, advTypeRepeater),
password: '',
),
'RepeaterSettings': (c) => RepeaterSettingsScreen(
repeater: _contactOfType(c, advTypeRepeater),
password: '',
),
'RepeaterCli': (c) => RepeaterCliScreen(
repeater: _contactOfType(c, advTypeRepeater),
password: '',
),
'Neighbors': (c) => NeighborsScreen(
repeater: _contactOfType(c, advTypeRepeater),
password: '',
),
'PathTraceMap': (c) {
final r = _contactOfType(c, advTypeRepeater);
return PathTraceMapScreen(
title: 'Trace',
path: r.publicKey.sublist(0, 1),
targetContact: r,
);
},
'LineOfSightMap': (_) => const LineOfSightMapScreen(
title: 'Line of sight',
candidates: [
LineOfSightEndpoint(label: 'A', point: LatLng(45.5, -122.6)),
LineOfSightEndpoint(label: 'B', point: LatLng(45.6, -122.7)),
],
),
};
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final tempDir = Directory.systemTemp.createTempSync('small_screen_test');
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
const MethodChannel('plugins.flutter.io/path_provider'),
(call) async => tempDir.path,
);
setUpAll(() async {
SharedPreferences.setMockInitialValues({});
PrefsManager.reset();
await PrefsManager.initialize();
});
final variants = [
for (final entry in _screens.entries) (entry, false),
// Repeater screens add a banner while the companion radio is offline.
for (final entry in _screens.entries)
if (entry.key.startsWith('Repeater') || entry.key == 'Neighbors')
(entry, true),
];
for (final (entry, offline) in variants) {
for (final (size, scales) in _layouts) {
for (final scale in scales) {
final state = offline ? ' (radio offline)' : '';
testWidgets('${entry.key}$state fits ${size.width.toInt()}dp at '
'${scale}x', (tester) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.reset);
final shared = _shared ??= await _connect(tester);
final env = offline
? _Env(shared.connector, [
ChangeNotifierProvider.value(value: MeshCoreConnector()),
...shared.providers.skip(1),
])
: shared;
final overflows = <String>[];
final previous = FlutterError.onError;
FlutterError.onError = (details) {
final text = details.exceptionAsString();
if (!text.contains('overflowed')) {
previous?.call(details);
return;
}
// The creation location names the overflowing Flex in lib/.
final where = RegExp(r'lib/[\w/]+\.dart:\d+')
.allMatches(details.toString())
.map((m) => m[0])
.toSet()
.join(', ');
overflows.add('${text.split('\n').first} at $where');
};
addTearDown(() => FlutterError.onError = previous);
await tester.pumpWidget(
MultiProvider(
providers: env.providers,
child: MaterialApp(
theme: MeshTheme.light(),
locale: const Locale('en'),
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: AppLocalizations.supportedLocales,
builder: (context, child) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(scale)),
child: child!,
),
home: entry.value(env.connector),
),
),
);
for (var i = 0; i < 10; i++) {
await tester.pump(const Duration(milliseconds: 100));
}
final interaction = _interactions[entry.key];
if (interaction != null) {
await interaction(tester, env.connector);
for (var i = 0; i < 10; i++) {
await tester.pump(const Duration(milliseconds: 100));
}
}
await tester.pumpWidget(const SizedBox());
// Let one-shot timers (scan and request timeouts) run out.
await tester.pump(const Duration(minutes: 1));
FlutterError.onError = previous;
expect(overflows, isEmpty, reason: overflows.join('\n---\n'));
});
}
}
}
}