Browse Source

Merge pull request #37 from CaiJingLong/support-HDR

For HDR
Caijinglong 5 years ago
parent
commit
3b42479533
No account linked to committer's email address
6 changed files with 108 additions and 6 deletions
  1. 4
    0
      CHANGELOG.md
  2. 64
    0
      example/lib/asset_image.dart
  3. 6
    0
      example/lib/main.dart
  4. 28
    0
      example/lib/preview.dart
  5. 4
    4
      pubspec.lock
  6. 2
    2
      pubspec.yaml

+ 4
- 0
CHANGELOG.md View File

1
 # CHANGELOG
1
 # CHANGELOG
2
 
2
 
3
+## 0.3.2
4
+
5
+rollback `photo_manager` to `0.3.2`
6
+
3
 ## 0.3.1
7
 ## 0.3.1
4
 
8
 
5
 `photo_manager` to `0.3.1`
9
 `photo_manager` to `0.3.1`

+ 64
- 0
example/lib/asset_image.dart View File

1
+import 'dart:typed_data';
2
+
3
+import 'package:flutter/material.dart';
4
+import 'package:photo_manager/photo_manager.dart';
5
+
6
+class AssetImageWidget extends StatelessWidget {
7
+  final AssetEntity assetEntity;
8
+  final double width;
9
+  final double height;
10
+  final BoxFit boxFit;
11
+
12
+  const AssetImageWidget({
13
+    Key key,
14
+    @required this.assetEntity,
15
+    this.width,
16
+    this.height,
17
+    this.boxFit,
18
+  }) : super(key: key);
19
+
20
+  @override
21
+  Widget build(BuildContext context) {
22
+    if (assetEntity == null) {
23
+      return _buildContainer();
24
+    }
25
+    return FutureBuilder<Size>(
26
+      builder: (c, s) {
27
+        if (!s.hasData) {
28
+          return Container();
29
+        }
30
+        var size = s.data;
31
+        return FutureBuilder<Uint8List>(
32
+          builder: (BuildContext context, snapshot) {
33
+            if (snapshot.hasData) {
34
+              return _buildContainer(
35
+                child: Image.memory(
36
+                  snapshot.data,
37
+                  width: width,
38
+                  height: height,
39
+                  fit: boxFit,
40
+                ),
41
+              );
42
+            } else {
43
+              return _buildContainer();
44
+            }
45
+          },
46
+          future: assetEntity.thumbDataWithSize(
47
+            size.width.toInt(),
48
+            size.height.toInt(),
49
+          ),
50
+        );
51
+      },
52
+      future: assetEntity.size,
53
+    );
54
+  }
55
+
56
+  Widget _buildContainer({Widget child}) {
57
+    child ??= Container();
58
+    return Container(
59
+      width: width,
60
+      height: height,
61
+      child: child,
62
+    );
63
+  }
64
+}

+ 6
- 0
example/lib/main.dart View File

1
+import 'package:example/preview.dart';
1
 import 'package:flutter/cupertino.dart';
2
 import 'package:flutter/cupertino.dart';
2
 import 'package:flutter/material.dart';
3
 import 'package:flutter/material.dart';
3
 import 'package:photo/photo.dart';
4
 import 'package:photo/photo.dart';
162
         r.add(file.absolute.path);
163
         r.add(file.absolute.path);
163
       }
164
       }
164
       currentSelected = r.join("\n\n");
165
       currentSelected = r.join("\n\n");
166
+
167
+      List<AssetEntity> preview = [];
168
+      preview.addAll(imgList);
169
+      Navigator.push(context,
170
+          MaterialPageRoute(builder: (_) => PreviewPage(list: preview)));
165
     }
171
     }
166
     setState(() {});
172
     setState(() {});
167
   }
173
   }

+ 28
- 0
example/lib/preview.dart View File

1
+import 'package:example/asset_image.dart';
2
+import 'package:flutter/material.dart';
3
+import 'package:photo_manager/photo_manager.dart';
4
+
5
+class PreviewPage extends StatelessWidget {
6
+  final List<AssetEntity> list;
7
+
8
+  const PreviewPage({Key key, this.list = const []}) : super(key: key);
9
+
10
+  @override
11
+  Widget build(BuildContext context) {
12
+    return Scaffold(
13
+      appBar: AppBar(
14
+        title: Text("预览"),
15
+      ),
16
+      body: ListView(
17
+        children: list
18
+            .map((item) => AssetImageWidget(
19
+                  assetEntity: item,
20
+                  width: 300,
21
+                  height: 200,
22
+                  boxFit: BoxFit.cover,
23
+                ))
24
+            .toList(),
25
+      ),
26
+    );
27
+  }
28
+}

+ 4
- 4
pubspec.lock View File

66
       name: pedantic
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: "1.4.0"
69
+    version: "1.5.0"
70
   photo_manager:
70
   photo_manager:
71
     dependency: "direct main"
71
     dependency: "direct main"
72
     description:
72
     description:
73
       name: photo_manager
73
       name: photo_manager
74
       url: "https://pub.flutter-io.cn"
74
       url: "https://pub.flutter-io.cn"
75
     source: hosted
75
     source: hosted
76
-    version: "0.3.1"
76
+    version: "0.3.2"
77
   quiver:
77
   quiver:
78
     dependency: transitive
78
     dependency: transitive
79
     description:
79
     description:
92
       name: source_span
92
       name: source_span
93
       url: "https://pub.flutter-io.cn"
93
       url: "https://pub.flutter-io.cn"
94
     source: hosted
94
     source: hosted
95
-    version: "1.5.4"
95
+    version: "1.5.5"
96
   stack_trace:
96
   stack_trace:
97
     dependency: transitive
97
     dependency: transitive
98
     description:
98
     description:
143
     source: hosted
143
     source: hosted
144
     version: "2.0.8"
144
     version: "2.0.8"
145
 sdks:
145
 sdks:
146
-  dart: ">=2.1.0 <3.0.0"
146
+  dart: ">=2.1.1-dev.0.0 <3.0.0"

+ 2
- 2
pubspec.yaml View File

1
 name: photo
1
 name: photo
2
 description: image picker, multi picker support video / icloud asset ,use flutter as ui, if you want to build custom ui,you just use photo_manager.
2
 description: image picker, multi picker support video / icloud asset ,use flutter as ui, if you want to build custom ui,you just use photo_manager.
3
-version: 0.3.1
3
+version: 0.3.2
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.3.1
14
+  photo_manager: ^0.3.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