Skip to content

Commit

Permalink
fixup! Added presentation layer for taking a photo or video
Browse files Browse the repository at this point in the history
  • Loading branch information
KhaledNjim committed Jun 27, 2024
1 parent 591d115 commit 6b8165d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/presentation/util/media_picker_from_camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ class MediaPickerFromCamera {
try {
var fileinfo;
List<FileInfo> pickedFiles = [];
var status = await PermissionService().checkPermissionForCameraActions();
var microphoneStatus =
await PermissionService().checkPermissionForAudioRecordingActions();
final cameraPermission =
await PermissionService().tryToGetPermissionForCamera();
final microphonePermission =
await PermissionService().tryToGetPermissionForAudioRecording();

if (status.isGranted && microphoneStatus.isGranted) {
if (cameraPermission.isGranted && microphonePermission.isGranted) {
await CameraPicker.pickFromCamera(
context,
pickerConfig: CameraPickerConfig(
Expand All @@ -58,8 +59,6 @@ class MediaPickerFromCamera {
onEntitySaving: ((context, viewType, file) {
fileinfo = FileInfo(file.path.split('/').last,
'${file.parent.path}/', file.lengthSync());
Navigator.pop(context);
Navigator.pop(context);
}),
textDelegate: cameraPickerTextDelegateFromLocale(
Localizations.localeOf(context)),
Expand All @@ -72,8 +71,8 @@ class MediaPickerFromCamera {
} else {
return Left(MediaPickerCanceled());
}
} else if (status.isPermanentlyDenied ||
microphoneStatus.isPermanentlyDenied) {
} else if (cameraPermission.isPermanentlyDenied ||
microphonePermission.isPermanentlyDenied) {
await showDialog(
context: context,
builder: (context) => OpenSettingsDialog(appNavigation));
Expand Down

0 comments on commit 6b8165d

Please sign in to comment.