Browse Source

add pick type params

Caijinglong 5 years ago
parent
commit
04f8abaf81

+ 13
- 12
.vscode/launch.json View File

1
 {
1
 {
2
-    // 使用 IntelliSense 了解相关属性。 
3
-    // 悬停以查看现有属性的描述。
4
-    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5
-    "version": "0.2.0",
6
-    "configurations": [
7
-        {
8
-            "name": "Flutter",
9
-            "request": "launch",
10
-            "type": "dart"
11
-        }
12
-    ]
13
-}
2
+  // 使用 IntelliSense 了解相关属性。
3
+  // 悬停以查看现有属性的描述。
4
+  // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5
+  "version": "0.2.0",
6
+  "configurations": [
7
+    {
8
+      "name": "Flutter",
9
+      "request": "launch",
10
+      "type": "dart",
11
+      "program": "example/lib/main.dart"
12
+    }
13
+  ]
14
+}

+ 0
- 4
example/ios/Runner.xcodeproj/project.pbxproj View File

8
 
8
 
9
 /* Begin PBXBuildFile section */
9
 /* Begin PBXBuildFile section */
10
 		1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
10
 		1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11
-		2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
12
 		3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
11
 		3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
13
 		3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
12
 		3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
14
 		3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
13
 		3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
41
 /* Begin PBXFileReference section */
40
 /* Begin PBXFileReference section */
42
 		1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
41
 		1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
43
 		1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
42
 		1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
44
-		2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
45
 		3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
43
 		3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
46
 		3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
44
 		3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
47
 		7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
45
 		7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
