mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
Merge branch 'main' into issue-fix-channel-edit-delete-actions
This commit is contained in:
commit
81a423d096
4 changed files with 47 additions and 11 deletions
|
|
@ -19,13 +19,13 @@ android {
|
|||
ndkVersion = flutter.ndkVersion
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
isCoreLibraryDesugaringEnabled = true
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_11.toString()
|
||||
jvmTarget = JavaVersion.VERSION_17.toString()
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'dart:math';
|
|||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:meshcore_open/storage/channel_message_store.dart';
|
||||
import 'package:meshcore_open/widgets/app_bar.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
|
@ -105,6 +106,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final connector = context.watch<MeshCoreConnector>();
|
||||
final channelMessageStore = ChannelMessageStore();
|
||||
|
||||
// Auto-navigate back to scanner if disconnected
|
||||
if (!checkConnectionAndNavigate(connector)) {
|
||||
|
|
@ -304,6 +306,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||
return _buildChannelTile(
|
||||
context,
|
||||
connector,
|
||||
channelMessageStore,
|
||||
channel,
|
||||
showDragHandle: true,
|
||||
dragIndex: index,
|
||||
|
|
@ -323,6 +326,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||
return _buildChannelTile(
|
||||
context,
|
||||
connector,
|
||||
channelMessageStore,
|
||||
channel,
|
||||
);
|
||||
},
|
||||
|
|
@ -352,6 +356,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||
Widget _buildChannelTile(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
ChannelMessageStore channelMessageStore,
|
||||
Channel channel, {
|
||||
bool showDragHandle = false,
|
||||
int? dragIndex,
|
||||
|
|
@ -468,7 +473,12 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||
);
|
||||
}
|
||||
},
|
||||
onLongPress: () => _showChannelActions(context, connector, channel),
|
||||
onLongPress: () => _showChannelActions(
|
||||
context,
|
||||
connector,
|
||||
channelMessageStore,
|
||||
channel,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -476,6 +486,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||
void _showChannelActions(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
ChannelMessageStore channelMessageStore,
|
||||
Channel channel,
|
||||
) {
|
||||
final parentContext = context;
|
||||
|
|
@ -529,7 +540,12 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||
Navigator.pop(sheetContext);
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
if (parentContext.mounted) {
|
||||
_confirmDeleteChannel(parentContext, connector, channel);
|
||||
_confirmDeleteChannel(
|
||||
context,
|
||||
connector,
|
||||
channelMessageStore,
|
||||
channel,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
|
|
@ -1487,6 +1503,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||
void _confirmDeleteChannel(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
ChannelMessageStore channelMessageStore,
|
||||
Channel channel,
|
||||
) {
|
||||
showDialog(
|
||||
|
|
@ -1506,19 +1523,38 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||
Navigator.pop(dialogContext);
|
||||
try {
|
||||
await connector.deleteChannel(channel.index);
|
||||
|
||||
channelMessageStore.clearChannelMessages(
|
||||
channel.index,
|
||||
);
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
context.l10n.channels_channelDeleted(channel.name),
|
||||
context.l10n.channels_channelDeleted(
|
||||
channel.name,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (e, st) {
|
||||
debugPrint(st.toString());
|
||||
if (!context.mounted) return;
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Failed to delete channel: $e')),
|
||||
SnackBar(
|
||||
content: Text(
|
||||
context.l10n.channels_channelDeleteFailed(
|
||||
channel.name,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Preserve existing logging (if it was there)
|
||||
debugPrint(
|
||||
'Failed to delete channel: $e\n$st',
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -513,10 +513,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
||||
sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.17.0"
|
||||
version: "1.18.0"
|
||||
mgrs_dart:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ dependencies:
|
|||
cached_network_image: ^3.4.1
|
||||
flutter_cache_manager: ^3.4.1
|
||||
flutter_foreground_task: ^9.2.0
|
||||
wakelock_plus: ^1.2.8
|
||||
wakelock_plus: ^1.4.0
|
||||
characters: ^1.4.0
|
||||
package_info_plus: ^9.0.0
|
||||
mobile_scanner: ^7.1.4 # QR/barcode scanning
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue