mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 12:48:41 +00:00
fixing wide angle on ios
This commit is contained in:
parent
2a9414ae4f
commit
5371114e21
1 changed files with 21 additions and 4 deletions
|
|
@ -41,6 +41,7 @@ class _CameraZoomButtonsState extends State<CameraZoomButtons> {
|
||||||
bool showWideAngleZoom = false;
|
bool showWideAngleZoom = false;
|
||||||
bool showWideAngleZoomIOS = false;
|
bool showWideAngleZoomIOS = false;
|
||||||
bool _isDisposed = false;
|
bool _isDisposed = false;
|
||||||
|
int? _wideCameraIndex;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -51,7 +52,19 @@ class _CameraZoomButtonsState extends State<CameraZoomButtons> {
|
||||||
Future<void> initAsync() async {
|
Future<void> initAsync() async {
|
||||||
showWideAngleZoom = (await widget.controller.getMinZoomLevel()) < 1;
|
showWideAngleZoom = (await widget.controller.getMinZoomLevel()) < 1;
|
||||||
Log.info('Found ${gCameras.length} cameras for zoom.');
|
Log.info('Found ${gCameras.length} cameras for zoom.');
|
||||||
if (!showWideAngleZoom && Platform.isIOS && gCameras.length == 3) {
|
|
||||||
|
var index =
|
||||||
|
gCameras.indexWhere((t) => t.lensType == CameraLensType.ultraWide);
|
||||||
|
if (index == -1) {
|
||||||
|
index = gCameras.indexWhere(
|
||||||
|
(t) => t.lensType == CameraLensType.wide,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (index != -1) {
|
||||||
|
_wideCameraIndex = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!showWideAngleZoom && Platform.isIOS && _wideCameraIndex != null) {
|
||||||
showWideAngleZoomIOS = true;
|
showWideAngleZoomIOS = true;
|
||||||
}
|
}
|
||||||
if (_isDisposed) return;
|
if (_isDisposed) return;
|
||||||
|
|
@ -76,10 +89,12 @@ class _CameraZoomButtonsState extends State<CameraZoomButtons> {
|
||||||
|
|
||||||
const zoomTextStyle = TextStyle(fontSize: 13);
|
const zoomTextStyle = TextStyle(fontSize: 13);
|
||||||
final isSmallerFocused = widget.scaleFactor < 1 ||
|
final isSmallerFocused = widget.scaleFactor < 1 ||
|
||||||
(showWideAngleZoomIOS && widget.selectedCameraDetails.cameraId == 2);
|
(showWideAngleZoomIOS &&
|
||||||
|
widget.selectedCameraDetails.cameraId == _wideCameraIndex);
|
||||||
final isMiddleFocused = widget.scaleFactor >= 1 &&
|
final isMiddleFocused = widget.scaleFactor >= 1 &&
|
||||||
widget.scaleFactor < 2 &&
|
widget.scaleFactor < 2 &&
|
||||||
!(showWideAngleZoomIOS && widget.selectedCameraDetails.cameraId == 2);
|
!(showWideAngleZoomIOS &&
|
||||||
|
widget.selectedCameraDetails.cameraId == _wideCameraIndex);
|
||||||
|
|
||||||
final maxLevel = max(
|
final maxLevel = max(
|
||||||
min(widget.selectedCameraDetails.maxAvailableZoom, 2),
|
min(widget.selectedCameraDetails.maxAvailableZoom, 2),
|
||||||
|
|
@ -106,7 +121,9 @@ class _CameraZoomButtonsState extends State<CameraZoomButtons> {
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (showWideAngleZoomIOS) {
|
if (showWideAngleZoomIOS) {
|
||||||
await widget.selectCamera(2, true);
|
if (_wideCameraIndex != null) {
|
||||||
|
await widget.selectCamera(_wideCameraIndex!, true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final level = await widget.controller.getMinZoomLevel();
|
final level = await widget.controller.getMinZoomLevel();
|
||||||
widget.updateScaleFactor(level);
|
widget.updateScaleFactor(level);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue