Add QR code scanning API
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 827
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 40
Description
### What is the problem or limitation you are having?
Toga has a camera API, implemented on iOS, Android and macOS. However, this interface is focussed on taking photographs, using an external camera panel/app.
Another common use case for cameras is to scan QR codes. Toga should have an API for capturing QR codes.
### Describe the solution you'd like
An API, similar to `await app.camera.take_photo` to capture QR codes. `await app.camera.capture_qr_code` would be an obvious starting point.
Calling the API would display a full-page live camera view (with a QR code "target" square); when a QR code is seen, the window would be dismissed, and the coroutine return the captured QR code.
As part of implementing this, it may be necessary to add a "live camera view" widget. That widget would allow the user to define a box that will display a view of the live camera. That widget should then have a `async def take_photo()` API, and handler for `on_qr_code()` that is invoked whenever a QR code is "seen". If a `on_qr_code` handler is provided, the camera view would be displayed with a target.
### Describe alternatives you've considered
Leave QR code implementations to the user to implement.
### Additional context
User @ezzygarmyz has implemented a QR scanner for Android in [this project](https://github.com/ezzygarmyz/QRScanner-android). This demonstrates how Android QR code APIs can be invoked to capture
iOS/macOS implementations will need to use AVCaptureSession APIs; there are many examples of usage online (e.g., [this one](https://www.programmersought.com/article/8211808189/) and [this one](https://github.com/mercari/QRScanner))
Contributor guide
Research direction
Start by reading the existing app.camera.take_photo API and its camera implementations on Android, iOS, and macOS. Compare the proposed app.camera.capture_qr_code entry point with the live camera view and on_qr_code alternatives, then clarify the cross-platform scope and behavior before implementation; done means an agreed API and working QR capture on the supported platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, ios, macos, python
- Domain
- api, desktop, mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100