Merge dev into ez_import_export_5
Resolve pubspec.yaml conflict (keep dev's share_plus ^13.3.1 and file_selector), regenerate localizations, and add the missing map_labelUpdateHint translation for all locales.
This commit is contained in:
commit
3cfa6a786a
77 files changed
+4416
-360
No files matched your search
@@ -38,6 +38,7 @@ import '../widgets/received_image_message.dart';
|
||||
import '../widgets/byte_count_input.dart';
|
||||
import '../widgets/chat_day_separator.dart';
|
||||
import '../widgets/empty_state.dart';
|
||||
|
||||
import '../widgets/chat_zoom_wrapper.dart';
|
||||
import '../widgets/emoji_picker.dart';
|
||||
import '../widgets/gif_message.dart';
|
||||
@@ -2011,6 +2012,79 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
}
|
||||
|
||||
Widget _buildInputBar() {
|
||||
Future<String?> promptForMarkerLabel(
|
||||
BuildContext context, {
|
||||
required double lat,
|
||||
required double lon,
|
||||
required String defaultLabel,
|
||||
required String flags,
|
||||
}) async {
|
||||
final controller = TextEditingController(text: defaultLabel);
|
||||
controller.selection = TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: controller.text.length,
|
||||
);
|
||||
final focusNode = FocusNode();
|
||||
|
||||
final latStr = lat.toStringAsFixed(6);
|
||||
final lonStr = lon.toStringAsFixed(6);
|
||||
final prefix = 'm:$latStr,$lonStr|';
|
||||
final suffix = '|$flags';
|
||||
final overheadBytes = utf8.encode(prefix + suffix).length;
|
||||
final maxForContact = maxContactMessageBytes();
|
||||
final maxForChannel = maxChannelMessageBytes(null);
|
||||
final maxPayload = maxForContact < maxForChannel
|
||||
? maxForContact
|
||||
: maxForChannel;
|
||||
final allowedLabelBytes = (maxPayload - overheadBytes) > 0
|
||||
? (maxPayload - overheadBytes)
|
||||
: 0;
|
||||
|
||||
try {
|
||||
final result = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (dialogContext.mounted) {
|
||||
focusNode.requestFocus();
|
||||
controller.selection = TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: controller.text.length,
|
||||
);
|
||||
}
|
||||
});
|
||||
return AlertDialog(
|
||||
title: Text(dialogContext.l10n.map_pinLabel),
|
||||
content: ByteCountedTextField(
|
||||
focusNode: focusNode,
|
||||
maxBytes: allowedLabelBytes,
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
helperText: dialogContext.l10n.map_labelUpdateHint,
|
||||
helperMaxLines: 3,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, null),
|
||||
child: Text(dialogContext.l10n.common_cancel),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () =>
|
||||
Navigator.pop(dialogContext, controller.text.trim()),
|
||||
child: Text(dialogContext.l10n.common_share),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
return result;
|
||||
} finally {
|
||||
focusNode.dispose();
|
||||
controller.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
final connector = context.watch<MeshCoreConnector>();
|
||||
final maxBytes = maxChannelMessageBytes(connector.selfName);
|
||||
final settings = context.watch<AppSettingsService>().settings;
|
||||
@@ -2041,44 +2115,135 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
PopupMenuButton<String>(
|
||||
icon: const Icon(Icons.add_circle_outline),
|
||||
position: PopupMenuPosition.over,
|
||||
offset: Offset(0, showImageAction ? -112 : -64),
|
||||
tooltip: context.l10n.chat_selectSendAction,
|
||||
onSelected: (action) {
|
||||
switch (action) {
|
||||
case 'gif':
|
||||
_showGifPicker(context);
|
||||
break;
|
||||
case 'meshcore-image':
|
||||
_showImageSendPreview();
|
||||
break;
|
||||
}
|
||||
Builder(
|
||||
builder: (menuContext) {
|
||||
return IconButton(
|
||||
icon: const Icon(Icons.add_circle_outline),
|
||||
tooltip: context.l10n.chat_selectSendAction,
|
||||
onPressed: () async {
|
||||
final RenderBox button =
|
||||
menuContext.findRenderObject() as RenderBox;
|
||||
final RenderBox overlay =
|
||||
Overlay.of(menuContext).context.findRenderObject()
|
||||
as RenderBox;
|
||||
final Offset buttonOffset = button.localToGlobal(
|
||||
Offset.zero,
|
||||
ancestor: overlay,
|
||||
);
|
||||
final items = <PopupMenuEntry<String>>[
|
||||
PopupMenuItem(
|
||||
value: 'gif',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.gif_box),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.chat_sendGif),
|
||||
],
|
||||
),
|
||||
),
|
||||
];
|
||||
if (showImageAction) {
|
||||
items.add(
|
||||
PopupMenuItem(
|
||||
value: 'meshcore-image',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.image_outlined),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.chat_sendImageLora),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (context.read<MeshCoreConnector>().selfLatitude !=
|
||||
null &&
|
||||
context.read<MeshCoreConnector>().selfLongitude !=
|
||||
null) {
|
||||
items.add(
|
||||
PopupMenuItem(
|
||||
value: 'send-my-location',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.my_location),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.map_shareMarkerHere),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final menuHeight =
|
||||
items.length * kMinInteractiveDimension + 16;
|
||||
final menuTop = (buttonOffset.dy - menuHeight).clamp(
|
||||
8.0,
|
||||
overlay.size.height,
|
||||
);
|
||||
final position = RelativeRect.fromLTRB(
|
||||
buttonOffset.dx,
|
||||
menuTop,
|
||||
overlay.size.width -
|
||||
buttonOffset.dx -
|
||||
button.size.width,
|
||||
overlay.size.height - buttonOffset.dy,
|
||||
);
|
||||
|
||||
final selected = await showMenu<String>(
|
||||
context: menuContext,
|
||||
position: position,
|
||||
items: items,
|
||||
);
|
||||
if (!mounted || !menuContext.mounted) return;
|
||||
if (selected == null) return;
|
||||
switch (selected) {
|
||||
case 'gif':
|
||||
_showGifPicker(context);
|
||||
break;
|
||||
case 'meshcore-image':
|
||||
_showImageSendPreview();
|
||||
break;
|
||||
case 'send-my-location':
|
||||
final connector = context
|
||||
.read<MeshCoreConnector>();
|
||||
if (connector.selfLatitude == null ||
|
||||
connector.selfLongitude == null) {
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(
|
||||
context.l10n.map_connectToShareMarkers,
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
final lat = connector.selfLatitude!;
|
||||
final lon = connector.selfLongitude!;
|
||||
final initialLabel =
|
||||
connector.selfName?.isNotEmpty == true
|
||||
? connector.selfName!
|
||||
: context.l10n.map_sharedPin;
|
||||
final label = await promptForMarkerLabel(
|
||||
context,
|
||||
lat: lat,
|
||||
lon: lon,
|
||||
defaultLabel: initialLabel,
|
||||
flags: 'poi',
|
||||
);
|
||||
if (label == null || label.trim().isEmpty) break;
|
||||
if (!mounted || !menuContext.mounted) break;
|
||||
final connector2 = context
|
||||
.read<MeshCoreConnector>();
|
||||
final markerText =
|
||||
'm:${lat.toStringAsFixed(6)},${lon.toStringAsFixed(6)}|${label.trim()}|poi';
|
||||
connector2.sendChannelMessage(
|
||||
widget.channel,
|
||||
markerText,
|
||||
);
|
||||
break;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'gif',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.gif_box),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.chat_sendGif),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (showImageAction)
|
||||
PopupMenuItem(
|
||||
value: 'meshcore-image',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.image_outlined),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.chat_sendImageLora),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (settings.translationEnabled)
|
||||
MessageTranslationButton(
|
||||
@@ -2478,6 +2643,9 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
|
||||
void _copyMessageText(String text) {
|
||||
Clipboard.setData(ClipboardData(text: text));
|
||||
// Android shows its own clipboard chip; the snackbar is redundant there
|
||||
// and lingers over the input field after the chip dismisses.
|
||||
if (PlatformInfo.isAndroid) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.chat_messageCopied),
|
||||
|
||||
+172
-156
@@ -35,6 +35,7 @@ import 'community_qr_scanner_screen.dart';
|
||||
import 'contacts_screen.dart';
|
||||
import 'map_screen.dart';
|
||||
import 'settings_screen.dart';
|
||||
import '../review_mode/review_mode_banner.dart';
|
||||
|
||||
class ChannelsScreen extends StatefulWidget {
|
||||
final bool hideBackButton;
|
||||
@@ -166,172 +167,187 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
),
|
||||
],
|
||||
),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await context.read<MeshCoreConnector>().getChannels(force: true);
|
||||
},
|
||||
child: () {
|
||||
final channels = connector.channels;
|
||||
final waitingForFirstChannel =
|
||||
connector.isLoadingChannels && channels.isEmpty;
|
||||
body: Column(
|
||||
children: [
|
||||
const ReviewModeBanner(),
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await context.read<MeshCoreConnector>().getChannels(
|
||||
force: true,
|
||||
);
|
||||
},
|
||||
child: () {
|
||||
final channels = connector.channels;
|
||||
final waitingForFirstChannel =
|
||||
connector.isLoadingChannels && channels.isEmpty;
|
||||
|
||||
// Only block the list while the first channel is actively loading.
|
||||
// If the initial sync aborts, show cached/partial channels instead
|
||||
// of trapping the user behind an idle spinner.
|
||||
if (waitingForFirstChannel) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
// Only block the list while the first channel is actively loading.
|
||||
// If the initial sync aborts, show cached/partial channels instead
|
||||
// of trapping the user behind an idle spinner.
|
||||
if (waitingForFirstChannel) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (channels.isEmpty) {
|
||||
return ListView(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height - 200,
|
||||
child: EmptyState(
|
||||
icon: Icons.tag,
|
||||
title: context.l10n.channels_noChannelsConfigured,
|
||||
action: FilledButton.icon(
|
||||
onPressed: () => _addPublicChannel(context, connector),
|
||||
icon: const Icon(Icons.public),
|
||||
label: Text(context.l10n.channels_addPublicChannel),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
if (channels.isEmpty) {
|
||||
return ListView(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height - 200,
|
||||
child: EmptyState(
|
||||
icon: Icons.tag,
|
||||
title: context.l10n.channels_noChannelsConfigured,
|
||||
action: FilledButton.icon(
|
||||
onPressed: () =>
|
||||
_addPublicChannel(context, connector),
|
||||
icon: const Icon(Icons.public),
|
||||
label: Text(
|
||||
context.l10n.channels_addPublicChannel,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
final filteredChannels = _filterAndSortChannels(
|
||||
channels,
|
||||
connector,
|
||||
viewState,
|
||||
);
|
||||
final filteredChannels = _filterAndSortChannels(
|
||||
channels,
|
||||
connector,
|
||||
viewState,
|
||||
);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
decoration: InputDecoration(
|
||||
hintText: context.l10n.channels_searchChannels,
|
||||
prefixIcon: const Icon(Icons.search),
|
||||
suffixIcon: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (viewState.channelsSearchText.isNotEmpty)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
tooltip: context.l10n.common_clearSearch,
|
||||
onPressed: () {
|
||||
_searchDebounce?.cancel();
|
||||
_searchDebounce = null;
|
||||
_searchController.clear();
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
decoration: InputDecoration(
|
||||
hintText: context.l10n.channels_searchChannels,
|
||||
prefixIcon: const Icon(Icons.search),
|
||||
suffixIcon: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (viewState.channelsSearchText.isNotEmpty)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
tooltip: context.l10n.common_clearSearch,
|
||||
onPressed: () {
|
||||
_searchDebounce?.cancel();
|
||||
_searchDebounce = null;
|
||||
_searchController.clear();
|
||||
context
|
||||
.read<UiViewStateService>()
|
||||
.setChannelsSearchText('');
|
||||
},
|
||||
),
|
||||
_buildFilterButton(viewState),
|
||||
],
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
),
|
||||
onChanged: (value) {
|
||||
_searchDebounce?.cancel();
|
||||
_searchDebounce = Timer(
|
||||
const Duration(milliseconds: 300),
|
||||
() {
|
||||
if (!mounted) return;
|
||||
context
|
||||
.read<UiViewStateService>()
|
||||
.setChannelsSearchText('');
|
||||
.setChannelsSearchText(value);
|
||||
},
|
||||
),
|
||||
_buildFilterButton(viewState),
|
||||
],
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
),
|
||||
onChanged: (value) {
|
||||
_searchDebounce?.cancel();
|
||||
_searchDebounce = Timer(
|
||||
const Duration(milliseconds: 300),
|
||||
() {
|
||||
if (!mounted) return;
|
||||
context
|
||||
.read<UiViewStateService>()
|
||||
.setChannelsSearchText(value);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: filteredChannels.isEmpty
|
||||
? LayoutBuilder(
|
||||
builder: (context, constraints) => ListView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: constraints.maxHeight,
|
||||
),
|
||||
child: EmptyState(
|
||||
icon: Icons.search_off,
|
||||
title: context.l10n.channels_noChannelsFound,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: (viewState.channelsSortOption ==
|
||||
ChannelSortOption.manual &&
|
||||
viewState.channelsSearchText.isEmpty)
|
||||
? ReorderableListView.builder(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 8,
|
||||
bottom: 88,
|
||||
),
|
||||
buildDefaultDragHandles: false,
|
||||
itemCount: filteredChannels.length,
|
||||
onReorderItem: (oldIndex, newIndex) {
|
||||
final reordered = List<Channel>.from(
|
||||
filteredChannels,
|
||||
);
|
||||
final item = reordered.removeAt(oldIndex);
|
||||
reordered.insert(newIndex, item);
|
||||
unawaited(
|
||||
connector.setChannelOrder(
|
||||
reordered.map((c) => c.index).toList(),
|
||||
),
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, index) {
|
||||
final channel = filteredChannels[index];
|
||||
return _buildChannelTile(
|
||||
context,
|
||||
connector,
|
||||
channelMessageStore,
|
||||
channel,
|
||||
showDragHandle: true,
|
||||
dragIndex: index,
|
||||
listIndex: index,
|
||||
);
|
||||
},
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 8,
|
||||
bottom: 88,
|
||||
),
|
||||
itemCount: filteredChannels.length,
|
||||
itemBuilder: (context, index) {
|
||||
final channel = filteredChannels[index];
|
||||
return _buildChannelTile(
|
||||
context,
|
||||
connector,
|
||||
channelMessageStore,
|
||||
channel,
|
||||
listIndex: index,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}(),
|
||||
),
|
||||
Expanded(
|
||||
child: filteredChannels.isEmpty
|
||||
? LayoutBuilder(
|
||||
builder: (context, constraints) => ListView(
|
||||
physics:
|
||||
const AlwaysScrollableScrollPhysics(),
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: constraints.maxHeight,
|
||||
),
|
||||
child: EmptyState(
|
||||
icon: Icons.search_off,
|
||||
title: context
|
||||
.l10n
|
||||
.channels_noChannelsFound,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: (viewState.channelsSortOption ==
|
||||
ChannelSortOption.manual &&
|
||||
viewState.channelsSearchText.isEmpty)
|
||||
? ReorderableListView.builder(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 8,
|
||||
bottom: 88,
|
||||
),
|
||||
buildDefaultDragHandles: false,
|
||||
itemCount: filteredChannels.length,
|
||||
onReorderItem: (oldIndex, newIndex) {
|
||||
final reordered = List<Channel>.from(
|
||||
filteredChannels,
|
||||
);
|
||||
final item = reordered.removeAt(oldIndex);
|
||||
reordered.insert(newIndex, item);
|
||||
unawaited(
|
||||
connector.setChannelOrder(
|
||||
reordered.map((c) => c.index).toList(),
|
||||
),
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, index) {
|
||||
final channel = filteredChannels[index];
|
||||
return _buildChannelTile(
|
||||
context,
|
||||
connector,
|
||||
channelMessageStore,
|
||||
channel,
|
||||
showDragHandle: true,
|
||||
dragIndex: index,
|
||||
listIndex: index,
|
||||
);
|
||||
},
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 8,
|
||||
bottom: 88,
|
||||
),
|
||||
itemCount: filteredChannels.length,
|
||||
itemBuilder: (context, index) {
|
||||
final channel = filteredChannels[index];
|
||||
return _buildChannelTile(
|
||||
context,
|
||||
connector,
|
||||
channelMessageStore,
|
||||
channel,
|
||||
listIndex: index,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => _showAddChannelDialog(context),
|
||||
|
||||
@@ -472,6 +472,79 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
}
|
||||
|
||||
Widget _buildInputBar(MeshCoreConnector connector) {
|
||||
Future<String?> promptForMarkerLabel(
|
||||
BuildContext context, {
|
||||
required double lat,
|
||||
required double lon,
|
||||
required String defaultLabel,
|
||||
required String flags,
|
||||
}) async {
|
||||
final controller = TextEditingController(text: defaultLabel);
|
||||
controller.selection = TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: controller.text.length,
|
||||
);
|
||||
final focusNode = FocusNode();
|
||||
|
||||
final latStr = lat.toStringAsFixed(6);
|
||||
final lonStr = lon.toStringAsFixed(6);
|
||||
final prefix = 'm:$latStr,$lonStr|';
|
||||
final suffix = '|$flags';
|
||||
final overheadBytes = utf8.encode(prefix + suffix).length;
|
||||
final maxForContact = maxContactMessageBytes();
|
||||
final maxForChannel = maxChannelMessageBytes(null);
|
||||
final maxPayload = maxForContact < maxForChannel
|
||||
? maxForContact
|
||||
: maxForChannel;
|
||||
final allowedLabelBytes = (maxPayload - overheadBytes) > 0
|
||||
? (maxPayload - overheadBytes)
|
||||
: 0;
|
||||
|
||||
try {
|
||||
final result = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (dialogContext.mounted) {
|
||||
focusNode.requestFocus();
|
||||
controller.selection = TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: controller.text.length,
|
||||
);
|
||||
}
|
||||
});
|
||||
return AlertDialog(
|
||||
title: Text(dialogContext.l10n.map_pinLabel),
|
||||
content: ByteCountedTextField(
|
||||
focusNode: focusNode,
|
||||
maxBytes: allowedLabelBytes,
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
helperText: dialogContext.l10n.map_labelUpdateHint,
|
||||
helperMaxLines: 3,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, null),
|
||||
child: Text(dialogContext.l10n.common_cancel),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () =>
|
||||
Navigator.pop(dialogContext, controller.text.trim()),
|
||||
child: Text(dialogContext.l10n.common_share),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
return result;
|
||||
} finally {
|
||||
focusNode.dispose();
|
||||
controller.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
final maxBytes = maxContactMessageBytes();
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final settings = context.watch<AppSettingsService>().settings;
|
||||
@@ -486,10 +559,106 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.gif_box_outlined),
|
||||
tooltip: context.l10n.chat_sendGif,
|
||||
onPressed: () => _showGifPicker(context),
|
||||
Builder(
|
||||
builder: (menuContext) {
|
||||
return IconButton(
|
||||
icon: const Icon(Icons.add_circle_outline),
|
||||
tooltip: context.l10n.chat_selectSendAction,
|
||||
onPressed: () async {
|
||||
final RenderBox button =
|
||||
menuContext.findRenderObject() as RenderBox;
|
||||
final RenderBox overlay =
|
||||
Overlay.of(menuContext).context.findRenderObject()
|
||||
as RenderBox;
|
||||
final Offset buttonOffset = button.localToGlobal(
|
||||
Offset.zero,
|
||||
ancestor: overlay,
|
||||
);
|
||||
const menuHeight = 2 * kMinInteractiveDimension + 16;
|
||||
final menuTop = (buttonOffset.dy - menuHeight).clamp(
|
||||
8.0,
|
||||
overlay.size.height,
|
||||
);
|
||||
final position = RelativeRect.fromLTRB(
|
||||
buttonOffset.dx,
|
||||
menuTop,
|
||||
overlay.size.width -
|
||||
buttonOffset.dx -
|
||||
button.size.width,
|
||||
overlay.size.height - buttonOffset.dy,
|
||||
);
|
||||
|
||||
final selected = await showMenu<String>(
|
||||
context: menuContext,
|
||||
position: position,
|
||||
items: [
|
||||
PopupMenuItem(
|
||||
value: 'gif',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.gif_box),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.chat_sendGif),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'send-my-location',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.my_location),
|
||||
const SizedBox(width: 12),
|
||||
Text(context.l10n.map_shareMarkerHere),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
if (!mounted || !menuContext.mounted) return;
|
||||
if (selected == null) return;
|
||||
switch (selected) {
|
||||
case 'gif':
|
||||
_showGifPicker(context);
|
||||
break;
|
||||
case 'send-my-location':
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
if (connector.selfLatitude == null ||
|
||||
connector.selfLongitude == null) {
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(
|
||||
context.l10n.map_connectToShareMarkers,
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
final lat = connector.selfLatitude!;
|
||||
final lon = connector.selfLongitude!;
|
||||
final initialLabel =
|
||||
connector.selfName?.isNotEmpty == true
|
||||
? connector.selfName!
|
||||
: context.l10n.map_sharedPin;
|
||||
final label = await promptForMarkerLabel(
|
||||
context,
|
||||
lat: lat,
|
||||
lon: lon,
|
||||
defaultLabel: initialLabel,
|
||||
flags: 'poi',
|
||||
);
|
||||
if (label == null || label.trim().isEmpty) break;
|
||||
if (!mounted || !menuContext.mounted) break;
|
||||
final connector2 = context.read<MeshCoreConnector>();
|
||||
final markerText =
|
||||
'm:${lat.toStringAsFixed(6)},${lon.toStringAsFixed(6)}|${label.trim()}|poi';
|
||||
connector2.sendMessage(
|
||||
_resolveContact(connector2),
|
||||
markerText,
|
||||
);
|
||||
break;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
if (settings.translationEnabled)
|
||||
MessageTranslationButton(
|
||||
@@ -1279,6 +1448,9 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
|
||||
void _copyMessageText(String text) {
|
||||
Clipboard.setData(ClipboardData(text: text));
|
||||
// Android shows its own clipboard chip; the snackbar is redundant there
|
||||
// and lingers over the input field after the chip dismisses.
|
||||
if (PlatformInfo.isAndroid) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.chat_messageCopied),
|
||||
|
||||
@@ -37,6 +37,7 @@ import 'chat_screen.dart';
|
||||
import 'contact_qr_scanner_screen.dart';
|
||||
import 'discovery_screen.dart';
|
||||
import 'map_screen.dart';
|
||||
import '../review_mode/review_mode_banner.dart';
|
||||
import 'repeater_hub_screen.dart';
|
||||
import 'settings_screen.dart';
|
||||
|
||||
@@ -477,7 +478,12 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
),
|
||||
],
|
||||
),
|
||||
body: _buildContactsBody(context, connector),
|
||||
body: Column(
|
||||
children: [
|
||||
const ReviewModeBanner(),
|
||||
Expanded(child: _buildContactsBody(context, connector)),
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => _showAddContactSheet(context),
|
||||
child: const Icon(Icons.person_add),
|
||||
|
||||
+107
-29
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -36,6 +37,7 @@ import 'chat_screen.dart';
|
||||
import 'contacts_screen.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../widgets/byte_count_input.dart';
|
||||
import '../widgets/repeater_login_dialog.dart';
|
||||
import '../widgets/room_login_dialog.dart';
|
||||
import '../helpers/guessed_location_estimator.dart';
|
||||
@@ -3119,7 +3121,11 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
return;
|
||||
}
|
||||
|
||||
final label = await _promptForLabel(context, defaultLabel);
|
||||
final initialLabel =
|
||||
connector.selfName == null || connector.selfName!.isEmpty
|
||||
? defaultLabel
|
||||
: connector.selfName!;
|
||||
final label = await _promptForLabel(context, position, initialLabel, flags);
|
||||
if (label == null || !mounted) return;
|
||||
|
||||
final markerText = _formatMarkerMessage(position, label, flags);
|
||||
@@ -3135,42 +3141,114 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
|
||||
Future<String?> _promptForLabel(
|
||||
BuildContext context,
|
||||
LatLng position,
|
||||
String defaultLabel,
|
||||
String flags,
|
||||
) async {
|
||||
final controller = TextEditingController(text: defaultLabel);
|
||||
controller.selection = TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: controller.text.length,
|
||||
);
|
||||
return showDialog<String>(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(context.l10n.map_pinLabel),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
hintText: context.l10n.map_label,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: Text(context.l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
final label = controller.text.trim().replaceAll('|', '/');
|
||||
Navigator.pop(
|
||||
dialogContext,
|
||||
label.isEmpty ? defaultLabel : label,
|
||||
final focusNode = FocusNode();
|
||||
// Compute available bytes for the label taking marker overhead into
|
||||
// account. Use a conservative limit based on both contact and channel
|
||||
// message maxima.
|
||||
final lat = position.latitude.toStringAsFixed(6);
|
||||
final lon = position.longitude.toStringAsFixed(6);
|
||||
final prefix = 'm:$lat,$lon|';
|
||||
final suffix = '|$flags';
|
||||
final overheadBytes = utf8.encode(prefix + suffix).length;
|
||||
final maxForContact = maxContactMessageBytes();
|
||||
final maxForChannel = maxChannelMessageBytes(null);
|
||||
final maxPayload = maxForContact < maxForChannel
|
||||
? maxForContact
|
||||
: maxForChannel;
|
||||
final allowedLabelBytes = (maxPayload - overheadBytes) > 0
|
||||
? (maxPayload - overheadBytes)
|
||||
: 0;
|
||||
|
||||
try {
|
||||
final result = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
final scheme = Theme.of(dialogContext).colorScheme;
|
||||
// Request focus and ensure selection after the frame so the
|
||||
// keyboard appears and text is selected for replacement.
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (dialogContext.mounted) {
|
||||
focusNode.requestFocus();
|
||||
controller.selection = TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: controller.text.length,
|
||||
);
|
||||
},
|
||||
child: Text(context.l10n.common_continue),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
return AlertDialog(
|
||||
title: Text(dialogContext.l10n.map_pinLabel),
|
||||
content: ByteCountedTextField(
|
||||
focusNode: focusNode,
|
||||
maxBytes: allowedLabelBytes,
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
hintText: dialogContext.l10n.map_label,
|
||||
helperText: dialogContext.l10n.map_labelUpdateHint,
|
||||
helperMaxLines: 3,
|
||||
helperStyle: TextStyle(
|
||||
color: _overlaySecondaryTextColor,
|
||||
fontSize: 12,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(MeshRadii.md),
|
||||
borderSide: BorderSide(color: scheme.outlineVariant),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(MeshRadii.md),
|
||||
borderSide: BorderSide(color: scheme.outlineVariant),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(MeshRadii.md),
|
||||
borderSide: BorderSide(color: scheme.primary, width: 1.5),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: scheme.surfaceContainerLow,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 18,
|
||||
vertical: 12,
|
||||
),
|
||||
),
|
||||
onSubmitted: (_) {
|
||||
final label = controller.text.trim().replaceAll('|', '/');
|
||||
Navigator.pop(
|
||||
dialogContext,
|
||||
label.isEmpty ? defaultLabel : label,
|
||||
);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: Text(dialogContext.l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
final label = controller.text.trim().replaceAll('|', '/');
|
||||
Navigator.pop(
|
||||
dialogContext,
|
||||
label.isEmpty ? defaultLabel : label,
|
||||
);
|
||||
},
|
||||
child: Text(dialogContext.l10n.common_continue),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
return result;
|
||||
} finally {
|
||||
focusNode.dispose();
|
||||
controller.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
String _formatMarkerMessage(LatLng position, String label, String flags) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import '../widgets/device_tile.dart';
|
||||
import '../widgets/empty_state.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
import '../review_mode/review_mode_entry.dart';
|
||||
import 'channels_screen.dart';
|
||||
import 'tcp_screen.dart';
|
||||
import 'usb_screen.dart';
|
||||
@@ -103,7 +104,9 @@ class _ScannerScreenState extends State<ScannerScreen> {
|
||||
},
|
||||
)
|
||||
: null,
|
||||
title: AdaptiveAppBarTitle(context.l10n.scanner_title),
|
||||
title: ReviewModeLongPress(
|
||||
child: AdaptiveAppBarTitle(context.l10n.scanner_title),
|
||||
),
|
||||
centerTitle: true,
|
||||
automaticallyImplyLeading: false,
|
||||
actions: [
|
||||
|
||||
@@ -1231,6 +1231,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
bool autoAddRoomServer = false;
|
||||
bool autoAddSensor = false;
|
||||
bool overwriteOldest = false;
|
||||
final appSettingsService = context.read<AppSettingsService>();
|
||||
bool evictDiscoveredContactsEnabled =
|
||||
appSettingsService.settings.evictDiscoveredContactsEnabled;
|
||||
bool saving = false;
|
||||
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
autoAddChat = connector.autoAddUsers ?? false;
|
||||
@@ -1292,6 +1296,20 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
setDialogState(() => overwriteOldest = value);
|
||||
},
|
||||
),
|
||||
const Divider(height: 4),
|
||||
FeatureToggleRow(
|
||||
title: l10n.contactsSettings_evictDiscoveredContactsTitle,
|
||||
subtitle: l10n
|
||||
.contactsSettings_evictDiscoveredContactsSubtitle(
|
||||
MeshCoreConnector.maxDiscoveredContacts,
|
||||
),
|
||||
value: evictDiscoveredContactsEnabled,
|
||||
onChanged: (value) {
|
||||
setDialogState(
|
||||
() => evictDiscoveredContactsEnabled = value,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -1301,17 +1319,38 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
child: Text(l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
_sendSettings(
|
||||
connector,
|
||||
autoAddChat,
|
||||
autoAddRepeater,
|
||||
autoAddRoomServer,
|
||||
autoAddSensor,
|
||||
overwriteOldest,
|
||||
);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onPressed: saving
|
||||
? null
|
||||
: () async {
|
||||
setDialogState(() => saving = true);
|
||||
_sendSettings(
|
||||
connector,
|
||||
autoAddChat,
|
||||
autoAddRepeater,
|
||||
autoAddRoomServer,
|
||||
autoAddSensor,
|
||||
overwriteOldest,
|
||||
);
|
||||
try {
|
||||
await appSettingsService
|
||||
.setEvictDiscoveredContactsEnabled(
|
||||
evictDiscoveredContactsEnabled,
|
||||
);
|
||||
if (evictDiscoveredContactsEnabled) {
|
||||
await connector.trimDiscoveredContactsToLimit();
|
||||
}
|
||||
} catch (e) {
|
||||
if (!context.mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(l10n.settings_error(e.toString())),
|
||||
);
|
||||
setDialogState(() => saving = false);
|
||||
return;
|
||||
}
|
||||
if (!context.mounted) return;
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text(l10n.common_save),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user