Ver código fonte

Merge pull request #37 from CaiJingLong/support-HDR

For HDR
Caijinglong 5 anos atrás
pai
commit
3b42479533
Nenhuma conta vinculada ao e-mail do autor do commit
6 arquivos alterados com 108 adições e 6 exclusões
  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 Ver arquivo

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

+ 64
- 0
example/lib/asset_image.dart Ver arquivo

@@ -0,0 +1,64 @@
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 Ver arquivo

@@ -1,3 +1,4 @@
1
+import 'package:example/preview.dart';
1 2
 import 'package:flutter/cupertino.dart';
2 3
 import 'package:flutter/material.dart';
3 4
 import 'package:photo/photo.dart';
@@ -162,6 +163,11 @@ class _MyHomePageState extends State<MyHomePage> with LoadingDelegate {
162 163
         r.add(file.absolute.path);
163 164
       }
164 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 172
     setState(() {});
167 173
   }

+ 28
- 0
example/lib/preview.dart Ver arquivo

@@ -0,0 +1,28 @@
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 Ver arquivo

@@ -66,14 +66,14 @@ packages:
66 66
       name: pedantic
67 67
       url: "https://pub.flutter-io.cn"
68 68
     source: hosted
69
-    version: "1.4.0"
69
+    version: "1.5.0"
70 70
   photo_manager:
71 71
     dependency: "direct main"
72 72
     description:
73 73
       name: photo_manager
74 74
       url: "https://pub.flutter-io.cn"
75 75
     source: hosted
76
-    version: "0.3.1"
76
+    version: "0.3.2"
77 77
   quiver:
78 78
     dependency: transitive
79 79
     description:
@@ -92,7 +92,7 @@ packages:
92 92
       name: source_span
93 93
       url: "https://pub.flutter-io.cn"
94 94
     source: hosted
95
-    version: "1.5.4"
95
+    version: "1.5.5"
96 96
   stack_trace:
97 97
     dependency: transitive
98 98
     description:
@@ -143,4 +143,4 @@ packages:
143 143
     source: hosted
144 144
     version: "2.0.8"
145 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 Ver arquivo

@@ -1,6 +1,6 @@
1 1
 name: photo
2 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 4
 author: caijinglong<cjl_spy@163.com>
5 5
 homepage: https://github.com/CaiJingLong/flutter_photo
6 6
 
@@ -11,7 +11,7 @@ dependencies:
11 11
   flutter:
12 12
     sdk: flutter
13 13
 
14
-  photo_manager: ^0.3.1
14
+  photo_manager: ^0.3.2
15 15
   # photo_manager:
16 16
   #   git:
17 17
   #     url: https://github.com/CaiJingLong/flutter_photo_manager.git