From 170c0daa5ba66997a07978a9b3d0e00bc5f2fea5 Mon Sep 17 00:00:00 2001 From: fmodf Date: Thu, 4 Jul 2024 17:01:30 +0200 Subject: [PATCH] wip --- .../Resources/Strings/Localizable.strings | 1 + .../AttachmentLocationPickerView.swift | 73 +++++++++---------- .../View/UIToolkit/View+If.swift | 11 +++ 3 files changed, 47 insertions(+), 38 deletions(-) create mode 100644 ConversationsClassic/View/UIToolkit/View+If.swift diff --git a/ConversationsClassic/Resources/Strings/Localizable.strings b/ConversationsClassic/Resources/Strings/Localizable.strings index 730872d..718bf02 100644 --- a/ConversationsClassic/Resources/Strings/Localizable.strings +++ b/ConversationsClassic/Resources/Strings/Localizable.strings @@ -66,4 +66,5 @@ "Attachment.Tab.location" = "Location"; "Attachment.Tab.contacts" = "Contacts"; "Attachment.Send.media" = "Send media"; +"Attachment.Send.location" = "Send location"; diff --git a/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift b/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift index b714789..c745d3e 100644 --- a/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift +++ b/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift @@ -5,47 +5,44 @@ import SwiftUI struct AttachmentLocationPickerView: View { @State var region = MKCoordinateRegion() - @State var userInteracting = false var body: some View { - ZStack { - if userInteracting { - Map( - coordinateRegion: $region, - interactionModes: .all, - showsUserLocation: false, - userTrackingMode: .constant(.none) - ) - .overlay { - VStack { - Spacer() - HStack { - Spacer() - Image(systemName: "location.north.circle.fill") - .resizable() - .frame(width: 30, height: 30) - .foregroundColor(.Material.Elements.active) - .padding() - .tappablePadding(.symmetric(10)) { - userInteracting = false - } - } - } - } - } else { - Map( - coordinateRegion: $region, - interactionModes: .all, - showsUserLocation: false, - userTrackingMode: .constant(.follow) - ) - .gesture(DragGesture().onChanged { _ in - userInteracting = true - }) + VStack(spacing: 0) { + // Map + Map( + coordinateRegion: $region, + interactionModes: .all, + showsUserLocation: false, + userTrackingMode: .constant(.follow) + ) + .overlay { + Image(systemName: "mappin") + .font(.system(size: 30)) + .foregroundColor(.Material.Elements.active) } - Image(systemName: "mappin") - .font(.system(size: 30)) - .foregroundColor(.Material.Elements.active) + + // 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 location + print("Send location") + } } } } diff --git a/ConversationsClassic/View/UIToolkit/View+If.swift b/ConversationsClassic/View/UIToolkit/View+If.swift new file mode 100644 index 0000000..f6611ca --- /dev/null +++ b/ConversationsClassic/View/UIToolkit/View+If.swift @@ -0,0 +1,11 @@ +import SwiftUI + +public extension View { + @ViewBuilder func `if`(_ condition: @autoclosure () -> Bool, transform: (Self) -> Content) -> some View { + if condition() { + transform(self) + } else { + self + } + } +}