Skip to content

Instantly share code, notes, and snippets.

@GerardPaligot
Last active March 19, 2022 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GerardPaligot/fa04c4840fed556ff5a69ef0bc89e30c to your computer and use it in GitHub Desktop.
Save GerardPaligot/fa04c4840fed556ff5a69ef0bc89e30c to your computer and use it in GitHub Desktop.
struct Networking: View {
@ObservedObject var viewModel: NetworkingViewModel
// state to displau a sheet
@State private var isPresentingScanner = false
var body: some View {
let uiState = viewModel.uiState
NavigationView {
Group {
Networking(networkingUi: uiState.networkingUi)
}
// use the state to display the sheet or not
.sheet(isPresented: $isPresentingScanner) {
CodeScannerView(codeTypes: [.qr]) { response in
if case let .success(result) = response {
// close the sheet
isPresentingScanner = false
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment