Browse Source

fix video ui

lucky1213 4 years ago
parent
commit
03315eeeb7
5 changed files with 40 additions and 19 deletions
  1. BIN
      lib/fonts/iconfont.ttf
  2. 5
    5
      lib/photo.dart
  3. 20
    14
      lib/src/delegate/badge_delegate.dart
  4. 10
    0
      lib/src/engine/iconfont.dart
  5. 5
    0
      pubspec.yaml

BIN
lib/fonts/iconfont.ttf View File


+ 5
- 5
lib/photo.dart View File

@@ -29,7 +29,7 @@ export 'package:photo/src/entity/options.dart' show PickType, PickedEntity;
29 29
 export 'package:photo/src/delegate/badge_delegate.dart';
30 30
 export 'package:photo/src/entity/_theme.dart';
31 31
 export 'package:image_picker/image_picker.dart' show CameraDevice, PickedFile;
32
-export 'package:photo_manager/photo_manager.dart' show AssetEntity;
32
+export 'package:photo_manager/photo_manager.dart' show AssetEntity, AssetType;
33 33
 
34 34
 class PhotoPicker {
35 35
   static PhotoPicker _instance;
@@ -60,7 +60,7 @@ class PhotoPicker {
60 60
     @required BuildContext context,
61 61
     int rowCount = 4,
62 62
     int maxSelected = 9,
63
-    double padding = 1,
63
+    double padding = 0.5,
64 64
     double itemRadio = 1.0,
65 65
     int thumbSize = 180,
66 66
     PhotoTheme theme,
@@ -90,7 +90,7 @@ class PhotoPicker {
90 90
       sortDelegate: sortDelegate,
91 91
       checkBoxBuilderDelegate: DefaultCheckBoxBuilderDelegate(),
92 92
       loadingDelegate: loadingDelegate,
93
-      badgeDelegate: DefaultBadgeDelegate(),
93
+      badgeDelegate: DurationBadgeDelegate(),
94 94
       pickType: pickType,
95 95
     );
96 96
 
@@ -106,7 +106,7 @@ class PhotoPicker {
106 106
   static Future<AssetEntity> pickSingleAsset({
107 107
     @required BuildContext context,
108 108
     int rowCount = 4,
109
-    double padding = 1,
109
+    double padding = 0.5,
110 110
     double itemRadio = 1.0,
111 111
     int thumbSize = 180,
112 112
     PhotoTheme theme,
@@ -207,7 +207,7 @@ class PhotoPicker {
207 207
       sortDelegate: sortDelegate,
208 208
       checkBoxBuilderDelegate: DefaultCheckBoxBuilderDelegate(),
209 209
       loadingDelegate: loadingDelegate,
210
-      badgeDelegate: DefaultBadgeDelegate(),
210
+      badgeDelegate: DurationBadgeDelegate(),
211 211
       pickType: pickType,
212 212
     );
213 213
     assert(provider != null, "provider must be not null");

+ 20
- 14
lib/src/delegate/badge_delegate.dart View File

@@ -1,4 +1,5 @@
1 1
 import 'package:flutter/material.dart';
2
+import 'package:photo/src/engine/iconfont.dart';
2 3
 import 'package:photo_manager/photo_manager.dart';
3 4
 
4 5
 abstract class BadgeDelegate {
@@ -51,28 +52,33 @@ class DurationBadgeDelegate extends BadgeDelegate {
51 52
   Widget buildBadge(BuildContext context, AssetType type, Duration duration) {
52 53
     if (type == AssetType.video) {
53 54
       var s = duration.inSeconds % 60;
54
-      var m = duration.inMinutes % 60;
55
-      var h = duration.inHours;
55
+      var m = duration.inMinutes;
56 56
 
57
-      String text =
58
-          "$h:${m.toString().padLeft(2, '0')}:${s.toString().padLeft(2, '0')}";
57
+      String text = "${m.toString().padLeft(2, '0')}:${s.toString().padLeft(2, '0')}";
59 58
 
60 59
       return Padding(
61
-        padding: const EdgeInsets.all(2.0),
60
+        padding: const EdgeInsets.all(4.0),
62 61
         child: Align(
63 62
           alignment: alignment,
64 63
           child: Container(
65
-            decoration: BoxDecoration(
66
-              color: Theme.of(context).primaryColor.withOpacity(0.65),
64
+            child: Row(
65
+              children: [
66
+                Icon(MutliImagePickerFont.video, size: 20, color: Colors.white,),
67
+                Padding(
68
+                  padding: EdgeInsets.only(left: 6.0),
69
+                  child: Text(
70
+                    text,
71
+                    style: const TextStyle(
72
+                      fontSize: 14.0,
73
+                      color: Colors.white,
74
+                    ),
75
+                  ),
76
+                ),
77
+              ],
67 78
             ),
68
-            child: Text(
69
-              text,
70
-              style: const TextStyle(
71
-                fontSize: 12.0,
72
-                color: Colors.white,
73
-              ),
79
+            padding: EdgeInsets.symmetric(
80
+              horizontal: 2,
74 81
             ),
75
-            padding: const EdgeInsets.all(4.0),
76 82
           ),
77 83
         ),
78 84
       );

+ 10
- 0
lib/src/engine/iconfont.dart View File

@@ -0,0 +1,10 @@
1
+
2
+import 'package:flutter/material.dart';
3
+
4
+class MutliImagePickerFont {
5
+  MutliImagePickerFont._();
6
+  static const String _family = 'PhotoFont';
7
+  static const String _fontPackage = 'photo';
8
+
9
+  static const IconData video = IconData(0xe6bd, fontFamily: _family, fontPackage: _fontPackage);
10
+}

+ 5
- 0
pubspec.yaml View File

@@ -25,6 +25,11 @@ dev_dependencies:
25 25
 
26 26
 # The following section is specific to Flutter.
27 27
 flutter:
28
+  uses-material-design: true
29
+  fonts:
30
+    - family: PhotoFont
31
+      fonts:
32
+        - asset: lib/fonts/iconfont.ttf
28 33
   # To add assets to your package, add an assets section, like this:
29 34
   # assets:
30 35
   #  - images/a_dot_burr.jpeg