Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,29 @@ Here's an example on how to present the QR code-scanning view as a sheet and how
struct QRCodeScannerExampleView: View {
@State private var isPresentingScanner = false
@State private var scannedCode: String?
@State private var navigationPath = NavigationPath()

var body: some View {
VStack(spacing: 10) {
if let code = scannedCode {
NavigationLink("Next page", destination: NextView(scannedCode: code), isActive: .constant(true)).hidden()
}
NavigationStack(path: $navigationPath) {
VStack(spacing: 10) {
Button("Scan Code") {
isPresentingScanner = true
}

Button("Scan Code") {
isPresentingScanner = true
Text("Scan a QR code to begin")
}

Text("Scan a QR code to begin")
}
.sheet(isPresented: $isPresentingScanner) {
CodeScannerView(codeTypes: [.qr]) { response in
if case let .success(result) = response {
scannedCode = result.string
isPresentingScanner = false
.sheet(isPresented: $isPresentingScanner) {
CodeScannerView(codeTypes: [.qr]) { response in
if case let .success(result) = response {
scannedCode = result.string
isPresentingScanner = false
navigationPath.append(scannedCode)
}
}
}
.navigationDestination(for: String.self) { code in
NextView(scannedCode: code)
}
}
}
}
Expand Down