This commit is contained in:
fmodf 2024-07-08 10:58:24 +02:00
parent b3518ea71b
commit 103dd130ca
2 changed files with 35 additions and 2 deletions

View file

@ -67,4 +67,5 @@
"Attachment.Tab.contacts" = "Contacts";
"Attachment.Send.media" = "Send media";
"Attachment.Send.location" = "Send location";
"Attachment.Send.contact" = "Send contact";

View file

@ -1,6 +1,8 @@
import SwiftUI
struct AttachmentContactsPickerView: View {
@State private var selectedContact: Roster?
var body: some View {
VStack(spacing: 0) {
// Contacts list
@ -8,7 +10,7 @@ struct AttachmentContactsPickerView: View {
if !rosters.isEmpty {
List {
ForEach(rosters) { roster in
ContactRow(roster: roster)
ContactRow(roster: roster, selectedContact: $selectedContact)
}
}
.listStyle(.plain)
@ -16,12 +18,36 @@ struct AttachmentContactsPickerView: View {
} else {
Spacer()
}
// 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 {
// TODO: Send selected media
print("Send location")
}
}
}
}
private struct ContactRow: View {
var roster: Roster
@Binding var selectedContact: Roster?
var body: some View {
VStack(spacing: 0) {
@ -38,6 +64,12 @@ private struct ContactRow: View {
.foregroundColor(Color.Material.Text.main)
.font(.body2)
Spacer()
if selectedContact == roster {
Image(systemName: "checkmark")
.foregroundColor(.Material.Text.main)
.font(.body1)
.padding(.trailing, 8)
}
}
.padding(.horizontal, 16)
.padding(.vertical, 4)
@ -48,7 +80,7 @@ private struct ContactRow: View {
}
.sharedListRow()
.onTapGesture {
print(roster.contactBareJid)
selectedContact = roster
}
}
}