瀏覽代碼

fix pickCamera parameter default & update readme

lucky1213 4 年之前
父節點
當前提交
b05dd0e3bf
共有 4 個文件被更改,包括 81 次插入102 次删除
  1. 67
    79
      README.md
  2. 1
    1
      example/ios/Flutter/.last_build_id
  3. 7
    0
      example/lib/main.dart
  4. 6
    22
      lib/photo.dart

+ 67
- 79
README.md 查看文件

@@ -1,30 +1,24 @@
1 1
 # photo
2 2
 
3
-[![pub package](https://img.shields.io/pub/v/photo.svg)](https://pub.dartlang.org/packages/photo)
4
-[![GitHub](https://img.shields.io/github/license/CaiJingLong/flutter_photo.svg?style=flat-square)](https://github.com/CaiJingLong/flutter_photo)
5
-[![GitHub stars](https://img.shields.io/github/stars/CaiJingLong/flutter_photo.svg?style=social&label=Stars)](https://github.com/CaiJingLong/flutter_photo)
6
-
7 3
 image picker, multi picker
8 4
 
9 5
 support ios icloud
10 6
 
11 7
 support video
12 8
 
9
+support camera
10
+
13 11
 use flutter as ui
14 12
 
15 13
 if you want to build custom ui, you just need api to make custom ui. to use [photo_manager](https://github.com/CaiJingLong/flutter_photo_manager) or fork the library to custom ui.
16 14
 
17
-## Screenshot
18
-
19
-![image](https://github.com/CaiJingLong/some_asset/blob/master/image_picker1.gif)
20
-
21 15
 ## install
22 16
 
23
-latest version : [![pub package](https://img.shields.io/pub/v/photo.svg)](https://pub.dartlang.org/packages/photo)
24
-
25 17
 ```yaml
26 18
 dependencies:
27
-  photo: $latest_version
19
+  photo: 
20
+    git: 
21
+      url: https://git.links123.net/lucky1213/mutli_image_picker.git
28 22
 ```
29 23
 
30 24
 ## Import
@@ -34,65 +28,80 @@ import 'package:photo/photo.dart';
34 28
 import 'package:photo_manager/photo_manager.dart';
35 29
 ```
36 30
 
37
-## Usage
31
+## Usage 从相册选择
38 32
 
39
-### Simple use
33
+### 简单示例
40 34
 
41 35
 ```dart
42 36
 void pickAssets() async {
43
-    List<AssetEntity> assetList = await PhotoPicker.pickAsset(context: context);
44
-    /// Use assetList to do something.
37
+  PickedEntity result = await PhotoPicker.pickAsset(
38
+    context: context, 
39
+    provider: locale,
40
+    type: PickType.onlyImage,
41
+  );
42
+  /// Use assetList to do something.
45 43
 }
46 44
 ```
47 45
 
48
-### More option
46
+### 更多的参数
49 47
 
50 48
 The context is required, other params is optional.
51 49
 
52 50
 ```dart
53 51
 void pickAsset() async {
54
-    List<AssetEntity> imgList = await PhotoPicker.pickAsset(
55
-      context: context,
56
-      // BuildContext requied
57
-
58
-      /// The following are optional parameters.
59
-      themeColor: Colors.green,
60
-      // the title color and bottom color
61
-      padding: 1.0,
62
-      // item padding
63
-      dividerColor: Colors.grey,
64
-      // divider color
65
-      disableColor: Colors.grey.shade300,
66
-      // the check box disable color
67
-      itemRadio: 0.88,
68
-      // the content item radio
69
-      maxSelected: 8,
70
-      // max picker image count
71
-      provider: I18nProvider.chinese,
72
-      // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
73
-      rowCount: 5,
74
-      // item row count
75
-      textColor: Colors.white,
76
-      // text color
77
-      thumbSize: 150,
78
-      // preview thumb size , default is 64
79
-      sortDelegate: SortDelegate.common,
80
-      // default is common ,or you make custom delegate to sort your gallery
81
-      checkBoxBuilderDelegate: DefaultCheckBoxBuilderDelegate(
82
-        activeColor: Colors.white,
83
-        unselectedColor: Colors.white,
84
-        checkColor: Colors.blue,
85
-      ), // default is DefaultCheckBoxBuilderDelegate ,or you make custom delegate to create checkbox
86
-
87
-      loadingDelegate:
88
-          this, // if you want to build custom loading widget,extends LoadingDelegate [see example/lib/main.dart]
89
-
90
-      badgeDelegate: const DefaultBadgeDelegate(), /// or custom class extends [BadgeDelegate]
91
-
92
-      pickType: type, // all/image/video
93
-
94
-      List<AssetPathEntity> photoPathList, /// when [photoPathList] is not null , [pickType] invalid .
95
-    );
52
+  PickedEntity result = await PhotoPicker.pickAsset(
53
+    // BuildContext requied
54
+    context: context,
55
+    // item row count
56
+    rowCount: 4,
57
+    // item radio
58
+    itemRadio: 1,
59
+    // max picker image count
60
+    maxSelected: 8,
61
+    // item padding
62
+    padding: 1,
63
+    // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
64
+    provider: I18nProvider.chinese,
65
+    // preview thumb size , default is 128
66
+    thumbSize: 150,
67
+    // theme, 默认使用MaterialApp定义的theme
68
+    theme: PhotoTheme(),
69
+    // default is common ,or you make custom delegate to sort your gallery
70
+    sortDelegate: SortDelegate.common,
71
+    // if you want to build custom loading widget,extends LoadingDelegate [see example/lib/main.dart]
72
+    loadingDelegate: DefaultLoadingDelegate(), 
73
+    // all/image/video
74
+    pickType: type, 
75
+    // 可以理解为相册文件夹 when [photoPathList] is not null , [pickType] invalid .
76
+    List<AssetPathEntity> photoPathList, 
77
+    //  已选择的asset
78
+    List<AssetEntity> pickedAssetList 
79
+  );
80
+```
81
+
82
+## Usage 使用相机
83
+
84
+```dart
85
+void pickCamera() async {
86
+  // 参数来源自 ImagePicker.pickImage
87
+  File result = await PhotoPicker.pickCamera(
88
+    maxWidth: 100, 
89
+    maxHeight: 100,
90
+    imageQuality: 100,
91
+    preferredCameraDevice: CameraDevice.rear,
92
+  );
93
+}
94
+```
95
+
96
+
97
+### 关于`PickedEntity`
98
+
99
+```dart
100
+// 选中的assets 取消/默认 是空数组
101
+List<AssetEntity> asset
102
+
103
+// 是否是原图 默认 false
104
+bool isFullImage
96 105
 ```
97 106
 
98 107
 ### About photoPathList params
@@ -101,10 +110,6 @@ You can use [photo_manager] package to get `List<AssetPathEntity>` and handle or
101 110
 
102 111
 This parameter is then passed into the `pickAsset` method, where the incoming photoList is rendered instead of the data in the album.
103 112
 
104
-## Whole example
105
-
106
-You can see [github](https://github.com/caijinglong/flutter_photo/blob/master/example/) [main.dart](https://github.com/caijinglong/flutter_photo/blob/master/example/lib/main.dart)
107
-
108 113
 ## About android
109 114
 
110 115
 ### Migrate to androidX
@@ -149,23 +154,6 @@ like next
149 154
 <string>App need your agree, can visit your album</string>
150 155
 ```
151 156
 
152
-xcode like image
153
-![in xcode](https://github.com/CaiJingLong/some_asset/blob/master/flutter_photo2.png)
154
-
155 157
 ### Build error
156 158
 
157 159
 if you build error like include of non-modular header inside framework module, see [#10](https://github.com/CaiJingLong/flutter_photo/issues/10) or [so](https://stackoverflow.com/questions/27776497/include-of-non-modular-header-inside-framework-module)
158
-
159
-## Thanks
160
-
161
-Part of the Android code comes from [debuggerx01](https://github.com/debuggerx01).
162
-
163
-## Donate
164
-
165
-If my code helps you, and you're willing to buy me a cup of coffee.
166
-
167
-you can use [paypal](https://paypal.me/caijinglong)
168
-
169
-or scan my alipay
170
-
171
-<img width="200px"  src="https://raw.githubusercontent.com/CaiJingLong/asset_for_picgo/master/20181228213953.png"/>

+ 1
- 1
example/ios/Flutter/.last_build_id 查看文件

@@ -1 +1 @@
1
-e66d98e32fcb326d739aa957c5133ebc
1
+894f424b8531a69bd75214bc0c525b8a

+ 7
- 0
example/lib/main.dart 查看文件

@@ -115,6 +115,13 @@ class _MyHomePageState extends State<MyHomePage> with LoadingDelegate {
115 115
                 text: "all",
116 116
                 onTap: () => _pickAsset(PickType.all),
117 117
               ),
118
+              IconTextButton(
119
+                icon: Icons.camera,
120
+                text: "camera",
121
+                onTap: () {
122
+                  PhotoPicker.pickCamera();
123
+                },
124
+              ),
118 125
               IconTextButton(
119 126
                 icon: CupertinoIcons.reply_all,
120 127
                 text: "Picked asset example.",

+ 6
- 22
lib/photo.dart 查看文件

@@ -29,6 +29,7 @@ export 'package:photo/src/provider/i18n_provider.dart'
29 29
 export 'package:photo/src/entity/options.dart' show PickType, PickedEntity;
30 30
 export 'package:photo/src/delegate/badge_delegate.dart';
31 31
 export 'package:photo/src/entity/_theme.dart';
32
+export 'package:image_picker/image_picker.dart' show CameraDevice;
32 33
 
33 34
 class PhotoPicker {
34 35
   static PhotoPicker _instance;
@@ -44,34 +45,17 @@ class PhotoPicker {
44 45
 
45 46
   /// 没有授予权限的时候,会开启一个dialog去帮助用户去应用设置页面开启权限
46 47
   /// 确定开启设置页面,取消关闭弹窗,无论选择什么,返回值都是null
47
-  ///
48
-  ///
49 48
   /// 当用户给予权限后
50 49
   ///
51
-  ///   当用户确定时,返回一个图片[AssetEntity]列表
50
+  /// 返回一个[PickedEntity] 内有[AssetEntity]以及[isFullImage]
52 51
   ///
53
-  ///   当用户取消时返回一个空数组
52
+  /// 当用户取消时[AssetEntity]返回一个空数组
54 53
   ///
55
-  ///   [photoPathList] 一旦设置 则 [pickType]参数无效
54
+  /// [photoPathList] 一旦设置 则 [pickType]参数无效
56 55
   ///
57
-  ///   [pickedAssetList] 已选择的asset
56
+  /// [pickedAssetList] 已选择的asset
58 57
   ///
59 58
   /// 关于参数可以查看readme文档介绍
60
-  ///
61
-  /// if user not grand permission, then return null and show a dialog to help user open setting.
62
-  /// sure is open setting cancel ,cancel to dismiss dialog, return null
63
-  ///
64
-  /// when user give permission.
65
-  ///
66
-  ///   when user sure , return a [AssetEntity] of [List]
67
-  ///
68
-  ///   when user cancel selected,result is empty list
69
-  ///
70
-  ///   when [photoPathList] is not null , [pickType] invalid
71
-  ///
72
-  ///   [pickedAssetList]: The results of the last selection can be passed in for easy secondary selection.
73
-  ///
74
-  /// params see readme.md
75 59
   static Future<PickedEntity> pickAsset({
76 60
     @required BuildContext context,
77 61
     int rowCount = 4,
@@ -122,7 +106,7 @@ class PhotoPicker {
122 106
     double maxWidth,
123 107
     double maxHeight,
124 108
     int imageQuality,
125
-    CameraDevice preferredCameraDevice,
109
+    CameraDevice preferredCameraDevice = CameraDevice.rear,
126 110
   }) async {
127 111
     return ImagePicker.pickImage(
128 112
       source: ImageSource.camera,