forked from openfoodfacts/smooth-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into issue-openfoodfacts#1667
- Loading branch information
Showing
164 changed files
with
1,460 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
### What | ||
- description of the PR | ||
<!-- description of the PR --> | ||
- Changed x to achieve y | ||
|
||
### Screenshot | ||
(Insert a screenshot to provide visual record of your changes, if visible) | ||
<!-- Insert a screenshot to provide visual record of your changes, if visible --> | ||
|
||
### Fixes bug(s) | ||
- #1, #2 and #3 (change by appropriate issues) | ||
<!-- change by appropriate issues. --> | ||
<!-- Please use a linking keyword https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword --> | ||
- Fixes: #1 | ||
- Closes: #2 | ||
|
||
### Part of | ||
- https://github.com/openfoodfacts/smooth-app/issues/525 | ||
(please be as granular as possible) | ||
<!-- please be as granular as possible --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
"NSCameraUsageDescription" = "This app needs camera access to scan barcodes and to take product photos"; | ||
"NSCameraUsageDescription" = "Cette application a besoin d'un accès à l'appareil photo pour scanner des codes à barres et pour prendre des photos de produits"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import 'package:camera/camera.dart'; | ||
|
||
class CameraHelper { | ||
const CameraHelper._(); | ||
|
||
static List<CameraDescription>? _cameras; | ||
|
||
/// Mandatory method to call before [findBestCamera] | ||
static Future<void> init() async { | ||
_cameras = await availableCameras(); | ||
} | ||
|
||
/// Find the most relevant camera to use if none of these criteria are met, | ||
/// the default value of [_cameraIndex] will be used to select the first | ||
/// camera in the global cameras list. | ||
/// if non matching is found we fall back to the first in the list | ||
/// initValue of [_cameraIndex]/ | ||
static CameraDescription? findBestCamera({ | ||
CameraLensDirection cameraLensDirection = CameraLensDirection.back, | ||
}) { | ||
if (_cameras == null) { | ||
throw Exception('Please call [init] before!'); | ||
} else if (_cameras!.isEmpty) { | ||
return null; | ||
} | ||
|
||
int cameraIndex = -1; | ||
|
||
if (_cameras!.any( | ||
(CameraDescription element) => | ||
element.lensDirection == cameraLensDirection && | ||
element.sensorOrientation == 90, | ||
)) { | ||
cameraIndex = _cameras!.indexOf( | ||
_cameras!.firstWhere((CameraDescription element) => | ||
element.lensDirection == cameraLensDirection && | ||
element.sensorOrientation == 90), | ||
); | ||
} else if (_cameras!.any((CameraDescription element) => | ||
element.lensDirection == cameraLensDirection)) { | ||
cameraIndex = _cameras!.indexOf( | ||
_cameras!.firstWhere( | ||
(CameraDescription element) => | ||
element.lensDirection == cameraLensDirection, | ||
), | ||
); | ||
} | ||
|
||
return _cameras![cameraIndex]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.