mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-28 17:07:19 +00:00
9794829d74
* core: option to show group as sender of chat item (for the initial items, e.g. welcome message) * add chat item to contact request chats * return AChat for prepared chats and contact requests * update iOS api types, show prepared contact as blue, show preview info when content message is not available (previously was showing feature item) * ios: remove ContactType * ios: show group as sender, fix avatar not showing when member message sequence starts with merged items * ios: update compose UI for all connection scenarios * address settings * ios: address settings UI * fix tests * fix tests 2 * ios: fix minor issues
77 lines
2.6 KiB
Swift
77 lines
2.6 KiB
Swift
//
|
|
// ContextContactRequestActionsView.swift
|
|
// SimpleX (iOS)
|
|
//
|
|
// Created by spaced4ndy on 02.05.2025.
|
|
// Copyright © 2025 SimpleX Chat. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
import SimpleXChat
|
|
|
|
struct ContextContactRequestActionsView: View {
|
|
@EnvironmentObject var theme: AppTheme
|
|
var contactRequestId: Int64
|
|
@UserDefault(DEFAULT_TOOLBAR_MATERIAL) private var toolbarMaterial = ToolbarMaterial.defaultMaterial
|
|
|
|
var body: some View {
|
|
HStack(spacing: 0) {
|
|
Label("Reject", systemImage: "multiply")
|
|
.foregroundColor(.red)
|
|
.frame(maxWidth: .infinity)
|
|
.contentShape(Rectangle())
|
|
.onTapGesture {
|
|
showRejectRequestAlert(contactRequestId)
|
|
}
|
|
|
|
Label("Accept", systemImage: "checkmark").foregroundColor(theme.colors.primary)
|
|
.frame(maxWidth: .infinity)
|
|
.contentShape(Rectangle())
|
|
.onTapGesture {
|
|
if ChatModel.shared.addressShortLinkDataSet {
|
|
Task { await acceptContactRequest(incognito: false, contactRequestId: contactRequestId) }
|
|
} else {
|
|
showAcceptRequestAlert(contactRequestId)
|
|
}
|
|
}
|
|
}
|
|
.frame(minHeight: 60)
|
|
.frame(maxWidth: .infinity)
|
|
.background(ToolbarMaterial.material(toolbarMaterial))
|
|
}
|
|
}
|
|
|
|
func showRejectRequestAlert(_ contactRequestId: Int64) {
|
|
showAlert(
|
|
NSLocalizedString("Reject contact request", comment: "alert title"),
|
|
message: NSLocalizedString("The sender will NOT be notified", comment: "alert message"),
|
|
actions: {[
|
|
UIAlertAction(title: NSLocalizedString("Reject", comment: "alert action"), style: .destructive) { _ in
|
|
Task { await rejectContactRequest(contactRequestId, dismissToChatList: true) }
|
|
},
|
|
cancelAlertAction
|
|
]}
|
|
)
|
|
}
|
|
|
|
func showAcceptRequestAlert(_ contactRequestId: Int64) {
|
|
showAlert(
|
|
NSLocalizedString("Accept contact request", comment: "alert title"),
|
|
actions: {[
|
|
UIAlertAction(title: NSLocalizedString("Accept", comment: "alert action"), style: .default) { _ in
|
|
Task { await acceptContactRequest(incognito: false, contactRequestId: contactRequestId) }
|
|
},
|
|
UIAlertAction(title: NSLocalizedString("Accept incognito", comment: "alert action"), style: .default) { _ in
|
|
Task { await acceptContactRequest(incognito: true, contactRequestId: contactRequestId) }
|
|
},
|
|
cancelAlertAction
|
|
]}
|
|
)
|
|
}
|
|
|
|
#Preview {
|
|
ContextContactRequestActionsView(
|
|
contactRequestId: 1
|
|
)
|
|
}
|