-
-
Save sturdysturge/d588dfff96209cb5f359908937f2caee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
//Whatever scheme you entered in your project settings under URL types | |
let myURLScheme = "my-scheme://" | |
@State var text = "" | |
@State var openedURLs = [String]() | |
var fullURL: URL { | |
return URL(unsafeString: myURLScheme + text) | |
} | |
var body: some View { | |
Form { | |
HStack { | |
Text(myURLScheme) | |
TextField("Add text to URL", text: $text) | |
} | |
Link(destination: fullURL) { | |
Text("Open") | |
} | |
.onOpenURL { url in | |
openedURLs.append(url.absoluteString) | |
} | |
Section(header: Text("Opened URLs")) { | |
ForEach(0..<openedURLs.count, id: \.self) { | |
index in Text(openedURLs[index]) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment