ios – NavigationLink would not work in nested ScrollView after EnvironmentObject replace from community request

0
5


I’ve two tabs for navigationView, Dashboard and Userscreen.

Userscreen is used for fetching person data by way of community request, and dashboard is exhibiting data by way of community request primarily based on person data, hense person data is the surroundings object right here.

After replace person data I can view dashboard properties however click on on navigation hyperlink is just not working.
After performing some testing, I discovered that the navigation hyperlink(exhibiting primarily based on person information) beneath ScrollView -> ScrollView(.horizontal) -> NavigationLink is just not working, however navigation hyperlink(exhibiting primarily based on person information) beneath VStack -> ScrollView(.horizontal) -> NavigationLink performs effectively.

I’m wondering if I used to be lacking one thing on the implementation or might I ask is it an present bug for XCode?

struct ExampleView: View {
@StateObject var infoUpdateManager = InfoUpdateManager()

var physique: some View {
    NavigationView {
        TabView (){
            Dashboard()
                .environmentObject(infoUpdateManager)
                .tabItem{
                    Textual content("Dashboard")
                }
            UserScreen()
                .environmentObject(infoUpdateManager)
                .tabItem{
                    Textual content("UpdateInfo")
                }
        }
        .navigationBarTitleDisplayMode(.inline)
    }
    .navigationViewStyle(StackNavigationViewStyle())
}
}

struct Dashboard: View {

@EnvironmentObject var infoUpdateManager : InfoUpdateManager
@ObservedObject var infoRequest = InfoRequest()

func loadRequest(){
    infoRequest.loadNetworkRequest(passedPreference: infoUpdateManager.desire)
}

var physique: some View {
    if(infoUpdateManager.showFirstTabInfo){
        ScrollView{//if change ScrollView right here to VStack then NavigationLink would work
            if(infoRequest.customizedDataArray.depend != 0){
                ScrollView(.horizontal){
                    NavigationLink(vacation spot: EmptyView()){
                        Textual content("Hiya")
                    }
                    NavigationLink(vacation spot: EmptyView()){
                        Textual content("Hiya")
                    }
                    NavigationLink(vacation spot: EmptyView()){
                        Textual content("Hiya")
                    }
                }
            }
            else{
                ProgressView().onAppear{loadRequest()}
            }
        }
    }else{
        ProgressView().onAppear{infoUpdateManager.showFirstTabInfo = true}
    }
}
}

struct UserScreen: View{
@EnvironmentObject var infoUpdateManager : InfoUpdateManager

var physique: some View{
    Button(
        motion:{
            infoUpdateManager.loadNetworkRequest()
        }
    ){Textual content("Click on me for replace")}
}
}

class InfoUpdateManager : ObservableObject{
@Printed var showFirstTabInfo = true
@Printed var desire = "SomeValue"

func loadNetworkRequest(){
    showFirstTabInfo = false
    //right here is the code will do community request and have an effect on worth of desire
}
}

class InfoRequest : ObservableObject{
@Printed var customizedDataArray : [CustomizedData]

init(){
    customizedDataArray = []
}

func loadNetworkRequest(passedPreference: String){
    //right here is the code will do community request and have an effect on CustomizedDataArray
}
}

struct CustomizedData{
//One thing customise
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here