another.im-ios/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift
2024-07-04 16:42:01 +02:00

52 lines
1.7 KiB
Swift

import Combine
import CoreLocation
import MapKit
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
})
}
Image(systemName: "mappin")
.font(.system(size: 30))
.foregroundColor(.Material.Elements.active)
}
}
}