From dfa048e918e4a32ee49e96b02436c72cafced948 Mon Sep 17 00:00:00 2001 From: fmodf Date: Thu, 4 Jul 2024 16:38:00 +0200 Subject: [PATCH] wip --- .../AttachmentLocationPickerView.swift | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift b/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift index 49c3f7d..b714789 100644 --- a/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift +++ b/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift @@ -5,22 +5,18 @@ import SwiftUI struct AttachmentLocationPickerView: View { @State var region = MKCoordinateRegion() - @State var userTrackingMode: MapUserTrackingMode = .follow + @State var userInteracting = false var body: some View { ZStack { - Map( - coordinateRegion: $region, - interactionModes: .all, - showsUserLocation: false, - userTrackingMode: $userTrackingMode - ) - .overlay { - Image(systemName: "mappin") - .resizable() - .frame(width: 30, height: 30) - .foregroundColor(.Material.Elements.active) - if userTrackingMode != .follow { + if userInteracting { + Map( + coordinateRegion: $region, + interactionModes: .all, + showsUserLocation: false, + userTrackingMode: .constant(.none) + ) + .overlay { VStack { Spacer() HStack { @@ -31,12 +27,25 @@ struct AttachmentLocationPickerView: View { .foregroundColor(.Material.Elements.active) .padding() .tappablePadding(.symmetric(10)) { - userTrackingMode = .follow + userInteracting = false } } } } + } else { + Map( + coordinateRegion: $region, + interactionModes: .all, + showsUserLocation: false, + userTrackingMode: .constant(.follow) + ) + .gesture(DragGesture().onChanged { _ in + userInteracting = true + }) } + Image(systemName: "mappin") + .font(.system(size: 30)) + .foregroundColor(.Material.Elements.active) } } }