Skip to content

Commit f52f820

Browse files
authored
✨ Introduce PreviewTransformBuilder (#79)
1 parent abe049b commit f52f820

File tree

5 files changed

+85
-61
lines changed

5 files changed

+85
-61
lines changed

README-ZH.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -94,29 +94,30 @@ final AssetEntity? entity = await CameraPicker.pickFromCamera(
9494

9595
`CameraPickerConfig` 的成员说明:
9696

97-
| 参数名 | 类型 | 描述 | 默认值 |
98-
|------------------------------|---------------------------------|----------------------------------------------------|----------------------------------------|
99-
| enableRecording | `bool` | 选择器是否可以录像 | `false` |
100-
| onlyEnableRecording | `bool` | 选择器是否仅可以录像。只在 `enableRecording``true` 时有效。 | `false` |
101-
| enableTapRecording | `bool` | 选择器是否可以单击录像。只在 `onlyEnableRecording``true` 时生效。 | `false` |
102-
| enableAudio | `bool` | 选择器是否需要录制音频。只在 `enableRecording``true` 时有效。 | `true` |
103-
| enableSetExposure | `bool` | 用户是否可以在界面上通过点击设定曝光点 | `true` |
104-
| enableExposureControlOnPoint | `bool` | 用户是否可以根据已经设置的曝光点调节曝光度 | `true` |
105-
| enablePinchToZoom | `bool` | 用户是否可以在界面上双指缩放相机对焦 | `true` |
106-
| enablePullToZoomInRecord | `bool` | 用户是否可以在录制视频时上拉缩放 | `true` |
107-
| shouldDeletePreviewFile | `bool` | 返回页面时是否删除预览文件 | `false` |
108-
| shouldAutoPreviewVideo | `bool` | 在预览时是否直接播放视频 | `false` |
109-
| maximumRecordingDuration | `Duration` | 录制视频最长时长 | `const Duration(seconds: 15)` |
110-
| theme | `ThemeData?` | 选择器的主题 | `CameraPicker.themeData(C.themeColor)` |
111-
| textDelegate | `CameraPickerTextDelegate?` | 控制部件中的文字实现 | `DefaultCameraPickerTextDelegate` |
112-
| resolutionPreset | `ResolutionPreset` | 相机的分辨率预设 | `ResolutionPreset.max` |
113-
| cameraQuarterTurns | `int` | 摄像机视图顺时针旋转次数,每次 90 度 | `0` |
114-
| imageFormatGroup | `ImageFormatGroup` | 输出图像的格式描述 | `ImageFormatGroup.unknown` |
115-
| preferredLensDirection | `CameraLensDirection` | 首次使用相机时首选的镜头方向 | `CameraLensDirection.back` |
116-
| lockCaptureOrientation | `DeviceOrientation?` | 摄像机在拍摄时锁定的旋转角度 | null |
117-
| foregroundBuilder | `Widget Function(CameraValue)?` | 覆盖在相机预览上方的前景构建 | null |
118-
| onEntitySaving | `EntitySaveCallback?` | 在查看器中保存图片时的回调 | null |
119-
| onError | `CameraErrorHandler?` | 拍摄照片过程中的自定义错误处理 | null |
97+
| 参数名 | 类型 | 描述 | 默认值 |
98+
|------------------------------|-----------------------------|----------------------------------------------------|----------------------------------------|
99+
| enableRecording | `bool` | 选择器是否可以录像 | `false` |
100+
| onlyEnableRecording | `bool` | 选择器是否仅可以录像。只在 `enableRecording``true` 时有效。 | `false` |
101+
| enableTapRecording | `bool` | 选择器是否可以单击录像。只在 `onlyEnableRecording``true` 时生效。 | `false` |
102+
| enableAudio | `bool` | 选择器是否需要录制音频。只在 `enableRecording``true` 时有效。 | `true` |
103+
| enableSetExposure | `bool` | 用户是否可以在界面上通过点击设定曝光点 | `true` |
104+
| enableExposureControlOnPoint | `bool` | 用户是否可以根据已经设置的曝光点调节曝光度 | `true` |
105+
| enablePinchToZoom | `bool` | 用户是否可以在界面上双指缩放相机对焦 | `true` |
106+
| enablePullToZoomInRecord | `bool` | 用户是否可以在录制视频时上拉缩放 | `true` |
107+
| shouldDeletePreviewFile | `bool` | 返回页面时是否删除预览文件 | `false` |
108+
| shouldAutoPreviewVideo | `bool` | 在预览时是否直接播放视频 | `false` |
109+
| maximumRecordingDuration | `Duration` | 录制视频最长时长 | `const Duration(seconds: 15)` |
110+
| theme | `ThemeData?` | 选择器的主题 | `CameraPicker.themeData(C.themeColor)` |
111+
| textDelegate | `CameraPickerTextDelegate?` | 控制部件中的文字实现 | `DefaultCameraPickerTextDelegate` |
112+
| resolutionPreset | `ResolutionPreset` | 相机的分辨率预设 | `ResolutionPreset.max` |
113+
| cameraQuarterTurns | `int` | 摄像机视图顺时针旋转次数,每次 90 度 | `0` |
114+
| imageFormatGroup | `ImageFormatGroup` | 输出图像的格式描述 | `ImageFormatGroup.unknown` |
115+
| preferredLensDirection | `CameraLensDirection` | 首次使用相机时首选的镜头方向 | `CameraLensDirection.back` |
116+
| lockCaptureOrientation | `DeviceOrientation?` | 摄像机在拍摄时锁定的旋转角度 | null |
117+
| foregroundBuilder | `ForegroundBuilder?` | 覆盖在相机预览上方的前景构建 | null |
118+
| previewTransformBuilder | `PreviewTransformBuilder?` | 对相机预览做变换的构建 | null |
119+
| onEntitySaving | `EntitySaveCallback?` | 在查看器中保存图片时的回调 | null |
120+
| onError | `CameraErrorHandler?` | 拍摄照片过程中的自定义错误处理 | null |
120121

121122
## 常见问题 💭
122123

README.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,29 +79,30 @@ final AssetEntity? entity = await CameraPicker.pickFromCamera(
7979

8080
Fields in `CameraPickerConfig`:
8181

82-
| Name | Type | Description | Default Value |
83-
|------------------------------|---------------------------------|-------------------------------------------------------------------------------------------------------|----------------------------------------|
84-
| enableRecording | `bool` | Whether the picker can record video. | `false` |
85-
| onlyEnableRecording | `bool` | Whether the picker can only record video. Only available when `enableRecording` is `true `. | `false` |
86-
| enableTapRecording | `bool` | Whether allow the record can start with single tap. Only available when `enableRecording` is `true `. | `false` |
87-
| enableAudio | `bool` | Whether Whether the picker should record audio. Only available with recording. | `true` |
88-
| enableSetExposure | `bool` | Whether users can set the exposure point by tapping. | `true` |
89-
| enableExposureControlOnPoint | `bool` | Whether users can adjust exposure according to the set point. | `true` |
90-
| enablePinchToZoom | `bool` | Whether users can zoom the camera by pinch. | `true` |
91-
| enablePullToZoomInRecord | `bool` | Whether users can zoom by pulling up when recording video. | `true` |
92-
| shouldDeletePreviewFile | `bool` | Whether the preview file will be delete when pop. | `false` |
93-
| shouldAutoPreviewVideo | `bool` | Whether the video should be played instantly in the preview. | `false` |
94-
| maximumRecordingDuration | `Duration` | The maximum duration of the video recording process. | `const Duration(seconds: 15)` |
95-
| theme | `ThemeData?` | Theme data for the picker. | `CameraPicker.themeData(C.themeColor)` |
96-
| textDelegate | `CameraPickerTextDelegate?` | Text delegate that controls text in widgets. | `DefaultCameraPickerTextDelegate` |
97-
| resolutionPreset | `ResolutionPreset` | Present resolution for the camera. | `ResolutionPreset.max` |
98-
| cameraQuarterTurns | `int` | The number of clockwise quarter turns the camera view should be rotated. | `0` |
99-
| imageFormatGroup | `ImageFormatGroup` | Describes the output of the raw image format. | `ImageFormatGroup.unknown` |
100-
| preferredLensDirection | `CameraLensDirection` | Which lens direction is preferred when first using the camera. | `CameraLensDirection.back` |
101-
| lockCaptureOrientation | `DeviceOrientation?` | Whether the camera should be locked to the specific orientation during captures. | null |
102-
| foregroundBuilder | `Widget Function(CameraValue)?` | The foreground widget builder which will cover the whole camera preview. | null |
103-
| onEntitySaving | `EntitySaveCallback?` | The callback type define for saving entity in the viewer. | null |
104-
| onError | `CameraErrorHandler?` | The error handler when any error occurred during the picking process. | null |
82+
| Name | Type | Description | Default Value |
83+
|------------------------------|-----------------------------|-------------------------------------------------------------------------------------------------------|----------------------------------------|
84+
| enableRecording | `bool` | Whether the picker can record video. | `false` |
85+
| onlyEnableRecording | `bool` | Whether the picker can only record video. Only available when `enableRecording` is `true `. | `false` |
86+
| enableTapRecording | `bool` | Whether allow the record can start with single tap. Only available when `enableRecording` is `true `. | `false` |
87+
| enableAudio | `bool` | Whether Whether the picker should record audio. Only available with recording. | `true` |
88+
| enableSetExposure | `bool` | Whether users can set the exposure point by tapping. | `true` |
89+
| enableExposureControlOnPoint | `bool` | Whether users can adjust exposure according to the set point. | `true` |
90+
| enablePinchToZoom | `bool` | Whether users can zoom the camera by pinch. | `true` |
91+
| enablePullToZoomInRecord | `bool` | Whether users can zoom by pulling up when recording video. | `true` |
92+
| shouldDeletePreviewFile | `bool` | Whether the preview file will be delete when pop. | `false` |
93+
| shouldAutoPreviewVideo | `bool` | Whether the video should be played instantly in the preview. | `false` |
94+
| maximumRecordingDuration | `Duration` | The maximum duration of the video recording process. | `const Duration(seconds: 15)` |
95+
| theme | `ThemeData?` | Theme data for the picker. | `CameraPicker.themeData(C.themeColor)` |
96+
| textDelegate | `CameraPickerTextDelegate?` | Text delegate that controls text in widgets. | `DefaultCameraPickerTextDelegate` |
97+
| resolutionPreset | `ResolutionPreset` | Present resolution for the camera. | `ResolutionPreset.max` |
98+
| cameraQuarterTurns | `int` | The number of clockwise quarter turns the camera view should be rotated. | `0` |
99+
| imageFormatGroup | `ImageFormatGroup` | Describes the output of the raw image format. | `ImageFormatGroup.unknown` |
100+
| preferredLensDirection | `CameraLensDirection` | Which lens direction is preferred when first using the camera. | `CameraLensDirection.back` |
101+
| lockCaptureOrientation | `DeviceOrientation?` | Whether the camera should be locked to the specific orientation during captures. | null |
102+
| foregroundBuilder | `ForegroundBuilder?` | The foreground widget builder which will cover the whole camera preview. | null |
103+
| previewTransformBuilder | `PreviewTransformBuilder?` | The widget builder which will transform the camera preview. | null |
104+
| onEntitySaving | `EntitySaveCallback?` | The callback type define for saving entity in the viewer. | null |
105+
| onError | `CameraErrorHandler?` | The error handler when any error occurred during the picking process. | null |
105106

106107
## Frequently asked question 💭
107108

lib/src/constants/config.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class CameraPickerConfig {
3434
this.preferredLensDirection = CameraLensDirection.back,
3535
this.lockCaptureOrientation,
3636
this.foregroundBuilder,
37+
this.previewTransformBuilder,
3738
this.onEntitySaving,
3839
this.onError,
3940
}) : assert(
@@ -120,9 +121,11 @@ class CameraPickerConfig {
120121
/// 首次使用相机时首选的镜头方向,通常是前置或后置。
121122
final CameraLensDirection preferredLensDirection;
122123

123-
/// The foreground widget builder which will cover the whole camera preview.
124-
/// 覆盖在相机预览上方的前景构建
125-
final Widget Function(CameraValue)? foregroundBuilder;
124+
/// {@macro wechat_camera_picker.ForegroundBuilder}
125+
final ForegroundBuilder? foregroundBuilder;
126+
127+
/// {@macro wechat_camera_picker.PreviewTransformBuilder}
128+
final PreviewTransformBuilder? previewTransformBuilder;
126129

127130
/// Whether the camera should be locked to the specific orientation
128131
/// during captures.

0 commit comments

Comments
 (0)