Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add CameraPreview quarterTurns paramater #9

Merged
merged 3 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README-ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Language: [English](README.md) | 中文简体
## 截图 📸

| ![](https://tva1.sinaimg.cn/large/007S8ZIlgy1ggtt6yrdqej30u01t017w.jpg) | ![](https://tva1.sinaimg.cn/large/007S8ZIlgy1ggtt6yh3x4j30u01t0wuo.jpg) |
|-----------------|------------------|
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| ![](https://tva1.sinaimg.cn/large/007S8ZIlgy1ggtt6z1h7xj30u01t01kx.jpg) | ![](https://tva1.sinaimg.cn/large/007S8ZIlgy1ggtt6zarvhj30u01t0x5f.jpg) |

## 准备工作 🍭
Expand All @@ -41,15 +41,15 @@ Language: [English](README.md) | 中文简体

## 使用方法 📖

| 参数名 | 类型 | 描述 | 默认值 |
| ------------------------ | -------------------------- | ---------------------------------------------------- | -------------------------------------- |
| isAllowRecording | `bool` | 选择器是否可以录像 | `false` |
| isOnlyAllowRecording | `bool` | 选择器是否仅可以录像。只在 `isAllowRecording` 为 `true` 时有效。 | `false` |
| maximumRecordingDuration | `Duration` | 录制视频最长时长 | `const Duration(seconds: 15)` |
| theme | `ThemeData` | 选择器的主题 | `CameraPicker.themeData(C.themeColor)` |
| textDelegate | `CameraPickerTextDelegate` | 控制部件中的文字实现 | `DefaultCameraPickerTextDelegate` |
| resolutionPreset | `ResolutionPreset` | 相机的分辨率预设 | `ResolutionPreset.max` |

| 参数名 | 类型 | 描述 | 默认值 |
| ------------------------ | -------------------------- | ----------------------------------------------------------------- | -------------------------------------- |
| isAllowRecording | `bool` | 选择器是否可以录像 | `false` |
| isOnlyAllowRecording | `bool` | 选择器是否仅可以录像。只在 `isAllowRecording` 为 `true` 时有效。 | `false` |
| maximumRecordingDuration | `Duration` | 录制视频最长时长 | `const Duration(seconds: 15)` |
| theme | `ThemeData` | 选择器的主题 | `CameraPicker.themeData(C.themeColor)` |
| textDelegate | `CameraPickerTextDelegate` | 控制部件中的文字实现 | `DefaultCameraPickerTextDelegate` |
| resolutionPreset | `ResolutionPreset` | 相机的分辨率预设 | `ResolutionPreset.max` |
| cameraQuarterTurns | `int` | 摄像机视图顺时针旋转次数,每次90度 | `0` |
### 简单的使用方法

```dart
Expand Down
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ This project follows the [all-contributors](https://github.com/all-contributors/

## Category 🗂

* [Features](#features-)
* [Screenshots](#screenshots-)
* [Preparing for use](#preparing-for-use-)
* [Usage](#usage-)
- [Flutter WeChat Camera Picker](#flutter-wechat-camera-picker)
- [Contributors ✨](#contributors-)
- [Category 🗂](#category-)
- [Features ✨](#features-)
- [Screenshots 📸](#screenshots-)
- [Preparing for use 🍭](#preparing-for-use-)
- [Usage 📖](#usage-)
- [Simple usage](#simple-usage)

## Features ✨

Expand All @@ -49,7 +53,7 @@ This project follows the [all-contributors](https://github.com/all-contributors/
## Screenshots 📸

| ![](https://tva1.sinaimg.cn/large/007S8ZIlgy1ggtt6yrdqej30u01t017w.jpg) | ![](https://tva1.sinaimg.cn/large/007S8ZIlgy1ggtt6yh3x4j30u01t0wuo.jpg) |
|-----------------|------------------|
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| ![](https://tva1.sinaimg.cn/large/007S8ZIlgy1ggtt6z1h7xj30u01t01kx.jpg) | ![](https://tva1.sinaimg.cn/large/007S8ZIlgy1ggtt6zarvhj30u01t0x5f.jpg) |

## Preparing for use 🍭
Expand All @@ -60,14 +64,15 @@ Reference:

## Usage 📖

| Name | Type | Description | Default Value |
| ------------------------ | -------------------------- | ------------------------------------------------------------ | -------------------------------------- |
| isAllowRecording | `bool` | Whether the picker can record video. | `false` |
| Name | Type | Description | Default Value |
| ------------------------ | -------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------- |
| isAllowRecording | `bool` | Whether the picker can record video. | `false` |
| isOnlyAllowRecording | `bool` | Whether the picker can only record video. Only available when `isAllowRecording` is `true `. | `false` |
| maximumRecordingDuration | `Duration` | The maximum duration of the video recording process. | `const Duration(seconds: 15)` |
| theme | `ThemeData` | Theme data for the picker. | `CameraPicker.themeData(C.themeColor)` |
| textDelegate | `CameraPickerTextDelegate` | Text delegate that controls text in widgets. | `DefaultCameraPickerTextDelegate` |
| resolutionPreset | `ResolutionPreset` | Present resolution for the camera. | `ResolutionPreset.max` |
| maximumRecordingDuration | `Duration` | The maximum duration of the video recording process. | `const Duration(seconds: 15)` |
| theme | `ThemeData` | Theme data for the picker. | `CameraPicker.themeData(C.themeColor)` |
| textDelegate | `CameraPickerTextDelegate` | Text delegate that controls text in widgets. | `DefaultCameraPickerTextDelegate` |
| resolutionPreset | `ResolutionPreset` | Present resolution for the camera. | `ResolutionPreset.max` |
| cameraQuarterTurns | `int` | The number of clockwise quarter turns the camera view should be rotated. | `0` |

### Simple usage

Expand Down
18 changes: 14 additions & 4 deletions lib/src/widget/camera_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class CameraPicker extends StatefulWidget {
this.maximumRecordingDuration = const Duration(seconds: 15),
this.theme,
this.resolutionPreset = ResolutionPreset.max,
this.cameraQuarterTurns = 0,
CameraPickerTextDelegate textDelegate,
}) : assert(
isAllowRecording == true || isOnlyAllowRecording != true,
Expand All @@ -50,6 +51,10 @@ class CameraPicker extends StatefulWidget {
: DefaultCameraPickerTextDelegate());
}

/// The number of clockwise quarter turns the camera view should be rotated.
/// 摄像机视图顺时针旋转次数,每次90度
final int cameraQuarterTurns;

/// Whether the picker can record video.
/// 选择器是否可以录像
final bool isAllowRecording;
Expand Down Expand Up @@ -81,6 +86,7 @@ class CameraPicker extends StatefulWidget {
bool isOnlyAllowRecording = false,
Duration maximumRecordingDuration = const Duration(seconds: 15),
ThemeData theme,
int cameraQuarterTurns = 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用同样的参数名

CameraPickerTextDelegate textDelegate,
ResolutionPreset resolutionPreset = ResolutionPreset.max,
}) async {
Expand All @@ -99,6 +105,7 @@ class CameraPicker extends StatefulWidget {
isAllowRecording: isAllowRecording,
isOnlyAllowRecording: isOnlyAllowRecording,
theme: theme,
cameraQuarterTurns: cameraQuarterTurns,
textDelegate: textDelegate,
resolutionPreset: resolutionPreset,
),
Expand Down Expand Up @@ -533,7 +540,7 @@ class CameraPickerState extends State<CameraPicker> {
children: <Widget>[
const Spacer(),
// TODO(Alex): There's an issue tracking NPE of the camera plugin, so switching is temporary disabled .
if ((cameras?.length ?? 0) > 1)
if ((cameras?.length ?? 0) > 1)
switchCamerasButton,
],
),
Expand Down Expand Up @@ -683,9 +690,12 @@ class CameraPickerState extends State<CameraPicker> {
children: <Widget>[
if (isInitialized)
Center(
child: AspectRatio(
aspectRatio: cameraController.value.aspectRatio,
child: CameraPreview(cameraController),
child: RotatedBox(
quarterTurns: widget.cameraQuarterTurns ?? 0,
child: AspectRatio(
aspectRatio: cameraController.value.aspectRatio,
child: CameraPreview(cameraController),
),
),
)
else
Expand Down