0

Is it at all possible to use an actionSheet with navigationView? I want clicking a button in an actionSheet to take them to a new view.

                .actionSheet(isPresented: $showingActionSheet) {
                    ActionSheet(title: Text("Login"), message: Text("Choose how to login"), Buttons: [
                        .default(Text("Email and Password")) {
                        //Navigate somewhere using NavigationView
                        }

Edit: Was told to do this, but still not working

                    .actionSheet(isPresented: $showingSheet) {
                    ActionSheet(title: Text("Login With:"), message: Text("Choose how to login"), buttons: [
                        .default(Text("Email")) { self.navigateTo = "emaillogin" },
                        .default(Text("QR Code")) { self.navigateTo = "QR" },
                        .default(Text("Key")) { self.navigateTo = "keylogin" },
                        .default(Text("Text")) { self.navigateTo = "textlogin" },
                        .cancel()
                    ])
                }
                .background(
                    NavigationLink(destination: Text(self.navigateTo), isActive: $isActive) {
                        EmptyView();
                    })

1 Answers1

0

Am I doing something wrong here? it still isn't working

It looks like missed link activation:

.actionSheet(isPresented: $showingSheet) {
    ActionSheet(title: Text("Login With:"), message: Text("Choose how to login"), buttons: [
        .default(Text("Email")) { self.navigateTo = "emaillogin"; isActive = true },
        .default(Text("QR Code")) { self.navigateTo = "QR"; isActive = true },
        .default(Text("Key")) { self.navigateTo = "keylogin"; isActive = true },
        .default(Text("Text")) { self.navigateTo = "textlogin"; isActive = true },
        .cancel()
    ])
}
Asperi
  • 228,894
  • 20
  • 464
  • 690