Skip to content

Commit c6a3da8

Browse files
authored
♻️ Abstract AssetPickerConfig (#250)
1 parent 6ed8423 commit c6a3da8

File tree

9 files changed

+399
-214
lines changed

9 files changed

+399
-214
lines changed

README-ZH.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,23 @@ platform :ios, '9.0'
168168

169169
## 使用方法 📖
170170

171+
### 简单的使用方法
172+
173+
```dart
174+
final List<AssetEntity> assets = await AssetPicker.pickAssets(context);
175+
```
176+
177+
你可以使用 `AssetPickerConfig` 来调整选择时的行为。
178+
179+
```dart
180+
final AssetEntity? entity = await AssetPicker.pickAssets(
181+
context,
182+
pickerConfig: const AssetPickerConfig(),
183+
);
184+
```
185+
186+
`AssetPickerConfig` 的成员说明:
187+
171188
| 参数名 | 类型 | 描述 | 默认值 |
172189
|---------------------------|------------------------------------|------------------------------------------------|-------------------------------------|
173190
| selectedAssets | `List<AssetEntity>?` | 已选的资源。确保不重复选择。如果你允许重复选择,请将其置空。 | `null` |
@@ -192,11 +209,9 @@ platform :ios, '9.0'
192209
| shouldRevertGrid | `bool?` | 判断资源网格是否需要倒序排列 | `null` |
193210
| pageRouteBuilder | `AssetPickerPageRouteBuilder` | 构建 `AssetPickerPageRoute` | `null` |
194211

195-
### 简单的使用方法
212+
### 更详细的使用方法
196213

197-
```dart
198-
final List<AssetEntity> assets = await AssetPicker.pickAssets(context);
199-
```
214+
我们已将常用的调用方法封装在 [example](example) 中。
200215

201216
### 使用自定义代理
202217

@@ -206,10 +221,6 @@ final List<AssetEntity> assets = await AssetPicker.pickAssets(context);
206221
想要了解更多关于自定义代理实现的内容,
207222
查阅 [`example/lib/customs`](example/lib/customs)
208223

209-
### 更详细的使用方法
210-
211-
我们已将常用的调用方法封装在 [example](example) 中。
212-
213224
#### 一般的调用选择情况
214225

215226
你可以在 `example/lib/pages/multi_assets_page.dart`

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ UI designs will be updated following the WeChat update in anytime.
3838
* [Usage](#usage-)
3939
* [Simple usage](#simple-usage)
4040
* [Detailed usage](#detailed-usage)
41+
* [Using custom delegate](#using-custom-delegate)
4142
* [Display selected assets](#display-selected-assets)
4243
* [Register assets change observe callback](#register-assets-change-observe-callback)
4344
* [Customize with your own type or UI](#customize-with-your-own-type-or-ui)
@@ -162,6 +163,23 @@ platform :osx, '10.15'
162163

163164
## Usage 📖
164165

166+
### Simple usage
167+
168+
```dart
169+
final List<AssetEntity> assets = await AssetPicker.pickAssets(context);
170+
```
171+
172+
Use `AssetPickerConfig` for more picking behaviors.
173+
174+
```dart
175+
final AssetEntity? entity = await AssetPicker.pickAssets(
176+
context,
177+
pickerConfig: const AssetPickerConfig(),
178+
);
179+
```
180+
181+
Fields in `AssetPickerConfig`:
182+
165183
| Name | Type | Description | Default |
166184
|---------------------------|-------------------------------|---------------------------------------------------------------------------------------------------------------------|-------------------------------------|
167185
| selectedAssets | `List<AssetEntity>?` | Selected assets. Prevent duplicate selection. If you don't need to prevent duplicate selection, just don't pass it. | `null` |
@@ -184,13 +202,10 @@ platform :osx, '10.15'
184202
| allowSpecialItemWhenEmpty | `bool` | Whether the special item will display or not when assets is empty. | `false` |
185203
| selectPredicate | `AssetSelectPredicate` | Predicate whether an asset can be selected or unselected. | `null` |
186204
| shouldRevertGrid | `bool?` | Whether the assets grid should revert. | `null` |
187-
| pageRouteBuilder | `AssetPickerPageRouteBuilder` | Build `AssetPickerPageRoute` with the given generic type. | `null` |
188205

189-
### Simple usage
206+
### Detailed usage
190207

191-
```dart
192-
final List<AssetEntity> assets = await AssetPicker.pickAssets(context);
193-
```
208+
TL;DR, we've put multiple common usage with the packages into the [example](example).
194209

195210
### Using custom delegate
196211

@@ -200,10 +215,6 @@ See the `Keep scroll offset` pick method in the example for how to implement it.
200215
For more details about custom delegates,
201216
head over to [`example/lib/customs`](example/lib/customs).
202217

203-
### Detailed usage
204-
205-
TL;DR, we've put multiple common usage with the packages into the [example](example).
206-
207218
#### Regular picking
208219

209220
You can both found `List<PickMethod> pickMethods` in

0 commit comments

Comments
 (0)