Răsfoiți Sursa

保留1*2和2*4卡片

chendeben 1 an în urmă
părinte
comite
4e7e680976

+ 0 - 364
entry/src/main/ets/widget/pages/PlayerWidgetLarge.ets

@@ -1,364 +0,0 @@
-import { WidgetController } from '../../common/widget/WidgetController';
-/**
- * 大尺寸播放器卡片 (4x3)
- * 显示专辑封面、完整信息和扩展控制
- * 需求: 5.3, 2.3, 2.4
- */
-@Entry
-@Component
-struct PlayerWidgetLarge {
-  @LocalStorageProp('isPlaying') isPlaying: boolean = false;
-  @LocalStorageProp('songTitle') songTitle: string = '暂无播放';
-  @LocalStorageProp('songArtist') songArtist: string = '未知艺术家';
-  @LocalStorageProp('songAlbum') songAlbum: string = '未知专辑';
-  @LocalStorageProp('coverImage') coverImage: string = '';
-  @LocalStorageProp('currentTime') currentTime: string = '00:00';
-  @LocalStorageProp('totalTime') totalTime: string = '00:00';
-  @LocalStorageProp('progressPercentage') progressPercentage: number = 0;
-  @LocalStorageProp('hasNext') hasNext: boolean = false;
-  @LocalStorageProp('hasPrevious') hasPrevious: boolean = false;
-  @LocalStorageProp('showProgress') showProgress: boolean = true;
-  @LocalStorageProp('showCover') showCover: boolean = true;
-  @LocalStorageProp('isLoading') isLoading: boolean = false;
-
-  /**
-   * 获取播放按钮图标
-   */
-  private getPlayButtonIcon(): Resource {
-    if (this.isLoading) {
-      return $r('app.media.icon_load');
-    }
-    return this.isPlaying ? $r('app.media.hm_pause') : $r('app.media.hm_play');
-  }
-
-  /**
-   * 格式化显示文本
-   */
-  private getDisplayText(text: string, defaultText: string): string {
-    return (!text || text.trim() === '') ? defaultText : text;
-  }
-
-  /**
-   * 获取文本颜色
-   */
-  private getTextColor(text: string, defaultText: string, normalColor: string): string {
-    return text === defaultText ? '#99000000' : normalColor;
-  }
-
-  /**
-   * 获取专辑封面图片
-   */
-  private getCoverImage(): Resource | string {
-    if (this.coverImage && this.coverImage.trim() !== '' && this.coverImage !== 'undefined') {
-      return this.coverImage;
-    }
-    return $r('app.media.bg_music');
-  }
-
-  build() {
-    Column() {
-      // 顶部信息区域
-      Row() {
-        // 专辑封面 - 更大更圆润
-        Stack() {
-          Image(this.getCoverImage())
-            .width(72)
-            .height(72)
-            .borderRadius(16)
-            .objectFit(ImageFit.Cover)
-          
-          // 播放状态指示器 - 简化版本
-          if (this.isPlaying) {
-            Text('♪')
-              .fontSize(12)
-              .fontColor('#FFFFFF')
-              .padding(4)
-              .backgroundColor('#FF6B6B')
-              .borderRadius(6)
-              .position({ x: 4, y: 4 })
-          } else {
-            Text('⏸')
-              .fontSize(12)
-              .fontColor('#FFFFFF')
-              .padding(4)
-              .backgroundColor('#666666')
-              .borderRadius(6)
-              .position({ x: 4, y: 4 })
-          }
-        }
-        .margin({ right: 16 })
-        .stateStyles({
-          pressed: {
-            .opacity(0.7)
-          },
-          normal: {
-            .opacity(1.0)
-          }
-        })
-        .onClick(() => {
-          console.info('Heanup PlayerWidgetLarge: Cover image clicked');
-          postCardAction(this, {
-            'action': 'router',
-            'abilityName': 'EntryAbility'
-          });
-        })
-
-        // 歌曲信息 - 更现代的排版
-        Column() {
-          // 歌曲标题 - 更大更醒目
-          Text(this.getDisplayText(this.songTitle, '暂无播放'))
-            .fontSize(18)
-            .fontColor(this.getTextColor(this.songTitle, '暂无播放', '#1A1A1A'))
-            .fontWeight(FontWeight.Bold)
-            .maxLines(2)
-            .textOverflow({ overflow: TextOverflow.Ellipsis })
-            .width('100%')
-            .textAlign(TextAlign.Start)
-            .lineHeight(24)
-
-          // 艺术家信息 - 更柔和的颜色
-          Text(this.getDisplayText(this.songArtist, '未知艺术家'))
-            .fontSize(14)
-            .fontColor('#666666')
-            .fontWeight(FontWeight.Medium)
-            .maxLines(1)
-            .textOverflow({ overflow: TextOverflow.Ellipsis })
-            .width('100%')
-            .textAlign(TextAlign.Start)
-            .margin({ top: 4 })
-
-          // 专辑信息 - 更小更淡
-          Text(this.getDisplayText(this.songAlbum, '未知专辑'))
-            .fontSize(12)
-            .fontColor('#999999')
-            .fontWeight(FontWeight.Normal)
-            .maxLines(1)
-            .textOverflow({ overflow: TextOverflow.Ellipsis })
-            .width('100%')
-            .textAlign(TextAlign.Start)
-            .margin({ top: 2 })
-        }
-        .layoutWeight(1)
-        .alignItems(HorizontalAlign.Start)
-        .justifyContent(FlexAlign.Start)
-        .stateStyles({
-          pressed: {
-            .opacity(0.7)
-          },
-          normal: {
-            .opacity(1.0)
-          }
-        })
-        .onClick(() => {
-          console.info('Heanup PlayerWidgetLarge: Song info area clicked');
-          postCardAction(this, {
-            'action': 'router',
-            'abilityName': 'EntryAbility'
-
-          });
-        })
-      }
-      .width('100%')
-      .alignItems(VerticalAlign.Top)
-      .margin({ bottom: 20 })
-
-      // 播放进度区域 - 重新设计
-      if (this.showProgress) {
-        Column() {
-          // 进度条 - 更粗更现代
-          Stack() {
-            // 背景进度条
-            Row()
-              .width('100%')
-              .height(6)
-              .backgroundColor('#F0F0F0')
-              .borderRadius(3)
-            
-            // 当前进度
-            Row()
-              .width(`${this.progressPercentage}%`)
-              .height(6)
-              .backgroundColor('#FF6B6B')  // 使用纯色替代渐变
-              .borderRadius(3)
-          }
-          .width('100%')
-          .stateStyles({
-            pressed: {
-              .opacity(0.7)
-            },
-            normal: {
-              .opacity(1.0)
-            }
-          })
-          .onClick((event) => {
-            if (!this.isLoading) {
-              console.info('Heanup PlayerWidgetLarge: Progress bar clicked');
-              const width = Number(event.target.area.width);
-              const percentage = width > 0 ? (event.x / width * 100) : 0;
-              postCardAction(this, {
-                'action': 'message',
-                'params': {
-                  "func":"seek_to",
-                  'percentage': percentage
-                }
-              });
-            }
-          })
-
-          // 时间显示 - 更现代的样式
-          Row() {
-            Text(this.currentTime)
-              .fontSize(12)
-              .fontColor('#666666')
-              .fontWeight(FontWeight.Medium)
-
-            Blank()
-
-            Text(this.totalTime)
-              .fontSize(12)
-              .fontColor('#666666')
-              .fontWeight(FontWeight.Medium)
-          }
-          .width('100%')
-          .margin({ top: 8 })
-        }
-        .width('100%')
-        .margin({ bottom: 20 })
-      }
-
-      // 播放控制区域 - 重新设计
-      Row() {
-        // 上一首按钮 - 更现代的设计
-        Button() {
-          Image($r('app.media.ic_previous'))
-            .width(24)
-            .height(24)
-            .fillColor(this.hasPrevious ? '#333333' : '#CCCCCC')
-        }
-        .width(48)
-        .height(48)
-        .backgroundColor('#F8F8F8')
-        .borderRadius(24)
-        .enabled(!this.isLoading)
-        .opacity(this.hasPrevious ? 1.0 : 0.6)
-        .stateStyles({
-          pressed: {
-            .opacity(0.7)
-            .backgroundColor('#EEEEEE')
-          },
-          normal: {
-            .opacity(this.hasPrevious ? 1.0 : 0.6)
-            .backgroundColor('#F8F8F8')
-          }
-        })
-        .onClick(() => {
-          console.info(`Heanup PlayerWidgetLarge: Previous button clicked, hasPrevious=${this.hasPrevious}, isLoading=${this.isLoading}`);
-          if (!this.isLoading) {
-            console.info('Heanup PlayerWidgetLarge: Previous button action sent');
-            postCardAction(this, {
-              'action': 'message',
-              'params': {
-                "func":"prev_song"
-              }
-            });
-          } else {
-            console.info('Heanup PlayerWidgetLarge: Previous button disabled due to loading');
-          }
-        })
-
-        Blank()
-
-        // 播放/暂停按钮 - 更大更突出
-        Button() {
-          Image(this.getPlayButtonIcon())
-            .width(32)
-            .height(32)
-            .fillColor('#FFFFFF')
-        }
-        .width(64)
-        .height(64)
-        .backgroundColor(this.isLoading ? '#CCCCCC' : '#FF6B6B')  // 使用纯色替代渐变
-        .borderRadius(32)
-        .enabled(!this.isLoading)
-        .stateStyles({
-          pressed: {
-            .opacity(0.8)
-            .backgroundColor(this.isLoading ? '#AAAAAA' : '#FF5252')
-          },
-          normal: {
-            .opacity(1.0)
-            .backgroundColor(this.isLoading ? '#CCCCCC' : '#FF6B6B')
-          }
-        })
-        .onClick(() => {
-          if (!this.isLoading) {
-            console.info('Heanup PlayerWidgetLarge: Play/Pause button clicked');
-            postCardAction(this, {
-              'action': 'message',
-              'params': {
-                "func":"play_pause"
-              }
-            });
-          }
-        })
-
-        Blank()
-
-        // 下一首按钮 - 与上一首对称
-        Button() {
-          Image($r('app.media.ic_next'))
-            .width(24)
-            .height(24)
-            .fillColor(this.hasNext ? '#333333' : '#CCCCCC')
-        }
-        .width(48)
-        .height(48)
-        .backgroundColor('#F8F8F8')
-        .borderRadius(24)
-        .enabled(!this.isLoading && this.hasNext)  // 确保按钮状态正确
-        .opacity(this.hasNext ? 1.0 : 0.6)
-        .stateStyles({
-          pressed: {
-            .opacity(0.7)
-            .backgroundColor('#EEEEEE')
-          },
-          normal: {
-            .opacity(this.hasNext ? 1.0 : 0.6)
-            .backgroundColor('#F8F8F8')
-          }
-        })
-        .onClick(() => {
-          console.info(`Heanup PlayerWidgetLarge: Next button clicked, hasNext=${this.hasNext}, isLoading=${this.isLoading}`);
-          if (!this.isLoading && this.hasNext) {
-            console.info('Heanup PlayerWidgetLarge: Next button action sent');
-            postCardAction(this, {
-              'action': 'message',
-              'params': {
-                "func":"next_song"
-              }
-            });
-          } else {
-            console.info('Heanup PlayerWidgetLarge: Next button disabled due to loading or no next song');
-          }
-        })
-      }
-      .width('100%')
-      .justifyContent(FlexAlign.SpaceBetween)
-      .alignItems(VerticalAlign.Center)
-    }
-    .width('100%')
-    .height('100%')
-    .padding(20)
-    .backgroundColor('#FFFFFF')
-    .borderRadius(20)
-    .alignItems(HorizontalAlign.Start)
-    .justifyContent(FlexAlign.SpaceBetween)
-    .shadow({
-      radius: 8,
-      color: '#20000000',
-      offsetX: 0,
-      offsetY: 4
-    })
-    // 移除手势支持,form应用不支持复杂交互
-  }
-}

