|
@@ -3,7 +3,7 @@ import { VideoItem } from '../viewmodel/VideoItem';
|
|
|
import PlaylistTable from '../common/util/PlaylistTable';
|
|
import PlaylistTable from '../common/util/PlaylistTable';
|
|
|
import MediaTable from '../common/util/MediaTable';
|
|
import MediaTable from '../common/util/MediaTable';
|
|
|
import { emitter } from '@kit.BasicServicesKit';
|
|
import { emitter } from '@kit.BasicServicesKit';
|
|
|
-import { ToastUtil, AppUtil, LogUtil, PreferencesUtil } from '@pura/harmony-utils';
|
|
|
|
|
|
|
+import { ToastUtil, AppUtil, LogUtil, PreferencesUtil, StrUtil } from '@pura/harmony-utils';
|
|
|
import { showEditPlaylistDialog } from '../dialog/PlaylistDialog';
|
|
import { showEditPlaylistDialog } from '../dialog/PlaylistDialog';
|
|
|
import { showAddSongsToPlaylistDialog } from '../dialog/AddSongsToPlaylistDialog';
|
|
import { showAddSongsToPlaylistDialog } from '../dialog/AddSongsToPlaylistDialog';
|
|
|
import { router } from '@kit.ArkUI';
|
|
import { router } from '@kit.ArkUI';
|
|
@@ -31,9 +31,10 @@ interface PlaylistEventData {
|
|
|
@Component
|
|
@Component
|
|
|
export struct PlaylistDetailPage {
|
|
export struct PlaylistDetailPage {
|
|
|
context = this.getUIContext().getHostContext() as common.UIAbilityContext
|
|
context = this.getUIContext().getHostContext() as common.UIAbilityContext
|
|
|
|
|
+ @StorageProp('topRectHeight') topRectHeight: number = 0;
|
|
|
@State playlist: Playlist | null = null
|
|
@State playlist: Playlist | null = null
|
|
|
@State songList: VideoItem[] = []
|
|
@State songList: VideoItem[] = []
|
|
|
- @State isLoading: boolean = true
|
|
|
|
|
|
|
+ @State isLoading: boolean = false
|
|
|
@State isShowEditDialog: boolean = false
|
|
@State isShowEditDialog: boolean = false
|
|
|
@State isPlaying: boolean = false
|
|
@State isPlaying: boolean = false
|
|
|
@State curIndex: number = -1
|
|
@State curIndex: number = -1
|
|
@@ -48,9 +49,7 @@ export struct PlaylistDetailPage {
|
|
|
@StorageProp('themeColor') themeColor: string = CommonConstants.DEFAULT_THEME_COLOR;
|
|
@StorageProp('themeColor') themeColor: string = CommonConstants.DEFAULT_THEME_COLOR;
|
|
|
|
|
|
|
|
aboutToAppear() {
|
|
aboutToAppear() {
|
|
|
- let themeColor = PreferencesUtil.getStringSync('THEME_COLOR', CommonConstants.DEFAULT_THEME_COLOR);
|
|
|
|
|
- AppStorage.setOrCreate('themeColor', themeColor);
|
|
|
|
|
- this.themeColor = themeColor
|
|
|
|
|
|
|
+
|
|
|
// 获取传入的歌单对象
|
|
// 获取传入的歌单对象
|
|
|
const params = router.getParams() as Record<string, Object>
|
|
const params = router.getParams() as Record<string, Object>
|
|
|
if (params && params['playlist']) {
|
|
if (params && params['playlist']) {
|
|
@@ -72,8 +71,14 @@ export struct PlaylistDetailPage {
|
|
|
*/
|
|
*/
|
|
|
async loadPlaylistDetail() {
|
|
async loadPlaylistDetail() {
|
|
|
try {
|
|
try {
|
|
|
- this.isLoading = true
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //先获取缓存
|
|
|
|
|
+ const cacheSongs:string =PreferencesUtil.getStringSync(this.playlistId+'currentSongList', '')
|
|
|
|
|
+ if(StrUtil.isNotEmpty(cacheSongs)){
|
|
|
|
|
+ console.log('onecold loadPlaylistDetail 获取缓存成功')
|
|
|
|
|
+ this.songList = JSON.parse(cacheSongs) as VideoItem[]
|
|
|
|
|
+ }else{
|
|
|
|
|
+ console.log('onecold loadPlaylistDetail 歌曲数据为空')
|
|
|
|
|
+ }
|
|
|
if (!this.playlist) {
|
|
if (!this.playlist) {
|
|
|
ToastUtil.showToast('歌单不存在')
|
|
ToastUtil.showToast('歌单不存在')
|
|
|
router.back()
|
|
router.back()
|
|
@@ -399,7 +404,7 @@ export struct PlaylistDetailPage {
|
|
|
// 顶部安全区和标题栏
|
|
// 顶部安全区和标题栏
|
|
|
Column() {
|
|
Column() {
|
|
|
Blank()
|
|
Blank()
|
|
|
- .height(px2vp(AppUtil.getStatusBarHeight()))
|
|
|
|
|
|
|
+ .height(this.topRectHeight+5)
|
|
|
.backgroundColor($r('app.color.title_bar_bg'))
|
|
.backgroundColor($r('app.color.title_bar_bg'))
|
|
|
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
|
|
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
|
|
|
|
|
|
|
@@ -679,24 +684,25 @@ export struct PlaylistDetailPage {
|
|
|
// 歌曲列表标题 - 简化设计,与LocalMusic保持一致
|
|
// 歌曲列表标题 - 简化设计,与LocalMusic保持一致
|
|
|
if (this.songList.length > 0) {
|
|
if (this.songList.length > 0) {
|
|
|
Row() {
|
|
Row() {
|
|
|
|
|
+
|
|
|
Text('歌曲列表')
|
|
Text('歌曲列表')
|
|
|
.fontSize(16)
|
|
.fontSize(16)
|
|
|
.fontWeight(FontWeight.Medium)
|
|
.fontWeight(FontWeight.Medium)
|
|
|
.fontColor($r('app.color.text_color'))
|
|
.fontColor($r('app.color.text_color'))
|
|
|
.opacity(0.9)
|
|
.opacity(0.9)
|
|
|
- .layoutWeight(1)
|
|
|
|
|
|
|
|
|
|
Text(`${this.songList.length}首`)
|
|
Text(`${this.songList.length}首`)
|
|
|
.fontSize(14)
|
|
.fontSize(14)
|
|
|
.fontColor($r('app.color.text_color'))
|
|
.fontColor($r('app.color.text_color'))
|
|
|
|
|
+ .margin({ left: 8 })
|
|
|
.opacity(0.6)
|
|
.opacity(0.6)
|
|
|
-
|
|
|
|
|
|
|
+ Blank()
|
|
|
// 添加歌曲按钮
|
|
// 添加歌曲按钮
|
|
|
Button() {
|
|
Button() {
|
|
|
Row({ space: 6 }) {
|
|
Row({ space: 6 }) {
|
|
|
SymbolGlyph($r('sys.symbol.plus'))
|
|
SymbolGlyph($r('sys.symbol.plus'))
|
|
|
- .fontSize(22)
|
|
|
|
|
- .fontColor([this.themeColor])
|
|
|
|
|
|
|
+ .fontSize(20)
|
|
|
|
|
+ .fontColor([Color.White])
|
|
|
.effectStrategy(SymbolEffectStrategy.HIERARCHICAL)
|
|
.effectStrategy(SymbolEffectStrategy.HIERARCHICAL)
|
|
|
.alignSelf(ItemAlign.Center)
|
|
.alignSelf(ItemAlign.Center)
|
|
|
|
|
|
|
@@ -752,7 +758,7 @@ export struct PlaylistDetailPage {
|
|
|
.objectFit(ImageFit.Cover)
|
|
.objectFit(ImageFit.Cover)
|
|
|
.interpolation(ImageInterpolation.High)
|
|
.interpolation(ImageInterpolation.High)
|
|
|
.autoResize(true)
|
|
.autoResize(true)
|
|
|
- .margin({ left: 16 })
|
|
|
|
|
|
|
+ .margin({ left: 20 })
|
|
|
.onClick(() => {
|
|
.onClick(() => {
|
|
|
this.playSong(song, index)
|
|
this.playSong(song, index)
|
|
|
})
|
|
})
|
|
@@ -772,6 +778,12 @@ export struct PlaylistDetailPage {
|
|
|
.layoutWeight(1)
|
|
.layoutWeight(1)
|
|
|
.margin({ top: 8, left: 12 })
|
|
.margin({ top: 8, left: 12 })
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ .width('100%')
|
|
|
|
|
+
|
|
|
|
|
+ // 歌手和专辑信息 - 参考LocalMusic的第二行布局
|
|
|
|
|
+ Row() {
|
|
|
// 音质标签
|
|
// 音质标签
|
|
|
if (song.md5Str) {
|
|
if (song.md5Str) {
|
|
|
Text(song.md5Str?.includes('Lossless') ? '无损' : song.md5Str)
|
|
Text(song.md5Str?.includes('Lossless') ? '无损' : song.md5Str)
|
|
@@ -780,41 +792,25 @@ export struct PlaylistDetailPage {
|
|
|
.fontWeight(500)
|
|
.fontWeight(500)
|
|
|
.padding({ top: 2, right: 6, left: 6, bottom: 2 })
|
|
.padding({ top: 2, right: 6, left: 6, bottom: 2 })
|
|
|
.borderRadius(4)
|
|
.borderRadius(4)
|
|
|
- .margin({ top: 8, left: 8 })
|
|
|
|
|
.backgroundColor( '#FFC107')
|
|
.backgroundColor( '#FFC107')
|
|
|
.visibility(song.md5Str ? Visibility.Visible : Visibility.None)
|
|
.visibility(song.md5Str ? Visibility.Visible : Visibility.None)
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- .width('100%')
|
|
|
|
|
-
|
|
|
|
|
- // 歌手和专辑信息 - 参考LocalMusic的第二行布局
|
|
|
|
|
- Row() {
|
|
|
|
|
Text(song.artist)
|
|
Text(song.artist)
|
|
|
.fontSize(13)
|
|
.fontSize(13)
|
|
|
.fontColor(this.isPlaying && this.curIndex === index ?this.themeColor : $r('app.color.text_color'))
|
|
.fontColor(this.isPlaying && this.curIndex === index ?this.themeColor : $r('app.color.text_color'))
|
|
|
.fontWeight(this.isPlaying && this.curIndex === index ? FontWeight.Medium : FontWeight.Normal)
|
|
.fontWeight(this.isPlaying && this.curIndex === index ? FontWeight.Medium : FontWeight.Normal)
|
|
|
.maxLines(1)
|
|
.maxLines(1)
|
|
|
|
|
+ .margin({ left: 8 })
|
|
|
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
|
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
|
|
- .layoutWeight(1)
|
|
|
|
|
.opacity(this.isPlaying && this.curIndex === index ? 1.0 : 0.8)
|
|
.opacity(this.isPlaying && this.curIndex === index ? 1.0 : 0.8)
|
|
|
- Text(song.album)
|
|
|
|
|
|
|
+ Text(song.duration)
|
|
|
.fontSize(13)
|
|
.fontSize(13)
|
|
|
.fontColor(this.isPlaying && this.curIndex === index ? this.themeColor : $r('app.color.text_color'))
|
|
.fontColor(this.isPlaying && this.curIndex === index ? this.themeColor : $r('app.color.text_color'))
|
|
|
.fontWeight(this.isPlaying && this.curIndex === index ? FontWeight.Medium : FontWeight.Normal)
|
|
.fontWeight(this.isPlaying && this.curIndex === index ? FontWeight.Medium : FontWeight.Normal)
|
|
|
.maxLines(1)
|
|
.maxLines(1)
|
|
|
|
|
+ .margin({ left: 8 })
|
|
|
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
|
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
|
|
- .layoutWeight(1)
|
|
|
|
|
.opacity(this.isPlaying && this.curIndex === index ? 1.0 : 0.8)
|
|
.opacity(this.isPlaying && this.curIndex === index ? 1.0 : 0.8)
|
|
|
-
|
|
|
|
|
- // 时长显示
|
|
|
|
|
- if (song.duration && typeof song.duration === 'number' && song.duration > 0) {
|
|
|
|
|
- Text(this.formatDuration(song.duration))
|
|
|
|
|
- .fontSize(13)
|
|
|
|
|
- .fontColor(this.isPlaying && this.curIndex === index ? this.themeColor : $r('app.color.text_color'))
|
|
|
|
|
- .fontWeight(this.isPlaying && this.curIndex === index ? FontWeight.Medium : FontWeight.Normal)
|
|
|
|
|
- .opacity(this.isPlaying && this.curIndex === index ? 1.0 : 0.7)
|
|
|
|
|
- .margin({ right: 20 })
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
.width('100%')
|
|
.width('100%')
|
|
|
.margin({ left: 12, top: 4 })
|
|
.margin({ left: 12, top: 4 })
|
|
@@ -936,52 +932,14 @@ export struct PlaylistDetailPage {
|
|
|
Column() {
|
|
Column() {
|
|
|
// 空状态图标容器
|
|
// 空状态图标容器
|
|
|
emptyView(this.themeColor)
|
|
emptyView(this.themeColor)
|
|
|
- // Stack() {
|
|
|
|
|
- // // 背景圆圈
|
|
|
|
|
- // Circle({ width: 160, height: 160 })
|
|
|
|
|
- // .fill('#0a59f715')
|
|
|
|
|
- // .border({
|
|
|
|
|
- // width: 2,
|
|
|
|
|
- // color: '#0a59f71a'
|
|
|
|
|
- // })
|
|
|
|
|
- //
|
|
|
|
|
- // // 中间圆圈
|
|
|
|
|
- // Circle({ width: 120, height: 120 })
|
|
|
|
|
- // .fill('#0a59f722')
|
|
|
|
|
- //
|
|
|
|
|
- // // 音符图标
|
|
|
|
|
- // Image($r('app.media.music_red'))
|
|
|
|
|
- // .width(64)
|
|
|
|
|
- // .height(64)
|
|
|
|
|
- // .opacity(0.6)
|
|
|
|
|
- // .fillColor(this.themeColor )
|
|
|
|
|
- // }
|
|
|
|
|
- // .margin({ bottom: 32 })
|
|
|
|
|
- //
|
|
|
|
|
- // // 空状态标题
|
|
|
|
|
- // Text('歌单还是空的')
|
|
|
|
|
- // .fontSize(22)
|
|
|
|
|
- // .fontColor($r('app.color.text_color'))
|
|
|
|
|
- // .fontWeight(FontWeight.Bold)
|
|
|
|
|
- // .margin({ bottom: 12 })
|
|
|
|
|
- // .letterSpacing(0.5)
|
|
|
|
|
- //
|
|
|
|
|
- // // 空状态描述
|
|
|
|
|
- // Text('快来添加你喜欢的音乐吧\n让这个歌单充满美妙的旋律')
|
|
|
|
|
- // .fontSize(15)
|
|
|
|
|
- // .fontColor($r('app.color.text_color'))
|
|
|
|
|
- // .opacity(0.8)
|
|
|
|
|
- // .margin({ bottom: 40 })
|
|
|
|
|
- // .textAlign(TextAlign.Center)
|
|
|
|
|
- // .lineHeight(24)
|
|
|
|
|
- // .maxLines(2)
|
|
|
|
|
|
|
|
|
|
// 添加歌曲按钮
|
|
// 添加歌曲按钮
|
|
|
Button() {
|
|
Button() {
|
|
|
Row({ space: 8 }) {
|
|
Row({ space: 8 }) {
|
|
|
- Text('+')
|
|
|
|
|
|
|
+ SymbolGlyph($r('sys.symbol.plus'))
|
|
|
.fontSize(20)
|
|
.fontSize(20)
|
|
|
- .fontColor(Color.White)
|
|
|
|
|
|
|
+ .fontColor([Color.White])
|
|
|
|
|
+ .alignSelf(ItemAlign.Center)
|
|
|
|
|
|
|
|
Text('添加歌曲')
|
|
Text('添加歌曲')
|
|
|
.fontSize(16)
|
|
.fontSize(16)
|