|
|
|
@ -489,12 +489,13 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|
|
|
ChannelMessageStore channelMessageStore,
|
|
|
|
ChannelMessageStore channelMessageStore,
|
|
|
|
Channel channel,
|
|
|
|
Channel channel,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
final parentContext = context;
|
|
|
|
final settingsService = context.read<AppSettingsService>();
|
|
|
|
final settingsService = context.read<AppSettingsService>();
|
|
|
|
final isMuted = settingsService.isChannelMuted(channel.name);
|
|
|
|
final isMuted = settingsService.isChannelMuted(channel.name);
|
|
|
|
|
|
|
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
showModalBottomSheet(
|
|
|
|
context: context,
|
|
|
|
context: parentContext,
|
|
|
|
builder: (context) => SafeArea(
|
|
|
|
builder: (sheetContext) => SafeArea(
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
@ -502,10 +503,10 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|
|
|
leading: const Icon(Icons.edit_outlined),
|
|
|
|
leading: const Icon(Icons.edit_outlined),
|
|
|
|
title: Text(context.l10n.channels_editChannel),
|
|
|
|
title: Text(context.l10n.channels_editChannel),
|
|
|
|
onTap: () async {
|
|
|
|
onTap: () async {
|
|
|
|
Navigator.pop(context);
|
|
|
|
Navigator.pop(sheetContext);
|
|
|
|
await Future.delayed(const Duration(milliseconds: 100));
|
|
|
|
await Future.delayed(const Duration(milliseconds: 100));
|
|
|
|
if (context.mounted) {
|
|
|
|
if (parentContext.mounted) {
|
|
|
|
_showEditChannelDialog(context, connector, channel);
|
|
|
|
_showEditChannelDialog(parentContext, connector, channel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -521,7 +522,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|
|
|
: context.l10n.channels_muteChannel,
|
|
|
|
: context.l10n.channels_muteChannel,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onTap: () async {
|
|
|
|
onTap: () async {
|
|
|
|
Navigator.pop(context);
|
|
|
|
Navigator.pop(sheetContext);
|
|
|
|
if (isMuted) {
|
|
|
|
if (isMuted) {
|
|
|
|
await settingsService.unmuteChannel(channel.name);
|
|
|
|
await settingsService.unmuteChannel(channel.name);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -536,9 +537,9 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|
|
|
style: const TextStyle(color: Colors.red),
|
|
|
|
style: const TextStyle(color: Colors.red),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onTap: () async {
|
|
|
|
onTap: () async {
|
|
|
|
Navigator.pop(context);
|
|
|
|
Navigator.pop(sheetContext);
|
|
|
|
await Future.delayed(const Duration(milliseconds: 100));
|
|
|
|
await Future.delayed(const Duration(milliseconds: 100));
|
|
|
|
if (context.mounted) {
|
|
|
|
if (parentContext.mounted) {
|
|
|
|
_confirmDeleteChannel(
|
|
|
|
_confirmDeleteChannel(
|
|
|
|
context,
|
|
|
|
context,
|
|
|
|
connector,
|
|
|
|
connector,
|
|
|
|
@ -1454,7 +1455,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|
|
|
child: Text(dialogContext.l10n.common_cancel),
|
|
|
|
child: Text(dialogContext.l10n.common_cancel),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
FilledButton(
|
|
|
|
FilledButton(
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () async {
|
|
|
|
final name = nameController.text.trim();
|
|
|
|
final name = nameController.text.trim();
|
|
|
|
final pskHex = pskController.text.trim();
|
|
|
|
final pskHex = pskController.text.trim();
|
|
|
|
|
|
|
|
|
|
|
|
@ -1471,13 +1472,25 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Navigator.pop(dialogContext);
|
|
|
|
Navigator.pop(dialogContext);
|
|
|
|
connector.setChannel(channel.index, name, psk);
|
|
|
|
try {
|
|
|
|
connector.setChannelSmazEnabled(channel.index, smazEnabled);
|
|
|
|
await connector.setChannel(channel.index, name, psk);
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
await connector.setChannelSmazEnabled(
|
|
|
|
SnackBar(
|
|
|
|
channel.index,
|
|
|
|
content: Text(context.l10n.channels_channelUpdated(name)),
|
|
|
|
smazEnabled,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
if (!context.mounted) return;
|
|
|
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
|
|
|
SnackBar(
|
|
|
|
|
|
|
|
content: Text(context.l10n.channels_channelUpdated(name)),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} catch (e, st) {
|
|
|
|
|
|
|
|
debugPrint(st.toString());
|
|
|
|
|
|
|
|
if (!context.mounted) return;
|
|
|
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
|
|
|
SnackBar(content: Text('Failed to update channel: $e')),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: Text(dialogContext.l10n.common_save),
|
|
|
|
child: Text(dialogContext.l10n.common_save),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -1506,17 +1519,36 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|
|
|
child: Text(dialogContext.l10n.common_cancel),
|
|
|
|
child: Text(dialogContext.l10n.common_cancel),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
TextButton(
|
|
|
|
TextButton(
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () async {
|
|
|
|
Navigator.pop(dialogContext);
|
|
|
|
Navigator.pop(dialogContext);
|
|
|
|
connector.deleteChannel(channel.index);
|
|
|
|
try {
|
|
|
|
channelMessageStore.clearChannelMessages(channel.index);
|
|
|
|
await connector.deleteChannel(channel.index);
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
|
|
|
SnackBar(
|
|
|
|
channelMessageStore.clearChannelMessages(channel.index);
|
|
|
|
content: Text(
|
|
|
|
|
|
|
|
context.l10n.channels_channelDeleted(channel.name),
|
|
|
|
if (!context.mounted) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
|
|
|
SnackBar(
|
|
|
|
|
|
|
|
content: Text(
|
|
|
|
|
|
|
|
context.l10n.channels_channelDeleted(channel.name),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} catch (e, st) {
|
|
|
|
|
|
|
|
if (!context.mounted) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
|
|
|
SnackBar(
|
|
|
|
|
|
|
|
content: Text(
|
|
|
|
|
|
|
|
context.l10n.channels_channelDeleteFailed(channel.name),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Preserve existing logging (if it was there)
|
|
|
|
|
|
|
|
debugPrint('Failed to delete channel: $e\n$st');
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
child: Text(
|
|
|
|
dialogContext.l10n.common_delete,
|
|
|
|
dialogContext.l10n.common_delete,
|
|
|
|
|