83
 		9740EEB11CF90186004384FC /* Flutter */ = {
81
 		9740EEB11CF90186004384FC /* Flutter */ = {
84
 			isa = PBXGroup;
82
 			isa = PBXGroup;
85
 			children = (
83
 			children = (
86
-				2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
87
 				3B80C3931E831B6300D905FE /* App.framework */,
84
 				3B80C3931E831B6300D905FE /* App.framework */,
88
 				3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
85
 				3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
89
 				9740EEBA1CF902C7004384FC /* Flutter.framework */,
86
 				9740EEBA1CF902C7004384FC /* Flutter.framework */,
211
 				3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
208
 				3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
212
 				9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
209
 				9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
213
 				97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
210
 				97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
214
-				2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
215
 				97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
211
 				97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
216
 			);
212
 			);
217
 			runOnlyForDeploymentPostprocessing = 0;
213
 			runOnlyForDeploymentPostprocessing = 0;

+ 41
- 12
example/lib/main.dart View File

30
 class _MyHomePageState extends State<MyHomePage> with LoadingDelegate {
30
 class _MyHomePageState extends State<MyHomePage> with LoadingDelegate {
31
   String currentSelected = "";
31
   String currentSelected = "";
32
 
32
 
33
-  void _pickImage() async {
33
+  void _pickAsset(PickType type) async {
34
     List<AssetEntity> imgList = await PhotoPicker.pickAsset(
34
     List<AssetEntity> imgList = await PhotoPicker.pickAsset(
35
       // BuildContext required
35
       // BuildContext required
36
       context: context,
36
       context: context,
48
       // the content item radio
48
       // the content item radio
49
       maxSelected: 8,
49
       maxSelected: 8,
50
       // max picker image count
50
       // max picker image count
51
-      provider: I18nProvider.english,
52
-      // provider: I18nProvider.chinese,
51
+      // provider: I18nProvider.english,
52
+      provider: I18nProvider.chinese,
53
       // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
53
       // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
54
       rowCount: 3,
54
       rowCount: 3,
55
       // item row count
55
       // item row count
69
       // if you want to build custom loading widget,extends LoadingDelegate, [see example/lib/main.dart]
69
       // if you want to build custom loading widget,extends LoadingDelegate, [see example/lib/main.dart]
70
 
70
 
71
       badgeDelegate: const DurationBadgeDelegate(),
71
       badgeDelegate: const DurationBadgeDelegate(),
72
+      // badgeDelegate to show badge widget
73
+
74
+      pickType: type,
72
     );
75
     );
73
 
76
 
74
     if (imgList == null) {
77
     if (imgList == null) {
85
   }
88
   }
86
 
89
 
87
   @override
90
   @override
88
-  Widget buildBigImageLoading(
89
-      BuildContext context, AssetEntity entity, Color themeColor) {
91
+  Widget buildBigImageLoading(BuildContext context, AssetEntity entity, Color themeColor) {
90
     return Center(
92
     return Center(
91
       child: Container(
93
       child: Container(
92
         width: 50.0,
94
         width: 50.0,
99
   }
101
   }
100
 
102
 
101
   @override
103
   @override
102
-  Widget buildPreviewLoading(
103
-      BuildContext context, AssetEntity entity, Color themeColor) {
104
+  Widget buildPreviewLoading(BuildContext context, AssetEntity entity, Color themeColor) {
104
     return Center(
105
     return Center(
105
       child: Container(
106
       child: Container(
106
         width: 50.0,
107
         width: 50.0,
119
         title: new Text(widget.title),
120
         title: new Text(widget.title),
120
       ),
121
       ),
121
       body: Container(
122
       body: Container(
122
-        child: Center(
123
-          child: Text(
124
-            '$currentSelected',
125
-            textAlign: TextAlign.center,
123
+        child: SingleChildScrollView(
124
+          child: Column(
125
+            children: <Widget>[
126
+              IconTextButton(icon: Icons.photo, text: "photo", onTap: () => _pickAsset(PickType.onlyImage)),
127
+              IconTextButton(icon: Icons.videocam, text: "video", onTap: () => _pickAsset(PickType.onlyVideo)),
128
+              IconTextButton(icon: Icons.album, text: "all", onTap: () => _pickAsset(PickType.all)),
129
+              Text(
130
+                '$currentSelected',
131
+                textAlign: TextAlign.center,
132
+              ),
133
+            ],
126
           ),
134
           ),
127
         ),
135
         ),
128
       ),
136
       ),
129
       floatingActionButton: new FloatingActionButton(
137
       floatingActionButton: new FloatingActionButton(
130
-        onPressed: _pickImage,
138
+        onPressed: () => _pickAsset(PickType.all),
131
         tooltip: 'pickImage',
139
         tooltip: 'pickImage',
132
         child: new Icon(Icons.add),
140
         child: new Icon(Icons.add),
133
       ),
141
       ),
134
     );
142
     );
135
   }
143
   }
136
 }
144
 }
145
+
146
+class IconTextButton extends StatelessWidget {
147
+  final IconData icon;
148
+  final String text;
149
+  final Function onTap;
150
+
151
+  const IconTextButton({Key key, this.icon, this.text, this.onTap}) : super(key: key);
152
+
153
+  @override
154
+  Widget build(BuildContext context) {
155
+    return InkWell(
156
+      onTap: onTap,
157
+      child: Container(
158
+        child: ListTile(
159
+          leading: Icon(icon ?? Icons.device_unknown),
160
+          title: Text(text ?? ""),
161
+        ),
162
+      ),
163
+    );
164
+  }
165
+}

+ 8
- 44
lib/photo.dart View File

16
 export 'package:photo/src/delegate/checkbox_builder_delegate.dart';
16
 export 'package:photo/src/delegate/checkbox_builder_delegate.dart';
17
 export 'package:photo/src/delegate/loading_delegate.dart';
17
 export 'package:photo/src/delegate/loading_delegate.dart';
18
 export 'package:photo/src/delegate/sort_delegate.dart';
18
 export 'package:photo/src/delegate/sort_delegate.dart';
19
-export 'package:photo/src/provider/i18n_provider.dart'
20
-    show I18NCustomProvider, I18nProvider, CNProvider, ENProvider;
19
+export 'package:photo/src/provider/i18n_provider.dart' show I18NCustomProvider, I18nProvider, CNProvider, ENProvider;
20
+export 'package:photo/src/entity/options.dart' show PickType;
21
 export 'package:photo/src/delegate/badge_delegate.dart';
21
 export 'package:photo/src/delegate/badge_delegate.dart';
22
 
22
 
23
 class PhotoPicker {
23
 class PhotoPicker {
32
 
32
 
33
   static const String rootRouteName = "photo_picker_image";
33
   static const String rootRouteName = "photo_picker_image";
34
 
34
 
35
-  /// use new method [pickAsset]
36
-  ///
37
-  /// This method will be removed in the future.
38
-  @deprecated
39
-  static Future<List<AssetEntity>> pickImage({
40
-    @required BuildContext context,
41
-    int rowCount = 4,
42
-    int maxSelected = 9,
43
-    double padding = 0.5,
44
-    double itemRadio = 1.0,
45
-    Color themeColor,
46
-    Color dividerColor,
47
-    Color textColor,
48
-    Color disableColor,
49
-    int thumbSize = 64,
50
-    I18nProvider provider = I18nProvider.chinese,
51
-    SortDelegate sortDelegate,
52
-    CheckBoxBuilderDelegate checkBoxBuilderDelegate,
53
-    LoadingDelegate loadingDelegate,
54
-  }) {
55
-    return pickAsset(
56
-      context: context,
57
-      rowCount: rowCount,
58
-      maxSelected: maxSelected,
59
-      padding: padding,
60
-      itemRadio: itemRadio,
61
-      themeColor: themeColor,
62
-      dividerColor: dividerColor,
63
-      textColor: textColor,
64
-      disableColor: disableColor,
65
-      thumbSize: thumbSize,
66
-      provider: provider,
67
-      sortDelegate: sortDelegate,
68
-      checkBoxBuilderDelegate: checkBoxBuilderDelegate,
69
-      loadingDelegate: loadingDelegate,
70
-    );
71
-  }
72
-
73
   /// 没有授予权限的时候,会开启一个dialog去帮助用户去应用设置页面开启权限
35
   /// 没有授予权限的时候,会开启一个dialog去帮助用户去应用设置页面开启权限
74
   /// 确定开启设置页面,取消关闭弹窗,无论选择什么,返回值都是null
36
   /// 确定开启设置页面,取消关闭弹窗,无论选择什么,返回值都是null
75
   ///
37
   ///
107
     SortDelegate sortDelegate,
69
     SortDelegate sortDelegate,
108
     CheckBoxBuilderDelegate checkBoxBuilderDelegate,
70
     CheckBoxBuilderDelegate checkBoxBuilderDelegate,
109
     LoadingDelegate loadingDelegate,
71
     LoadingDelegate loadingDelegate,
72
+    PickType pickType = PickType.all,
110
     BadgeDelegate badgeDelegate = const DefaultBadgeDelegate(),
73
     BadgeDelegate badgeDelegate = const DefaultBadgeDelegate(),
111
   }) {
74
   }) {
112
     assert(provider != null, "provider must be not null");
75
     assert(provider != null, "provider must be not null");
113
     assert(context != null, "context must be not null");
76
     assert(context != null, "context must be not null");
77
+    assert(pickType != null, "pickType must be not null");
114
 
78
 
115
     themeColor ??= Theme.of(context)?.primaryColor ?? Colors.black;
79
     themeColor ??= Theme.of(context)?.primaryColor ?? Colors.black;
116
     dividerColor ??= Theme.of(context)?.dividerColor ?? Colors.grey;
80
     dividerColor ??= Theme.of(context)?.dividerColor ?? Colors.grey;
136
       checkBoxBuilderDelegate: checkBoxBuilderDelegate,
100
       checkBoxBuilderDelegate: checkBoxBuilderDelegate,
137
       loadingDelegate: loadingDelegate,
101
       loadingDelegate: loadingDelegate,
138
       badgeDelegate: badgeDelegate,
102
       badgeDelegate: badgeDelegate,
103
+      pickType: pickType,
139
     );
104
     );
140
 
105
 
141
-    return PhotoPicker()._pickImage(
106
+    return PhotoPicker()._pickAsset(
142
       context,
107
       context,
143
       options,
108
       options,
144
       provider,
109
       provider,
145
     );
110
     );
146
   }
111
   }
147
 
112
 
148
-  Future<List<AssetEntity>> _pickImage(
113
+  Future<List<AssetEntity>> _pickAsset(
149
     BuildContext context,
114
     BuildContext context,
150
     Options options,
115
     Options options,
151
     I18nProvider provider,
116
     I18nProvider provider,
167
     return _openGalleryContentPage(context, options, provider);
132
     return _openGalleryContentPage(context, options, provider);
168
   }
133
   }
169
 
134
 
170
-  Future<List<AssetEntity>> _openGalleryContentPage(
171
-      BuildContext context, Options options, I18nProvider provider) async {
135
+  Future<List<AssetEntity>> _openGalleryContentPage(BuildContext context, Options options, I18nProvider provider) async {
172
     return Navigator.of(context).push(
136
     return Navigator.of(context).push(
173
       MaterialPageRoute(
137
       MaterialPageRoute(
174
         builder: (ctx) => PhotoApp(
138
         builder: (ctx) => PhotoApp(

+ 3
- 4
lib/src/delegate/sort_delegate.dart View File

23
   @override
23
   @override
24
   void sort(List<AssetPathEntity> list) {
24
   void sort(List<AssetPathEntity> list) {
25
     list.sort((path1, path2) {
25
     list.sort((path1, path2) {
26
-      if (path1 == AssetPathEntity.all) {
26
+      if (path1.isAll) {
27
         return -1;
27
         return -1;
28
       }
28
       }
29
 
29
 
30
-      if (path2 == AssetPathEntity.all) {
30
+      if (path2.isAll) {
31
         return 1;
31
         return 1;
32
       }
32
       }
33
 
33
 
60
   }
60
   }
61
 
61
 
62
   bool _isScreenShot(AssetPathEntity entity) {
62
   bool _isScreenShot(AssetPathEntity entity) {
63
-    return entity.name.toUpperCase() == "screenshots".toUpperCase() ||
64
-        entity.name.toUpperCase() == "screenshot".toUpperCase();
63
+    return entity.name.toUpperCase() == "screenshots".toUpperCase() || entity.name.toUpperCase() == "screenshot".toUpperCase();
65
   }
64
   }
66
 }
65
 }

+ 9
- 0
lib/src/entity/options.dart View File

31
 
31
 
32
   final BadgeDelegate badgeDelegate;
32
   final BadgeDelegate badgeDelegate;
33
 
33
 
34
+  final PickType pickType;
35
+
34
   const Options({
36
   const Options({
35
     this.rowCount,
37
     this.rowCount,
36
     this.maxSelected,
38
     this.maxSelected,
45
     this.checkBoxBuilderDelegate,
47
     this.checkBoxBuilderDelegate,
46
     this.loadingDelegate,
48
     this.loadingDelegate,
47
     this.badgeDelegate,
49
     this.badgeDelegate,
50
+    this.pickType,
48
   });
51
   });
49
 }
52
 }
53
+
54
+enum PickType {
55
+  all,
56
+  onlyImage,
57
+  onlyVideo,
58
+}

+ 1
- 2
lib/src/provider/config_provider.dart View File

18
     return true;
18
     return true;
19
   }
19
   }
20
 
20
 
21
-  static ConfigProvider of(BuildContext context) =>
22
-      context.inheritFromWidgetOfExactType(ConfigProvider);
21
+  static ConfigProvider of(BuildContext context) => context.inheritFromWidgetOfExactType(ConfigProvider);
23
 }
22
 }

+ 48
- 30
lib/src/ui/page/photo_main_page.dart View File

16
 
16
 
17
 class PhotoMainPage extends StatefulWidget {
17
 class PhotoMainPage extends StatefulWidget {
18
   final ValueChanged<List<AssetEntity>> onClose;
18
   final ValueChanged<List<AssetEntity>> onClose;
19
+  final Options options;
19
 
20
 
20
   const PhotoMainPage({
21
   const PhotoMainPage({
21
     Key key,
22
     Key key,
22
     this.onClose,
23
     this.onClose,
24
+    this.options,
23
   }) : super(key: key);
25
   }) : super(key: key);
24
 
26
 
25
   @override
27
   @override
26
   _PhotoMainPageState createState() => _PhotoMainPageState();
28
   _PhotoMainPageState createState() => _PhotoMainPageState();
27
 }
29
 }
28
 
30
 
29
-class _PhotoMainPageState extends State<PhotoMainPage>
30
-    with SelectedProvider, GalleryListProvider {
31
-  Options get options => ConfigProvider.of(context).options;
31
+class _PhotoMainPageState extends State<PhotoMainPage> with SelectedProvider, GalleryListProvider {
32
+  Options get options => widget.options;
32
 
33
 
33
   I18nProvider get i18nProvider => ConfigProvider.of(context).provider;
34
   I18nProvider get i18nProvider => ConfigProvider.of(context).provider;
34
 
35
 
94
                 splashColor: Colors.transparent,
95
                 splashColor: Colors.transparent,
95
                 child: Text(
96
                 child: Text(
96
                   i18nProvider.getSureText(options, selectedCount),
97
                   i18nProvider.getSureText(options, selectedCount),
97
-                  style: selectedCount == 0
98
-                      ? textStyle.copyWith(color: options.disableColor)
99
-                      : textStyle,
98
+                  style: selectedCount == 0 ? textStyle.copyWith(color: options.disableColor) : textStyle,
100
                 ),
99
                 ),
101
                 onPressed: selectedCount == 0 ? null : sure,
100
                 onPressed: selectedCount == 0 ? null : sure,
102
               ),
101
               ),
154
   }
153
   }
155
 
154
 
156
   Future<void> _refreshList() async {
155
   Future<void> _refreshList() async {
157
-    var pathList = await PhotoManager.getAssetPathList();
156
+    List<AssetPathEntity> pathList;
157
+    switch (options.pickType) {
158
+      case PickType.onlyImage:
159
+        pathList = await PhotoManager.getImageAsset();
160
+        break;
161
+      case PickType.onlyVideo:
162
+        pathList = await PhotoManager.getVideoAsset();
163
+        break;
164
+      default:
165
+        pathList = await PhotoManager.getAssetPathList();
166
+    }
167
+
168
+    if (pathList == null) {
169
+      return;
170
+    }
158
 
171
 
159
     options.sortDelegate.sort(pathList);
172
     options.sortDelegate.sort(pathList);
160
 
173
 
161
     galleryPathList.clear();
174
     galleryPathList.clear();
162
     galleryPathList.addAll(pathList);
175
     galleryPathList.addAll(pathList);
163
 
176
 
164
-    var imageList = await currentPath.assetList;
165
-    AssetPathEntity.all.name = i18nProvider.getAllGalleryText(options);
177
+    List<AssetEntity> imageList;
178
+
179
+    if (pathList.isNotEmpty) {
180
+      imageList = await pathList[0].assetList;
181
+      _currentPath = pathList[0];
182
+    }
183
+
184
+    for (var path in pathList) {
185
+      if (path.isAll) {
186
+        path.name = i18nProvider.getAllGalleryText(options);
187
+      }
188
+    }
189
+
166
     this.list.clear();
190
     this.list.clear();
167
-    this.list.addAll(imageList);
191
+    if (imageList != null) {
192
+      this.list.addAll(imageList);
193
+    }
168
     setState(() {
194
     setState(() {
169
       _isInit = true;
195
       _isInit = true;
170
     });
196
     });
320
     });
346
     });
321
   }
347
   }
322
 
348
 
323
-  void _onTapPreview() {
349
+  void _onTapPreview() async {
324
     var result = new PhotoPreviewResult();
350
     var result = new PhotoPreviewResult();
325
     isPushed = true;
351
     isPushed = true;
326
-    Navigator.of(context)
327
-        .push(
352
+    var v = await Navigator.of(context).push(
328
       MaterialPageRoute(
353
       MaterialPageRoute(
329
         builder: (ctx) => ConfigProvider(
354
         builder: (ctx) => ConfigProvider(
330
               provider: ConfigProvider.of(context).provider,
355
               provider: ConfigProvider.of(context).provider,
337
               ),
362
               ),
338
             ),
363
             ),
339
       ),
364
       ),
340
-    )
341
-        .then(
342
-      (v) {
343
-        if (handlePreviewResult(v)) {
344
-          print(v);
345
-          Navigator.pop(context, v);
346
-          return;
347
-        }
348
-        isPushed = false;
349
-        compareAndRemoveEntities(result.previewSelectedList);
350
-      },
351
     );
365
     );
366
+    if (handlePreviewResult(v)) {
367
+      // print(v);
368
+      Navigator.pop(context, v);
369
+      return;
370
+    }
371
+    isPushed = false;
372
+    compareAndRemoveEntities(result.previewSelectedList);
352
   }
373
   }
