Browse Source

调整下grid的高度

onecold 1 year ago
parent
commit
d61622a33a
2 changed files with 16 additions and 70 deletions
  1. 2 58
      entry/src/main/ets/common/util/Utility.ets
  2. 14 12
      entry/src/main/ets/view/LocalMusic.ets

+ 2 - 58
entry/src/main/ets/common/util/Utility.ets

@@ -375,64 +375,6 @@ export class Utility {
   }
 
 
-  //获取资源的属性值
-  static async uriGetAssets(context:Context,uri:string,type:number): Promise<VideoItem> {
-    let isFromFileMan:boolean = false
-    if(uri.startsWith('file://media')){//图库的视频
-      isFromFileMan = false
-    }else{//从文件管理器
-      isFromFileMan = true
-    }
-
-    if(isFromFileMan){
-      return await Utility.uriGetAssetsFromFile(context,uri,type);
-    }
-    try {
-      let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
-      let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
-      // 配置查询条件,使用PhotoViewPicker选择图片返回的uri进行查询
-      predicates.equalTo('uri', uri);
-      let fetchOption: photoAccessHelper.FetchOptions = {
-        fetchColumns: [photoAccessHelper.PhotoKeys.WIDTH, photoAccessHelper.PhotoKeys.HEIGHT,
-          photoAccessHelper.PhotoKeys.TITLE, photoAccessHelper.PhotoKeys.SIZE, photoAccessHelper.PhotoKeys.DURATION],
-        predicates: predicates
-      };
-      let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> =
-        await phAccessHelper.getAssets(fetchOption);
-      // 得到uri对应的PhotoAsset对象,读取文件的部分信息
-      const asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
-
-      let fd = await Utility.getFdDir(uri)
-
-
-      let videoSize = asset.get(photoAccessHelper.PhotoKeys.SIZE).toString()
-      let videoTime = asset.get(photoAccessHelper.PhotoKeys.DATE_ADDED_MS).toString()
-      let fileSize = Utility.formatFSize(Number(videoSize))
-      let cTime = Utility.getFormatDateStr(videoTime,'yyyy-MM-dd HH:mm')
-      // let modifyDate = asset.get(photoAccessHelper.PhotoKeys.DATE_MODIFIED_MS).toString()
-      let item:VideoItem = new VideoItem( asset.displayName, fd,uri,type,Number(videoSize),cTime,
-        await Utility.getFetchFrameByTime(uri),fileSize)
-      console.info('asset displayName: ', asset.displayName);
-      console.info('asset uri: ', asset.uri);
-      console.info('asset photoType: ', asset.photoType);
-      console.info('asset width: ', asset.get(photoAccessHelper.PhotoKeys.WIDTH));
-      console.info('asset height: ', asset.get(photoAccessHelper.PhotoKeys.HEIGHT));
-      console.info('asset SIZE: ' + asset.get(photoAccessHelper.PhotoKeys.SIZE));
-      console.info('asset DURATION: ' + asset.get(photoAccessHelper.PhotoKeys.DURATION));
-      // 获取缩略图
-      // asset.getThumbnail((err, pixelMap) => {
-      //   if (err == undefined) {
-      //     console.info('getThumbnail successful ' + JSON.stringify(pixelMap));
-      //   } else {
-      //     console.error('getThumbnail fail', err);
-      //   }
-      // });
-      return item
-    } catch (error) {
-      console.error('uriGetAssets failed with err: ' + JSON.stringify(error));
-      return new VideoItem('','','',0,0,'')
-    }
-  }
 
   static getTimestampFromDateStr(dateStr: string, format: string = 'yyyy-MM-dd HH:mm'): number {
     // 定义正则表达式以匹配日期字符串中的各部分
@@ -718,6 +660,8 @@ export class Utility {
 
             if(StrUtil.isNotEmpty(metadata.album)){
               album = metadata.album
+            }else{
+              album = ''
             }
 
             if(StrUtil.isNotEmpty(metadata.duration)){

+ 14 - 12
entry/src/main/ets/view/LocalMusic.ets

@@ -643,6 +643,7 @@ export struct LocalMusic {
 
         case 104: //收到查询专辑列表
           this.albumMap = e.data.data1;
+
           this.albumList = e.data.data2
           break;
 
@@ -2330,7 +2331,7 @@ export struct LocalMusic {
             Text(`${this.artistMap.get(item.name)?.length ?? 0}首`)
               .fontSize(this.twoFingerType==1?11:this.twoFingerType==2?12:14)
               .padding({ top: 8 })
-              .visibility(this.modeType === 2 ? Visibility.Visible : Visibility.None)
+              .visibility(this.modeType === 2? Visibility.Visible : Visibility.None)
               .fontColor($r('app.color.text_color'))
               .margin({ left: 10 })
             Text(`${this.albumMap.get(item.name)?.length ?? 0}首`)
@@ -3075,7 +3076,7 @@ export struct LocalMusic {
     .cachedCount(3)
     // .columnsTemplate('1fr '.repeat(this.currentWidthBreakpoint === WidthBreakpoint.WIDTH_SM ? 2 : 5))
     .columnsTemplate(this.twoFingerType==3?'repeat(auto-fit, 150)':this.twoFingerType==2?'repeat(auto-fit, 110)':'repeat(auto-fit, 80)')
-    .rowsGap(this.twoFingerType==3?25:this.twoFingerType==2?20:10)
+    .rowsGap(this.twoFingerType==3?18:this.twoFingerType==2?12:3)
     .visibility(this.isGridMusic?Visibility.Visible:Visibility.None)
     .scale({x:this.scaleValue,y:this.scaleValue,z:1})
     .gesture(PinchGesture({ fingers: 2 })
@@ -3151,8 +3152,8 @@ export struct LocalMusic {
             .alt($r('app.media.ic_avatar6'))
             .clip(true)
             .borderRadius({
-              topLeft: 20,
-              topRight	: 20,
+              topLeft: 12,
+              topRight	: 12,
               bottomLeft: 0,
               bottomRight: 0
             })
@@ -3243,7 +3244,7 @@ export struct LocalMusic {
 
         }
         .width(this.getGridWight())
-        .borderRadius(20)
+        .borderRadius(12)
         .backgroundImage(item.pixelMapPath)
         .backgroundImageSize({ height: '100%',width:'100%' })
         .backgroundBlurStyle(BlurStyle.BACKGROUND_ULTRA_THICK)
@@ -3268,6 +3269,7 @@ export struct LocalMusic {
     }
     .backgroundColor(Color.Transparent)
     .width('100%')
+    .padding({top:15})
     .height(this.getGridAllHeight())
     .onClick(() => {
       if(this.isMultiSelect&&item.type!==CommonConstants.TYPE_IS_DIR){
@@ -3281,16 +3283,16 @@ export struct LocalMusic {
   }
 
   getGridAllHeight(){
-    let heightG = 210
+    let heightG = 222
     switch (this.twoFingerType){
       case 1:
-        heightG = 105
+        heightG = 118
         break;
       case 2:
-        heightG = 155
+        heightG = 168
         break;
       case 3:
-        heightG = 210
+        heightG = 222
         break;
     }
     return heightG
@@ -6223,9 +6225,9 @@ export struct LocalMusic {
           .visibility(this.isPuraWP()?Visibility.None:Visibility.Visible)
           .borderRadius(this.isCoverRectangle ? 20 : '100%')
           .clickEffect({level:ClickEffectLevel.MIDDLE})
-          // .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 1.2, y: 1.2 }).animation({ duration: 500 }),
-          //   TransitionEffect.scale({ x: 0, y: 0 })  ))
-          .align(Alignment.Center)// .opacity(this.isCoverOpacity()||this.isCoverRectangle?0:1)
+          .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 1.2, y: 1.2 }).animation({ duration: 500 }),
+            TransitionEffect.scale({ x: 0, y: 0 })  ))
+          .align(Alignment.Center)//
           .clip(true)
           .rotate({
             x: 0,