Below is the code. Here, LocationManager is the Observable class where I have marked "locationStatus" property as @Published. Now, what I want to achieve is when user sees the location Popup and gives Location access, it should navigate to next screen. Can someone please help me with this one? Thanks in advance
struct MyLocationScreen: View {
@ObservedObject var locationManager = LocationManager()
@State var isShowLinkTarget :Bool = false
var body: some View {
NavigationView{
ZStack{
Button(action: {
let locStatus = self.locationManager.locationStatus
if locStatus == .authorizedWhenInUse || locStatus == .authorizedAlways {
self.showLinkTarget = true
} else {
self.locationManager.requestAuthorization()
self.locationManager.startUpdate()
}
}) {
Text("Share Location")
}
NavigationLink(destination: NextScreen(), isActive: $showLinkTarget) {
Text("")
}
}
}
}
}