another.im-ios/ConversationsClassic/View/Screens/Attachments/AttachmentLocationPickerView.swift

52 lines
1.7 KiB
Swift
Raw Normal View History

2024-07-04 14:25:25 +00:00
import Combine
2024-07-04 11:45:39 +00:00
import CoreLocation
2024-07-02 09:56:27 +00:00
import MapKit
import SwiftUI
struct AttachmentLocationPickerView: View {
2024-07-04 14:25:25 +00:00
@State var region = MKCoordinateRegion()
2024-07-04 14:38:00 +00:00
@State var userInteracting = false
2024-07-02 09:56:27 +00:00
var body: some View {
2024-07-04 14:25:25 +00:00
ZStack {
2024-07-04 14:38:00 +00:00
if userInteracting {
Map(
coordinateRegion: $region,
interactionModes: .all,
showsUserLocation: false,
userTrackingMode: .constant(.none)
)
.overlay {
2024-07-04 14:25:25 +00:00
VStack {
Spacer()
HStack {
Spacer()
Image(systemName: "location.north.circle.fill")
.resizable()
.frame(width: 30, height: 30)
.foregroundColor(.Material.Elements.active)
.padding()
.tappablePadding(.symmetric(10)) {
2024-07-04 14:38:00 +00:00
userInteracting = false
2024-07-04 14:25:25 +00:00
}
2024-07-04 12:55:47 +00:00
}
}
}
2024-07-04 14:38:00 +00:00
} else {
Map(
coordinateRegion: $region,
interactionModes: .all,
showsUserLocation: false,
userTrackingMode: .constant(.follow)
)
.gesture(DragGesture().onChanged { _ in
userInteracting = true
})
2024-07-04 12:55:47 +00:00
}
2024-07-04 14:38:00 +00:00
Image(systemName: "mappin")
.font(.system(size: 30))
.foregroundColor(.Material.Elements.active)
2024-07-04 13:40:32 +00:00
}
2024-07-02 09:56:27 +00:00
}
}