353
 
374
 
354
   bool handlePreviewResult(List<AssetEntity> v) {
375
   bool handlePreviewResult(List<AssetEntity> v) {
462
                   height: 44.0,
483
                   height: 44.0,
463
                   alignment: Alignment.center,
484
                   alignment: Alignment.center,
464
                   child: Text(
485
                   child: Text(
465
-                    i18nProvider.getPreviewText(
466
-                        options, widget.selectedProvider),
486
+                    i18nProvider.getPreviewText(options, widget.selectedProvider),
467
                     style: textStyle,
487
                     style: textStyle,
468
                   ),
488
                   ),
469
                   padding: textPadding,
489
                   padding: textPadding,
519
       future: entity.thumbDataWithSize(size, size),
539
       future: entity.thumbDataWithSize(size, size),
520
       builder: (BuildContext context, AsyncSnapshot<Uint8List> snapshot) {
540
       builder: (BuildContext context, AsyncSnapshot<Uint8List> snapshot) {
521
         var futureData = snapshot.data;
541
         var futureData = snapshot.data;
522
-        if (snapshot.connectionState == ConnectionState.done &&
523
-            futureData != null) {
542
+        if (snapshot.connectionState == ConnectionState.done && futureData != null) {
524
           ImageLruCache.setData(entity, size, futureData);
543
           ImageLruCache.setData(entity, size, futureData);
525
           return _buildImageItem(context, futureData);
544
           return _buildImageItem(context, futureData);
526
         }
545
         }
547
       future: entity.videoDuration,
566
       future: entity.videoDuration,
548
       builder: (ctx, snapshot) {
567
       builder: (ctx, snapshot) {
549
         if (snapshot.hasData && snapshot != null) {
568
         if (snapshot.hasData && snapshot != null) {
550
-          var buildBadge =
551
-              badgeDelegate?.buildBadge(context, entity.type, snapshot.data);
569
+          var buildBadge = badgeDelegate?.buildBadge(context, entity.type, snapshot.data);
552
           if (buildBadge == null) {
570
           if (buildBadge == null) {
553
             return Container();
571
             return Container();
554
           } else {
572
           } else {

+ 1
- 0
lib/src/ui/photo_app.dart View File

20
         onClose: (List<AssetEntity> value) {
20
         onClose: (List<AssetEntity> value) {
21
           Navigator.pop(context, value);
21
           Navigator.pop(context, value);
22
         },
22
         },
23
+        options: options,
23
       ),
24
       ),
24
     );
25
     );
25
   }
26
   }

+ 15
- 8
pubspec.lock View File

60
       url: "https://pub.flutter-io.cn"
60
       url: "https://pub.flutter-io.cn"
61
     source: hosted
61
     source: hosted
62
     version: "1.6.2"
62
     version: "1.6.2"
63
-  photo_manager:
64
-    dependency: "direct main"
63
+  pedantic:
64
+    dependency: transitive
65
     description:
65
     description:
66
-      name: photo_manager
66
+      name: pedantic
67
       url: "https://pub.flutter-io.cn"
67
       url: "https://pub.flutter-io.cn"
68
     source: hosted
68
     source: hosted
69
-    version: "0.1.10"
69
+    version: "1.4.0"
70
+  photo_manager:
71
+    dependency: "direct main"
72
+    description:
73
+      path: "../flutter_photo_manager"
74
+      relative: true
75
+    source: path
76
+    version: "0.2.0"
70
   quiver:
77
   quiver:
71
     dependency: transitive
78
     dependency: transitive
72
     description:
79
     description:
85
       name: source_span
92
       name: source_span
86
       url: "https://pub.flutter-io.cn"
93
       url: "https://pub.flutter-io.cn"
87
     source: hosted
94
     source: hosted
88
-    version: "1.4.1"
95
+    version: "1.5.4"
89
   stack_trace:
96
   stack_trace:
90
     dependency: transitive
97
     dependency: transitive
91
     description:
98
     description:
113
       name: term_glyph
120
       name: term_glyph
114
       url: "https://pub.flutter-io.cn"
121
       url: "https://pub.flutter-io.cn"
115
     source: hosted
122
     source: hosted
116
-    version: "1.0.1"
123
+    version: "1.1.0"
117
   test_api:
124
   test_api:
118
     dependency: transitive
125
     dependency: transitive
119
     description:
126
     description:
120
       name: test_api
127
       name: test_api
121
       url: "https://pub.flutter-io.cn"
128
       url: "https://pub.flutter-io.cn"
122
     source: hosted
129
     source: hosted
123
-    version: "0.2.1"
130
+    version: "0.2.2"
124
   typed_data:
131
   typed_data:
125
     dependency: transitive
132
     dependency: transitive
126
     description:
133
     description:
136
     source: hosted
143
     source: hosted
137
     version: "2.0.8"
144
     version: "2.0.8"
138
 sdks:
145
 sdks:
139
-  dart: ">=2.0.0 <3.0.0"
146
+  dart: ">=2.1.0 <3.0.0"

+ 4
- 4
pubspec.yaml View File

11
   flutter:
11
   flutter:
12
     sdk: flutter
12
     sdk: flutter
13
 
13
 
14
-  photo_manager: ^0.1.10
14
+  # photo_manager: ^0.1.10
15
   # photo_manager:
15
   # photo_manager:
16
   #   git:
16
   #   git:
17
   #     url: https://github.com/CaiJingLong/flutter_photo_manager.git
17
   #     url: https://github.com/CaiJingLong/flutter_photo_manager.git
18
-  #     ref: 11705633cbd01724af6aaa6aa8c8b9ca86ea385c
19
-#  photo_manager:
20
-#    path: /Users/caijinglong/code/flutter/plugin/flutter_photo_manager
18
+  #     ref: 29d844b2c4594d7e524d0169658bc4f3b9ef2ddc
19
+  photo_manager:
20
+    path: ../flutter_photo_manager
21
 
21
 
22
 dev_dependencies:
22
 dev_dependencies:
23
   flutter_test:
23
   flutter_test: