Skip to content

Commit 8df4195

Browse files
authored
enableTapRecording (#58)
1 parent 0400d4e commit 8df4195

File tree

4 files changed

+154
-97
lines changed

4 files changed

+154
-97
lines changed

README-ZH.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,26 @@ Flutter SDK:`>=2.0.0` 。
5858

5959
## 使用方法 📖
6060

61-
| 参数名 | 类型 | 描述 | 默认值 |
62-
| ---------------------------- | ------------------------------- | ---------------------------------------------------------------- | -------------------------------------- |
63-
| enableRecording | `bool` | 选择器是否可以录像 | `false` |
64-
| onlyEnableRecording | `bool` | 选择器是否仅可以录像。只在 `enableRecording``true` 时有效。 | `false` |
65-
| enableAudio | `bool` | 选择器是否需要录制音频。只于录像配合有效。 | `true` |
66-
| enableSetExposure | `bool` | 用户是否可以在界面上通过点击设定曝光点 | `true` |
67-
| enableExposureControlOnPoint | `bool` | 用户是否可以根据已经设置的曝光点调节曝光度 | `true` |
68-
| enablePinchToZoom | `bool` | 用户是否可以在界面上双指缩放相机对焦 | `true` |
69-
| enablePullToZoomInRecord | `bool` | 用户是否可以在录制视频时上拉缩放 | `true` |
70-
| shouldDeletePreviewFile | `bool` | 返回页面时是否删除预览文件 | `false` |
71-
| maximumRecordingDuration | `Duration` | 录制视频最长时长 | `const Duration(seconds: 15)` |
61+
| 参数名 | 类型 | 描述 | 默认值 |
62+
| ---------------------------- | ------------------------------- | --------------------------------------------------------------- | -------------------------------------- |
63+
| enableRecording | `bool` | 选择器是否可以录像 | `false` |
64+
| onlyEnableRecording | `bool` | 选择器是否仅可以录像。只在 `enableRecording``true` 时有效。 | `false` |
65+
| onlyEnableRecording | `bool` | 选择器是否可以单击录像。只在 `onlyEnableRecording 为 `true` 时生效。 | `false` |
66+
| enableAudio | `bool` | 选择器是否需要录制音频。只在 `enableRecording``true` 时有效。 | `true` |
67+
| enableSetExposure | `bool` | 用户是否可以在界面上通过点击设定曝光点 | `true` |
68+
| enableExposureControlOnPoint | `bool` | 用户是否可以根据已经设置的曝光点调节曝光度 | `true` |
69+
| enablePinchToZoom | `bool` | 用户是否可以在界面上双指缩放相机对焦 | `true` |
70+
| enablePullToZoomInRecord | `bool` | 用户是否可以在录制视频时上拉缩放 | `true` |
71+
| shouldDeletePreviewFile | `bool` | 返回页面时是否删除预览文件 | `false` |
72+
| maximumRecordingDuration | `Duration` | 录制视频最长时长 | `const Duration(seconds: 15)` |
7273
| theme | `ThemeData?` | 选择器的主题 | `CameraPicker.themeData(C.themeColor)` |
73-
| textDelegate | `CameraPickerTextDelegate?` | 控制部件中的文字实现 | `DefaultCameraPickerTextDelegate` |
74-
| resolutionPreset | `ResolutionPreset` | 相机的分辨率预设 | `ResolutionPreset.max` |
75-
| cameraQuarterTurns | `int` | 摄像机视图顺时针旋转次数,每次90度 | `0` |
76-
| imageFormatGroup | `ImageFormatGroup` | 输出图像的格式描述 | `ImageFormatGroup.unknown` |
77-
| foregroundBuilder | `Widget Function(CameraValue)?` | 覆盖在相机预览上方的前景构建 | null |
78-
| onEntitySaving | `EntitySaveCallback?` | 在查看器中保存图片时的回调 | null |
79-
| onError | `CameraErrorHandler?` | 拍摄照片过程中的自定义错误处理 | null |
74+
| textDelegate | `CameraPickerTextDelegate?` | 控制部件中的文字实现 | `DefaultCameraPickerTextDelegate` |
75+
| resolutionPreset | `ResolutionPreset` | 相机的分辨率预设 | `ResolutionPreset.max` |
76+
| cameraQuarterTurns | `int` | 摄像机视图顺时针旋转次数,每次 90 度 | `0` |
77+
| imageFormatGroup | `ImageFormatGroup` | 输出图像的格式描述 | `ImageFormatGroup.unknown` |
78+
| foregroundBuilder | `Widget Function(CameraValue)?` | 覆盖在相机预览上方的前景构建 | null |
79+
| onEntitySaving | `EntitySaveCallback?` | 在查看器中保存图片时的回调 | null |
80+
| onError | `CameraErrorHandler?` | 拍摄照片过程中的自定义错误处理 | null |
8081

8182
### 简单的使用方法
8283

README.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,26 @@ Flutter SDK: `>=2.0.0` .
5959

6060
## Usage 📖
6161

62-
| Name | Type | Description | Default Value |
63-
| ---------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------- | -------------------------------------- |
64-
| enableRecording | `bool` | Whether the picker can record video. | `false` |
65-
| onlyEnableRecording | `bool` | Whether the picker can only record video. Only available when `enableRecording` is `true `. | `false` |
66-
| enableAudio | `bool` | Whether Whether the picker should record audio. Only available with recording. | `true` |
67-
| enableSetExposure | `bool` | Whether users can set the exposure point by tapping. | `true` |
68-
| enableExposureControlOnPoint | `bool` | Whether users can adjust exposure according to the set point. | `true` |
69-
| enablePinchToZoom | `bool` | Whether users can zoom the camera by pinch. | `true` |
70-
| enablePullToZoomInRecord | `bool` | Whether users can zoom by pulling up when recording video. | `true` |
71-
| shouldDeletePreviewFile | `bool` | Whether the preview file will be delete when pop. | `false` |
72-
| maximumRecordingDuration | `Duration` | The maximum duration of the video recording process. | `const Duration(seconds: 15)` |
73-
| theme | `ThemeData?` | Theme data for the picker. | `CameraPicker.themeData(C.themeColor)` |
74-
| textDelegate | `CameraPickerTextDelegate?` | Text delegate that controls text in widgets. | `DefaultCameraPickerTextDelegate` |
75-
| resolutionPreset | `ResolutionPreset` | Present resolution for the camera. | `ResolutionPreset.max` |
76-
| cameraQuarterTurns | `int` | The number of clockwise quarter turns the camera view should be rotated. | `0` |
77-
| imageFormatGroup | `ImageFormatGroup` | Describes the output of the raw image format. | `ImageFormatGroup.unknown` |
78-
| foregroundBuilder | `Widget Function(CameraValue)?` | The foreground widget builder which will cover the whole camera preview. | null |
79-
| onEntitySaving | `EntitySaveCallback?` | The callback type define for saving entity in the viewer. | null |
80-
| onError | `CameraErrorHandler?` | The error handler when any error occurred during the picking process. | null |
62+
| Name | Type | Description | Default Value |
63+
| ---------------------------- | ------------------------------- | ----------------------------------------------------------------------------------------------------- | -------------------------------------- |
64+
| enableRecording | `bool` | Whether the picker can record video. | `false` |
65+
| onlyEnableRecording | `bool` | Whether the picker can only record video. Only available when `enableRecording` is `true `. | `false` |
66+
| enableTapRecording | `bool` | Whether allow the record can start with single tap. Only available when `enableRecording` is `true `. | `false` |
67+
| enableAudio | `bool` | Whether Whether the picker should record audio. Only available with recording. | `true` |
68+
| enableSetExposure | `bool` | Whether users can set the exposure point by tapping. | `true` |
69+
| enableExposureControlOnPoint | `bool` | Whether users can adjust exposure according to the set point. | `true` |
70+
| enablePinchToZoom | `bool` | Whether users can zoom the camera by pinch. | `true` |
71+
| enablePullToZoomInRecord | `bool` | Whether users can zoom by pulling up when recording video. | `true` |
72+
| shouldDeletePreviewFile | `bool` | Whether the preview file will be delete when pop. | `false` |
73+
| maximumRecordingDuration | `Duration` | The maximum duration of the video recording process. | `const Duration(seconds: 15)` |
74+
| theme | `ThemeData?` | Theme data for the picker. | `CameraPicker.themeData(C.themeColor)` |
75+
| textDelegate | `CameraPickerTextDelegate?` | Text delegate that controls text in widgets. | `DefaultCameraPickerTextDelegate` |
76+
| resolutionPreset | `ResolutionPreset` | Present resolution for the camera. | `ResolutionPreset.max` |
77+
| cameraQuarterTurns | `int` | The number of clockwise quarter turns the camera view should be rotated. | `0` |
78+
| imageFormatGroup | `ImageFormatGroup` | Describes the output of the raw image format. | `ImageFormatGroup.unknown` |
79+
| foregroundBuilder | `Widget Function(CameraValue)?` | The foreground widget builder which will cover the whole camera preview. | null |
80+
| onEntitySaving | `EntitySaveCallback?` | The callback type define for saving entity in the viewer. | null |
81+
| onError | `CameraErrorHandler?` | The error handler when any error occurred during the picking process. | null |
8182

8283
### Simple usage
8384

lib/src/delegates/camera_picker_text_delegate.dart

Lines changed: 40 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,95 +8,87 @@
88
abstract class CameraPickerTextDelegate {
99
/// Confirm string for the confirm button.
1010
/// 确认按钮的字段
11-
late String confirm;
11+
String get confirm;
1212

1313
/// Tips string above the shooting button before shooting.
1414
/// 拍摄前确认按钮上方的提示文字
15-
late String shootingTips;
15+
String get shootingTips;
1616

1717
/// Load failed string for item.
1818
/// 资源加载失败时的字段
19-
late final String loadFailed;
19+
String get loadFailed;
2020
}
2121

2222
/// Default text delegate implements with Chinese.
2323
/// 中文文字实现
24-
class DefaultCameraPickerTextDelegate implements CameraPickerTextDelegate {
25-
factory DefaultCameraPickerTextDelegate() => _instance;
26-
27-
DefaultCameraPickerTextDelegate._internal();
28-
29-
static final DefaultCameraPickerTextDelegate _instance =
30-
DefaultCameraPickerTextDelegate._internal();
31-
24+
class DefaultCameraPickerTextDelegate extends CameraPickerTextDelegate {
3225
@override
33-
String confirm = '确认';
26+
String get confirm => '确认';
3427

3528
@override
36-
String shootingTips = '轻触拍照';
29+
String get shootingTips => '轻触拍照';
3730

3831
@override
39-
String loadFailed = '加载失败';
32+
String get loadFailed => '加载失败';
4033
}
4134

4235
/// Default text delegate including recording implements with Chinese.
43-
/// 中文文字实现
36+
/// 中文文字实现(包括摄像)
4437
class DefaultCameraPickerTextDelegateWithRecording
45-
implements CameraPickerTextDelegate {
46-
factory DefaultCameraPickerTextDelegateWithRecording() => _instance;
47-
48-
DefaultCameraPickerTextDelegateWithRecording._internal();
49-
50-
static final DefaultCameraPickerTextDelegateWithRecording _instance =
51-
DefaultCameraPickerTextDelegateWithRecording._internal();
52-
38+
extends DefaultCameraPickerTextDelegate {
5339
@override
54-
String confirm = '确认';
40+
String get shootingTips => '轻触拍照,长按摄像';
41+
}
5542

43+
/// Default text delegate including only recording implements with Chinese.
44+
/// 中文文字实现(仅摄像)
45+
class DefaultCameraPickerTextDelegateWithOnlyRecording
46+
extends DefaultCameraPickerTextDelegate {
5647
@override
57-
String shootingTips = '轻触拍照,长按摄像';
48+
String get shootingTips => '长按摄像';
49+
}
5850

51+
/// Default text delegate including tap recording implements with Chinese.
52+
/// 中文文字实现(仅轻触摄像)
53+
class DefaultCameraPickerTextDelegateWithTapRecording
54+
extends DefaultCameraPickerTextDelegate {
5955
@override
60-
String loadFailed = '加载失败';
56+
String get shootingTips => '轻触摄像';
6157
}
6258

6359
/// Default text delegate implements with English.
6460
/// 英文文字实现
6561
class EnglishCameraPickerTextDelegate implements CameraPickerTextDelegate {
66-
factory EnglishCameraPickerTextDelegate() => _instance;
67-
68-
EnglishCameraPickerTextDelegate._internal();
69-
70-
static final EnglishCameraPickerTextDelegate _instance =
71-
EnglishCameraPickerTextDelegate._internal();
72-
7362
@override
74-
String confirm = 'Confirm';
63+
String get confirm => 'Confirm';
7564

7665
@override
77-
String shootingTips = 'Tap to take photo.';
66+
String get shootingTips => 'Tap to take photo.';
7867

7968
@override
80-
String loadFailed = 'Load failed';
69+
String get loadFailed => 'Load failed';
8170
}
8271

8372
/// Default text delegate including recording implements with English.
84-
/// 英文文字实现
73+
/// 英文文字实现(包括摄像)
8574
class EnglishCameraPickerTextDelegateWithRecording
86-
implements CameraPickerTextDelegate {
87-
factory EnglishCameraPickerTextDelegateWithRecording() => _instance;
88-
89-
EnglishCameraPickerTextDelegateWithRecording._internal();
90-
91-
static final EnglishCameraPickerTextDelegateWithRecording _instance =
92-
EnglishCameraPickerTextDelegateWithRecording._internal();
93-
75+
extends EnglishCameraPickerTextDelegate {
9476
@override
95-
String confirm = 'Confirm';
77+
String get shootingTips => 'Tap to take photo. Long press to record video.';
78+
}
9679

80+
/// Default text delegate including only recording implements with English.
81+
/// 英文文字实现(仅摄像)
82+
class EnglishCameraPickerTextDelegateWithOnlyRecording
83+
extends EnglishCameraPickerTextDelegate {
9784
@override
98-
String shootingTips = 'Tap to take photo. Long press to record video.';
85+
String get shootingTips => 'Long press to record video.';
86+
}
9987

88+
/// Default text delegate including tap recording implements with English.
89+
/// 英文文字实现(仅轻触摄像)
90+
class EnglishCameraPickerTextDelegateWithTapRecording
91+
extends EnglishCameraPickerTextDelegate {
10092
@override
101-
String loadFailed = 'Load failed';
93+
String get shootingTips => 'Tap to record video.';
10294
}

0 commit comments

Comments
 (0)