From 2bb2042d7d6bc844f5d95b411c6da28f8a972640 Mon Sep 17 00:00:00 2001
From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com>
Date: Wed, 2 Aug 2023 12:10:11 +0400
Subject: [PATCH] ios, android: alert on connect via member address button
(#2819)
* ios: alert on connect via member address button
* android
* Update apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
* Update apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
* ios texts
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
---
.../Chat/Group/GroupMemberInfoView.swift | 18 +++++++++++--
.../views/chat/group/GroupMemberInfoView.kt | 25 +++++++++++++------
.../commonMain/resources/MR/base/strings.xml | 2 ++
3 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/apps/ios/Shared/Views/Chat/Group/GroupMemberInfoView.swift b/apps/ios/Shared/Views/Chat/Group/GroupMemberInfoView.swift
index 37e00863fe..47a2131d30 100644
--- a/apps/ios/Shared/Views/Chat/Group/GroupMemberInfoView.swift
+++ b/apps/ios/Shared/Views/Chat/Group/GroupMemberInfoView.swift
@@ -28,6 +28,7 @@ struct GroupMemberInfoView: View {
case switchAddressAlert
case abortSwitchAddressAlert
case syncConnectionForceAlert
+ case connectViaMemberAddressAlert(contactLink: String)
case connRequestSentAlert(type: ConnReqType)
case error(title: LocalizedStringKey, error: LocalizedStringKey)
case other(alert: Alert)
@@ -38,8 +39,9 @@ struct GroupMemberInfoView: View {
case let .changeMemberRoleAlert(_, role): return "changeMemberRoleAlert \(role.rawValue)"
case .switchAddressAlert: return "switchAddressAlert"
case .abortSwitchAddressAlert: return "abortSwitchAddressAlert"
- case .connRequestSentAlert: return "connRequestSentAlert"
case .syncConnectionForceAlert: return "syncConnectionForceAlert"
+ case .connectViaMemberAddressAlert: return "connectViaMemberAddressAlert"
+ case .connRequestSentAlert: return "connRequestSentAlert"
case let .error(title, _): return "error \(title)"
case let .other(alert): return "other \(alert)"
}
@@ -201,6 +203,7 @@ struct GroupMemberInfoView: View {
case .switchAddressAlert: return switchAddressAlert(switchMemberAddress)
case .abortSwitchAddressAlert: return abortSwitchAddressAlert(abortSwitchMemberAddress)
case .syncConnectionForceAlert: return syncConnectionForceAlert({ syncMemberConnection(force: true) })
+ case let .connectViaMemberAddressAlert(contactLink): return connectViaMemberAddressAlert(contactLink)
case let .connRequestSentAlert(type): return connReqSentAlert(type)
case let .error(title, error): return Alert(title: Text(title), message: Text(error))
case let .other(alert): return alert
@@ -210,12 +213,23 @@ struct GroupMemberInfoView: View {
func connectViaAddressButton(_ contactLink: String) -> some View {
Button {
- connectViaAddress(contactLink)
+ alert = .connectViaMemberAddressAlert(contactLink: contactLink)
} label: {
Label("Connect", systemImage: "link")
}
}
+ func connectViaMemberAddressAlert(_ contactLink: String) -> Alert {
+ return Alert(
+ title: Text("Connect directly?"),
+ message: Text("Сonnection request will be sent to this group member."),
+ primaryButton: .default(Text("Connect")) {
+ connectViaAddress(contactLink)
+ },
+ secondaryButton: .cancel()
+ )
+ }
+
func connectViaAddress(_ contactLink: String) {
Task {
let (connReqType, connectAlert) = await apiConnect_(connReq: contactLink)
diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupMemberInfoView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupMemberInfoView.kt
index bfe9aff82b..f730c6ef21 100644
--- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupMemberInfoView.kt
+++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupMemberInfoView.kt
@@ -76,13 +76,7 @@ fun GroupMemberInfoView(
}
},
connectViaAddress = { connReqUri ->
- val uri = URI(connReqUri)
- withUriAction(uri) { linkType ->
- withApi {
- Log.d(TAG, "connectViaUri: connecting")
- connectViaUri(chatModel, linkType, uri)
- }
- }
+ connectViaMemberAddressAlert(connReqUri)
},
removeMember = { removeMemberDialog(groupInfo, member, chatModel, close) },
onRoleSelected = {
@@ -450,6 +444,23 @@ private fun updateMemberRoleDialog(
)
}
+fun connectViaMemberAddressAlert(connReqUri: String) {
+ AlertManager.shared.showAlertDialog(
+ title = generalGetString(MR.strings.connect_via_member_address_alert_title),
+ text = generalGetString(MR.strings.connect_via_member_address_alert_desc),
+ confirmText = generalGetString(MR.strings.connect_via_link_verb),
+ onConfirm = {
+ val uri = URI(connReqUri)
+ withUriAction(uri) { linkType ->
+ withApi {
+ Log.d(TAG, "connectViaUri: connecting")
+ connectViaUri(chatModel, linkType, uri)
+ }
+ }
+ },
+ )
+}
+
@Preview
@Composable
fun PreviewGroupMemberInfoLayout() {
diff --git a/apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml b/apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml
index a54a1a9320..753e89a1d4 100644
--- a/apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml
+++ b/apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml
@@ -1212,6 +1212,8 @@
Change group role?
The role will be changed to \"%s\". Everyone in the group will be notified.
The role will be changed to \"%s\". The member will receive a new invitation.
+ Connect directly?
+ Сonnection request will be sent to this group member.
Error removing member
Error changing role
Group