|
| 1 | +/// |
| 2 | +/// [Author] Alex (https://github.com/AlexV525) |
| 3 | +/// [Date] 2022/2/14 12:05 |
| 4 | +/// |
| 5 | +import 'package:camera/camera.dart'; |
| 6 | +import 'package:flutter/material.dart'; |
| 7 | +import 'package:flutter/services.dart'; |
| 8 | + |
| 9 | +import '../delegates/camera_picker_text_delegate.dart'; |
| 10 | +import '../internals/type_defs.dart'; |
| 11 | + |
| 12 | +/// {@template wechat_camera_picker.CameraPickerConfig} |
| 13 | +/// Configurations for the [CameraPicker]. |
| 14 | +/// [CameraPicker] 的配置项 |
| 15 | +/// {@endtemplate} |
| 16 | +class CameraPickerConfig { |
| 17 | + const CameraPickerConfig({ |
| 18 | + this.enableRecording = false, |
| 19 | + this.onlyEnableRecording = false, |
| 20 | + this.enableTapRecording = false, |
| 21 | + this.enableAudio = true, |
| 22 | + this.enableSetExposure = true, |
| 23 | + this.enableExposureControlOnPoint = true, |
| 24 | + this.enablePinchToZoom = true, |
| 25 | + this.enablePullToZoomInRecord = true, |
| 26 | + this.shouldDeletePreviewFile = false, |
| 27 | + this.shouldAutoPreviewVideo = false, |
| 28 | + this.maximumRecordingDuration = const Duration(seconds: 15), |
| 29 | + this.theme, |
| 30 | + this.textDelegate, |
| 31 | + this.cameraQuarterTurns = 0, |
| 32 | + this.resolutionPreset = ResolutionPreset.max, |
| 33 | + this.imageFormatGroup = ImageFormatGroup.unknown, |
| 34 | + this.preferredLensDirection = CameraLensDirection.back, |
| 35 | + this.lockCaptureOrientation, |
| 36 | + this.foregroundBuilder, |
| 37 | + this.onEntitySaving, |
| 38 | + this.onError, |
| 39 | + }) : assert( |
| 40 | + enableRecording == true || onlyEnableRecording != true, |
| 41 | + 'Recording mode error.', |
| 42 | + ); |
| 43 | + |
| 44 | + /// Whether the picker can record video. |
| 45 | + /// 选择器是否可以录像 |
| 46 | + final bool enableRecording; |
| 47 | + |
| 48 | + /// Whether the picker can record video. |
| 49 | + /// 选择器是否可以录像 |
| 50 | + final bool onlyEnableRecording; |
| 51 | + |
| 52 | + /// Whether allow the record can start with single tap. |
| 53 | + /// 选择器是否可以单击录像 |
| 54 | + /// |
| 55 | + /// It only works when [onlyEnableRecording] is true. |
| 56 | + /// 仅在 [onlyEnableRecording] 为 true 时生效。 |
| 57 | + final bool enableTapRecording; |
| 58 | + |
| 59 | + /// Whether the picker should record audio. |
| 60 | + /// 选择器录像时是否需要录制声音 |
| 61 | + final bool enableAudio; |
| 62 | + |
| 63 | + /// Whether users can set the exposure point by tapping. |
| 64 | + /// 用户是否可以在界面上通过点击设定曝光点 |
| 65 | + final bool enableSetExposure; |
| 66 | + |
| 67 | + /// Whether users can adjust exposure according to the set point. |
| 68 | + /// 用户是否可以根据已经设置的曝光点调节曝光度 |
| 69 | + final bool enableExposureControlOnPoint; |
| 70 | + |
| 71 | + /// Whether users can zoom the camera by pinch. |
| 72 | + /// 用户是否可以在界面上双指缩放相机对焦 |
| 73 | + final bool enablePinchToZoom; |
| 74 | + |
| 75 | + /// Whether users can zoom by pulling up when recording video. |
| 76 | + /// 用户是否可以在录制视频时上拉缩放 |
| 77 | + final bool enablePullToZoomInRecord; |
| 78 | + |
| 79 | + /// {@template wechat_camera_picker.shouldDeletePreviewFile} |
| 80 | + /// Whether the preview file will be delete when pop. |
| 81 | + /// 返回页面时是否删除预览文件 |
| 82 | + /// {@endtemplate} |
| 83 | + final bool shouldDeletePreviewFile; |
| 84 | + |
| 85 | + /// {@template wechat_camera_picker.shouldAutoPreviewVideo} |
| 86 | + /// Whether the video should be played instantly in the preview. |
| 87 | + /// 在预览时是否直接播放视频 |
| 88 | + /// {@endtemplate} |
| 89 | + final bool shouldAutoPreviewVideo; |
| 90 | + |
| 91 | + /// The maximum duration of the video recording process. |
| 92 | + /// 录制视频最长时长 |
| 93 | + /// |
| 94 | + /// Defaults to 15 seconds, allow `null` for unrestricted video recording. |
| 95 | + /// 默认为 15 秒,可以使用 `null` 来设置无限制的视频录制 |
| 96 | + final Duration? maximumRecordingDuration; |
| 97 | + |
| 98 | + /// Theme data for the picker. |
| 99 | + /// 选择器的主题 |
| 100 | + final ThemeData? theme; |
| 101 | + |
| 102 | + /// The number of clockwise quarter turns the camera view should be rotated. |
| 103 | + /// 摄像机视图顺时针旋转次数,每次90度 |
| 104 | + final int cameraQuarterTurns; |
| 105 | + |
| 106 | + /// Text delegate that controls text in widgets. |
| 107 | + /// 控制部件中的文字实现 |
| 108 | + final CameraPickerTextDelegate? textDelegate; |
| 109 | + |
| 110 | + /// Present resolution for the camera. |
| 111 | + /// 相机的分辨率预设 |
| 112 | + final ResolutionPreset resolutionPreset; |
| 113 | + |
| 114 | + /// The [ImageFormatGroup] describes the output of the raw image format. |
| 115 | + /// 输出图像的格式描述 |
| 116 | + final ImageFormatGroup imageFormatGroup; |
| 117 | + |
| 118 | + /// Which lens direction is preferred when first using the camera, |
| 119 | + /// typically with the front or the back direction. |
| 120 | + /// 首次使用相机时首选的镜头方向,通常是前置或后置。 |
| 121 | + final CameraLensDirection preferredLensDirection; |
| 122 | + |
| 123 | + /// The foreground widget builder which will cover the whole camera preview. |
| 124 | + /// 覆盖在相机预览上方的前景构建 |
| 125 | + final Widget Function(CameraValue)? foregroundBuilder; |
| 126 | + |
| 127 | + /// Whether the camera should be locked to the specific orientation |
| 128 | + /// during captures. |
| 129 | + /// 摄像机在拍摄时锁定的旋转角度 |
| 130 | + final DeviceOrientation? lockCaptureOrientation; |
| 131 | + |
| 132 | + /// {@macro wechat_camera_picker.EntitySaveCallback} |
| 133 | + final EntitySaveCallback? onEntitySaving; |
| 134 | + |
| 135 | + /// {@macro wechat_camera_picker.CameraErrorHandler} |
| 136 | + final CameraErrorHandler? onError; |
| 137 | +} |
0 commit comments