From b3518ea71b63eaacf8048bf7c6f32f74a23110a8 Mon Sep 17 00:00:00 2001 From: fmodf Date: Mon, 8 Jul 2024 09:41:35 +0200 Subject: [PATCH] wip --- .../AttachmentContactsPickerView.swift | 50 ++++++++++- .../AttachmentLocationPickerView.swift | 85 ++++++++++++------- 2 files changed, 103 insertions(+), 32 deletions(-) diff --git a/ConversationsClassic/View/Screens/Attachments/AttachmentContactsPickerView.swift b/ConversationsClassic/View/Screens/Attachments/AttachmentContactsPickerView.swift index a532814..e01297a 100644 --- a/ConversationsClassic/View/Screens/Attachments/AttachmentContactsPickerView.swift +++ b/ConversationsClassic/View/Screens/Attachments/AttachmentContactsPickerView.swift @@ -2,7 +2,53 @@ import SwiftUI struct AttachmentContactsPickerView: View { var body: some View { - Text("Contact Picker") - // Implement your contact picker here + VStack(spacing: 0) { + // Contacts list + let rosters = store.state.rostersState.rosters.filter { !$0.locallyDeleted } + if !rosters.isEmpty { + List { + ForEach(rosters) { roster in + ContactRow(roster: roster) + } + } + .listStyle(.plain) + .background(Color.Material.Background.light) + } else { + Spacer() + } + } + } +} + +private struct ContactRow: View { + var roster: Roster + + var body: some View { + VStack(spacing: 0) { + HStack(spacing: 8) { + ZStack { + Circle() + .frame(width: 44, height: 44) + .foregroundColor(.red) + Text(roster.name?.firstLetter ?? roster.contactBareJid.firstLetter) + .foregroundColor(.white) + .font(.body1) + } + Text(roster.contactBareJid) + .foregroundColor(Color.Material.Text.main) + .font(.body2) + Spacer() + } + .padding(.horizontal, 16) + .padding(.vertical, 4) + Rectangle() + .frame(maxWidth: .infinity) + .frame(height: 1) + .foregroundColor(.Material.Background.dark) + } + .sharedListRow() + .onTapGesture { + print(roster.contactBareJid) + } } } diff --git a/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift b/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift index 30e3ffc..59c45ed 100644 --- a/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift +++ b/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift @@ -6,40 +6,65 @@ struct AttachmentLocationPickerView: View { @State private var region = MKCoordinateRegion() var body: some View { - ZStack { - // MapView - MapView(region: $region) - .onAppear { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - self.region = locationManager.region - } - } - .overlay { - Image(systemName: "mappin") - .foregroundColor(.Material.Elements.active) - .font(.system(size: 30)) - .shadow(color: .white, radius: 2) - } - - // Track button - VStack { - Spacer() - HStack { - Spacer() - Image(systemName: "location.circle") - .resizable() - .frame(width: 40, height: 40) - .foregroundColor(.Material.Elements.active) - .background(Color.Material.Shape.white) - .clipShape(Circle()) - .shadow(color: .white, radius: 2) - .padding(.trailing) - .padding(.bottom, 50) - .tappablePadding(.symmetric(10)) { + VStack(spacing: 0) { + ZStack { + // MapView + MapView(region: $region) + .onAppear { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { self.region = locationManager.region } + } + .overlay { + Image(systemName: "mappin") + .foregroundColor(.Material.Elements.active) + .font(.system(size: 30)) + .shadow(color: .white, radius: 2) + } + + // Track button + VStack { + Spacer() + HStack { + Spacer() + Image(systemName: "location.circle") + .resizable() + .frame(width: 40, height: 40) + .foregroundColor(.Material.Elements.active) + .background(Color.Material.Shape.white) + .clipShape(Circle()) + .shadow(color: .white, radius: 2) + .padding(.trailing) + .padding(.bottom, 50) + .tappablePadding(.symmetric(10)) { + self.region = locationManager.region + } + } } } + + // Send panel + Rectangle() + .foregroundColor(.Material.Shape.black) + .frame(maxWidth: .infinity) + .frame(height: 50) + .overlay { + HStack { + Text(L10n.Attachment.Send.location) + .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") + } } .onAppear { locationManager.start()