2024-07-02 09:56:27 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
2024-07-13 13:58:38 +00:00
|
|
|
struct SharingContactsPickerView: View {
|
2024-07-09 12:37:51 +00:00
|
|
|
@EnvironmentObject var store: AppStore
|
2024-07-08 08:58:24 +00:00
|
|
|
@State private var selectedContact: Roster?
|
|
|
|
|
2024-07-02 09:56:27 +00:00
|
|
|
var body: some View {
|
2024-07-08 07:41:35 +00:00
|
|
|
VStack(spacing: 0) {
|
|
|
|
// Contacts list
|
|
|
|
let rosters = store.state.rostersState.rosters.filter { !$0.locallyDeleted }
|
|
|
|
if !rosters.isEmpty {
|
|
|
|
List {
|
|
|
|
ForEach(rosters) { roster in
|
2024-07-08 08:58:24 +00:00
|
|
|
ContactRow(roster: roster, selectedContact: $selectedContact)
|
2024-07-08 07:41:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
.listStyle(.plain)
|
|
|
|
.background(Color.Material.Background.light)
|
|
|
|
} else {
|
|
|
|
Spacer()
|
|
|
|
}
|
2024-07-08 08:58:24 +00:00
|
|
|
|
|
|
|
// Send panel
|
|
|
|
Rectangle()
|
|
|
|
.foregroundColor(.Material.Shape.black)
|
|
|
|
.frame(maxWidth: .infinity)
|
|
|
|
.frame(height: selectedContact == nil ? 0 : 50)
|
|
|
|
.overlay {
|
|
|
|
HStack {
|
|
|
|
Text(L10n.Attachment.Send.contact)
|
|
|
|
.foregroundColor(.Material.Text.white)
|
|
|
|
.font(.body1)
|
|
|
|
Image(systemName: "arrow.up.circle")
|
|
|
|
.foregroundColor(.Material.Text.white)
|
|
|
|
.font(.body1)
|
|
|
|
.padding(.leading, 8)
|
|
|
|
}
|
|
|
|
.padding()
|
|
|
|
}
|
|
|
|
.clipped()
|
|
|
|
.onTapGesture {
|
2024-07-10 11:09:59 +00:00
|
|
|
if let selectedContact = selectedContact {
|
2024-07-10 14:48:18 +00:00
|
|
|
store.dispatch(.sharingAction(.shareContact(jid: selectedContact.contactBareJid)))
|
2024-07-10 14:13:47 +00:00
|
|
|
store.dispatch(.sharingAction(.showSharing(false)))
|
2024-07-10 11:09:59 +00:00
|
|
|
}
|
2024-07-08 08:58:24 +00:00
|
|
|
}
|
2024-07-08 07:41:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private struct ContactRow: View {
|
|
|
|
var roster: Roster
|
2024-07-08 08:58:24 +00:00
|
|
|
@Binding var selectedContact: Roster?
|
2024-07-08 07:41:35 +00:00
|
|
|
|
|
|
|
var body: some View {
|
2024-08-07 19:07:39 +00:00
|
|
|
SharedListRow(
|
|
|
|
iconType: .charCircle(roster.name?.firstLetter ?? roster.contactBareJid.firstLetter),
|
|
|
|
text: roster.contactBareJid
|
|
|
|
)
|
2024-07-08 07:41:35 +00:00
|
|
|
.onTapGesture {
|
2024-07-08 08:58:24 +00:00
|
|
|
selectedContact = roster
|
2024-07-08 07:41:35 +00:00
|
|
|
}
|
2024-07-02 09:56:27 +00:00
|
|
|
}
|
|
|
|
}
|