Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not Dismissing ScannerView on iOS 14 #53

Open
mxnmike opened this issue Dec 29, 2021 · 1 comment
Open

Not Dismissing ScannerView on iOS 14 #53

mxnmike opened this issue Dec 29, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@mxnmike
Copy link

mxnmike commented Dec 29, 2021

This is my code, if I run it on iOS 15, it runs incredible..... but when I run it on iOS 14.8.2 the Scanner view won't get dismissed, it does execute the handleScan Method, because if I dismiss the view manually, I see for a moment the expected url.

Any ideas why is not working just on iOS 14?

Thanks.

`struct BottomNavigationItem: View {

@State private var isShowingScanner = false
let webViewModel: WebViewModel

private let logoutUrlString = "some url"
private let qrCodeUrlString = "another url"
private let homeUrlString = "home url"

var body: some View {
	return Text("")
		.toolbar {
			ToolbarItemGroup(placement: .bottomBar) {
				Spacer()
				Button(action: homeButtonPressed) {
					VStack {
						Image("home_icon")
						Text("Home")
							.foregroundColor(.black)
							.font(.system(size: 10))
					}
				}
				
				Spacer()
				
				Button(action: qrReaderButtonPressed) {
					VStack{
						Image("camera_icon")
						Text("Read QR")
							.foregroundColor(.black)
							.font(.system(size: 10))
					}.sheet(isPresented: $isShowingScanner) {
						CodeScannerView(codeTypes: [.qr], simulatedData: "16", completion: self.handleScan)
                            .edgesIgnoringSafeArea(.vertical)
					}
				}
				Spacer()
				
				Button(action: logoutButtonPressed) {
					VStack{
						Image("power_icon")
						Text("Logout")
							.foregroundColor(.black)
							.font(.system(size: 10))
					}
				}
				Spacer()
			}
			
			
		}
}

func homeButtonPressed() {
	webViewModel.urlString = homeUrlString
	webViewModel.loadUrl()
}

func qrReaderButtonPressed() {
	isShowingScanner = true
}

func logoutButtonPressed() {
	webViewModel.hiddenBottomView = true
	webViewModel.urlString = logoutUrlString
	webViewModel.loadUrl()
	
}

func handleScan(result: Result<ScanResult, ScanError>) {
	self.isShowingScanner = false
	
	switch result {
	case .success(let code):
		let details = code.string
		guard details != "" else { return }
		webViewModel.urlString = qrCodeUrlString + details
		webViewModel.loadUrl()
	case .failure(let error):
		print("Scanning Failed:\(error)")
		
	}
}

}`

@nathanfallet nathanfallet added the bug Something isn't working label Aug 28, 2022
@nathanfallet
Copy link
Collaborator

I'm going to take a look and try your code to see what is wrong with it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants