Skip to content

Commit 14de79e

Browse files
WeiJun0507AlexV525
andauthored
➕ Support Drag-to-select feature (#660)
Resolves #674 --------- Co-authored-by: Alex Li <[email protected]>
1 parent fa258ea commit 14de79e

11 files changed

+535
-116
lines changed

.github/workflows/publishable.yml

-26
This file was deleted.

.github/workflows/runnable.yml

+16-13
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ on:
44
push:
55
branches:
66
- main
7-
paths-ignore:
8-
- "**.md"
97
pull_request:
108
branches:
119
- main
12-
paths-ignore:
13-
- "**.md"
1410

1511
env:
16-
MINIMUM_FLUTTER_VERSION: '3.16.0'
12+
MINIMUM_FLUTTER_VERSION: '3.22.3'
1713

1814
jobs:
1915
analyze:
@@ -29,24 +25,31 @@ jobs:
2925
with:
3026
distribution: 'zulu'
3127
java-version: '17'
32-
- uses: subosito/flutter-action@v2
28+
- uses: flutter-actions/setup-flutter@v4
3329
with:
34-
channel: 'stable'
35-
flutter-version: ${{ matrix.flutter-version == 'min' && env.MINIMUM_FLUTTER_VERSION || '' }}
30+
channel: stable
31+
version: ${{ matrix.flutter-version == 'min' && env.MINIMUM_FLUTTER_VERSION || 'latest' }}
3632
- name: Log Dart/Flutter versions
3733
run: |
3834
dart --version
3935
flutter --version
4036
- name: Prepare dependencies
4137
run: flutter pub get
4238
- name: Check Dart code formatting
39+
if: matrix.flutter-version != 'min'
4340
run: dart format . -o none --set-exit-if-changed
4441
- name: Analyze Dart code
4542
run: flutter analyze .
4643
- name: Run tests
4744
run: flutter test
45+
- name: Publish dry-run
46+
if: matrix.flutter-version != 'min'
47+
run: dart pub publish --dry-run
4848
- name: Generate docs
49-
run: dart doc --dry-run .
49+
if: matrix.flutter-version != 'min'
50+
run: |
51+
dart pub global activate dartdoc
52+
dart pub global run dartdoc
5053
5154
test_iOS:
5255
needs: analyze
@@ -61,10 +64,10 @@ jobs:
6164
with:
6265
distribution: 'zulu'
6366
java-version: '17'
64-
- uses: subosito/flutter-[email protected]
67+
- uses: flutter-actions/setup-flutter@v4
6568
with:
6669
channel: stable
67-
flutter-version: ${{ matrix.flutter-version == 'min' && env.MINIMUM_FLUTTER_VERSION || '' }}
70+
version: ${{ matrix.flutter-version == 'min' && env.MINIMUM_FLUTTER_VERSION || 'latest' }}
6871
- run: dart --version
6972
- run: flutter --version
7073
- run: flutter pub get
@@ -83,10 +86,10 @@ jobs:
8386
with:
8487
distribution: 'zulu'
8588
java-version: '17'
86-
- uses: subosito/flutter-[email protected]
89+
- uses: flutter-actions/setup-flutter@v4
8790
with:
8891
channel: stable
89-
flutter-version: ${{ matrix.flutter-version == 'min' && env.MINIMUM_FLUTTER_VERSION || '' }}
92+
version: ${{ matrix.flutter-version == 'min' && env.MINIMUM_FLUTTER_VERSION || 'latest' }}
9093
- run: dart --version
9194
- run: flutter --version
9295
- run: flutter pub get

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ that can be found in the LICENSE file. -->
99
1010
## Unreleased
1111

12+
### New features
13+
14+
- Support drag to select.
15+
1216
### Fixes
1317

1418
- Fixes semantics issues.

README-ZH.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@ Language: [English](README.md) | 中文
3434
该插件仅保证能与 **stable 渠道的 Flutter SDK** 配合使用。
3535
我们不会为其他渠道的 Flutter SDK 做实时支持。
3636

37-
| | 3.0 | 3.3 | 3.7 | 3.10 | 3.13 | 3.16 |
38-
|--------|:---:|:---:|:---:|:----:|:----:|:----:|
39-
| 8.9.0+ |||||||
40-
| 8.7.0+ |||||||
41-
| 8.5.0+ |||||||
42-
| 8.4.0+ |||||||
43-
| 8.0.0+ |||||||
44-
| 7.3.0+ |||||||
37+
| | 3.7 | 3.10 | 3.13 | 3.16 | 3.22 |
38+
|--------|:---:|:----:|:----:|:----:|:----:|
39+
| 9.5.0+ ||||||
40+
| 8.9.0+ ||||||
41+
| 8.7.0+ ||||||
42+
| 8.5.0+ ||||||
43+
| 8.4.0+ ||||||
4544

4645
如果在 `flutter pub get` 时遇到了 `resolve conflict` 失败问题,
4746
请使用 `dependency_overrides` 解决。
@@ -305,6 +304,7 @@ final List<AssetEntity>? result = await AssetPicker.pickAssets(
305304
| assetsChangeCallback | `AssetsChangeCallback<AssetPathEntity>?` | 当系统通知资源变化时将调用的回调 | `null` |
306305
| assetsChangeRefreshPredicate | `AssetsChangeRefreshPredicate<AssetPathEntity>?` | 判断资源变化是否根据 call 和当前选中的路径进行更新 | `null` |
307306
| shouldAutoplayPreview | `bool` | 预览是否应自动播放 | `false` |
307+
| dragToSelect | `bool` | 是否开启拖拽选择 | `true` |
308308

309309
-`maxAssets` 等于 `1`(即单选模式),搭配
310310
`SpecialPickerType.noPreview` 使用会在用户点选资源换时立刻选中并返回。

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ See the [Migration Guide][] to learn how to migrate between breaking changes.
3636
The package only guarantees to be working on **the stable version of Flutter**.
3737
We won't update it in real-time to align with other channels of Flutter.
3838

39-
| | 3.0 | 3.3 | 3.7 | 3.10 | 3.13 | 3.16 |
40-
|--------|:---:|:---:|:---:|:----:|:----:|:----:|
41-
| 8.9.0+ |||||||
42-
| 8.7.0+ |||||||
43-
| 8.5.0+ |||||||
44-
| 8.4.0+ |||||||
45-
| 8.0.0+ |||||||
46-
| 7.3.0+ |||||||
39+
| | 3.7 | 3.10 | 3.13 | 3.16 | 3.22 |
40+
|--------|:---:|:----:|:----:|:----:|:----:|
41+
| 9.5.0+ ||||||
42+
| 8.9.0+ ||||||
43+
| 8.7.0+ ||||||
44+
| 8.5.0+ ||||||
45+
| 8.4.0+ ||||||
4746

4847
If you got a `resolve conflict` error when running `flutter pub get`,
4948
please use `dependency_overrides` to fix it.
@@ -314,6 +313,7 @@ Fields in `AssetPickerConfig`:
314313
| assetsChangeCallback | `AssetsChangeCallback<AssetPathEntity>?` | The callback that will be called when the system notifies assets changes. | `null` |
315314
| assetsChangeRefreshPredicate | `AssetsChangeRefreshPredicate<AssetPathEntity>?` | Whether assets changing should call refresh with the given call and the current selected path. | `null` |
316315
| shouldAutoPlayPreview | `bool` | Whether the preview should auto play. | `false` |
316+
| dragToSelect | `bool` | Whether assets selection can be done with drag gestures. | `true` |
317317

318318
- When `maxAssets` equals to `1` (a.k.a. single picking mode),
319319
use `SpecialPickerType.noPreview` will immediately select asset

example/pubspec.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ version: 9.4.2+64
44
publish_to: none
55

66
environment:
7-
sdk: ^3.2.0
8-
flutter: '>=3.16.0'
7+
sdk: ^3.4.0
8+
flutter: '>=3.22.0'
99

1010
dependencies:
1111
flutter:
@@ -18,7 +18,7 @@ dependencies:
1818
wechat_camera_picker: ^4.2.0
1919

2020
extended_image: any
21-
package_info_plus: '>=5.0.0 <9.0.0'
21+
package_info_plus: '>=6.0.0 <9.0.0'
2222
path: ^1.8.0
2323
path_provider: ^2.0.15
2424
provider: any

lib/src/constants/config.dart

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class AssetPickerConfig {
3939
this.assetsChangeCallback,
4040
this.assetsChangeRefreshPredicate,
4141
this.shouldAutoplayPreview = false,
42+
this.dragToSelect,
4243
}) : assert(
4344
pickerTheme == null || themeColor == null,
4445
'pickerTheme and themeColor cannot be set at the same time.',
@@ -205,4 +206,13 @@ class AssetPickerConfig {
205206
/// Whether the preview should auto play.
206207
/// 预览是否自动播放
207208
final bool shouldAutoplayPreview;
209+
210+
/// {@template wechat_assets_picker.constants.AssetPickerConfig.dragToSelect}
211+
/// Whether assets selection can be done with drag gestures.
212+
/// 是否开启拖拽选择
213+
///
214+
/// The feature enables by default if no accessibility service is being used.
215+
/// 在未使用辅助功能的情况下会默认启用该功能。
216+
/// {@endtemplate}
217+
final bool? dragToSelect;
208218
}

0 commit comments

Comments
 (0)