mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
disable location sharing if setting is not enabled.
This commit is contained in:
parent
6165629c6d
commit
6f32a793e8
2 changed files with 36 additions and 0 deletions
|
|
@ -938,6 +938,14 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||
|
||||
Future<void> _shareLocation() async {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final isGpsEnabled = connector.currentCustomVars?['gps'] == '1';
|
||||
if (!isGpsEnabled) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(context.l10n.chat_locationUnavailable)),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final lat = connector.selfLatitude;
|
||||
final lon = connector.selfLongitude;
|
||||
if (lat == null || lon == null) {
|
||||
|
|
@ -1142,6 +1150,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||
|
||||
Widget _buildMessageComposer() {
|
||||
final connector = context.watch<MeshCoreConnector>();
|
||||
final isGpsEnabled = connector.currentCustomVars?['gps'] == '1';
|
||||
final maxBytes = maxChannelMessageBytes(connector.selfName);
|
||||
final smazEncoder = connector.isChannelSmazEnabled(widget.channel.index)
|
||||
? Smaz.encodeIfSmaller
|
||||
|
|
@ -1185,12 +1194,21 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||
} else if (action == _ChannelChatInputAction.insertEmoji) {
|
||||
_showEmojiPickerForComposer(context);
|
||||
} else if (action == _ChannelChatInputAction.shareLocation) {
|
||||
if (!isGpsEnabled) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(context.l10n.chat_locationUnavailable),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
_shareLocation();
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: _ChannelChatInputAction.shareLocation,
|
||||
enabled: isGpsEnabled,
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.location_on, size: 20),
|
||||
|
|
|
|||
|
|
@ -499,6 +499,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||
}
|
||||
|
||||
Widget _buildInputBar(MeshCoreConnector connector) {
|
||||
final isGpsEnabled = connector.currentCustomVars?['gps'] == '1';
|
||||
final maxBytes = maxContactMessageBytes();
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
final smazEncoder =
|
||||
|
|
@ -527,12 +528,21 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||
} else if (action == _ChatInputAction.insertEmoji) {
|
||||
_showEmojiPicker(context);
|
||||
} else if (action == _ChatInputAction.shareLocation) {
|
||||
if (!isGpsEnabled) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(context.l10n.chat_locationUnavailable),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
_shareLocation(context.read<MeshCoreConnector>());
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: _ChatInputAction.shareLocation,
|
||||
enabled: isGpsEnabled,
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.my_location, size: 20),
|
||||
|
|
@ -688,6 +698,14 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||
}
|
||||
|
||||
Future<void> _shareLocation(MeshCoreConnector connector) async {
|
||||
final isGpsEnabled = connector.currentCustomVars?['gps'] == '1';
|
||||
if (!isGpsEnabled) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(context.l10n.chat_locationUnavailable)),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final lat = connector.selfLatitude;
|
||||
final lon = connector.selfLongitude;
|
||||
if (lat == null || lon == null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue