Tester feedback: offline mode, pt-PT, menus, layout and translations
Offline (read-only) mode - The last connected radio is remembered; with no radio the app opens on its saved contacts, channels, messages and unread counts. - Main screens stay open on disconnect. A Connect button replaces the battery and signal indicators, with a sheet to reconnect, choose a radio or stop a pending reconnect. - While disconnected everything is read-only: the composer becomes a "connect to send" bar (drafts kept) and controls that change the radio or stored history are disabled or hidden. - Resending while disconnected no longer deletes the message; a different radio no longer shows the previous radio's channels. - Notification taps open the saved chat while offline. Chats and menus - Channel chat menu: notifications, edit channel, delete channel; the filter row lines up with the others; bell moved out of the app bar. - DM and room menus: remove from contacts; rooms get room management. - Search field uses the full app bar; long-press a result to copy. - Hashtag channel titles no longer read "# #name"; more room around the radio activity dot. - Repeat filter: short messages from one sender are caught at the same count as long ones. Layout - Shared menu row (wraps to two lines) and segment label (never splits a word) used across the app. - One Scan button on the scanner; consistent settings tile titles; contact "last seen" wraps instead of truncating; unfetched repeater settings are dimmed. Localization - New European Portuguese locale (pt_PT); regional locales are handled by the language picker, notifications and the background service. - Fill 67 missing strings per locale, including backup and restore. - Keep "Flood" and "Zero Hop" untranslated, shorten "last seen" and routing labels, and fix mistranslated scan, theme and hop strings. - Received-image strings, badge and caption come from translations. - Regenerate the Czech localizations, which were missing strings. Docs - Add documentation/design.md (UI reference) and offline-mode.md; update channel, chat, navigation and scanner docs.
This commit is contained in:
1 parent
47f2293a5c
commit
462159e803
108 files changed
+17435
-4536
No files matched your search
@@ -45,92 +45,94 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
centerTitle: true,
|
||||
bottom: const SyncProgressAppBarBottom(),
|
||||
),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
// Each card subscribes to only what it shows, so connector traffic
|
||||
// and translation download ticks do not rebuild the whole list.
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 24),
|
||||
children: [
|
||||
// APPEARANCE
|
||||
SectionHeader(context.l10n.appSettings_appearance),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildAppearanceContent),
|
||||
),
|
||||
body: MeshSettingsTileTheme(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
// Each card subscribes to only what it shows, so connector traffic
|
||||
// and translation download ticks do not rebuild the whole list.
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 24),
|
||||
children: [
|
||||
// APPEARANCE
|
||||
SectionHeader(context.l10n.appSettings_appearance),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildAppearanceContent),
|
||||
),
|
||||
|
||||
// NOTIFICATIONS
|
||||
SectionHeader(context.l10n.appSettings_notifications),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildNotificationsContent),
|
||||
),
|
||||
// NOTIFICATIONS
|
||||
SectionHeader(context.l10n.appSettings_notifications),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildNotificationsContent),
|
||||
),
|
||||
|
||||
// MESSAGING
|
||||
SectionHeader(context.l10n.appSettings_messaging),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildMessagingContent),
|
||||
),
|
||||
// MESSAGING
|
||||
SectionHeader(context.l10n.appSettings_messaging),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildMessagingContent),
|
||||
),
|
||||
|
||||
// ROUTING
|
||||
SectionHeader(context.l10n.appSettings_routingSection),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildRoutingContent),
|
||||
),
|
||||
// ROUTING
|
||||
SectionHeader(context.l10n.appSettings_routingSection),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildRoutingContent),
|
||||
),
|
||||
|
||||
// IMAGE MESSAGES
|
||||
SectionHeader(context.l10n.appSettings_imageMessagesSection),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildImageMessagesContent),
|
||||
),
|
||||
// IMAGE MESSAGES
|
||||
SectionHeader(context.l10n.appSettings_imageMessagesSection),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildImageMessagesContent),
|
||||
),
|
||||
|
||||
// BATTERY
|
||||
SectionHeader(context.l10n.appSettings_battery),
|
||||
MeshCard(
|
||||
padding: const EdgeInsets.fromLTRB(16, 4, 16, 16),
|
||||
child: _settingsCard(_buildBatteryContent),
|
||||
),
|
||||
// BATTERY
|
||||
SectionHeader(context.l10n.appSettings_battery),
|
||||
MeshCard(
|
||||
padding: const EdgeInsets.fromLTRB(16, 4, 16, 16),
|
||||
child: _settingsCard(_buildBatteryContent),
|
||||
),
|
||||
|
||||
// MAP
|
||||
SectionHeader(context.l10n.appSettings_mapDisplay),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildMapContent),
|
||||
),
|
||||
// MAP
|
||||
SectionHeader(context.l10n.appSettings_mapDisplay),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildMapContent),
|
||||
),
|
||||
|
||||
// NETWORK MAP
|
||||
SectionHeader(context.l10n.networkMap_settingsSection),
|
||||
const MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: NetworkMapSettingsSection(),
|
||||
),
|
||||
|
||||
// TRANSLATION (non-web only)
|
||||
if (!kIsWeb) ...[
|
||||
SectionHeader(context.l10n.translation_title),
|
||||
// NETWORK MAP
|
||||
SectionHeader(context.l10n.networkMap_settingsSection),
|
||||
const MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: TranslationSettingsSection(),
|
||||
child: NetworkMapSettingsSection(),
|
||||
),
|
||||
|
||||
// TRANSLATION (non-web only)
|
||||
if (!kIsWeb) ...[
|
||||
SectionHeader(context.l10n.translation_title),
|
||||
const MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: TranslationSettingsSection(),
|
||||
),
|
||||
],
|
||||
|
||||
// CYR2LAT
|
||||
SectionHeader(context.l10n.channels_cyr2latSettingsHeading),
|
||||
MeshCard(
|
||||
padding: const EdgeInsets.fromLTRB(16, 4, 16, 16),
|
||||
child: _settingsCard(_buildCyr2LatContent),
|
||||
),
|
||||
|
||||
// DEBUG
|
||||
SectionHeader(context.l10n.appSettings_debugCard),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildDebugContent),
|
||||
),
|
||||
],
|
||||
|
||||
// CYR2LAT
|
||||
SectionHeader(context.l10n.channels_cyr2latSettingsHeading),
|
||||
MeshCard(
|
||||
padding: const EdgeInsets.fromLTRB(16, 4, 16, 16),
|
||||
child: _settingsCard(_buildCyr2LatContent),
|
||||
),
|
||||
|
||||
// DEBUG
|
||||
SectionHeader(context.l10n.appSettings_debugCard),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildDebugContent),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -182,15 +184,19 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
segments: [
|
||||
ButtonSegment(
|
||||
value: 'system',
|
||||
label: Text(context.l10n.appSettings_themeSystem),
|
||||
label: MeshSegmentLabel(
|
||||
context.l10n.appSettings_themeSystem,
|
||||
),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: 'light',
|
||||
label: Text(context.l10n.appSettings_themeLight),
|
||||
label: MeshSegmentLabel(
|
||||
context.l10n.appSettings_themeLight,
|
||||
),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: 'dark',
|
||||
label: Text(context.l10n.appSettings_themeDark),
|
||||
label: MeshSegmentLabel(context.l10n.appSettings_themeDark),
|
||||
),
|
||||
],
|
||||
// A custom theme sets its own brightness, so no stock mode
|
||||
|
||||
@@ -7,6 +7,7 @@ import '../connector/meshcore_protocol.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../widgets/adaptive_app_bar_title.dart';
|
||||
import '../widgets/confirm_clear_dialog.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
|
||||
enum _BleLogView { frames, rawLogRx }
|
||||
@@ -99,11 +100,11 @@ class _BleDebugLogScreenState extends State<BleDebugLogScreen> {
|
||||
segments: [
|
||||
ButtonSegment(
|
||||
value: _BleLogView.frames,
|
||||
label: Text(context.l10n.debugLog_frames),
|
||||
label: MeshSegmentLabel(context.l10n.debugLog_frames),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: _BleLogView.rawLogRx,
|
||||
label: Text(context.l10n.debugLog_rawLogRx),
|
||||
label: MeshSegmentLabel(context.l10n.debugLog_rawLogRx),
|
||||
),
|
||||
],
|
||||
selected: {_view},
|
||||
|
||||
@@ -33,8 +33,7 @@ import '../models/channel.dart';
|
||||
import '../models/channel_message.dart';
|
||||
import '../models/image_codec_support.dart' show aeicRatePointForUi;
|
||||
import '../models/message_filter.dart';
|
||||
import '../services/app_settings_service.dart'
|
||||
show AppSettingsService, ChannelNotificationMode;
|
||||
import '../services/app_settings_service.dart' show AppSettingsService;
|
||||
import '../services/chat_text_scale_service.dart';
|
||||
import '../services/image_chunk_transport.dart';
|
||||
import '../services/image_codec_service.dart';
|
||||
@@ -44,6 +43,7 @@ import '../services/received_image_store.dart';
|
||||
import '../services/translation_service.dart';
|
||||
import '../utils/image_save.dart';
|
||||
import '../utils/lora_airtime.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
import '../widgets/marker_label_dialog.dart';
|
||||
import '../widgets/received_image_message.dart';
|
||||
import '../widgets/channel_notification_mode_sheet.dart';
|
||||
@@ -73,6 +73,7 @@ import '../widgets/share_contact_sheet.dart';
|
||||
import '../widgets/shared_contact_card.dart';
|
||||
import 'app_settings_screen.dart';
|
||||
import 'channel_chat_transcript_grouping.dart';
|
||||
import 'channels_screen.dart' show confirmDeleteChannel, showEditChannelSheet;
|
||||
import 'channel_message_path_screen.dart';
|
||||
import 'map_screen.dart';
|
||||
import 'region_management_screen.dart';
|
||||
@@ -226,7 +227,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
/// (see [_onCoveringRouteStatus]).
|
||||
Future<void> _loadCommunities() async {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
_communityStore.setPublicKeyHex = connector.selfPublicKeyHex;
|
||||
_communityStore.setPublicKeyHex = connector.storageKeyHex;
|
||||
final communities = await _communityStore.loadCommunities();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@@ -547,6 +548,129 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
Widget _menuRow(IconData icon, String label, {Color? color}) =>
|
||||
MeshMenuItemRow(icon: icon, label: label, color: color);
|
||||
|
||||
// Region lives here (and on a tap of the title) so the channel name keeps
|
||||
// its room in the app bar; so does the notification mode.
|
||||
Widget _buildOverflowMenu(BuildContext context) {
|
||||
final muteKey = widget.channel.muteKey;
|
||||
final error = Theme.of(context).colorScheme.error;
|
||||
return PopupMenuButton<String>(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
onSelected: (value) {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
switch (value) {
|
||||
case 'messageFilter':
|
||||
_toggleChannelFiltering();
|
||||
case 'notifications':
|
||||
showChannelNotificationModeSheet(context, muteKey);
|
||||
case 'region':
|
||||
openRegionSelectDialog(widget.channel);
|
||||
case 'editChannel':
|
||||
showEditChannelSheet(
|
||||
context,
|
||||
connector,
|
||||
widget.channel,
|
||||
onSaved: _onChannelEdited,
|
||||
);
|
||||
case 'background':
|
||||
showChatBackgroundSheet(
|
||||
context,
|
||||
ChatBackgroundService.channelKey(widget.channel),
|
||||
);
|
||||
case 'clearChat':
|
||||
_confirmClearChat();
|
||||
case 'deleteChannel':
|
||||
confirmDeleteChannel(
|
||||
context,
|
||||
connector,
|
||||
widget.channel,
|
||||
onDeleted: () {
|
||||
if (mounted) Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) {
|
||||
final notificationMode = context
|
||||
.read<AppSettingsService>()
|
||||
.getChannelNotificationMode(muteKey);
|
||||
final readOnly = isRadioReadOnly(context.read<MeshCoreConnector>());
|
||||
return [
|
||||
if (_messageFilter case final filter? when filter.settings.enabled)
|
||||
PopupMenuItem(
|
||||
value: 'messageFilter',
|
||||
child: _menuRow(
|
||||
filter.isChannelFiltered(_messageFilterChannelId)
|
||||
? Icons.check_box
|
||||
: Icons.check_box_outline_blank,
|
||||
context.l10n.messageFilter_channelToggle,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'notifications',
|
||||
child: _menuRow(
|
||||
channelNotificationModeIcon(notificationMode),
|
||||
context.l10n.channels_notificationModeTooltip(
|
||||
channelNotificationModeLabel(context, notificationMode),
|
||||
),
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'region',
|
||||
child: _menuRow(
|
||||
Icons.landscape,
|
||||
context.l10n.channels_regionSelect_Title,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'editChannel',
|
||||
enabled: !readOnly,
|
||||
child: _menuRow(Icons.settings, context.l10n.channels_editChannel),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'background',
|
||||
child: _menuRow(Icons.wallpaper, context.l10n.chatBackground_title),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'clearChat',
|
||||
enabled: !readOnly,
|
||||
child: _menuRow(
|
||||
Icons.delete,
|
||||
context.l10n.contact_clearChat,
|
||||
color: readOnly ? null : error,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'deleteChannel',
|
||||
enabled: !readOnly,
|
||||
child: _menuRow(
|
||||
Icons.delete_forever,
|
||||
context.l10n.channels_deleteChannel,
|
||||
color: readOnly ? null : error,
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// A rename or new PSK changes what this screen is keyed on (mute key,
|
||||
/// type, stored history), so reopen it on the saved channel.
|
||||
void _onChannelEdited(Channel saved) {
|
||||
if (!mounted) return;
|
||||
final old = widget.channel;
|
||||
if (saved.name == old.name && saved.pskHex == old.pskHex) return;
|
||||
Navigator.of(context).pushReplacement(
|
||||
PageRouteBuilder<void>(
|
||||
transitionDuration: Duration.zero,
|
||||
reverseTransitionDuration: Duration.zero,
|
||||
pageBuilder: (_, _, _) => ChannelChatScreen(channel: saved),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<List<ChatSearchEntry>> _loadSearchEntries() async {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final messages = await connector.allChannelMessagesForSearch(
|
||||
@@ -602,8 +726,12 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
onTap: () => openRegionSelectDialog(widget.channel),
|
||||
child: Row(
|
||||
children: [
|
||||
_channelIcon(widget.channel),
|
||||
const SizedBox(width: 8),
|
||||
// A hashtag name already starts with '#'; a # icon
|
||||
// before it would read "# #name".
|
||||
if (!widget.channel.name.startsWith('#')) ...[
|
||||
_channelIcon(widget.channel),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -681,106 +809,20 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
),
|
||||
centerTitle: false,
|
||||
bottom: const SyncProgressAppBarBottom(),
|
||||
actions: [
|
||||
Consumer<AppSettingsService>(
|
||||
builder: (context, settings, _) {
|
||||
final muteKey = widget.channel.muteKey;
|
||||
final notificationMode = settings
|
||||
.getChannelNotificationMode(muteKey);
|
||||
return IconButton(
|
||||
tooltip: context.l10n.channels_notificationModeTooltip(
|
||||
channelNotificationModeLabel(context, notificationMode),
|
||||
actionsPadding: const EdgeInsetsDirectional.only(end: 4),
|
||||
// While searching the field gets the whole bar; the leading
|
||||
// arrow closes the search.
|
||||
actions: _searching
|
||||
? null
|
||||
: [
|
||||
const RadioStatsIconButton(),
|
||||
IconButton(
|
||||
tooltip: context.l10n.chatSearch_tooltip,
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: _openSearch,
|
||||
),
|
||||
icon: Icon(
|
||||
notificationMode == ChannelNotificationMode.muted
|
||||
? Icons.notifications_off
|
||||
: notificationMode ==
|
||||
ChannelNotificationMode.mentionsOnly
|
||||
? Icons.notification_important
|
||||
: Icons.notifications,
|
||||
),
|
||||
onPressed: () =>
|
||||
showChannelNotificationModeSheet(context, muteKey),
|
||||
);
|
||||
},
|
||||
),
|
||||
const RadioStatsIconButton(),
|
||||
if (!_searching)
|
||||
IconButton(
|
||||
tooltip: context.l10n.chatSearch_tooltip,
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: _openSearch,
|
||||
),
|
||||
PopupMenuButton<String>(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
onSelected: (value) {
|
||||
if (value == 'region') {
|
||||
openRegionSelectDialog(widget.channel);
|
||||
} else if (value == 'background') {
|
||||
showChatBackgroundSheet(
|
||||
context,
|
||||
ChatBackgroundService.channelKey(widget.channel),
|
||||
);
|
||||
} else if (value == 'clearChat') {
|
||||
_confirmClearChat();
|
||||
} else if (value == 'messageFilter') {
|
||||
_toggleChannelFiltering();
|
||||
}
|
||||
},
|
||||
// Region lives here (and on a tap of the title) so the channel
|
||||
// name keeps its room in the app bar.
|
||||
itemBuilder: (context) => [
|
||||
if (_messageFilter case final filter?
|
||||
when filter.settings.enabled)
|
||||
CheckedPopupMenuItem(
|
||||
value: 'messageFilter',
|
||||
checked: filter.isChannelFiltered(
|
||||
_messageFilterChannelId,
|
||||
),
|
||||
child: Text(context.l10n.messageFilter_channelToggle),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'region',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.landscape, size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.channels_regionSelect_Title),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'background',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.wallpaper, size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.chatBackground_title),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'clearChat',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.delete,
|
||||
size: 20,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
context.l10n.contact_clearChat,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
_buildOverflowMenu(context),
|
||||
],
|
||||
),
|
||||
body: _showSearchResults
|
||||
? _buildSearchResults(_loadSearchEntries)
|
||||
@@ -1432,7 +1474,9 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
if (_selecting) {
|
||||
return _buildSelectableRow(message, messageBody);
|
||||
}
|
||||
if (!isOutgoing && !PlatformInfo.isDesktop) {
|
||||
if (!isOutgoing &&
|
||||
!PlatformInfo.isDesktop &&
|
||||
!isRadioReadOnly(context.read<MeshCoreConnector>())) {
|
||||
return _SwipeReplyBubble(
|
||||
maxSwipeOffset: maxSwipeOffset,
|
||||
replySwipeThreshold: replySwipeThreshold,
|
||||
@@ -1917,6 +1961,8 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
}) async {
|
||||
final l10n = context.l10n;
|
||||
|
||||
// The image preview may still be open when the link drops.
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
if (!connector.supportsChannelData) {
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
@@ -2312,7 +2358,6 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
streamId: entry.streamId,
|
||||
isOutgoing: isOutgoing,
|
||||
fallbackTextColor: textColor,
|
||||
strings: _receivedImageStrings(context),
|
||||
// The placeholder's "no model installed" tap lands here.
|
||||
// `focusImageMessages` scrolls straight to the image block
|
||||
// — it sits below six other sections, so the plain screen
|
||||
@@ -2354,6 +2399,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
|
||||
void _showImageActions(ReceivedImageEntry entry) {
|
||||
final l10n = context.l10n;
|
||||
final readOnly = isRadioReadOnly(context.read<MeshCoreConnector>());
|
||||
final canSave = entry.state == ReceivedImageState.decoded;
|
||||
showMeshSheet(
|
||||
context,
|
||||
@@ -2388,13 +2434,18 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
),
|
||||
const Divider(height: 1),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
Icons.delete_outline,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
color: readOnly ? null : Theme.of(context).colorScheme.error,
|
||||
),
|
||||
title: Text(
|
||||
l10n.common_delete,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
style: TextStyle(
|
||||
color: readOnly
|
||||
? null
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -2731,7 +2782,8 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
/// Shares the radio's own position as a map marker on this channel. It is
|
||||
/// not a reply, so any reply in progress stays open for the next message;
|
||||
/// it shares the text send guard and cooldown.
|
||||
Future<void> _shareMyLocation(MeshCoreConnector connector) {
|
||||
Future<void> _shareMyLocation(MeshCoreConnector connector) async {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
return shareMyLocationMarker(
|
||||
context: context,
|
||||
connector: connector,
|
||||
@@ -2754,11 +2806,15 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
final replyTo = _replyingToMessage;
|
||||
final replyRegion = _useReplyRegion ? replyTo?.region : null;
|
||||
|
||||
// Before anything clears the text box: offline the draft must stay.
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
if (!_sendGuard.checkCooldown(context)) return;
|
||||
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final translation = await translateOutgoingText(context, text);
|
||||
if (translation == null || !mounted) return;
|
||||
// The link can drop while the translation runs.
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
|
||||
String messageText = translation.text;
|
||||
if (replyTo != null) {
|
||||
@@ -2819,6 +2875,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
}
|
||||
|
||||
void _showMessageActions(ChannelMessage message) {
|
||||
final readOnly = isRadioReadOnly(context.read<MeshCoreConnector>());
|
||||
final translationService = context.read<TranslationService>();
|
||||
final canTranslateMessage =
|
||||
translationService.canTranslateIncoming(
|
||||
@@ -2853,6 +2910,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
: null,
|
||||
),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: const Icon(Icons.reply),
|
||||
title: Text(context.l10n.chat_reply),
|
||||
onTap: () {
|
||||
@@ -2896,6 +2954,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
// Can't react to your own messages
|
||||
if (!message.isOutgoing)
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: const Icon(Icons.add_reaction_outlined),
|
||||
title: Text(context.l10n.chat_addReaction),
|
||||
onTap: () {
|
||||
@@ -2939,6 +2998,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
const Divider(height: 1),
|
||||
if (message.isFiltered)
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: const Icon(Icons.visibility_outlined),
|
||||
title: Text(context.l10n.messageFilter_notSpam),
|
||||
onTap: () {
|
||||
@@ -2948,6 +3008,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
)
|
||||
else
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: const Icon(Icons.visibility_off_outlined),
|
||||
title: Text(context.l10n.messageFilter_markSpam),
|
||||
onTap: () {
|
||||
@@ -2975,13 +3036,18 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
],
|
||||
const Divider(height: 1),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
Icons.delete_outline,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
color: readOnly ? null : Theme.of(context).colorScheme.error,
|
||||
),
|
||||
title: Text(
|
||||
context.l10n.common_delete,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
style: TextStyle(
|
||||
color: readOnly
|
||||
? null
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -3077,8 +3143,12 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
final l10n = context.l10n;
|
||||
final selected = _selectedMessages();
|
||||
final filter = _messageFilter;
|
||||
// Offline the stored conversation is read-only: no delete or spam marks.
|
||||
final readOnly = context.radioReadOnly;
|
||||
final filterCoversChannel =
|
||||
filter != null && filter.isChannelFiltered(_messageFilterChannelId);
|
||||
!readOnly &&
|
||||
filter != null &&
|
||||
filter.isChannelFiltered(_messageFilterChannelId);
|
||||
final spamCandidates = filterCoversChannel
|
||||
? selected.where(_canMarkSpam).toList()
|
||||
: const <ChannelMessage>[];
|
||||
@@ -3108,7 +3178,9 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
IconButton(
|
||||
tooltip: l10n.common_delete,
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
onPressed: selected.isEmpty ? null : () => _bulkDelete(selected),
|
||||
onPressed: selected.isEmpty || readOnly
|
||||
? null
|
||||
: () => _bulkDelete(selected),
|
||||
),
|
||||
PopupMenuButton<String>(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
@@ -3373,6 +3445,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
}
|
||||
|
||||
void _sendReaction(ChannelMessage message, String emoji) {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final emojiIndex = ReactionHelper.emojiToIndex(emoji);
|
||||
if (emojiIndex == null) return; // Unknown emoji, skip
|
||||
@@ -3387,7 +3460,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
message: context.l10n.channels_clearChatConfirm,
|
||||
);
|
||||
if (confirmed) {
|
||||
if (!mounted) return;
|
||||
if (!mounted || !ensureRadioConnected(context)) return;
|
||||
context.read<MeshCoreConnector>().clearMessagesForChannel(
|
||||
widget.channel.index,
|
||||
);
|
||||
@@ -3404,6 +3477,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
}
|
||||
|
||||
Future<void> _deleteMessage(ChannelMessage message) async {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
await context.read<MeshCoreConnector>().deleteChannelMessage(message);
|
||||
if (!mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
@@ -4027,29 +4101,6 @@ class _TranscriptLayout {
|
||||
}
|
||||
}
|
||||
|
||||
/// [ReceivedImageStrings] built from the app's localizations.
|
||||
///
|
||||
/// The R6 badge and caption are deliberately absent from this class — they are
|
||||
/// private consts in `received_image_message.dart` and must stay mandatory.
|
||||
ReceivedImageStrings _receivedImageStrings(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
return ReceivedImageStrings(
|
||||
incoming: l10n.receivedImage_incoming,
|
||||
queued: l10n.receivedImage_queued,
|
||||
tapToDecode: l10n.receivedImage_tapToDecode,
|
||||
awaiting: l10n.receivedImage_awaiting,
|
||||
tapToProcess: l10n.receivedImage_tapToProcess,
|
||||
decoding: l10n.receivedImage_decoding,
|
||||
incomplete: l10n.receivedImage_incomplete,
|
||||
corrupt: l10n.receivedImage_corrupt,
|
||||
decoderMissing: l10n.receivedImage_decoderMissing,
|
||||
evicted: l10n.receivedImage_evicted,
|
||||
retry: l10n.receivedImage_retry,
|
||||
decodeAgain: l10n.receivedImage_decodeAgain,
|
||||
openSettings: l10n.receivedImage_openSettings,
|
||||
);
|
||||
}
|
||||
|
||||
/// A message's route chip and region chip: stacked by default, or side by
|
||||
/// side (wrapping on narrow bubbles) when "Region next to hop count" is on.
|
||||
class _RouteRegionChips extends StatelessWidget {
|
||||
|
||||
+391
-402
@@ -18,10 +18,10 @@ import '../models/channel.dart';
|
||||
import '../models/community.dart';
|
||||
import '../storage/community_store.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../utils/dialog_utils.dart';
|
||||
import '../utils/disconnect_navigation_mixin.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
import '../utils/route_transitions.dart';
|
||||
import '../widgets/channel_notification_mode_sheet.dart';
|
||||
import '../widgets/connect_sheet.dart';
|
||||
import '../widgets/list_filter_widget.dart';
|
||||
import '../widgets/empty_state.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
@@ -51,8 +51,7 @@ class ChannelsScreen extends StatefulWidget {
|
||||
State<ChannelsScreen> createState() => _ChannelsScreenState();
|
||||
}
|
||||
|
||||
class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
with DisconnectNavigationMixin {
|
||||
class _ChannelsScreenState extends State<ChannelsScreen> {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
final CommunityStore _communityStore = CommunityStore();
|
||||
final CommunityPskIndex _communityIndex = CommunityPskIndex();
|
||||
@@ -74,7 +73,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
|
||||
Future<void> _loadCommunities() async {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
_communityStore.setPublicKeyHex = connector.selfPublicKeyHex;
|
||||
_communityStore.setPublicKeyHex = connector.storageKeyHex;
|
||||
final communities = await _communityStore.loadCommunities();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@@ -111,11 +110,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
// No message filter in this tree (tests); previews ignore it.
|
||||
}
|
||||
|
||||
// Auto-navigate back to scanner if disconnected
|
||||
if (!checkConnectionAndNavigate(connector)) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final readOnly = isRadioReadOnly(connector);
|
||||
final allowBack = !connector.isConnected;
|
||||
|
||||
return PopScope(
|
||||
@@ -132,36 +127,18 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
// capture the screen's context — not the itemBuilder's menu
|
||||
// context, which is deactivated by then.
|
||||
itemBuilder: (menuContext) => [
|
||||
connectionMenuItem(context, menuContext),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.logout,
|
||||
color: Theme.of(menuContext).colorScheme.error,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(menuContext.l10n.common_disconnect),
|
||||
],
|
||||
),
|
||||
onTap: () => _disconnect(context),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.groups),
|
||||
const SizedBox(width: 8),
|
||||
Text(menuContext.l10n.community_manageCommunities),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.groups,
|
||||
label: menuContext.l10n.community_manageCommunities,
|
||||
),
|
||||
onTap: () => _showManageCommunitiesDialog(context),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const ThemedIcon(ThemeIconSlot.settings),
|
||||
const SizedBox(width: 8),
|
||||
Text(menuContext.l10n.settings_title),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
leading: const ThemedIcon(ThemeIconSlot.settings, size: 20),
|
||||
label: menuContext.l10n.settings_title,
|
||||
),
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
@@ -181,6 +158,8 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
// Offline there is no radio to refresh from.
|
||||
if (readOnly) return;
|
||||
await context.read<MeshCoreConnector>().getChannels(
|
||||
force: true,
|
||||
);
|
||||
@@ -206,8 +185,9 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
icon: Icons.tag,
|
||||
title: context.l10n.channels_noChannelsConfigured,
|
||||
action: FilledButton.icon(
|
||||
onPressed: () =>
|
||||
_addPublicChannel(context, connector),
|
||||
onPressed: readOnly
|
||||
? null
|
||||
: () => _addPublicChannel(context, connector),
|
||||
icon: const Icon(Icons.public),
|
||||
label: Text(
|
||||
context.l10n.channels_addPublicChannel,
|
||||
@@ -355,11 +335,13 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => _showAddChannelDialog(context),
|
||||
tooltip: context.l10n.channels_addChannel,
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
floatingActionButton: readOnly
|
||||
? null
|
||||
: FloatingActionButton(
|
||||
onPressed: () => _showAddChannelDialog(context),
|
||||
tooltip: context.l10n.channels_addChannel,
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
bottomNavigationBar: SafeArea(
|
||||
top: false,
|
||||
child: QuickSwitchBar(
|
||||
@@ -641,6 +623,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
Channel channel,
|
||||
) {
|
||||
final parentContext = context;
|
||||
final readOnly = isRadioReadOnly(connector);
|
||||
|
||||
showMeshSheet(
|
||||
parentContext,
|
||||
@@ -650,13 +633,14 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: const Icon(Icons.edit_outlined),
|
||||
title: Text(sheetContext.l10n.channels_editChannel),
|
||||
onTap: () async {
|
||||
Navigator.pop(sheetContext);
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
if (parentContext.mounted) {
|
||||
_showEditChannelDialog(parentContext, connector, channel);
|
||||
showEditChannelSheet(parentContext, connector, channel);
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -677,21 +661,26 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
Icons.delete_outline,
|
||||
color: Theme.of(sheetContext).colorScheme.error,
|
||||
color: readOnly
|
||||
? null
|
||||
: Theme.of(sheetContext).colorScheme.error,
|
||||
),
|
||||
title: Text(
|
||||
sheetContext.l10n.channels_deleteChannel,
|
||||
style: TextStyle(
|
||||
color: Theme.of(sheetContext).colorScheme.error,
|
||||
color: readOnly
|
||||
? null
|
||||
: Theme.of(sheetContext).colorScheme.error,
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
Navigator.pop(sheetContext);
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
if (parentContext.mounted) {
|
||||
_confirmDeleteChannel(parentContext, connector, channel);
|
||||
confirmDeleteChannel(parentContext, connector, channel);
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -721,11 +710,6 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _disconnect(BuildContext context) async {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
await showDisconnectDialog(context, connector);
|
||||
}
|
||||
|
||||
Widget _buildFilterButton(UiViewStateService viewState) {
|
||||
return SortFilterMenu<ChannelSortOption>(
|
||||
tooltip: context.l10n.listFilter_tooltip,
|
||||
@@ -841,7 +825,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
bool isRegularHashtag = true;
|
||||
Community? selectedCommunity;
|
||||
|
||||
_communityStore.setPublicKeyHex = connector.selfPublicKeyHex;
|
||||
_communityStore.setPublicKeyHex = connector.storageKeyHex;
|
||||
|
||||
showMeshSheet(
|
||||
context,
|
||||
@@ -973,6 +957,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
Expanded(
|
||||
child: FilledButton(
|
||||
onPressed: () async {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
final name = nameController.text.trim();
|
||||
if (name.isEmpty) {
|
||||
showDismissibleSnackBar(
|
||||
@@ -1059,6 +1044,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
Expanded(
|
||||
child: FilledButton(
|
||||
onPressed: () {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
final name = nameController.text.trim();
|
||||
final pskHex = pskController.text.trim();
|
||||
if (name.isEmpty) {
|
||||
@@ -1125,6 +1111,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
Expanded(
|
||||
child: FilledButton(
|
||||
onPressed: () {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
final nextIndex = _resolveFreeChannelSlot(
|
||||
context,
|
||||
connector,
|
||||
@@ -1292,6 +1279,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
Expanded(
|
||||
child: FilledButton(
|
||||
onPressed: () async {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
var hashtag = hashtagController.text.trim();
|
||||
if (hashtag.isEmpty) {
|
||||
showDismissibleSnackBar(
|
||||
@@ -1481,6 +1469,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
Expanded(
|
||||
child: FilledButton(
|
||||
onPressed: () async {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
final name = nameController.text.trim();
|
||||
final publicLabel =
|
||||
context.l10n.channels_public;
|
||||
@@ -1665,323 +1654,6 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
);
|
||||
}
|
||||
|
||||
void _showEditChannelDialog(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
Channel channel,
|
||||
) {
|
||||
final appSettingsService = Provider.of<AppSettingsService>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
bool smazEnabled = connector.isChannelSmazEnabled(channel.index);
|
||||
bool cyr2latEnabled = connector.isChannelCyr2LatEnabled(channel.index);
|
||||
final initialUrlImagesEnabled = connector.isChannelUrlImagesEnabled(
|
||||
channel.index,
|
||||
);
|
||||
bool urlImagesEnabled = initialUrlImagesEnabled;
|
||||
final loadLinkImages = appSettingsService.settings.loadLinkImages;
|
||||
String? selectedCyr2LatProfileId = connector.getChannelCyr2LatProfileId(
|
||||
channel.index,
|
||||
);
|
||||
|
||||
showMeshSheet(
|
||||
context,
|
||||
builder: (sheetContext) => _SheetTextControllers(
|
||||
initialTexts: [channel.name, channel.pskHex],
|
||||
builder: (controllers) {
|
||||
final nameController = controllers[0];
|
||||
final pskController = controllers[1];
|
||||
return StatefulBuilder(
|
||||
builder: (sheetContext, setSheetState) => DraggableScrollableSheet(
|
||||
expand: false,
|
||||
initialChildSize: 0.65,
|
||||
minChildSize: 0.4,
|
||||
maxChildSize: 0.95,
|
||||
builder: (_, scrollController) => Column(
|
||||
children: [
|
||||
BottomSheetHeader(
|
||||
title: sheetContext.l10n.channels_editChannelTitle(
|
||||
channel.index,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
controller: scrollController,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
TextField(
|
||||
controller: nameController,
|
||||
decoration: InputDecoration(
|
||||
labelText: sheetContext.l10n.channels_channelName,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
inputFormatters: const [
|
||||
Utf8LengthLimitingTextInputFormatter(
|
||||
maxRadioNameBytes,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: pskController,
|
||||
decoration: InputDecoration(
|
||||
labelText: sheetContext.l10n.channels_pskHex,
|
||||
border: const OutlineInputBorder(),
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(Icons.casino),
|
||||
tooltip:
|
||||
sheetContext.l10n.channels_generateRandomPsk,
|
||||
onPressed: () {
|
||||
final bytes = randomBytes(16);
|
||||
pskController.text = Channel.formatPskHex(
|
||||
bytes,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(
|
||||
sheetContext.l10n.channels_smazCompression,
|
||||
),
|
||||
value: smazEnabled,
|
||||
onChanged: (value) => setSheetState(() {
|
||||
smazEnabled = value;
|
||||
if (smazEnabled) {
|
||||
cyr2latEnabled = false;
|
||||
}
|
||||
}),
|
||||
),
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(
|
||||
sheetContext.l10n.channels_cyr2latCompression,
|
||||
),
|
||||
subtitle: Text(
|
||||
sheetContext.l10n.channels_cyr2latCompressionDscr,
|
||||
),
|
||||
value: cyr2latEnabled,
|
||||
onChanged: (value) => setSheetState(() {
|
||||
cyr2latEnabled = value;
|
||||
if (cyr2latEnabled) {
|
||||
smazEnabled = false;
|
||||
}
|
||||
}),
|
||||
),
|
||||
if (cyr2latEnabled) ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 8),
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
initialValue: selectedCyr2LatProfileId,
|
||||
decoration: InputDecoration(
|
||||
labelText: sheetContext
|
||||
.l10n
|
||||
.channels_cyr2latSettingsSubheading,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
items: appSettingsService.settings.cyr2latProfiles
|
||||
.map((profile) {
|
||||
return DropdownMenuItem(
|
||||
value: profile.id,
|
||||
child: Text(
|
||||
profile.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
})
|
||||
.toList(),
|
||||
onChanged: (value) => setSheetState(() {
|
||||
selectedCyr2LatProfileId = value;
|
||||
}),
|
||||
),
|
||||
),
|
||||
],
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(sheetContext.l10n.urlImage_enable),
|
||||
subtitle: loadLinkImages
|
||||
? null
|
||||
: Text(
|
||||
sheetContext
|
||||
.l10n
|
||||
.urlImage_disabledInAppSettings,
|
||||
),
|
||||
value: urlImagesEnabled,
|
||||
onChanged: loadLinkImages
|
||||
? (value) => setSheetState(
|
||||
() => urlImagesEnabled = value,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
onPressed: () => Navigator.pop(sheetContext),
|
||||
child: Text(sheetContext.l10n.common_cancel),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: FilledButton(
|
||||
onPressed: () async {
|
||||
final name = nameController.text.trim();
|
||||
final pskHex = pskController.text.trim();
|
||||
if (name.isEmpty) {
|
||||
showDismissibleSnackBar(
|
||||
sheetContext,
|
||||
content: Text(
|
||||
sheetContext.l10n.channels_enterChannelName,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Uint8List psk;
|
||||
try {
|
||||
psk = Channel.parsePskHex(pskHex);
|
||||
} on FormatException {
|
||||
showDismissibleSnackBar(
|
||||
sheetContext,
|
||||
content: Text(
|
||||
sheetContext.l10n.channels_pskMustBe32Hex,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.pop(sheetContext);
|
||||
try {
|
||||
await connector.setChannel(
|
||||
channel.index,
|
||||
name,
|
||||
psk,
|
||||
);
|
||||
await connector.setChannelSmazEnabled(
|
||||
channel.index,
|
||||
smazEnabled,
|
||||
);
|
||||
await connector.setChannelCyr2LatEnabled(
|
||||
channel.index,
|
||||
cyr2latEnabled,
|
||||
);
|
||||
if (urlImagesEnabled !=
|
||||
initialUrlImagesEnabled) {
|
||||
await connector.setChannelUrlImagesEnabled(
|
||||
channel.index,
|
||||
urlImagesEnabled,
|
||||
);
|
||||
}
|
||||
await connector.setChannelCyr2LatProfileId(
|
||||
channel.index,
|
||||
selectedCyr2LatProfileId,
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(
|
||||
context.l10n.channels_channelUpdated(name),
|
||||
),
|
||||
);
|
||||
} catch (e, st) {
|
||||
debugPrint(st.toString());
|
||||
if (!context.mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(
|
||||
context.l10n.channels_channelUpdateFailed(
|
||||
'$e',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(sheetContext.l10n.common_save),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _confirmDeleteChannel(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
Channel channel,
|
||||
) {
|
||||
final channelLabel = channel.name.isEmpty
|
||||
? context.l10n.channels_channelIndex(channel.index)
|
||||
: channel.name;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(dialogContext.l10n.channels_deleteChannel),
|
||||
content: Text(
|
||||
dialogContext.l10n.channels_deleteChannelConfirm(channelLabel),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: Text(dialogContext.l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(dialogContext);
|
||||
try {
|
||||
await connector.deleteChannel(channel.index);
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(
|
||||
context.l10n.channels_channelDeleted(channelLabel),
|
||||
),
|
||||
);
|
||||
} catch (e, st) {
|
||||
if (!context.mounted) return;
|
||||
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(
|
||||
context.l10n.channels_channelDeleteFailed(channelLabel),
|
||||
),
|
||||
);
|
||||
|
||||
// Preserve existing logging (if it was there)
|
||||
debugPrint('Failed to delete channel: $e\n$st');
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
dialogContext.l10n.common_delete,
|
||||
style: TextStyle(
|
||||
color: Theme.of(dialogContext).colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Picks a free channel slot at the moment the user commits, or shows why
|
||||
/// none can be used. Slots are only trusted after a complete channel sync:
|
||||
/// while syncing, a slot that hasn't been fetched yet looks empty and
|
||||
@@ -2012,6 +1684,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
}
|
||||
|
||||
void _addPublicChannel(BuildContext context, MeshCoreConnector connector) {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
final index = _resolveFreeChannelSlot(context, connector);
|
||||
if (index == null) return;
|
||||
final psk = Channel.parsePskHex(Channel.publicChannelPsk);
|
||||
@@ -2123,40 +1796,31 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
_confirmLeaveCommunity(this.context, community);
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'share',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.qr_code),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.community_showQr),
|
||||
],
|
||||
itemBuilder: (context) {
|
||||
final readOnly = isRadioReadOnly(
|
||||
context.read<MeshCoreConnector>(),
|
||||
);
|
||||
return [
|
||||
PopupMenuItem(
|
||||
value: 'share',
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.qr_code,
|
||||
label: context.l10n.community_showQr,
|
||||
),
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'leave',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.exit_to_app,
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.error,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
context.l10n.community_delete,
|
||||
style: TextStyle(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.error,
|
||||
),
|
||||
),
|
||||
],
|
||||
PopupMenuItem(
|
||||
value: 'leave',
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.exit_to_app,
|
||||
label: context.l10n.community_delete,
|
||||
color: readOnly
|
||||
? null
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
];
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -2214,7 +1878,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
}
|
||||
|
||||
final channelCount = communityChannels.length;
|
||||
_communityStore.setPublicKeyHex = connector.selfPublicKeyHex;
|
||||
_communityStore.setPublicKeyHex = connector.storageKeyHex;
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -2233,6 +1897,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(dialogContext);
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
|
||||
// Delete all community channels from the device
|
||||
for (final channel in communityChannels) {
|
||||
@@ -2263,6 +1928,330 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
}
|
||||
}
|
||||
|
||||
/// Edits a channel's name, PSK and per-channel options. [onSaved] runs with
|
||||
/// the saved channel once the radio accepted the change.
|
||||
void showEditChannelSheet(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
Channel channel, {
|
||||
void Function(Channel saved)? onSaved,
|
||||
}) {
|
||||
final appSettingsService = Provider.of<AppSettingsService>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
bool smazEnabled = connector.isChannelSmazEnabled(channel.index);
|
||||
bool cyr2latEnabled = connector.isChannelCyr2LatEnabled(channel.index);
|
||||
final initialUrlImagesEnabled = connector.isChannelUrlImagesEnabled(
|
||||
channel.index,
|
||||
);
|
||||
bool urlImagesEnabled = initialUrlImagesEnabled;
|
||||
final loadLinkImages = appSettingsService.settings.loadLinkImages;
|
||||
String? selectedCyr2LatProfileId = connector.getChannelCyr2LatProfileId(
|
||||
channel.index,
|
||||
);
|
||||
|
||||
showMeshSheet(
|
||||
context,
|
||||
builder: (sheetContext) => _SheetTextControllers(
|
||||
initialTexts: [channel.name, channel.pskHex],
|
||||
builder: (controllers) {
|
||||
final nameController = controllers[0];
|
||||
final pskController = controllers[1];
|
||||
return StatefulBuilder(
|
||||
builder: (sheetContext, setSheetState) => DraggableScrollableSheet(
|
||||
expand: false,
|
||||
initialChildSize: 0.65,
|
||||
minChildSize: 0.4,
|
||||
maxChildSize: 0.95,
|
||||
builder: (_, scrollController) => Column(
|
||||
children: [
|
||||
BottomSheetHeader(
|
||||
title: sheetContext.l10n.channels_editChannelTitle(
|
||||
channel.index,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
controller: scrollController,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
TextField(
|
||||
controller: nameController,
|
||||
decoration: InputDecoration(
|
||||
labelText: sheetContext.l10n.channels_channelName,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
inputFormatters: const [
|
||||
Utf8LengthLimitingTextInputFormatter(
|
||||
maxRadioNameBytes,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: pskController,
|
||||
decoration: InputDecoration(
|
||||
labelText: sheetContext.l10n.channels_pskHex,
|
||||
border: const OutlineInputBorder(),
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(Icons.casino),
|
||||
tooltip:
|
||||
sheetContext.l10n.channels_generateRandomPsk,
|
||||
onPressed: () {
|
||||
final bytes = randomBytes(16);
|
||||
pskController.text = Channel.formatPskHex(bytes);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(sheetContext.l10n.channels_smazCompression),
|
||||
value: smazEnabled,
|
||||
onChanged: (value) => setSheetState(() {
|
||||
smazEnabled = value;
|
||||
if (smazEnabled) {
|
||||
cyr2latEnabled = false;
|
||||
}
|
||||
}),
|
||||
),
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(
|
||||
sheetContext.l10n.channels_cyr2latCompression,
|
||||
),
|
||||
subtitle: Text(
|
||||
sheetContext.l10n.channels_cyr2latCompressionDscr,
|
||||
),
|
||||
value: cyr2latEnabled,
|
||||
onChanged: (value) => setSheetState(() {
|
||||
cyr2latEnabled = value;
|
||||
if (cyr2latEnabled) {
|
||||
smazEnabled = false;
|
||||
}
|
||||
}),
|
||||
),
|
||||
if (cyr2latEnabled) ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 8),
|
||||
child: DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
initialValue: selectedCyr2LatProfileId,
|
||||
decoration: InputDecoration(
|
||||
labelText: sheetContext
|
||||
.l10n
|
||||
.channels_cyr2latSettingsSubheading,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
items: appSettingsService.settings.cyr2latProfiles
|
||||
.map((profile) {
|
||||
return DropdownMenuItem(
|
||||
value: profile.id,
|
||||
child: Text(
|
||||
profile.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
})
|
||||
.toList(),
|
||||
onChanged: (value) => setSheetState(() {
|
||||
selectedCyr2LatProfileId = value;
|
||||
}),
|
||||
),
|
||||
),
|
||||
],
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(sheetContext.l10n.urlImage_enable),
|
||||
subtitle: loadLinkImages
|
||||
? null
|
||||
: Text(
|
||||
sheetContext
|
||||
.l10n
|
||||
.urlImage_disabledInAppSettings,
|
||||
),
|
||||
value: urlImagesEnabled,
|
||||
onChanged: loadLinkImages
|
||||
? (value) =>
|
||||
setSheetState(() => urlImagesEnabled = value)
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
onPressed: () => Navigator.pop(sheetContext),
|
||||
child: Text(sheetContext.l10n.common_cancel),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: FilledButton(
|
||||
onPressed: () async {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
final name = nameController.text.trim();
|
||||
final pskHex = pskController.text.trim();
|
||||
if (name.isEmpty) {
|
||||
showDismissibleSnackBar(
|
||||
sheetContext,
|
||||
content: Text(
|
||||
sheetContext.l10n.channels_enterChannelName,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Uint8List psk;
|
||||
try {
|
||||
psk = Channel.parsePskHex(pskHex);
|
||||
} on FormatException {
|
||||
showDismissibleSnackBar(
|
||||
sheetContext,
|
||||
content: Text(
|
||||
sheetContext.l10n.channels_pskMustBe32Hex,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.pop(sheetContext);
|
||||
try {
|
||||
await connector.setChannel(
|
||||
channel.index,
|
||||
name,
|
||||
psk,
|
||||
);
|
||||
await connector.setChannelSmazEnabled(
|
||||
channel.index,
|
||||
smazEnabled,
|
||||
);
|
||||
await connector.setChannelCyr2LatEnabled(
|
||||
channel.index,
|
||||
cyr2latEnabled,
|
||||
);
|
||||
if (urlImagesEnabled != initialUrlImagesEnabled) {
|
||||
await connector.setChannelUrlImagesEnabled(
|
||||
channel.index,
|
||||
urlImagesEnabled,
|
||||
);
|
||||
}
|
||||
await connector.setChannelCyr2LatProfileId(
|
||||
channel.index,
|
||||
selectedCyr2LatProfileId,
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(
|
||||
context.l10n.channels_channelUpdated(name),
|
||||
),
|
||||
);
|
||||
onSaved?.call(
|
||||
Channel(
|
||||
index: channel.index,
|
||||
name: name,
|
||||
psk: psk,
|
||||
),
|
||||
);
|
||||
} catch (e, st) {
|
||||
debugPrint(st.toString());
|
||||
if (!context.mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(
|
||||
context.l10n.channels_channelUpdateFailed(
|
||||
'$e',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(sheetContext.l10n.common_save),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Asks before deleting a channel. [onDeleted] runs once the radio deleted it.
|
||||
void confirmDeleteChannel(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
Channel channel, {
|
||||
VoidCallback? onDeleted,
|
||||
}) {
|
||||
final channelLabel = channel.name.isEmpty
|
||||
? context.l10n.channels_channelIndex(channel.index)
|
||||
: channel.name;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(dialogContext.l10n.channels_deleteChannel),
|
||||
content: Text(
|
||||
dialogContext.l10n.channels_deleteChannelConfirm(channelLabel),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: Text(dialogContext.l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(dialogContext);
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
try {
|
||||
await connector.deleteChannel(channel.index);
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(
|
||||
context.l10n.channels_channelDeleted(channelLabel),
|
||||
),
|
||||
);
|
||||
onDeleted?.call();
|
||||
} catch (e, st) {
|
||||
if (!context.mounted) return;
|
||||
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(
|
||||
context.l10n.channels_channelDeleteFailed(channelLabel),
|
||||
),
|
||||
);
|
||||
|
||||
// Preserve existing logging (if it was there)
|
||||
debugPrint('Failed to delete channel: $e\n$st');
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
dialogContext.l10n.common_delete,
|
||||
style: TextStyle(color: Theme.of(dialogContext).colorScheme.error),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Owns a sheet's [TextEditingController]s so they are disposed together with
|
||||
/// the sheet's widgets (after its exit animation) instead of being leaked.
|
||||
class _SheetTextControllers extends StatefulWidget {
|
||||
|
||||
+172
-112
@@ -9,6 +9,7 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import '../utils/app_logger.dart';
|
||||
import '../utils/platform_info.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
|
||||
import '../connector/meshcore_connector.dart';
|
||||
import '../connector/meshcore_protocol.dart';
|
||||
@@ -41,11 +42,14 @@ import '../widgets/message_bubble_frame.dart';
|
||||
import '../widgets/reaction_chips.dart';
|
||||
import '../widgets/chat_day_separator.dart';
|
||||
import 'channel_message_path_screen.dart';
|
||||
import 'contacts_screen.dart' show confirmRemoveContact;
|
||||
import 'map_screen.dart';
|
||||
import 'repeater_hub_screen.dart';
|
||||
import '../widgets/emoji_picker.dart';
|
||||
import '../widgets/gif_message.dart';
|
||||
import '../widgets/jump_to_bottom_button.dart';
|
||||
import '../widgets/routing_sheet.dart';
|
||||
import '../widgets/room_login_dialog.dart';
|
||||
import '../widgets/radio_stats_entry.dart';
|
||||
import '../widgets/sync_progress_overlay.dart';
|
||||
import '../widgets/translated_message_content.dart';
|
||||
@@ -452,120 +456,135 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
),
|
||||
centerTitle: false,
|
||||
bottom: const SyncProgressAppBarBottom(),
|
||||
actions: [
|
||||
const RadioStatsIconButton(),
|
||||
if (!_searching)
|
||||
IconButton(
|
||||
tooltip: context.l10n.chatSearch_tooltip,
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: _openSearch,
|
||||
),
|
||||
Consumer<MeshCoreConnector>(
|
||||
builder: (context, connector, _) {
|
||||
final contact = _resolveContact(connector);
|
||||
actionsPadding: const EdgeInsetsDirectional.only(end: 4),
|
||||
// While searching the field gets the whole bar; the leading arrow
|
||||
// closes the search.
|
||||
actions: _searching
|
||||
? null
|
||||
: [
|
||||
const RadioStatsIconButton(),
|
||||
IconButton(
|
||||
tooltip: context.l10n.chatSearch_tooltip,
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: _openSearch,
|
||||
),
|
||||
Consumer<MeshCoreConnector>(
|
||||
builder: (context, connector, _) {
|
||||
final contact = _resolveContact(connector);
|
||||
final isRoom = contact.type == advTypeRoom;
|
||||
final readOnly = isRadioReadOnly(connector);
|
||||
|
||||
return PopupMenuButton<String>(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
onSelected: (value) {
|
||||
switch (value) {
|
||||
case 'routing':
|
||||
ContactRoutingSheet.show(context, contact: contact);
|
||||
case 'info':
|
||||
_showContactInfo(context);
|
||||
case 'settings':
|
||||
_showContactSettings(context);
|
||||
case 'background':
|
||||
showChatBackgroundSheet(
|
||||
context,
|
||||
ChatBackgroundService.contactKey(contact),
|
||||
);
|
||||
case 'telemetry':
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
TelemetryScreen(contact: widget.contact),
|
||||
return PopupMenuButton<String>(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
onSelected: (value) {
|
||||
switch (value) {
|
||||
case 'routing':
|
||||
ContactRoutingSheet.show(context, contact: contact);
|
||||
case 'info':
|
||||
_showContactInfo(context);
|
||||
case 'settings':
|
||||
_showContactSettings(context);
|
||||
case 'background':
|
||||
showChatBackgroundSheet(
|
||||
context,
|
||||
ChatBackgroundService.contactKey(contact),
|
||||
);
|
||||
case 'telemetry':
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
TelemetryScreen(contact: widget.contact),
|
||||
),
|
||||
);
|
||||
case 'roomManagement':
|
||||
_showRoomManagementLogin(contact);
|
||||
case 'clearChat':
|
||||
_confirmClearChat(context, connector);
|
||||
case 'removeContact':
|
||||
confirmRemoveContact(
|
||||
context,
|
||||
connector,
|
||||
contact,
|
||||
onRemoved: () {
|
||||
if (mounted) Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'routing',
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.route,
|
||||
label: context.l10n.routing_title,
|
||||
),
|
||||
),
|
||||
);
|
||||
case 'clearChat':
|
||||
_confirmClearChat(context, connector);
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'routing',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.route, size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.routing_title),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'info',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.info_outline, size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.contact_info),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'telemetry',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.bar_chart, size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.contact_telemetry),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'settings',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.settings, size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.contact_settings),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'background',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.wallpaper, size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.chatBackground_title),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'clearChat',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.delete,
|
||||
size: 20,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
PopupMenuItem(
|
||||
value: 'info',
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.info_outline,
|
||||
label: context.l10n.contact_info,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
context.l10n.contact_clearChat,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
PopupMenuItem(
|
||||
value: 'telemetry',
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.bar_chart,
|
||||
label: context.l10n.contact_telemetry,
|
||||
),
|
||||
),
|
||||
if (isRoom)
|
||||
PopupMenuItem(
|
||||
value: 'roomManagement',
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.room_preferences,
|
||||
label: context.l10n.room_management,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'settings',
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.settings,
|
||||
label: context.l10n.contact_settings,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'background',
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.wallpaper,
|
||||
label: context.l10n.chatBackground_title,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'clearChat',
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.delete,
|
||||
label: context.l10n.contact_clearChat,
|
||||
color: readOnly
|
||||
? null
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'removeContact',
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.person_remove,
|
||||
label: context.l10n.contacts_removeFromContacts,
|
||||
color: readOnly
|
||||
? null
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: _showSearchResults
|
||||
? _buildSearchResults(_loadSearchEntries)
|
||||
@@ -840,7 +859,8 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
|
||||
/// Shares the radio's own position as a map marker. Shares the text send
|
||||
/// guard and cooldown so it can't race or flood alongside typed messages.
|
||||
Future<void> _shareMyLocation(MeshCoreConnector connector) {
|
||||
Future<void> _shareMyLocation(MeshCoreConnector connector) async {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
return shareMyLocationMarker(
|
||||
context: context,
|
||||
connector: connector,
|
||||
@@ -857,10 +877,14 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
Future<void> _sendMessageInner(MeshCoreConnector connector) async {
|
||||
final text = _textController.text.trim();
|
||||
if (text.isEmpty) return;
|
||||
// Before anything clears the text box: offline the draft must stay.
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
if (!_sendGuard.checkCooldown(context)) return;
|
||||
|
||||
final translation = await translateOutgoingText(context, text);
|
||||
if (translation == null || !mounted) return;
|
||||
// The link can drop while the translation runs.
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
var outgoingText = translation.text;
|
||||
|
||||
final maxBytes = maxContactMessageBytes();
|
||||
@@ -912,7 +936,8 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
context,
|
||||
message: context.l10n.chat_clearChatConfirm,
|
||||
);
|
||||
if (confirmed) {
|
||||
if (!context.mounted) return;
|
||||
if (confirmed && ensureRadioConnected(context)) {
|
||||
connector.clearMessagesForContact(widget.contact);
|
||||
}
|
||||
}
|
||||
@@ -981,6 +1006,30 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
return PathHelper.splitPathBytes(pathBytes, hashWidth).length;
|
||||
}
|
||||
|
||||
/// Room management needs its own login (it may be as admin), as from the
|
||||
/// contact list.
|
||||
void _showRoomManagementLogin(Contact room) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => RoomLoginDialog(
|
||||
room: room,
|
||||
onLogin: (password, isAdmin) {
|
||||
if (!mounted) return;
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => RepeaterHubScreen(
|
||||
repeater: room,
|
||||
password: password,
|
||||
isAdmin: isAdmin,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showContactInfo(BuildContext context) {
|
||||
final connector = Provider.of<MeshCoreConnector>(context, listen: false);
|
||||
final contact = _resolveContact(connector);
|
||||
@@ -1326,6 +1375,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
}
|
||||
|
||||
void _showMessageActions(Message message, Contact contact) {
|
||||
final readOnly = isRadioReadOnly(context.read<MeshCoreConnector>());
|
||||
final translationService = context.read<TranslationService>();
|
||||
final canTranslateMessage =
|
||||
translationService.canTranslateIncoming(
|
||||
@@ -1350,6 +1400,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
// Can't react to your own messages
|
||||
if (!message.isOutgoing)
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: const Icon(Icons.add_reaction_outlined),
|
||||
title: Text(context.l10n.chat_addReaction),
|
||||
onTap: () {
|
||||
@@ -1408,6 +1459,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
),
|
||||
if (message.isOutgoing && message.status == MessageStatus.failed)
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: const Icon(Icons.refresh),
|
||||
title: Text(context.l10n.common_retry),
|
||||
onTap: () {
|
||||
@@ -1427,13 +1479,18 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
),
|
||||
const Divider(height: 1),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
Icons.delete_outline,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
color: readOnly ? null : Theme.of(context).colorScheme.error,
|
||||
),
|
||||
title: Text(
|
||||
context.l10n.common_delete,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
style: TextStyle(
|
||||
color: readOnly
|
||||
? null
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -1449,6 +1506,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
}
|
||||
|
||||
Future<void> _deleteMessage(Message message) async {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
await context.read<MeshCoreConnector>().deleteMessage(message);
|
||||
if (!mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
@@ -1458,6 +1516,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
}
|
||||
|
||||
void _retryMessage(Message message) {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
final connector = Provider.of<MeshCoreConnector>(context, listen: false);
|
||||
connector.resendMessage(_resolveContact(connector), message);
|
||||
showDismissibleSnackBar(
|
||||
@@ -1478,6 +1537,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
}
|
||||
|
||||
void _sendReaction(Message message, Contact senderContact, String emoji) {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final emojiIndex = ReactionHelper.emojiToIndex(emoji);
|
||||
if (emojiIndex == null) return; // Unknown emoji, skip
|
||||
|
||||
@@ -13,6 +13,7 @@ import '../models/community.dart';
|
||||
import '../storage/community_store.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../utils/channel_qr.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
import '../widgets/adaptive_app_bar_title.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../widgets/qr_scanner_widget.dart';
|
||||
@@ -89,7 +90,7 @@ class _CommunityQrScannerScreenState extends State<CommunityQrScannerScreen> {
|
||||
});
|
||||
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
_communityStore.setPublicKeyHex = connector.selfPublicKeyHex;
|
||||
_communityStore.setPublicKeyHex = connector.storageKeyHex;
|
||||
// Set when this screen is about to pop: keep the spinner up so the camera
|
||||
// doesn't restart on a closing route and detect the code again.
|
||||
var leaving = false;
|
||||
@@ -468,9 +469,10 @@ class _CommunityQrScannerScreenState extends State<CommunityQrScannerScreen> {
|
||||
Community community,
|
||||
bool addPublicChannel,
|
||||
) async {
|
||||
if (!ensureRadioConnected(context)) return false;
|
||||
// Save community to local storage
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
_communityStore.setPublicKeyHex = connector.selfPublicKeyHex;
|
||||
_communityStore.setPublicKeyHex = connector.storageKeyHex;
|
||||
await _communityStore.addCommunity(community);
|
||||
|
||||
// Optionally add the community public channel to the device. Only trust
|
||||
|
||||
+200
-210
@@ -21,8 +21,8 @@ import '../services/ui_view_state_service.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../utils/contact_search.dart';
|
||||
import '../storage/contact_group_store.dart';
|
||||
import '../utils/dialog_utils.dart';
|
||||
import '../utils/disconnect_navigation_mixin.dart';
|
||||
import '../widgets/connect_sheet.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
import '../utils/emoji_utils.dart';
|
||||
import '../utils/route_transitions.dart';
|
||||
import '../widgets/contact_visuals.dart';
|
||||
@@ -70,8 +70,7 @@ class ContactsScreen extends StatefulWidget {
|
||||
State<ContactsScreen> createState() => _ContactsScreenState();
|
||||
}
|
||||
|
||||
class _ContactsScreenState extends State<ContactsScreen>
|
||||
with DisconnectNavigationMixin {
|
||||
class _ContactsScreenState extends State<ContactsScreen> {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
final ContactGroupStore _groupStore = ContactGroupStore();
|
||||
MeshCoreConnector? _scopeSyncConnector;
|
||||
@@ -205,7 +204,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
}
|
||||
|
||||
Future<void> _loadGroups() async {
|
||||
final selfPublicKeyHex = context.read<MeshCoreConnector>().selfPublicKeyHex;
|
||||
final selfPublicKeyHex = context.read<MeshCoreConnector>().storageKeyHex;
|
||||
if (selfPublicKeyHex.isEmpty) {
|
||||
return;
|
||||
}
|
||||
@@ -220,7 +219,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
}
|
||||
|
||||
Future<void> _saveGroups() async {
|
||||
final selfPublicKeyHex = context.read<MeshCoreConnector>().selfPublicKeyHex;
|
||||
final selfPublicKeyHex = context.read<MeshCoreConnector>().storageKeyHex;
|
||||
if (selfPublicKeyHex.isEmpty) {
|
||||
return;
|
||||
}
|
||||
@@ -229,11 +228,11 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
}
|
||||
|
||||
bool _hasGroupStoreScope(MeshCoreConnector connector) {
|
||||
return connector.selfPublicKeyHex.isNotEmpty;
|
||||
return connector.storageKeyHex.isNotEmpty;
|
||||
}
|
||||
|
||||
void _syncGroupScopeIfNeeded(MeshCoreConnector connector) {
|
||||
final selfPublicKeyHex = connector.selfPublicKeyHex;
|
||||
final selfPublicKeyHex = connector.storageKeyHex;
|
||||
if (selfPublicKeyHex.isEmpty ||
|
||||
selfPublicKeyHex == _loadedGroupScopeKeyHex) {
|
||||
return;
|
||||
@@ -430,11 +429,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
Widget build(BuildContext context) {
|
||||
final connector = context.watch<MeshCoreConnector>();
|
||||
|
||||
// Auto-navigate back to scanner if disconnected
|
||||
if (!checkConnectionAndNavigate(connector)) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final readOnly = isRadioReadOnly(connector);
|
||||
final allowBack = !connector.isConnected;
|
||||
return PopScope(
|
||||
canPop: allowBack,
|
||||
@@ -448,12 +443,9 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
tooltip: context.l10n.contacts_moreOptions,
|
||||
itemBuilder: (context) => <PopupMenuEntry<dynamic>>[
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.person_add_rounded),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.discoveredContacts_Title),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.person_add_rounded,
|
||||
label: context.l10n.discoveredContacts_Title,
|
||||
),
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
@@ -463,22 +455,18 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.paste),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.contacts_addContactFromClipboard),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.paste,
|
||||
label: context.l10n.contacts_addContactFromClipboard,
|
||||
),
|
||||
onTap: () => _contactImport(),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.qr_code_scanner),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.contacts_scanQrCode),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.qr_code_scanner,
|
||||
label: context.l10n.contacts_scanQrCode,
|
||||
),
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
@@ -489,66 +477,43 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.connect_without_contact),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.contacts_zeroHopAdvert),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.connect_without_contact,
|
||||
label: context.l10n.contacts_zeroHopAdvert,
|
||||
),
|
||||
onTap: () => _sendSelfAdvert(connector, flood: false),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.cell_tower),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.contacts_floodAdvert),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.cell_tower,
|
||||
label: context.l10n.contacts_floodAdvert,
|
||||
),
|
||||
onTap: () => _sendSelfAdvert(connector, flood: true),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.copy),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.contacts_copyAdvertToClipboard),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.copy,
|
||||
label: context.l10n.contacts_copyAdvertToClipboard,
|
||||
),
|
||||
onTap: () => _contactExport(Uint8List.fromList([])),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.radar),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.manualTrace_menuItem),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.radar,
|
||||
label: context.l10n.manualTrace_menuItem,
|
||||
),
|
||||
onTap: () => ManualPathTraceScreen.open(context),
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
connectionMenuItem(this.context, context),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.logout,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.common_disconnect),
|
||||
],
|
||||
),
|
||||
onTap: () => _disconnect(context, connector),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const ThemedIcon(ThemeIconSlot.settings),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.settings_title),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
leading: const ThemedIcon(ThemeIconSlot.settings, size: 20),
|
||||
label: context.l10n.settings_title,
|
||||
),
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
@@ -568,10 +533,12 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
Expanded(child: _buildContactsBody(context, connector)),
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => _showAddContactSheet(context),
|
||||
child: const Icon(Icons.person_add),
|
||||
),
|
||||
floatingActionButton: readOnly
|
||||
? null
|
||||
: FloatingActionButton(
|
||||
onPressed: () => _showAddContactSheet(context),
|
||||
child: const Icon(Icons.person_add),
|
||||
),
|
||||
bottomNavigationBar: SafeArea(
|
||||
top: false,
|
||||
child: QuickSwitchBar(
|
||||
@@ -637,13 +604,6 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _disconnect(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
) async {
|
||||
await showDisconnectDialog(context, connector);
|
||||
}
|
||||
|
||||
ContactGroup? _selectedGroupForName(String selectedGroupName) {
|
||||
if (selectedGroupName == contactsAllGroupsValue) return null;
|
||||
for (final group in _groups) {
|
||||
@@ -824,17 +784,9 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem<String>(
|
||||
value: _manageGroupsValue,
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.group_add),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
menuContext.l10n.contacts_manageGroups,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.group_add,
|
||||
label: menuContext.l10n.contacts_manageGroups,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -1112,7 +1064,11 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
),
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () => connector.getContacts(),
|
||||
// Offline there is no radio to refresh from.
|
||||
onRefresh: () async {
|
||||
if (isRadioReadOnly(connector)) return;
|
||||
await connector.getContacts();
|
||||
},
|
||||
child: filteredAndSorted.isEmpty
|
||||
? LayoutBuilder(
|
||||
builder: (context, constraints) => ListView(
|
||||
@@ -1287,9 +1243,12 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
// Check if this is a repeater
|
||||
if (contact.type == advTypeRepeater) {
|
||||
_showRepeaterLogin(context, contact);
|
||||
} else if (contact.type == advTypeRoom) {
|
||||
} else if (contact.type == advTypeRoom &&
|
||||
!isRadioReadOnly(context.read<MeshCoreConnector>())) {
|
||||
_showRoomLogin(context, contact, RoomLoginDestination.chat);
|
||||
} else {
|
||||
// Offline a room opens straight onto its saved history, read-only:
|
||||
// logging in needs the radio.
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final unread = connector.getUnreadCountForContactKey(
|
||||
contact.publicKeyHex,
|
||||
@@ -1336,6 +1295,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
}
|
||||
|
||||
void _showRepeaterLogin(BuildContext context, Contact repeater) {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => RepeaterLoginDialog(
|
||||
@@ -1362,6 +1322,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
Contact room,
|
||||
RoomLoginDestination destination,
|
||||
) {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => RoomLoginDialog(
|
||||
@@ -1622,6 +1583,9 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
final isRepeater = contact.type == advTypeRepeater;
|
||||
final isRoom = contact.type == advTypeRoom;
|
||||
final isFavorite = contact.isFavorite;
|
||||
// Everything here except the header talks to the radio.
|
||||
final readOnly = isRadioReadOnly(connector);
|
||||
Color? tint(Color color) => readOnly ? null : color;
|
||||
|
||||
showMeshSheet(
|
||||
context,
|
||||
@@ -1636,7 +1600,8 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
),
|
||||
if (isRepeater) ...[
|
||||
ListTile(
|
||||
leading: Icon(Icons.radar, color: MeshPalette.signal),
|
||||
enabled: !readOnly,
|
||||
leading: Icon(Icons.radar, color: tint(MeshPalette.signal)),
|
||||
title: Text(context.l10n.contacts_ping),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -1660,7 +1625,11 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.cell_tower, color: MeshPalette.warn),
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
Icons.cell_tower,
|
||||
color: tint(MeshPalette.warn),
|
||||
),
|
||||
title: Text(context.l10n.contacts_manageRepeater),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -1669,7 +1638,8 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
),
|
||||
] else if (isRoom) ...[
|
||||
ListTile(
|
||||
leading: Icon(Icons.radar, color: MeshPalette.signal),
|
||||
enabled: !readOnly,
|
||||
leading: Icon(Icons.radar, color: tint(MeshPalette.signal)),
|
||||
title: Text(context.l10n.contacts_pathTrace),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -1695,7 +1665,11 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.meeting_room, color: MeshPalette.blue),
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
Icons.meeting_room,
|
||||
color: tint(MeshPalette.blue),
|
||||
),
|
||||
title: Text(context.l10n.contacts_roomLogin),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -1703,9 +1677,10 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
Icons.room_preferences,
|
||||
color: MeshPalette.warn,
|
||||
color: tint(MeshPalette.warn),
|
||||
),
|
||||
title: Text(context.l10n.room_management),
|
||||
onTap: () {
|
||||
@@ -1720,7 +1695,8 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
] else ...[
|
||||
if (contact.pathLength > 0)
|
||||
ListTile(
|
||||
leading: Icon(Icons.radar, color: MeshPalette.signal),
|
||||
enabled: !readOnly,
|
||||
leading: Icon(Icons.radar, color: tint(MeshPalette.signal)),
|
||||
title: Text(context.l10n.contacts_chatTraceRoute),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -1745,9 +1721,10 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
),
|
||||
],
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
isFavorite ? Icons.star : Icons.star_border,
|
||||
color: MeshPalette.warn,
|
||||
color: tint(MeshPalette.warn),
|
||||
),
|
||||
title: Text(
|
||||
isFavorite
|
||||
@@ -1763,6 +1740,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: const Icon(Icons.copy),
|
||||
title: Text(context.l10n.contacts_ShareContact),
|
||||
onTap: () {
|
||||
@@ -1771,6 +1749,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: const Icon(Icons.connect_without_contact),
|
||||
title: Text(context.l10n.contacts_ShareContactZeroHop),
|
||||
onTap: () {
|
||||
@@ -1779,17 +1758,20 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
Icons.delete,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
color: tint(Theme.of(context).colorScheme.error),
|
||||
),
|
||||
title: Text(
|
||||
context.l10n.contacts_removeFromContacts,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
style: TextStyle(
|
||||
color: tint(Theme.of(context).colorScheme.error),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
_confirmDelete(context, connector, contact);
|
||||
confirmRemoveContact(context, connector, contact);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
@@ -1809,81 +1791,84 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
.toInt();
|
||||
return Uint8List.fromList(contact.publicKey.sublist(0, width));
|
||||
}
|
||||
}
|
||||
|
||||
void _confirmDelete(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
Contact contact,
|
||||
) {
|
||||
var keepHistory = false;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) => StatefulBuilder(
|
||||
builder: (dialogContext, setDialogState) => AlertDialog(
|
||||
scrollable: true,
|
||||
title: Text(context.l10n.contacts_removeFromContacts),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
/// Asks before removing a contact from the radio. [onRemoved] runs once it
|
||||
/// was removed.
|
||||
void confirmRemoveContact(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
Contact contact, {
|
||||
VoidCallback? onRemoved,
|
||||
}) {
|
||||
var keepHistory = false;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) => StatefulBuilder(
|
||||
builder: (dialogContext, setDialogState) => AlertDialog(
|
||||
scrollable: true,
|
||||
title: Text(context.l10n.contacts_removeFromContacts),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(context.l10n.contacts_removeFromContactsConfirm(contact.name)),
|
||||
if (connector.autoAddsContactType(contact.type)) ...[
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
context.l10n.contacts_removeFromContactsConfirm(contact.name),
|
||||
),
|
||||
if (connector.autoAddsContactType(contact.type)) ...[
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
context.l10n.contacts_removeAutoAddNote,
|
||||
style: TextStyle(
|
||||
color: Theme.of(dialogContext).colorScheme.error,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
context.l10n.contacts_removeAutoAddNote,
|
||||
style: TextStyle(
|
||||
color: Theme.of(dialogContext).colorScheme.error,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
],
|
||||
CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
value: keepHistory,
|
||||
title: Text(context.l10n.contacts_keepChatHistory),
|
||||
onChanged: (value) =>
|
||||
setDialogState(() => keepHistory = value ?? false),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: Text(context.l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(dialogContext);
|
||||
try {
|
||||
await connector.removeContact(
|
||||
contact,
|
||||
keepMessages: keepHistory,
|
||||
);
|
||||
} catch (e) {
|
||||
appLogger.warn(
|
||||
'Remove contact failed: $e',
|
||||
tag: 'ContactsScreen',
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.contacts_removeFailed),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
context.l10n.contacts_remove,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
value: keepHistory,
|
||||
title: Text(context.l10n.contacts_keepChatHistory),
|
||||
onChanged: (value) =>
|
||||
setDialogState(() => keepHistory = value ?? false),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: Text(context.l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(dialogContext);
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
try {
|
||||
await connector.removeContact(
|
||||
contact,
|
||||
keepMessages: keepHistory,
|
||||
);
|
||||
onRemoved?.call();
|
||||
} catch (e) {
|
||||
appLogger.warn(
|
||||
'Remove contact failed: $e',
|
||||
tag: 'ContactsScreen',
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.contacts_removeFailed),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
context.l10n.contacts_remove,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class _ContactTile extends StatelessWidget {
|
||||
@@ -1996,44 +1981,49 @@ class _ContactTile extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
// Key prefix + path + last seen
|
||||
Row(
|
||||
// Key prefix + path, then last seen: on the same line when
|
||||
// both fit (time at the end), otherwise the time drops to
|
||||
// its own line instead of being cut off in long locales.
|
||||
Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 8,
|
||||
runSpacing: 2,
|
||||
children: [
|
||||
_KeyPrefixBadge(
|
||||
prefix: contact.publicKeyPrefixHex(pathHashByteWidth),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_KeyPrefixBadge(
|
||||
prefix: contact.publicKeyPrefixHex(
|
||||
pathHashByteWidth,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
contact.pathLabel(
|
||||
context.l10n,
|
||||
pathHashByteWidth: pathHashByteWidth,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
contact.pathLabel(
|
||||
context.l10n,
|
||||
pathHashByteWidth: pathHashByteWidth,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
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
|
||||
? scheme.primary
|
||||
: scheme.onSurfaceVariant,
|
||||
),
|
||||
Text(
|
||||
formatContactLastSeen(context.l10n, lastSeen),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 12.5,
|
||||
color: unreadCount > 0
|
||||
? scheme.primary
|
||||
: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -22,6 +22,7 @@ import '../widgets/list_filter_widget.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../widgets/node_scan_sheet.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
|
||||
class DiscoveryScreen extends StatefulWidget {
|
||||
const DiscoveryScreen({super.key});
|
||||
@@ -57,6 +58,7 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final connector = context.watch<MeshCoreConnector>();
|
||||
final readOnly = isRadioReadOnly(connector);
|
||||
|
||||
final discoveredContacts = connector.discoveredContacts;
|
||||
final filteredAndSorted = _filterAndSortContacts(
|
||||
@@ -96,36 +98,30 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
|
||||
itemBuilder: (context) => <PopupMenuEntry<String>>[
|
||||
PopupMenuItem<String>(
|
||||
value: 'export',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.upload_file),
|
||||
const SizedBox(width: 8),
|
||||
Text(l10n.discoveredContacts_export),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.upload_file,
|
||||
label: l10n.discoveredContacts_export,
|
||||
),
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
value: 'import',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.download),
|
||||
const SizedBox(width: 8),
|
||||
Text(l10n.discoveredContacts_import),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.download,
|
||||
label: l10n.discoveredContacts_import,
|
||||
),
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem<String>(
|
||||
value: 'delete_all',
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.delete,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.discoveredContacts_deleteContactAll),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.delete,
|
||||
label: context.l10n.discoveredContacts_deleteContactAll,
|
||||
iconColor: readOnly
|
||||
? null
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -283,7 +279,9 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
|
||||
IconButton(
|
||||
tooltip: context.l10n.discoveredContacts_addContact,
|
||||
icon: const Icon(Icons.person_add_alt_1),
|
||||
onPressed: () => _addContact(context, contact, connector),
|
||||
onPressed: isRadioReadOnly(connector)
|
||||
? null
|
||||
: () => _addContact(context, contact, connector),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -296,6 +294,7 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
|
||||
Contact contact,
|
||||
MeshCoreConnector connector,
|
||||
) async {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
try {
|
||||
final imported = await connector.importDiscoveredContact(contact);
|
||||
if (!context.mounted) return;
|
||||
@@ -354,6 +353,7 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
|
||||
onTap: () => Navigator.of(sheetContext).pop('copy_contact'),
|
||||
),
|
||||
ListTile(
|
||||
enabled: !isRadioReadOnly(connector),
|
||||
leading: const Icon(Icons.delete),
|
||||
title: Text(l10n.discoveredContacts_deleteContact),
|
||||
onTap: () => Navigator.of(sheetContext).pop('delete_contact'),
|
||||
|
||||
@@ -18,6 +18,7 @@ import '../services/map_tile_cache_service.dart';
|
||||
import '../utils/route_transitions.dart';
|
||||
import '../connector/meshcore_connector.dart';
|
||||
import '../widgets/app_bar.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../widgets/path_map_scaffold.dart';
|
||||
import '../widgets/quick_switch_bar.dart';
|
||||
import '../icons/los_icon.dart';
|
||||
@@ -372,12 +373,9 @@ class _LineOfSightMapScreenState extends State<LineOfSightMapScreen> {
|
||||
PopupMenuItem(
|
||||
value: 'clear',
|
||||
enabled: !_loading,
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.delete_outline),
|
||||
const SizedBox(width: 10),
|
||||
Text(context.l10n.losClearAllPoints),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.delete_outline,
|
||||
label: context.l10n.losClearAllPoints,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -563,20 +561,28 @@ class _LineOfSightMapScreenState extends State<LineOfSightMapScreen> {
|
||||
}
|
||||
|
||||
Widget _headerMetric(IconData icon, String value) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, color: LosPalette.textMuted, size: 16),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
value,
|
||||
style: MeshTheme.mono(
|
||||
color: LosPalette.text,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
// Capped so very large text scales shrink the reading instead of pushing
|
||||
// the panel off a narrow screen.
|
||||
return ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 80),
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, color: LosPalette.textMuted, size: 16),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
value,
|
||||
style: MeshTheme.mono(
|
||||
color: LosPalette.text,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -200,12 +200,12 @@ class _ManualPathTraceScreenState extends State<ManualPathTraceScreen> {
|
||||
ButtonSegment(
|
||||
value: true,
|
||||
icon: const Icon(Icons.sync_alt),
|
||||
label: Text(l10n.map_pathTraceModeRoundTrip),
|
||||
label: MeshSegmentLabel(l10n.map_pathTraceModeRoundTrip),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: false,
|
||||
icon: const Icon(Icons.arrow_forward),
|
||||
label: Text(l10n.map_pathTraceModeAsEntered),
|
||||
label: MeshSegmentLabel(l10n.map_pathTraceModeAsEntered),
|
||||
),
|
||||
],
|
||||
selected: {_returnPath},
|
||||
|
||||
+62
-99
@@ -29,9 +29,10 @@ import '../services/network_map/network_map_api_client.dart';
|
||||
import '../services/ui_view_state_service.dart';
|
||||
import '../storage/prefs_manager.dart';
|
||||
import '../utils/contact_search.dart';
|
||||
import '../utils/disconnect_navigation_mixin.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
import '../utils/battery_utils.dart';
|
||||
import '../utils/route_transitions.dart';
|
||||
import '../widgets/connect_sheet.dart';
|
||||
import '../widgets/map_poi_cluster.dart';
|
||||
import '../widgets/marker_label_dialog.dart';
|
||||
import '../widgets/network_map_online_layer.dart';
|
||||
@@ -74,7 +75,7 @@ class MapScreen extends StatefulWidget {
|
||||
State<MapScreen> createState() => _MapScreenState();
|
||||
}
|
||||
|
||||
class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
class _MapScreenState extends State<MapScreen> {
|
||||
// Zoom level at which node labels start to appear
|
||||
static const double _labelZoomThreshold = 14.0;
|
||||
// Below this zoom, nearby nodes collapse into clusters.
|
||||
@@ -513,9 +514,7 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
_MapConnectorSnapshot.fromConnector,
|
||||
);
|
||||
final connector = connectorSnapshot.connector;
|
||||
if (!checkConnectionAndNavigate(connector)) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final readOnly = isRadioReadOnly(connector);
|
||||
final settings = context.select<AppSettingsService, AppSettings>(
|
||||
(service) => service.settings,
|
||||
);
|
||||
@@ -767,12 +766,9 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
connector.selfLatitude != null &&
|
||||
connector.selfLongitude != null)
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.radar),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.contacts_pathTrace),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.radar,
|
||||
label: context.l10n.contacts_pathTrace,
|
||||
),
|
||||
onTap: () => _openPathTrace(
|
||||
connector,
|
||||
@@ -784,23 +780,18 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
),
|
||||
if (!_isBuildingPathTrace)
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.radar),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.manualTrace_menuItem),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.radar,
|
||||
label: context.l10n.manualTrace_menuItem,
|
||||
),
|
||||
onTap: () => ManualPathTraceScreen.open(context),
|
||||
),
|
||||
if (!_isBuildingPathTrace)
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const LosIcon(),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.map_lineOfSight),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
leading: const LosIcon(size: 20),
|
||||
label: context.l10n.map_lineOfSight,
|
||||
),
|
||||
onTap: () {
|
||||
final candidates = <LineOfSightEndpoint>[];
|
||||
@@ -839,26 +830,14 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
);
|
||||
},
|
||||
),
|
||||
connectionMenuItem(this.context, context),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.logout,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.common_disconnect),
|
||||
],
|
||||
),
|
||||
onTap: () => _disconnect(context, connector),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const ThemedIcon(ThemeIconSlot.settings),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.settings_title),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
leading: const ThemedIcon(
|
||||
ThemeIconSlot.settings,
|
||||
size: 20,
|
||||
),
|
||||
label: context.l10n.settings_title,
|
||||
),
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
@@ -1710,33 +1689,37 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
],
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'$count',
|
||||
style: MeshTheme.mono(
|
||||
fontSize: count >= 100 ? 13 : 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: MapPalette.markerOutline,
|
||||
),
|
||||
),
|
||||
if (online > 0)
|
||||
Container(
|
||||
width: 7,
|
||||
height: 7,
|
||||
margin: const EdgeInsets.only(top: 1),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: MapPalette.online,
|
||||
border: Border.all(
|
||||
color: MapPalette.markerOutline,
|
||||
width: 1,
|
||||
),
|
||||
// The marker has a fixed size; large text scales shrink to fit it.
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'$count',
|
||||
style: MeshTheme.mono(
|
||||
fontSize: count >= 100 ? 13 : 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: MapPalette.markerOutline,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (online > 0)
|
||||
Container(
|
||||
width: 7,
|
||||
height: 7,
|
||||
margin: const EdgeInsets.only(top: 1),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: MapPalette.online,
|
||||
border: Border.all(
|
||||
color: MapPalette.markerOutline,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -2204,19 +2187,19 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
ButtonSegment(
|
||||
value: MapSourceOption.local,
|
||||
icon: const Icon(Icons.radio, size: 20),
|
||||
label: Text(l10n.networkMap_sourceLocal),
|
||||
label: MeshSegmentLabel(l10n.networkMap_sourceLocal),
|
||||
tooltip: l10n.networkMap_sourceLocalHint,
|
||||
),
|
||||
ButtonSegment(
|
||||
value: MapSourceOption.online,
|
||||
icon: const Icon(Icons.public, size: 20),
|
||||
label: Text(l10n.networkMap_sourceOnline),
|
||||
label: MeshSegmentLabel(l10n.networkMap_sourceOnline),
|
||||
tooltip: l10n.networkMap_sourceOnlineHint,
|
||||
),
|
||||
ButtonSegment(
|
||||
value: MapSourceOption.both,
|
||||
icon: const Icon(Icons.layers, size: 20),
|
||||
label: Text(l10n.networkMap_sourceBoth),
|
||||
label: MeshSegmentLabel(l10n.networkMap_sourceBoth),
|
||||
tooltip: l10n.networkMap_sourceBothHint,
|
||||
),
|
||||
],
|
||||
@@ -3200,33 +3183,6 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _disconnect(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
) async {
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(context.l10n.common_disconnect),
|
||||
content: Text(context.l10n.map_disconnectConfirm),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, false),
|
||||
child: Text(context.l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, true),
|
||||
child: Text(context.l10n.common_disconnect),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (confirmed == true) {
|
||||
await connector.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void _showMarkerInfo(_SharedMarker marker) {
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -3348,6 +3304,7 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
required MeshCoreConnector connector,
|
||||
required LatLng position,
|
||||
}) {
|
||||
final readOnly = isRadioReadOnly(connector);
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (sheetContext) => SafeArea(
|
||||
@@ -3355,6 +3312,7 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: const Icon(Icons.place),
|
||||
title: Text(context.l10n.map_shareMarkerHere),
|
||||
onTap: () {
|
||||
@@ -3369,6 +3327,7 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: const Icon(Icons.my_location),
|
||||
title: Text(context.l10n.map_setAsMyLocation),
|
||||
onTap: () {
|
||||
@@ -4175,12 +4134,16 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
ButtonSegment(
|
||||
value: true,
|
||||
icon: const Icon(Icons.sync_alt),
|
||||
label: Text(l10n.map_pathTraceModeRoundTrip),
|
||||
label: MeshSegmentLabel(
|
||||
l10n.map_pathTraceModeRoundTrip,
|
||||
),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: false,
|
||||
icon: const Icon(Icons.arrow_forward),
|
||||
label: Text(l10n.map_pathTraceModeAsEntered),
|
||||
label: MeshSegmentLabel(
|
||||
l10n.map_pathTraceModeAsEntered,
|
||||
),
|
||||
),
|
||||
],
|
||||
selected: {returnPath},
|
||||
|
||||
@@ -30,50 +30,52 @@ class MessageFilterSettingsScreen extends StatelessWidget {
|
||||
title: AdaptiveAppBarTitle(l10n.messageFilter_title),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 24),
|
||||
children: [
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: SwitchListTile(
|
||||
key: const ValueKey('messageFilter_enabledSwitch'),
|
||||
contentPadding: _tilePadding,
|
||||
secondary: const Icon(Icons.filter_alt_outlined, size: 24),
|
||||
title: Text(l10n.messageFilter_enabled),
|
||||
subtitle: Text(l10n.messageFilter_enabledSubtitle),
|
||||
value: settings.enabled,
|
||||
onChanged: (value) => service.updateSettings(
|
||||
service.settings.copyWith(enabled: value),
|
||||
body: MeshSettingsTileTheme(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 24),
|
||||
children: [
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: SwitchListTile(
|
||||
key: const ValueKey('messageFilter_enabledSwitch'),
|
||||
contentPadding: _tilePadding,
|
||||
secondary: const Icon(Icons.filter_alt_outlined, size: 24),
|
||||
title: Text(l10n.messageFilter_enabled),
|
||||
subtitle: Text(l10n.messageFilter_enabledSubtitle),
|
||||
value: settings.enabled,
|
||||
onChanged: (value) => service.updateSettings(
|
||||
service.settings.copyWith(enabled: value),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SectionHeader(l10n.messageFilter_displayTitle),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: Column(
|
||||
children: [
|
||||
_DisplayModeOptions(service: service),
|
||||
const Divider(height: 1, indent: 16),
|
||||
const _FilteredMessagesTile(),
|
||||
],
|
||||
SectionHeader(l10n.messageFilter_displayTitle),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: Column(
|
||||
children: [
|
||||
_DisplayModeOptions(service: service),
|
||||
const Divider(height: 1, indent: 16),
|
||||
const _FilteredMessagesTile(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SectionHeader(l10n.messageFilter_rulesSection),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _RulesList(service: service),
|
||||
),
|
||||
SectionHeader(l10n.messageFilter_rulesSection),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _RulesList(service: service),
|
||||
),
|
||||
|
||||
SectionHeader(l10n.messageFilter_automaticSection),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _AutomaticOptions(service: service),
|
||||
),
|
||||
],
|
||||
SectionHeader(l10n.messageFilter_automaticSection),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _AutomaticOptions(service: service),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:meshcore_open/l10n/l10n.dart';
|
||||
import 'package:meshcore_open/models/contact.dart';
|
||||
import 'package:meshcore_open/storage/region_store.dart';
|
||||
import 'package:meshcore_open/theme/mesh_theme.dart';
|
||||
import 'package:meshcore_open/utils/radio_guard.dart';
|
||||
import 'package:meshcore_open/widgets/mesh_ui.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -56,7 +57,7 @@ class _RegionManagementScreenState extends State<RegionManagementScreen> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
_regionStore.setPublicKeyHex = connector.selfPublicKeyHex;
|
||||
_regionStore.setPublicKeyHex = connector.storageKeyHex;
|
||||
_loadRegions();
|
||||
}
|
||||
|
||||
@@ -72,6 +73,8 @@ class _RegionManagementScreenState extends State<RegionManagementScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
// Fetching asks repeaters over the mesh; offline it is unavailable.
|
||||
final canFetch = !_isFetchingRegions && !context.radioReadOnly;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(l10n.settings_regionManagement_screenTitle),
|
||||
@@ -91,7 +94,7 @@ class _RegionManagementScreenState extends State<RegionManagementScreen> {
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: const Icon(Icons.travel_explore),
|
||||
onPressed: _isFetchingRegions ? null : _showFetchRegionsDialog,
|
||||
onPressed: canFetch ? _showFetchRegionsDialog : null,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -123,6 +126,7 @@ class _RegionManagementScreenState extends State<RegionManagementScreen> {
|
||||
|
||||
Widget _buildEmptyState(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final canFetch = !_isFetchingRegions && !context.radioReadOnly;
|
||||
return Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
@@ -148,7 +152,7 @@ class _RegionManagementScreenState extends State<RegionManagementScreen> {
|
||||
FilledButton.icon(
|
||||
icon: const Icon(Icons.travel_explore),
|
||||
label: Text(l10n.settings_regionFetchFromRepeaters),
|
||||
onPressed: _isFetchingRegions ? null : _showFetchRegionsDialog,
|
||||
onPressed: canFetch ? _showFetchRegionsDialog : null,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
OutlinedButton.icon(
|
||||
@@ -294,13 +298,7 @@ class _RegionManagementScreenState extends State<RegionManagementScreen> {
|
||||
final l10n = context.l10n;
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
|
||||
if (!connector.isConnected) {
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(l10n.settings_notConnectedError),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
final knownRepeaters = connector.contacts
|
||||
.where((contact) => contact.type == advTypeRepeater)
|
||||
.toList();
|
||||
|
||||
@@ -10,6 +10,7 @@ import '../connector/meshcore_protocol.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../widgets/confirm_clear_dialog.dart';
|
||||
import '../widgets/debug_frame_viewer.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../widgets/radio_disconnected_banner.dart';
|
||||
import '../services/repeater_command_service.dart';
|
||||
import '../widgets/routing_sheet.dart';
|
||||
@@ -435,34 +436,25 @@ class _RepeaterCliScreenState extends State<RepeaterCliScreen> {
|
||||
PopupMenuItem(
|
||||
value: 'copy',
|
||||
enabled: hasHistory,
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.copy),
|
||||
const SizedBox(width: 8),
|
||||
Text(l10n.repeater_cliCopyTranscript),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.copy,
|
||||
label: l10n.repeater_cliCopyTranscript,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'share',
|
||||
enabled: hasHistory,
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.share),
|
||||
const SizedBox(width: 8),
|
||||
Text(l10n.repeater_cliShareTranscript),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.share,
|
||||
label: l10n.repeater_cliShareTranscript,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'debug',
|
||||
enabled: connected,
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.bug_report),
|
||||
const SizedBox(width: 8),
|
||||
Text(l10n.repeater_debugNextCommand),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.bug_report,
|
||||
label: l10n.repeater_debugNextCommand,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -13,6 +13,7 @@ import '../services/app_settings_service.dart';
|
||||
import '../services/repeater_command_service.dart';
|
||||
import '../services/storage_service.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../widgets/mesh_nav_tile.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../widgets/radio_disconnected_banner.dart';
|
||||
import '../widgets/routing_sheet.dart';
|
||||
@@ -895,83 +896,85 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
|
||||
)
|
||||
: null,
|
||||
),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
child: _isLoading && _controller('name').text.isEmpty
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: ListView(
|
||||
padding: const EdgeInsets.only(bottom: 32),
|
||||
children: [
|
||||
const RadioDisconnectedBanner(),
|
||||
// Keep this slot when the hint hides: shifting the cards
|
||||
// below would hand their state (e.g. an expanded
|
||||
// Advanced card) to the wrong card.
|
||||
if (_loadedKeys.isEmpty && !_loadingAll)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16),
|
||||
child: MeshCard(
|
||||
// The button sits under the message so neither is
|
||||
// squeezed on narrow screens or large text.
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.info_outline, size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
context.l10n.repeater_settingsNotLoaded,
|
||||
body: MeshSettingsTileTheme(
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
child: _isLoading && _controller('name').text.isEmpty
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: ListView(
|
||||
padding: const EdgeInsets.only(bottom: 32),
|
||||
children: [
|
||||
const RadioDisconnectedBanner(),
|
||||
// Keep this slot when the hint hides: shifting the cards
|
||||
// below would hand their state (e.g. an expanded
|
||||
// Advanced card) to the wrong card.
|
||||
if (_loadedKeys.isEmpty && !_loadingAll)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16),
|
||||
child: MeshCard(
|
||||
// The button sits under the message so neither is
|
||||
// squeezed on narrow screens or large text.
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.info_outline, size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
context.l10n.repeater_settingsNotLoaded,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
TextButton(
|
||||
onPressed: _isLoading || !connected
|
||||
? null
|
||||
: _refreshAll,
|
||||
child: Text(context.l10n.repeater_refreshAll),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
TextButton(
|
||||
onPressed: _isLoading || !connected
|
||||
? null
|
||||
: _refreshAll,
|
||||
child: Text(context.l10n.repeater_refreshAll),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
const SizedBox.shrink(),
|
||||
_buildSectionCard(
|
||||
l10n.repeater_basicSettings,
|
||||
RepeaterSettingSection.basic,
|
||||
extra: _buildPasswordFields(),
|
||||
),
|
||||
_buildRadioSettingsCard(),
|
||||
_buildSectionCard(
|
||||
l10n.repeater_locationSettings,
|
||||
RepeaterSettingSection.location,
|
||||
),
|
||||
_buildSectionCard(
|
||||
l10n.repeater_features,
|
||||
RepeaterSettingSection.features,
|
||||
extra: [_buildClockSyncToggle()],
|
||||
),
|
||||
_buildSectionCard(
|
||||
l10n.repeater_networkHealth,
|
||||
RepeaterSettingSection.networkHealth,
|
||||
),
|
||||
_buildSectionCard(
|
||||
l10n.repeater_advertisementSettings,
|
||||
RepeaterSettingSection.advertisement,
|
||||
),
|
||||
_buildSectionCard(
|
||||
l10n.repeater_ownerInfo,
|
||||
RepeaterSettingSection.ownerInfo,
|
||||
),
|
||||
_buildActionsCard(),
|
||||
_buildAdvancedCard(),
|
||||
_buildKeysCard(),
|
||||
const SizedBox(height: 16),
|
||||
_buildDangerZoneCard(),
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
const SizedBox.shrink(),
|
||||
_buildSectionCard(
|
||||
l10n.repeater_basicSettings,
|
||||
RepeaterSettingSection.basic,
|
||||
extra: _buildPasswordFields(),
|
||||
),
|
||||
_buildRadioSettingsCard(),
|
||||
_buildSectionCard(
|
||||
l10n.repeater_locationSettings,
|
||||
RepeaterSettingSection.location,
|
||||
),
|
||||
_buildSectionCard(
|
||||
l10n.repeater_features,
|
||||
RepeaterSettingSection.features,
|
||||
extra: [_buildClockSyncToggle()],
|
||||
),
|
||||
_buildSectionCard(
|
||||
l10n.repeater_networkHealth,
|
||||
RepeaterSettingSection.networkHealth,
|
||||
),
|
||||
_buildSectionCard(
|
||||
l10n.repeater_advertisementSettings,
|
||||
RepeaterSettingSection.advertisement,
|
||||
),
|
||||
_buildSectionCard(
|
||||
l10n.repeater_ownerInfo,
|
||||
RepeaterSettingSection.ownerInfo,
|
||||
),
|
||||
_buildActionsCard(),
|
||||
_buildAdvancedCard(),
|
||||
_buildKeysCard(),
|
||||
const SizedBox(height: 16),
|
||||
_buildDangerZoneCard(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -1115,22 +1118,36 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
/// Dims a control whose remote value has not been fetched (or set) yet,
|
||||
/// so a placeholder position is not mistaken for the repeater's value.
|
||||
/// The control stays usable: setting it makes the value known.
|
||||
Widget _dimIfUnknown(String key, Widget child) {
|
||||
return AnimatedOpacity(
|
||||
opacity: _known(key) ? 1 : 0.6,
|
||||
duration: const Duration(milliseconds: 150),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildToggleControl(RepeaterSettingSpec spec) {
|
||||
final l10n = context.l10n;
|
||||
final helper = spec.helper?.call(l10n);
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SwitchListTile(
|
||||
title: Text(spec.label(l10n)),
|
||||
subtitle: helper == null ? null : Text(helper),
|
||||
// An unknown setting shows as off until fetched or set.
|
||||
value: _known(spec.key) && _values[spec.key] == true,
|
||||
onChanged: (value) {
|
||||
setState(() => _values[spec.key] = value);
|
||||
_markChanged(spec.key);
|
||||
},
|
||||
contentPadding: EdgeInsets.zero,
|
||||
child: _dimIfUnknown(
|
||||
spec.key,
|
||||
SwitchListTile(
|
||||
title: Text(spec.label(l10n)),
|
||||
subtitle: helper == null ? null : Text(helper),
|
||||
// An unknown setting shows as off until fetched or set.
|
||||
value: _known(spec.key) && _values[spec.key] == true,
|
||||
onChanged: (value) {
|
||||
setState(() => _values[spec.key] = value);
|
||||
_markChanged(spec.key);
|
||||
},
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildSpecRefreshButton(spec),
|
||||
@@ -1191,29 +1208,32 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: title),
|
||||
Expanded(child: _dimIfUnknown(key, title)),
|
||||
_buildSpecRefreshButton(spec),
|
||||
],
|
||||
),
|
||||
Slider(
|
||||
value: (value ?? lo).clamp(lo, hi).toDouble(),
|
||||
min: lo.toDouble(),
|
||||
max: hi.toDouble(),
|
||||
divisions: divisions,
|
||||
label: value == null ? null : display,
|
||||
onChanged: canDisable && (value == null || isOff)
|
||||
? null
|
||||
: (v) {
|
||||
// Snap to the step, counting from the low end.
|
||||
final snapped =
|
||||
lo + ((v - lo) / spec.step).floor() * spec.step;
|
||||
setState(
|
||||
() => _values[key] = spec.isInteger
|
||||
? snapped.round()
|
||||
: snapped,
|
||||
);
|
||||
_markChanged(key);
|
||||
},
|
||||
_dimIfUnknown(
|
||||
key,
|
||||
Slider(
|
||||
value: (value ?? lo).clamp(lo, hi).toDouble(),
|
||||
min: lo.toDouble(),
|
||||
max: hi.toDouble(),
|
||||
divisions: divisions,
|
||||
label: value == null ? null : display,
|
||||
onChanged: canDisable && (value == null || isOff)
|
||||
? null
|
||||
: (v) {
|
||||
// Snap to the step, counting from the low end.
|
||||
final snapped =
|
||||
lo + ((v - lo) / spec.step).floor() * spec.step;
|
||||
setState(
|
||||
() => _values[key] = spec.isInteger
|
||||
? snapped.round()
|
||||
: snapped,
|
||||
);
|
||||
_markChanged(key);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@ import '../widgets/get_node_banner.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
import '../review_mode/review_mode_entry.dart';
|
||||
import 'channels_screen.dart';
|
||||
import '../utils/main_navigation.dart';
|
||||
import 'tcp_screen.dart';
|
||||
import 'usb_screen.dart';
|
||||
|
||||
@@ -56,9 +56,7 @@ class _ScannerScreenState extends State<ScannerScreen> {
|
||||
isCurrentRoute &&
|
||||
!_changedNavigation) {
|
||||
_changedNavigation = true;
|
||||
Navigator.of(
|
||||
context,
|
||||
).push(MaterialPageRoute(builder: (context) => const ChannelsScreen()));
|
||||
navigateToMainAfterConnect(context);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -86,7 +84,14 @@ class _ScannerScreenState extends State<ScannerScreen> {
|
||||
void dispose() {
|
||||
_connector.removeListener(_connectionListener);
|
||||
unawaited(_bluetoothStateSubscription.cancel());
|
||||
if (!_changedNavigation) {
|
||||
// Only cancel a Bluetooth connection this screen started; a pending
|
||||
// auto-reconnect (state disconnected) or a USB/TCP/review link is left
|
||||
// alone, so peeking at the scanner from the main screens is harmless.
|
||||
final state = _connector.state;
|
||||
if (!_changedNavigation &&
|
||||
_connector.activeTransport == MeshCoreTransportType.bluetooth &&
|
||||
(state == MeshCoreConnectionState.connecting ||
|
||||
state == MeshCoreConnectionState.connected)) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
unawaited(_connector.disconnect(manual: true));
|
||||
});
|
||||
@@ -249,16 +254,6 @@ class _ScannerScreenState extends State<ScannerScreen> {
|
||||
subtitle: isBluetoothOff
|
||||
? context.l10n.scanner_bluetoothOffMessage
|
||||
: null,
|
||||
action: (isBluetoothOff || isScanning)
|
||||
? null
|
||||
: FilledButton.icon(
|
||||
onPressed: () {
|
||||
HapticFeedback.lightImpact();
|
||||
_toggleScan(connector);
|
||||
},
|
||||
icon: const Icon(Icons.bluetooth_searching),
|
||||
label: Text(context.l10n.scanner_scan),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import '../widgets/sync_progress_overlay.dart';
|
||||
import 'region_management_screen.dart';
|
||||
import 'backup_restore_screen.dart';
|
||||
import 'export_screen.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
|
||||
class SettingsScreen extends StatefulWidget {
|
||||
const SettingsScreen({super.key});
|
||||
@@ -238,14 +239,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
/// Guards a radio command: returns false (after telling the user) when the
|
||||
/// radio is not connected, because the connector silently ignores commands
|
||||
/// sent while disconnected and a success message would be a lie.
|
||||
bool _ensureConnected(BuildContext context, MeshCoreConnector connector) {
|
||||
if (connector.isConnected) return true;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.settings_notConnectedError),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
bool _ensureConnected(BuildContext context, MeshCoreConnector connector) =>
|
||||
ensureRadioConnected(context);
|
||||
|
||||
Widget _buildIdentityCardContent(
|
||||
BuildContext context,
|
||||
@@ -1148,14 +1143,13 @@ void _privacySettings(BuildContext context, MeshCoreConnector connector) {
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SwitchListTile(
|
||||
title: Text(l10n.settings_multiAck),
|
||||
subtitle: Text(l10n.settings_multiAckSubtitle),
|
||||
FeatureToggleRow(
|
||||
title: l10n.settings_multiAck,
|
||||
subtitle: l10n.settings_multiAckSubtitle,
|
||||
value: multiAcks == 1,
|
||||
onChanged: (value) {
|
||||
setDialogState(() => multiAcks = value ? 1 : 0);
|
||||
},
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
DropdownButtonFormField<int>(
|
||||
|
||||
@@ -12,7 +12,7 @@ import '../utils/platform_info.dart';
|
||||
import '../widgets/adaptive_app_bar_title.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
import 'channels_screen.dart';
|
||||
import '../utils/main_navigation.dart';
|
||||
import 'usb_screen.dart';
|
||||
|
||||
class TcpScreen extends StatefulWidget {
|
||||
@@ -63,9 +63,7 @@ class _TcpScreenState extends State<TcpScreen> {
|
||||
int.tryParse(_portController.text) ?? 0,
|
||||
);
|
||||
_navigatedToChannels = true;
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(builder: (_) => const ChannelsScreen()),
|
||||
);
|
||||
navigateToMainAfterConnect(context);
|
||||
}
|
||||
};
|
||||
_connector.addListener(_connectionListener);
|
||||
|
||||
@@ -38,22 +38,25 @@ class ThemesScreen extends StatelessWidget {
|
||||
itemBuilder: (_) => [
|
||||
PopupMenuItem(
|
||||
onTap: () => _importFile(context, settingsService),
|
||||
child: _MenuRow(
|
||||
Icons.file_open_outlined,
|
||||
l10n.themes_importFile,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.file_open_outlined,
|
||||
label: l10n.themes_importFile,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: () => _showImportDialog(context, settingsService),
|
||||
child: _MenuRow(
|
||||
Icons.content_paste_go_outlined,
|
||||
l10n.themes_pasteCode,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.content_paste_go_outlined,
|
||||
label: l10n.themes_pasteCode,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
enabled: myThemes.isNotEmpty,
|
||||
onTap: () => _exportFile(context, myThemes, 'meshcore-themes'),
|
||||
child: _MenuRow(Icons.ios_share, l10n.themes_exportAll),
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.ios_share,
|
||||
label: l10n.themes_exportAll,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -164,11 +167,17 @@ class ThemesScreen extends StatelessWidget {
|
||||
startFrom: preset,
|
||||
copyName: l10n.themes_copyName(preset.name),
|
||||
),
|
||||
child: _MenuRow(Icons.tune, l10n.themes_customize),
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.tune,
|
||||
label: l10n.themes_customize,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: () => _copyCode(context, preset),
|
||||
child: _MenuRow(Icons.copy, l10n.themes_copyCode),
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.copy,
|
||||
label: l10n.themes_copyCode,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -186,19 +195,28 @@ class ThemesScreen extends StatelessWidget {
|
||||
itemBuilder: (_) => [
|
||||
PopupMenuItem(
|
||||
onTap: () => _openEditor(context, existing: theme),
|
||||
child: _MenuRow(Icons.edit_outlined, l10n.common_edit),
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.edit_outlined,
|
||||
label: l10n.common_edit,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: () => _copyCode(context, theme),
|
||||
child: _MenuRow(Icons.copy, l10n.themes_copyCode),
|
||||
child: MeshMenuItemRow(icon: Icons.copy, label: l10n.themes_copyCode),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: () => _exportFile(context, [theme], themeFileStem(theme.name)),
|
||||
child: _MenuRow(Icons.ios_share, l10n.themes_exportFile),
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.ios_share,
|
||||
label: l10n.themes_exportFile,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: () => _confirmDelete(context, settingsService, theme),
|
||||
child: _MenuRow(Icons.delete_outline, l10n.common_delete),
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.delete_outline,
|
||||
label: l10n.common_delete,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -422,24 +440,6 @@ class _AutoHolidayNote extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _MenuRow extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
|
||||
const _MenuRow(this.icon, this.label);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(icon, size: 22),
|
||||
const SizedBox(width: 12),
|
||||
Flexible(child: Text(label)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ThemeTile extends StatelessWidget {
|
||||
final String name;
|
||||
final String? subtitle;
|
||||
|
||||
@@ -14,7 +14,7 @@ import '../widgets/adaptive_app_bar_title.dart';
|
||||
import '../widgets/empty_state.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
import 'channels_screen.dart';
|
||||
import '../utils/main_navigation.dart';
|
||||
import 'tcp_screen.dart';
|
||||
|
||||
class UsbScreen extends StatefulWidget {
|
||||
@@ -56,9 +56,7 @@ class _UsbScreenState extends State<UsbScreen> with WidgetsBindingObserver {
|
||||
_connector.isUsbTransportConnected &&
|
||||
!_navigatedToChannels) {
|
||||
_navigatedToChannels = true;
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(builder: (_) => const ChannelsScreen()),
|
||||
);
|
||||
navigateToMainAfterConnect(context);
|
||||
}
|
||||
};
|
||||
_connector.addListener(_connectionListener);
|
||||
|
||||
Reference in new issue
Block a user