Browse Source

support custom loading widget delegate

update version to 0.1.1
Caijinglong 6 years ago
parent
commit
90f8744f79
5 changed files with 69 additions and 24 deletions
  1. 4
    0
      CHANGELOG.md
  2. 1
    1
      README.md
  3. 61
    20
      example/lib/main.dart
  4. 1
    1
      pubspec.lock
  5. 2
    2
      pubspec.yaml

+ 4
- 0
CHANGELOG.md View File

1
 # CHANGELOG
1
 # CHANGELOG
2
 
2
 
3
+## [0.1.1] fix bug and add params
4
+
5
+add loadingDelegate
6
+
3
 ## [0.1.0] support video
7
 ## [0.1.0] support video
4
 
8
 
5
 API incompatibility
9
 API incompatibility

+ 1
- 1
README.md View File

24
 
24
 
25
 ```yaml
25
 ```yaml
26
 dependencies:
26
 dependencies:
27
-  photo: ^0.1.0
27
+  photo: ^0.1.1
28
 ```
28
 ```
29
 
29
 
30
 ## import
30
 ## import

+ 61
- 20
example/lib/main.dart View File

1
+import 'package:flutter/cupertino.dart';
1
 import 'package:flutter/material.dart';
2
 import 'package:flutter/material.dart';
2
 import 'package:photo/photo.dart';
3
 import 'package:photo/photo.dart';
3
 import 'package:photo_manager/photo_manager.dart';
4
 import 'package:photo_manager/photo_manager.dart';
26
   _MyHomePageState createState() => new _MyHomePageState();
27
   _MyHomePageState createState() => new _MyHomePageState();
27
 }
28
 }
28
 
29
 
29
-class _MyHomePageState extends State<MyHomePage> {
30
+class _MyHomePageState extends State<MyHomePage> with LoadingDelegate {
30
   String currentSelected = "";
31
   String currentSelected = "";
31
 
32
 
32
   void _pickImage() async {
33
   void _pickImage() async {
33
     List<AssetEntity> imgList = await PhotoPicker.pickImage(
34
     List<AssetEntity> imgList = await PhotoPicker.pickImage(
34
-      context: context, // BuildContext requied
35
+      context: context,
36
+      // BuildContext requied
35
 
37
 
36
       /// The following are optional parameters.
38
       /// The following are optional parameters.
37
-      themeColor: Colors.green, // the title color and bottom color
38
-      padding: 1.0, // item padding
39
-      dividerColor: Colors.grey, // divider color
40
-      disableColor: Colors.grey.shade300, // the check box disable color
41
-      itemRadio: 0.88, // the content item radio
42
-      maxSelected: 8, // max picker image count
43
-      provider: I18nProvider
44
-          .chinese, // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
45
-      rowCount: 5, // item row count
46
-      textColor: Colors.white, // text color
47
-      thumbSize: 150, // preview thumb size , default is 64
48
-      sortDelegate: SortDelegate
49
-          .common, // default is common ,or you make custom delegate to sort your gallery
50
-      checkBoxBuilderDelegate:
51
-          DefaultCheckBoxBuilderDelegate(
52
-            activeColor: Colors.white,
53
-            unselectedColor: Colors.white,
54
-          ), // default is DefaultCheckBoxBuilderDelegate ,or you make custom delegate to create checkbox
39
+      themeColor: Colors.green,
40
+      // the title color and bottom color
41
+      padding: 1.0,
42
+      // item padding
43
+      dividerColor: Colors.grey,
44
+      // divider color
45
+      disableColor: Colors.grey.shade300,
46
+      // the check box disable color
47
+      itemRadio: 0.88,
48
+      // the content item radio
49
+      maxSelected: 8,
50
+      // max picker image count
51
+      provider: I18nProvider.chinese,
52
+      // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
53
+      rowCount: 5,
54
+      // item row count
55
+      textColor: Colors.white,
56
+      // text color
57
+      thumbSize: 150,
58
+      // preview thumb size , default is 64
59
+      sortDelegate: SortDelegate.common,
60
+      // default is common ,or you make custom delegate to sort your gallery
61
+      checkBoxBuilderDelegate: DefaultCheckBoxBuilderDelegate(
62
+        activeColor: Colors.white,
63
+        unselectedColor: Colors.white,
64
+      ),
65
+      // default is D
66
+      loadingDelegate:
67
+          this, // efaultCheckBoxBuilderDelegate ,or you make custom delegate to create checkbox
55
     );
68
     );
56
 
69
 
57
     if (imgList == null) {
70
     if (imgList == null) {
67
     setState(() {});
80
     setState(() {});
68
   }
81
   }
69
 
82
 
83
+  @override
84
+  Widget buildBigImageLoading(
85
+      BuildContext context, AssetEntity entity, Color themeColor) {
86
+    return Center(
87
+      child: Container(
88
+        width: 50.0,
89
+        height: 50.0,
90
+        child: CupertinoActivityIndicator(
91
+          radius: 25.0,
92
+        ),
93
+      ),
94
+    );
95
+  }
96
+
97
+  @override
98
+  Widget buildPreviewLoading(
99
+      BuildContext context, AssetEntity entity, Color themeColor) {
100
+    return Center(
101
+      child: Container(
102
+        width: 50.0,
103
+        height: 50.0,
104
+        child: CupertinoActivityIndicator(
105
+          radius: 25.0,
106
+        ),
107
+      ),
108
+    );
109
+  }
110
+
70
   @override
111
   @override
71
   Widget build(BuildContext context) {
112
   Widget build(BuildContext context) {
72
     return new Scaffold(
113
     return new Scaffold(

+ 1
- 1
pubspec.lock View File

213
       name: photo_manager
213
       name: photo_manager
214
       url: "https://pub.flutter-io.cn"
214
       url: "https://pub.flutter-io.cn"
215
     source: hosted
215
     source: hosted
216
-    version: "0.1.0"
216
+    version: "0.1.2"
217
   plugin:
217
   plugin:
218
     dependency: transitive
218
     dependency: transitive
219
     description:
219
     description:

+ 2
- 2
pubspec.yaml View File

1
 name: photo
1
 name: photo
2
 description: image picker, multi picker,use flutter as ui, if you want to build custom ui,you just use photo_manager.
2
 description: image picker, multi picker,use flutter as ui, if you want to build custom ui,you just use photo_manager.
3
-version: 0.1.0
3
+version: 0.1.1
4
 author: caijinglong<cjl_spy@163.com>
4
 author: caijinglong<cjl_spy@163.com>
5
 homepage: https://github.com/CaiJingLong/flutter_photo
5
 homepage: https://github.com/CaiJingLong/flutter_photo
6
 
6
 
11
   flutter:
11
   flutter:
12
     sdk: flutter
12
     sdk: flutter
13
 
13
 
14
-  photo_manager: ^0.1.0
14
+  photo_manager: ^0.1.2
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