+ 78 - 188
entry/src/main/ets/widget/pages/PlayerWidgetSmall.ets

@@ -1,217 +1,107 @@
 import { WidgetController } from '../../common/widget/WidgetController';
 /**
- * 小尺寸播放器卡片 (2x1)
- * 显示基本播放控制和歌曲名称
+ * 小尺寸播放器卡片 (1x2)
+ * 只显示播放控制按钮:上一首、播放/暂停、下一首
  * 需求: 5.1, 1.4, 1.5
  */
+
 @Entry
 @Component
 struct PlayerWidgetSmall {
   // 卡片数据属性 - 使用LocalStorageProp与FormExtensionAbility通信
   @LocalStorageProp('isPlaying') isPlaying: boolean = false;
-  @LocalStorageProp('songTitle') songTitle: string = '暂无播放';
   @LocalStorageProp('hasNext') hasNext: boolean = false;
   @LocalStorageProp('hasPrevious') hasPrevious: boolean = false;
   @LocalStorageProp('isLoading') isLoading: boolean = false;
 
-  /**
-   * 获取按钮透明度
-   */
-  private getButtonOpacity(enabled: boolean): number {
-    return enabled ? 1.0 : 0.4;
-  }
-
-  /**
-   * 获取按钮颜色
-   */
-  private getButtonColor(enabled: boolean): string {
-    return enabled ? '#FF007DFF' : '#66000000';
-  }
-
-  /**
-   * 获取播放按钮图标
-   */
-  private getPlayButtonIcon(): Resource {
-    if (this.isLoading) {
-      return $r('app.media.hm_play'); // 加载状态图标
-    }
-    console.log('Heanup 当前播放状态:'+this.isPlaying)
-    return this.isPlaying ? $r('app.media.hm_pause') : $r('app.media.hm_play');
-  }
-
-  /**
-   * 格式化歌曲标题显示
-   */
-  private getDisplayTitle(): string {
-    if (!this.songTitle || this.songTitle.trim() === '') {
-      return '暂无播放';
-    }
-    return this.songTitle;
-  }
-
   build() {
+    // 简洁的播放控制条
     Row() {
-      // 播放控制按钮区域
-      Row() {
-        // 上一首按钮
-        Button() {
-          Image($r('app.media.ic_previous2'))
-            .width(24)
-            .height(24)
-            .fillColor("#FF007DFF")
-        }
-        .width(32)
-        .height(32)
-        .backgroundColor(Color.White)
-        .enabled(!this.isLoading)  // 临时启用按钮进行测试
-        .opacity(this.hasPrevious ? 1.0 : 0.6)  // 视觉上显示状态但不禁用
-        .stateStyles({
-          pressed: {
-            .scale({ x: 0.95, y: 0.95 })
-            .opacity(0.8)
-          },
-          normal: {
-            .scale({ x: 1.0, y: 1.0 })
-            .opacity(this.getButtonOpacity(this.hasPrevious))
-          }
-        })
-        .onClick(() => {
-          console.info(`Heanup PlayerWidgetSmall: Previous button clicked, hasPrevious=${this.hasPrevious}, isLoading=${this.isLoading}`);
-          if (!this.isLoading) {
-            console.info('Heanup PlayerWidgetSmall: Previous button action sent');
-            postCardAction(this, {
-              'action': 'message',
-              'params': {
-                "func":"prev_song"
-              }
-            });
-          } else {
-            console.info('Heanup PlayerWidgetSmall: Previous button disabled due to loading');
-          }
-        })
-
-        // 播放/暂停按钮
-        Button() {
-          Image(this.getPlayButtonIcon())
-            .width(20)
-            .height(20)
-            .fillColor('#FFFFFF')
-        }
-        .width(36)
-        .height(36)
-        .backgroundColor(this.isLoading ? '#99007DFF' : '#FF007DFF')
-        .borderRadius(18)
-        .margin({ left: 8, right: 8 })
-        .enabled(!this.isLoading)
-        .stateStyles({
-          pressed: {
-            .scale({ x: 0.95, y: 0.95 })
-            .backgroundColor('#CC007DFF')
-          },
-          normal: {
-            .scale({ x: 1.0, y: 1.0 })
-            .backgroundColor(this.isLoading ? '#99007DFF' : '#FF007DFF')
-          }
-        })
-        .onClick(() => {
-          if (!this.isLoading) {
-            console.info('Heanup PlayerWidgetSmall: Play/Pause button clicked');
-            postCardAction(this, {
-              'action': 'message',
-              'params': {
-                "func":"play_pause"
-              }
-            });
-          }
-        })
-
-        // 下一首按钮
-        Button() {
-          Image($r('app.media.ic_next2'))
-            .width(24)
-            .height(24)
-            .fillColor("#FF007DFF")
-        }
-        .width(32)
-        .height(32)
-        .backgroundColor(Color.White)
-        .enabled(!this.isLoading)  // 临时启用按钮进行测试
-        .opacity(this.hasPrevious ? 1.0 : 0.6)  // 视觉上显示状态但不禁用
-        .stateStyles({
-          pressed: {
-            .scale({ x: 0.95, y: 0.95 })
-            .opacity(0.8)
-          },
-          normal: {
-            .scale({ x: 1.0, y: 1.0 })
-            .opacity(this.getButtonOpacity(this.hasNext))
-          }
-        })
-        .onClick(() => {
-          console.info(`Heanup PlayerWidgetSmall: Next button clicked, hasNext=${this.hasNext}, isLoading=${this.isLoading}`);
-          if (!this.isLoading) {
-            console.info('Heanup PlayerWidgetSmall: Next button action sent');
-            postCardAction(this, {
-              'action': 'message',
-              'params': {
-                "func":"next_song"
-              }
-            });
-          } else {
-            console.info('Heanup PlayerWidgetSmall: Next button disabled due to loading');
-          }
-        })
+      // 上一首按钮
+      Button() {
+        Image($r('app.media.hm_previous'))
+          .width(20)
+          .height(20)
+          .fillColor('#E5FFFFFF')
       }
-      .justifyContent(FlexAlign.Center)
-      .alignItems(VerticalAlign.Center)
+      .width(36)
+      .height(36)
+      .backgroundColor(Color.Transparent)
+      .enabled(!this.isLoading && this.hasPrevious)
+      .opacity(this.hasPrevious ? 1.0 : 0.5)
+      .onClick(() => {
+        console.info(`Heanup PlayerWidgetSmall: Previous button clicked`);
+        if (!this.isLoading && this.hasPrevious) {
+          postCardAction(this, {
+            'action': 'message',
+            'params': {
+              "func":"prev_song"
+            }
+          });
+        }
+      })
 
-      // 歌曲信息区域
-      Column() {
-        Text(this.getDisplayTitle())
-          .fontSize(14)
-          .fontColor(this.songTitle === '暂无播放' ? '#99000000' : '#E6000000')
-          .fontWeight(this.songTitle === '暂无播放' ? FontWeight.Normal : FontWeight.Medium)
-          .maxLines(1)
-          .textOverflow({ overflow: TextOverflow.Ellipsis })
-          .width('100%')
-          .textAlign(TextAlign.Start)
+      // 播放/暂停按钮
+      Button() {
+        SymbolGlyph(this.isPlaying ? $r('sys.symbol.pause_round_triangle_fill') : $r('sys.symbol.play_round_triangle_fill'))
+          .fontSize(28)
+          .symbolEffect(new ReplaceSymbolEffect(EffectScope.WHOLE), true)
+          .fontColor(['#E5FFFFFF'])
       }
-      .layoutWeight(1)
-      .margin({ left: 12 })
-      .alignItems(HorizontalAlign.Start)
-      .justifyContent(FlexAlign.Center)
-      .stateStyles({
-        pressed: {
-          .opacity(0.8)
-        },
-        normal: {
-          .opacity(1.0)
+      .width(44)
+      .height(44)
+      .backgroundColor(Color.Transparent)
+      .margin({ left: 8, right: 8 })
+      .enabled(!this.isLoading)
+      .onClick(() => {
+        console.info('Heanup PlayerWidgetSmall: Play/Pause button clicked');
+        if (!this.isLoading) {
+          postCardAction(this, {
+            'action': 'message',
+            'params': {
+              "func":"play_pause"
+            }
+          });
         }
       })
-      .onClick(() => {
-        console.info('Heanup PlayerWidgetSmall: Song info area clicked');
-        postCardAction(this, {
 
-          'action': 'message',
-          'params': {
-            "func":"open_player"
-          }
-        });
+      // 下一首按钮
+      Button() {
+        Image($r('app.media.hm_next'))
+          .width(20)
+          .height(20)
+          .fillColor('#E5FFFFFF')
+      }
+      .width(36)
+      .height(36)
+      .backgroundColor(Color.Transparent)
+      .enabled(!this.isLoading && this.hasNext)
+      .opacity(this.hasNext ? 1.0 : 0.5)
+      .onClick(() => {
+        console.info(`Heanup PlayerWidgetSmall: Next button clicked`);
+        if (!this.isLoading && this.hasNext) {
+          postCardAction(this, {
+            'action': 'message',
+            'params': {
+              "func":"next_song"
+            }
+          });
+        }
       })
     }
     .width('100%')
     .height('100%')
-    .padding({ left: 16, right: 16, top: 8, bottom: 8 })
-    .backgroundColor('#FFFFFF')
-    .borderRadius(12)
-    .justifyContent(FlexAlign.Start)
+    .justifyContent(FlexAlign.Center)
     .alignItems(VerticalAlign.Center)
-    .shadow({
-      radius: 8,
-      color: '#1A000000',
-      offsetX: 0,
-      offsetY: 2
+    .backgroundColor('#FF2A2A2A')
+    .borderRadius(8)
+    .padding(8)
+    .onClick(() => {
+      console.info('Heanup PlayerWidgetSmall: Container clicked, jumping to main app');
+      postCardAction(this, {
+        'action': 'router',
+        'abilityName': 'EntryAbility'
+      });
     })
-    // 移除手势支持,form应用不支持复杂交互
   }
 }

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
entry/src/main/resources/base/media/default_album_cover.svg


+ 0 - 19
entry/src/main/resources/base/profile/form_config.json

@@ -37,25 +37,6 @@
       "supportDimensions": [
         "2*4"
       ]
-    },
-    {
-      "name": "PlayerWidgetLarge",
-      "description": "大尺寸播放器卡片",
-      "src": "./ets/widget/pages/PlayerWidgetLarge.ets",
-      "uiSyntax": "arkts",
-      "window": {
-        "designWidth": 720,
-        "autoDesignWidth": true
-      },
-      "colorMode": "auto",
-      "isDefault": false,
-      "updateEnabled": true,
-      "scheduledUpdateTime": "10:30",
-      "updateDuration": 1,
-      "defaultDimension": "4*4",
-      "supportDimensions": [
-        "4*4"
-      ]
     }
   ]
 }

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff