Closed kumarlav0 closed 8 months ago
Your change is breaking the way the library currently works. You cannot remove isTorchOn
.
You can implement your own button and inject the value into isTorchOn
like this:
@State var torchIsOn: Bool
@State var isGalleryPresented: Bool
var body: some View {
ZStack {
CodeScannerView(
codeTypes: [.qr],
scanMode: .continuous,
isTorchOn: torchIsOn,
isGalleryPresented: $isGalleryPresented,
completion: { _ in }
)
Button(action: { torchIsOn.toggle() }) {
Image(systemName: torchIsOn ? "bolt.fill" : "bolt.slash.fill")
.foregroundColor(torchIsOn ? Color.yellow : Color.accentColor)
}
}
}
When I tried to implement this CodeScanner I found there is no manual button to turn on/off the torch at the time of Scanning QR code.
So, On the basis of that I create this branch with manual button on ui to turn on/off torch at the time of Scanning QR code. It is a small feature but it is very useful for users.
Previously we have only option to turn on torch at the time of initialisation of CodeScannerView. And due to this flashlight gets automatically on for longer time. Which I found very unknowing feature.
If user will have button to turn ON/OFF torch or flashlight at the time of scanning QR code it will be very helpful for them.
I hope this could be add on feature for this Code Scanner.