ソースを参照

[feat]增加日历中,在列表中视频类型显示时长

云天逵 11 ヶ月 前
コミット
cc5239a1cc

+ 1 - 1
lib/dialog/privacy_dialog.dart

@@ -12,7 +12,7 @@ void privacyDialog({required Function onAgree, required Function onDisagree}) {
   const tag = 'privacyDialog';
   SmartDialog.show(
       tag: tag,
-      backType: SmartBackType.normal,
+      backType: SmartBackType.block,
       clickMaskDismiss: false,
       maskColor: ColorName.black,
       builder: (_) {

+ 17 - 0
lib/module/calendar/calendar_month_view.dart

@@ -235,6 +235,22 @@ class CalendarMonthPage extends BasePage<CalendarMonthController> {
                       ),
                     ),
                   ),
+                  if (controller.photoGroup.value.images[index].type == AssetType.video)
+                    Positioned(
+                      bottom: 8.h,
+                      left: 8.w,
+                      child: Container(
+                        padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 2.h),
+                        decoration: BoxDecoration(
+                          color: Colors.black54,
+                          borderRadius: BorderRadius.circular(6.r),
+                        ),
+                        child: Text(
+                          CalendarState.formatDuration(controller.photoGroup.value.images[index].duration),
+                          style: TextStyle(color: Colors.white, fontSize: 12.sp),
+                        ),
+                      ),
+                    ),
                   Positioned(
                     right: 8.w,
                     bottom: 8.h,
@@ -257,6 +273,7 @@ class CalendarMonthPage extends BasePage<CalendarMonthController> {
                                   )),
                             ))),
                   ),
+
                 ],
               ));
         });

+ 6 - 0
lib/module/calendar/calendar_state.dart

@@ -16,6 +16,12 @@ class CalendarState {
     }
   }
 
+  static String formatDuration(int seconds) {
+    int minutes = seconds ~/ 60;
+    int secs = seconds % 60;
+    return '${minutes.toString().padLeft(2, '0')}:${secs.toString().padLeft(2, '0')}';
+  }
+
   static void removePhotosData(Set<String> selectedPhotosIds) {
     monthlyAlbums.removeWhere((album) {
       album.images

+ 34 - 11
lib/module/calendar/calendar_view.dart

@@ -127,20 +127,43 @@ class CalendarPage extends BaseView<CalendarController> {
                 children: List.generate(2, (index) {
                   if (index < photoGroup.images.length) {
                     return GestureDetector(
-                        onTap: () => controller.clickImage(photoGroup, index),
-                        child: Container(
-                          width: 146.w,
-                          height: 146.w,
-                          decoration: BoxDecoration(
-                            borderRadius: BorderRadius.circular(12.r),
-                            image: DecorationImage(
-                              image: AssetEntityImageProvider(
+                      onTap: () => controller.clickImage(photoGroup, index),
+                      child: Stack(
+                        children: [
+                          Container(
+                            width: 146.w,
+                            height: 146.w,
+                            decoration: BoxDecoration(
+                              borderRadius: BorderRadius.circular(12.r),
+                              image: DecorationImage(
+                                image: AssetEntityImageProvider(
                                   photoGroup.images[index],
-                                  isOriginal: false),
-                              fit: BoxFit.cover,
+                                  isOriginal: false,
+                                ),
+                                fit: BoxFit.cover,
+                              ),
                             ),
                           ),
-                        ));
+                          // 如果是视频,显示时长
+                          if (photoGroup.images[index].type == AssetType.video)
+                            Positioned(
+                              bottom: 8.w,
+                              right: 8.w,
+                              child: Container(
+                                padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 2.h),
+                                decoration: BoxDecoration(
+                                  color: Colors.black54,
+                                  borderRadius: BorderRadius.circular(6.r),
+                                ),
+                                child: Text(
+                                  CalendarState.formatDuration(photoGroup.images[index].duration),
+                                  style: TextStyle(color: Colors.white, fontSize: 12.sp),
+                                ),
+                              ),
+                            ),
+                        ],
+                      ),
+                    );
                   } else {
                     return Container(
                       width: 146.w,