wip
This commit is contained in:
parent
f679c7d357
commit
d4e4c18762
|
@ -10,14 +10,15 @@ struct AttachmentLocationPickerView: View {
|
|||
span: MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2)
|
||||
)
|
||||
@State private var showingAlert = false
|
||||
@State private var userInteraction = false
|
||||
|
||||
var body: some View {
|
||||
MapView(coordinateRegion: $region)
|
||||
MapView(coordinateRegion: $region, interactionState: $userInteraction)
|
||||
.onAppear {
|
||||
locationManager.start()
|
||||
}
|
||||
.onChange(of: locationManager.lastLocation) { newLocation in
|
||||
if let newLocation {
|
||||
if let newLocation, !userInteraction {
|
||||
region.center = newLocation.coordinate
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +36,28 @@ struct AttachmentLocationPickerView: View {
|
|||
}
|
||||
)
|
||||
}
|
||||
.overlay {
|
||||
Image(systemName: "mappin")
|
||||
.font(.title)
|
||||
.foregroundColor(.Material.Elements.active)
|
||||
.padding()
|
||||
if userInteraction {
|
||||
VStack {
|
||||
Spacer()
|
||||
HStack {
|
||||
Spacer()
|
||||
Image(systemName: "location.north.circle.fill")
|
||||
.font(.title)
|
||||
.foregroundColor(.Material.Elements.active)
|
||||
.padding()
|
||||
.tappablePadding(.symmetric(10)) {
|
||||
userInteraction = false
|
||||
region.center = locationManager.lastLocation?.coordinate ?? region.center
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,10 +88,12 @@ class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {
|
|||
|
||||
struct MapView: UIViewRepresentable {
|
||||
@Binding var coordinateRegion: MKCoordinateRegion
|
||||
@Binding var interactionState: Bool
|
||||
|
||||
func makeUIView(context: Context) -> MKMapView {
|
||||
let mapView = MKMapView()
|
||||
mapView.delegate = context.coordinator
|
||||
mapView.addGestureRecognizer(UIPanGestureRecognizer(target: context.coordinator, action: #selector(Coordinator.mapWasDragged)))
|
||||
return mapView
|
||||
}
|
||||
|
||||
|
@ -87,8 +112,8 @@ struct MapView: UIViewRepresentable {
|
|||
self.parent = parent
|
||||
}
|
||||
|
||||
func mapView(_ mapView: MKMapView, regionDidChangeAnimated _: Bool) {
|
||||
parent.coordinateRegion = mapView.region
|
||||
@objc func mapWasDragged() {
|
||||
parent.interactionState = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,8 @@ targets:
|
|||
NSPhotoLibraryUsageDescription: Allow app to send photo from gallery in attachments
|
||||
NSCameraUsageDescription: Allow app to take picture from camera and send it in atachments
|
||||
NSMicrophoneUsageDescription: Allow app to take sound from microphone for attachment video
|
||||
NSLocationWhenInUseUsageDescription: Allow app to take your geo to send it in attachment
|
||||
NSLocationAlwaysAndWhenInUseUsageDescription: Allow app to take your geo to send it in attachment
|
||||
# UIViewControllerBasedStatusBarAppearance: NO
|
||||
# UIStatusBarStyle: UIStatusBarStyleLightContent
|
||||
# NSFaceIDUsageDescription: Required for accessing to account info
|
||||
|
|
Loading…
Reference in a new issue