-
Notifications
You must be signed in to change notification settings - Fork 121
[Woo POS][Barcodes] Frame the QR code and increase brightness for better scanability #15934
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,58 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import SwiftUI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import UIKit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @available(iOS 17.0, *) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Observable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final class POSBrightnessControl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private var originalBrightness: CGFloat = 0.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private var isBrightnessIncreased: Bool = false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| init() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| originalBrightness = UIScreen.main.brightness | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func increaseBrightnessToMax() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guard !isBrightnessIncreased else { return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| originalBrightness = UIScreen.main.brightness | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UIScreen.main.brightness = 1.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isBrightnessIncreased = true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func restoreOriginalBrightness() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guard isBrightnessIncreased else { return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UIScreen.main.brightness = originalBrightness | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isBrightnessIncreased = false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deinit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if isBrightnessIncreased { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UIScreen.main.brightness = originalBrightness | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+18
to
+31
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UIScreen.main.brightness = 1.0 | |
| isBrightnessIncreased = true | |
| } | |
| func restoreOriginalBrightness() { | |
| guard isBrightnessIncreased else { return } | |
| UIScreen.main.brightness = originalBrightness | |
| isBrightnessIncreased = false | |
| } | |
| deinit { | |
| if isBrightnessIncreased { | |
| UIScreen.main.brightness = originalBrightness | |
| DispatchQueue.main.async { | |
| UIScreen.main.brightness = 1.0 | |
| } | |
| isBrightnessIncreased = true | |
| } | |
| func restoreOriginalBrightness() { | |
| guard isBrightnessIncreased else { return } | |
| DispatchQueue.main.async { | |
| UIScreen.main.brightness = originalBrightness | |
| } | |
| isBrightnessIncreased = false | |
| } | |
| deinit { | |
| if isBrightnessIncreased { | |
| DispatchQueue.main.async { | |
| UIScreen.main.brightness = originalBrightness | |
| } |
Copilot
AI
Jul 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UIScreen.main.brightness modification in deinit should be performed on the main thread. Consider using DispatchQueue.main.async to ensure thread safety during cleanup.
| UIScreen.main.brightness = originalBrightness | |
| DispatchQueue.main.async { | |
| UIScreen.main.brightness = originalBrightness | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UIScreen.main.brightness should be accessed on the main thread. Consider wrapping this in DispatchQueue.main.async or using @mainactor to ensure thread safety.