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.Tab.contacts" = "Contacts";
"Attachment.Send.media" = "Send media"; "Attachment.Send.media" = "Send media";
"Attachment.Send.location" = "Send location"; "Attachment.Send.location" = "Send location";
"Attachment.Send.contact" = "Send contact";

View file

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