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>
This commit is contained in:
spaced4ndy
2023-08-02 12:10:11 +04:00
committed by GitHub
parent 0a6133fe5b
commit 2bb2042d7d
3 changed files with 36 additions and 9 deletions

View File

@@ -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)

View File

@@ -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() {

View File

@@ -1212,6 +1212,8 @@
<string name="change_member_role_question">Change group role?</string>
<string name="member_role_will_be_changed_with_notification">The role will be changed to \"%s\". Everyone in the group will be notified.</string>
<string name="member_role_will_be_changed_with_invitation">The role will be changed to \"%s\". The member will receive a new invitation.</string>
<string name="connect_via_member_address_alert_title">Connect directly?</string>
<string name="connect_via_member_address_alert_desc">Сonnection request will be sent to this group member.</string>
<string name="error_removing_member">Error removing member</string>
<string name="error_changing_role">Error changing role</string>
<string name="info_row_group">Group</string>