0

I'm trying to get a NavigationLink to trigger when a string is no longer nil. Is there anyway to do this or something similar?

NavigationLink(destination: MainView(), isActive: $settings.isLoggedS !=nil)

Any help is greatly appreciated!

Sean Oplinger
  • 39
  • 1
  • 6
  • I'm not sure about your intention... Triggering `isActive` navigates to link automatically, ie. user won't be needed to click on it... so "Click here after sign in!" looks have no sense. – Asperi Dec 12 '19 at 19:35
  • @Asperi I originally had it as a button, but now I'm trying to do it programmatically and that text was left over. – Sean Oplinger Dec 12 '19 at 19:39

1 Answers1

1

You can program the link.

          @State var activeString : String = ""
          var body: some View {
            NavigationView{
                NavigationLink(destination: Text(""), isActive: Binding<Bool>(get: {self.activeString != ""}, set: { _ in
                }) ){
                    TextField("input", text: $activeString)}}}
E.Coms
  • 11,065
  • 2
  • 23
  • 35