mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-03-03 15:26:47 +00:00
fix #386
This commit is contained in:
parent
8e8027c63c
commit
6720604fc3
3 changed files with 39 additions and 28 deletions
|
|
@ -58,7 +58,8 @@ class MainCameraPreview extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (mainCameraController.focusPointOffset != null)
|
if (mainCameraController.focusPointOffset != null &&
|
||||||
|
!mainCameraController.isSharePreviewIsShown)
|
||||||
AspectRatio(
|
AspectRatio(
|
||||||
aspectRatio: 9 / 16,
|
aspectRatio: 9 / 16,
|
||||||
child: ClipRect(
|
child: ClipRect(
|
||||||
|
|
|
||||||
|
|
@ -109,12 +109,10 @@ class CameraPreviewView extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CameraPreviewViewState extends State<CameraPreviewView> {
|
class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
bool _sharePreviewIsShown = false;
|
|
||||||
bool _galleryLoadedImageIsShown = false;
|
bool _galleryLoadedImageIsShown = false;
|
||||||
bool _showSelfieFlash = false;
|
bool _showSelfieFlash = false;
|
||||||
double _basePanY = 0;
|
double _basePanY = 0;
|
||||||
double _baseScaleFactor = 0;
|
double _baseScaleFactor = 0;
|
||||||
bool _isVideoRecording = false;
|
|
||||||
bool _hasAudioPermission = true;
|
bool _hasAudioPermission = true;
|
||||||
DateTime? _videoRecordingStarted;
|
DateTime? _videoRecordingStarted;
|
||||||
Timer? _videoRecordingTimer;
|
Timer? _videoRecordingTimer;
|
||||||
|
|
@ -270,10 +268,10 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> takePicture() async {
|
Future<void> takePicture() async {
|
||||||
if (_sharePreviewIsShown || _isVideoRecording) return;
|
if (mc.isSharePreviewIsShown || mc.isVideoRecording) return;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_sharePreviewIsShown = true;
|
mc.isSharePreviewIsShown = true;
|
||||||
});
|
});
|
||||||
if (mc.selectedCameraDetails.isFlashOn) {
|
if (mc.selectedCameraDetails.isFlashOn) {
|
||||||
if (isFront) {
|
if (isFront) {
|
||||||
|
|
@ -306,7 +304,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
_sharePreviewIsShown = false;
|
mc.isSharePreviewIsShown = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -363,7 +361,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
) as bool?;
|
) as bool?;
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_sharePreviewIsShown = false;
|
mc.isSharePreviewIsShown = false;
|
||||||
_showSelfieFlash = false;
|
_showSelfieFlash = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -413,7 +411,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
Future<void> pickImageFromGallery() async {
|
Future<void> pickImageFromGallery() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_galleryLoadedImageIsShown = true;
|
_galleryLoadedImageIsShown = true;
|
||||||
_sharePreviewIsShown = true;
|
mc.isSharePreviewIsShown = true;
|
||||||
});
|
});
|
||||||
final picker = ImagePicker();
|
final picker = ImagePicker();
|
||||||
final pickedFile = await picker.pickMedia();
|
final pickedFile = await picker.pickMedia();
|
||||||
|
|
@ -456,7 +454,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
_galleryLoadedImageIsShown = false;
|
_galleryLoadedImageIsShown = false;
|
||||||
_sharePreviewIsShown = false;
|
mc.isSharePreviewIsShown = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -496,7 +494,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
_isVideoRecording = true;
|
mc.isVideoRecording = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -516,11 +514,11 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
});
|
});
|
||||||
setState(() {
|
setState(() {
|
||||||
_videoRecordingStarted = clock.now();
|
_videoRecordingStarted = clock.now();
|
||||||
_isVideoRecording = true;
|
mc.isVideoRecording = true;
|
||||||
});
|
});
|
||||||
} on CameraException catch (e) {
|
} on CameraException catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isVideoRecording = false;
|
mc.isVideoRecording = false;
|
||||||
});
|
});
|
||||||
_showCameraException(e);
|
_showCameraException(e);
|
||||||
return;
|
return;
|
||||||
|
|
@ -535,7 +533,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_videoRecordingStarted = null;
|
_videoRecordingStarted = null;
|
||||||
_isVideoRecording = false;
|
mc.isVideoRecording = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (mc.cameraController == null ||
|
if (mc.cameraController == null ||
|
||||||
|
|
@ -544,7 +542,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_sharePreviewIsShown = true;
|
mc.isSharePreviewIsShown = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -630,23 +628,23 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!_sharePreviewIsShown &&
|
if (!mc.isSharePreviewIsShown &&
|
||||||
widget.sendToGroup != null &&
|
widget.sendToGroup != null &&
|
||||||
!_isVideoRecording)
|
!mc.isVideoRecording)
|
||||||
ShowTitleText(
|
ShowTitleText(
|
||||||
title: widget.sendToGroup!.groupName,
|
title: widget.sendToGroup!.groupName,
|
||||||
desc: context.lang.cameraPreviewSendTo,
|
desc: context.lang.cameraPreviewSendTo,
|
||||||
),
|
),
|
||||||
if (!_sharePreviewIsShown &&
|
if (!mc.isSharePreviewIsShown &&
|
||||||
mc.sharedLinkForPreview != null &&
|
mc.sharedLinkForPreview != null &&
|
||||||
!_isVideoRecording)
|
!mc.isVideoRecording)
|
||||||
ShowTitleText(
|
ShowTitleText(
|
||||||
title: mc.sharedLinkForPreview?.host ?? '',
|
title: mc.sharedLinkForPreview?.host ?? '',
|
||||||
desc: 'Link',
|
desc: 'Link',
|
||||||
isLink: true,
|
isLink: true,
|
||||||
),
|
),
|
||||||
if (!_sharePreviewIsShown &&
|
if (!mc.isSharePreviewIsShown &&
|
||||||
!_isVideoRecording &&
|
!mc.isVideoRecording &&
|
||||||
!widget.hideControllers)
|
!widget.hideControllers)
|
||||||
Positioned(
|
Positioned(
|
||||||
right: 5,
|
right: 5,
|
||||||
|
|
@ -702,7 +700,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!_sharePreviewIsShown && !widget.hideControllers)
|
if (!mc.isSharePreviewIsShown && !widget.hideControllers)
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 30,
|
bottom: 30,
|
||||||
left: 0,
|
left: 0,
|
||||||
|
|
@ -713,7 +711,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
children: [
|
children: [
|
||||||
if (mc.cameraController!.value.isInitialized &&
|
if (mc.cameraController!.value.isInitialized &&
|
||||||
mc.selectedCameraDetails.isZoomAble &&
|
mc.selectedCameraDetails.isZoomAble &&
|
||||||
!_isVideoRecording)
|
!mc.isVideoRecording)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 120,
|
width: 120,
|
||||||
child: CameraZoomButtons(
|
child: CameraZoomButtons(
|
||||||
|
|
@ -729,7 +727,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
if (!_isVideoRecording)
|
if (!mc.isVideoRecording)
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: pressSideButtonLeft,
|
onTap: pressSideButtonLeft,
|
||||||
child: Align(
|
child: Align(
|
||||||
|
|
@ -765,7 +763,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
width: 7,
|
width: 7,
|
||||||
color: _isVideoRecording
|
color: mc.isVideoRecording
|
||||||
? Colors.red
|
? Colors.red
|
||||||
: Colors.white,
|
: Colors.white,
|
||||||
),
|
),
|
||||||
|
|
@ -774,7 +772,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!_isVideoRecording)
|
if (!mc.isVideoRecording)
|
||||||
if (isFront)
|
if (isFront)
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: pressSideButtonRight,
|
onTap: pressSideButtonRight,
|
||||||
|
|
@ -813,7 +811,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
videoRecordingStarted: _videoRecordingStarted,
|
videoRecordingStarted: _videoRecordingStarted,
|
||||||
maxVideoRecordingTime: maxVideoRecordingTime,
|
maxVideoRecordingTime: maxVideoRecordingTime,
|
||||||
),
|
),
|
||||||
if (!_sharePreviewIsShown && widget.sendToGroup != null ||
|
if (!mc.isSharePreviewIsShown && widget.sendToGroup != null ||
|
||||||
widget.hideControllers)
|
widget.hideControllers)
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 5,
|
left: 5,
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,9 @@ class MainCameraController {
|
||||||
GlobalKey cameraPreviewKey = GlobalKey();
|
GlobalKey cameraPreviewKey = GlobalKey();
|
||||||
bool isSelectingFaceFilters = false;
|
bool isSelectingFaceFilters = false;
|
||||||
|
|
||||||
|
bool isSharePreviewIsShown = false;
|
||||||
|
bool isVideoRecording = false;
|
||||||
|
|
||||||
Uri? sharedLinkForPreview;
|
Uri? sharedLinkForPreview;
|
||||||
|
|
||||||
void setSharedLinkForPreview(Uri url) {
|
void setSharedLinkForPreview(Uri url) {
|
||||||
|
|
@ -132,7 +135,9 @@ class MainCameraController {
|
||||||
await cameraController?.startImageStream(_processCameraImage);
|
await cameraController?.startImageStream(_processCameraImage);
|
||||||
} else {
|
} else {
|
||||||
await HapticFeedback.lightImpact();
|
await HapticFeedback.lightImpact();
|
||||||
|
await cameraController?.stopImageStream();
|
||||||
await cameraController?.setDescription(gCameras[cameraId]);
|
await cameraController?.setDescription(gCameras[cameraId]);
|
||||||
|
await cameraController?.startImageStream(_processCameraImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
await cameraController?.setZoomLevel(selectedCameraDetails.scaleFactor);
|
await cameraController?.setZoomLevel(selectedCameraDetails.scaleFactor);
|
||||||
|
|
@ -177,8 +182,12 @@ class MainCameraController {
|
||||||
setState();
|
setState();
|
||||||
|
|
||||||
await HapticFeedback.lightImpact();
|
await HapticFeedback.lightImpact();
|
||||||
await cameraController?.setFocusPoint(Offset(dx, dy));
|
try {
|
||||||
await cameraController?.setFocusMode(FocusMode.auto);
|
await cameraController?.setFocusPoint(Offset(dx, dy));
|
||||||
|
await cameraController?.setFocusMode(FocusMode.auto);
|
||||||
|
} catch (e) {
|
||||||
|
Log.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
focusPointOffset = null;
|
focusPointOffset = null;
|
||||||
setState();
|
setState();
|
||||||
|
|
@ -204,6 +213,9 @@ class MainCameraController {
|
||||||
};
|
};
|
||||||
|
|
||||||
void _processCameraImage(CameraImage image) {
|
void _processCameraImage(CameraImage image) {
|
||||||
|
if (isVideoRecording || isSharePreviewIsShown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final inputImage = _inputImageFromCameraImage(image);
|
final inputImage = _inputImageFromCameraImage(image);
|
||||||
if (inputImage == null) return;
|
if (inputImage == null) return;
|
||||||
_processBarcode(inputImage);
|
_processBarcode(inputImage);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue