Skip to content

Commit 62176e7

Browse files
committed
📝 Add migration guide.
1 parent 8ec0e0b commit 62176e7

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

README-ZH.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Language: [English](README.md) | 中文简体
1717

1818
## 目录 🗂
1919

20+
* [迁移指南](#迁移指南-)
2021
* [特性](#特性-)
2122
* [截图](#截图-)
2223
* [准备工作](#准备工作-)
@@ -38,6 +39,10 @@ Language: [English](README.md) | 中文简体
3839
* [`File``Uint8List`创建`AssetEntity`的方法](#从file或uint8list创建assetentity的方法)
3940
* [控制台提示 'Failed to find GeneratedAppGlideModule'](#控制台提示-failed-to-find-generatedappglidemodule)
4041

42+
## 迁移指南 ♻️
43+
44+
查看 [迁移指南](docs/migration_guide.md).
45+
4146
## 特性 ✨
4247

4348
- [x] 💚 99%的微信风格

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ This project follows the [all-contributors](https://github.com/all-contributors/
3838

3939
## Category 🗂
4040

41+
* [Migration Guide](#migration-guide-)
4142
* [Features](#features-)
4243
* [Screenshots](#screenshots-)
4344
* [Preparing for use](#preparing-for-use-)
@@ -59,6 +60,10 @@ This project follows the [all-contributors](https://github.com/all-contributors/
5960
* [Create `AssetEntity` from `File` or `Uint8List` (rawData)](#create-assetentity-from-file-or-uint8list-rawdata)
6061
* [Console warning 'Failed to find GeneratedAppGlideModule'](#glide-warning-failed-to-find-generatedappglidemodule)
6162

63+
## Migration Guide ♻️
64+
65+
See [Migration Guide](docs/migration_guide.md).
66+
6267
## Features ✨
6368

6469
- [x] 💚 99% simillar to WeChat style.

docs/migration_guide.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Migration Guide
2+
3+
## Migrate to 5.0.0
4+
5+
### Summary
6+
7+
_If you only use the `AssetPicker.pickAssets` and `AssetEntityImageProvider`,
8+
didn't use `AssetPickerViewer`, `AssetPickerProvider`, or other components separately,
9+
you can stop reading._
10+
11+
`AssetPicker` and `AssetPickerViewer` are only a builder since 5.x, all widgets construct were moved
12+
to `AssetPickerBuilderDelegate` and `AssetPickerViewerBuilderDelegate`, and these delegates are both
13+
abstract.
14+
15+
By splitting delegates, now you can build your own picker with custom types, style, and widgets.
16+
17+
### Migration steps
18+
19+
For how to implement a custom picker, see the example's custom page for more implementation details.
20+
21+
* If you have ever use `AssetPickerViewer.pushToViewer`, the properties `assets` has changed to
22+
`previewAssets`.
23+
24+
* If you have extends an `AssetPickerProvider` or `AssetPickerViewerProvider`, it now requires you
25+
to pass generic type `A` and `P`, and handle the entities on your own.
26+
27+
### References
28+
29+
API documentation:
30+
* `AssetPickerBuilderDelegate`: https://pub.dev/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerBuilderDelegate-class.html
31+
* `AssetPickerViewerBuilderDelegate`: https://pub.dev/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerViewerBuilderDelegate-class.html
32+
* `AssetPickerProvider`: https://pub.dev/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerProvider-class.html
33+
* `AssetPickerViewerProvider`: https://pub.dev/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerViewerProvider-class.html

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ import 'package:flutter/services.dart';
1212

1313
import '../constants/constants.dart';
1414

15+
/// The delegate to build the whole picker's components.
16+
///
17+
/// By extending the delegate, you can customize every components on you own.
18+
/// Delegate requires two generic types:
19+
/// * [A] "Asset": The type of your assets. Defaults to [AssetEntity].
20+
/// * [P] "Path": The type of your paths. Defaults to [AssetPathEntity].
1521
abstract class AssetPickerBuilderDelegate<A, P> {
1622
AssetPickerBuilderDelegate({
1723
@required this.provider,

lib/src/provider/asset_picker_provider.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import 'package:flutter/material.dart';
1010
import '../constants/constants.dart';
1111

1212
/// [ChangeNotifier] for assets picker.
13-
/// 资源选择器的 provider model
13+
///
14+
/// The provider maintain all methods that control assets and paths.
15+
/// By extending it you can customize how you can get all assets or paths,
16+
/// how to fetch the next page of assets, how to get the thumb data of a path.
1417
abstract class AssetPickerProvider<A, P> extends ChangeNotifier {
1518
/// Call [getAssetList] with route duration when constructing.
1619
/// 构造时根据路由时长延时获取资源

0 commit comments

Comments
 (0)