|
|
@@ -5,9 +5,22 @@ import { VideoItem } from '../viewmodel/VideoItem';
|
|
|
import MediaTable from '../common/util/MediaTable';
|
|
|
import PlaylistTable from '../common/util/PlaylistTable';
|
|
|
import { LazyDataSource } from '../common/util/LazyDataSource';
|
|
|
-import { common } from '@kit.AbilityKit';
|
|
|
+import { ConfigurationConstant, common } from '@kit.AbilityKit';
|
|
|
import { CommonConstants } from '../common/constants/CommonConstants';
|
|
|
|
|
|
+// 工具函数:将 #RRGGBB 字符串和透明度转为 'rgba(r,g,b,a)' 字符串,深色模式下可返回深色变体
|
|
|
+function themeColorWithAlpha(themeColor: string, alpha: number, isDarkMode: boolean = false): string {
|
|
|
+ if (isDarkMode) {
|
|
|
+ // 深色模式下返回更深的灰色或半透明黑色
|
|
|
+ return `rgba(34,34,34,${alpha + 0.2 > 1 ? 1 : alpha + 0.2})`;
|
|
|
+ }
|
|
|
+ const color = themeColor.replace('#', '');
|
|
|
+ const r = parseInt(color.substring(0, 2), 16);
|
|
|
+ const g = parseInt(color.substring(2, 4), 16);
|
|
|
+ const b = parseInt(color.substring(4, 6), 16);
|
|
|
+ return `rgba(${r},${g},${b},${alpha})`;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* 添加歌曲到歌单对话框内容组件
|
|
|
*/
|
|
|
@@ -16,6 +29,13 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
context = this.getUIContext().getHostContext() as common.UIAbilityContext
|
|
|
@State opacityItem: number = 1; // 控制透明度的状态变量
|
|
|
@StorageProp('themeColor') themeColor: string = CommonConstants.DEFAULT_THEME_COLOR;
|
|
|
+ @State isDarkMode: boolean = false
|
|
|
+ @StorageProp('currentColorMode') @Watch('onColorModeChange') currentMode: number =
|
|
|
+ ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT;
|
|
|
+
|
|
|
+ onColorModeChange() {
|
|
|
+ this.isDarkMode = this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK
|
|
|
+ }
|
|
|
@State selectedSongs: VideoItem[] = []
|
|
|
@State isLoading: boolean = false
|
|
|
@State searchText: string = ''
|
|
|
@@ -38,7 +58,10 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
onCancel?: () => void
|
|
|
|
|
|
aboutToAppear() {
|
|
|
+ // 初始化深色模式状态
|
|
|
+ this.isDarkMode = this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK
|
|
|
LogUtil.info('heanup AddSongsToPlaylistDialogContent aboutToAppear 开始')
|
|
|
+ LogUtil.info('heanup 初始化深色模式状态: ' + this.isDarkMode + ', currentMode: ' + this.currentMode)
|
|
|
LogUtil.info('heanup playlist: ' +
|
|
|
(this.playlist ? JSON.stringify({ id: this.playlist.id, name: this.playlist.name }) : 'null'))
|
|
|
console.info('onecold mediaKuList 对话框 aboutToAppear=' + this.mediaKuList.length)
|
|
|
@@ -150,17 +173,18 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
Image($r('app.media.ic_action_search'))
|
|
|
.width(20)
|
|
|
.height(20)
|
|
|
- .fillColor($r('app.color.text_color'))
|
|
|
+ .fillColor(this.isDarkMode ? '#8E8E93' : $r('app.color.text_color'))
|
|
|
.opacity(0.6)
|
|
|
|
|
|
TextInput({ placeholder: '搜索歌曲、歌手或专辑', text: this.searchText })
|
|
|
.layoutWeight(1)
|
|
|
.height(35)
|
|
|
- .backgroundColor($r('app.color.input_background'))
|
|
|
+ .backgroundColor(this.isDarkMode ? '#2C2C2E' : $r('app.color.input_background'))
|
|
|
.borderRadius(8)
|
|
|
.padding({ left: 8, right: 8 })
|
|
|
.fontSize(14)
|
|
|
- .fontColor($r('app.color.text_color'))
|
|
|
+ .fontColor(this.isDarkMode ? '#FFFFFF' : $r('app.color.text_color'))
|
|
|
+ .placeholderColor(this.isDarkMode ? '#8E8E93' : '#999999')
|
|
|
.onChange((value: string) => {
|
|
|
this.searchText = value
|
|
|
this.filterSongs()
|
|
|
@@ -168,7 +192,7 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
}
|
|
|
.width('100%')
|
|
|
.padding(12)
|
|
|
- .backgroundColor($r('app.color.input_background'))
|
|
|
+ .backgroundColor(this.isDarkMode ? '#2C2C2E' : $r('app.color.input_background'))
|
|
|
.borderRadius(20)
|
|
|
|
|
|
// 已选择歌曲数量
|
|
|
@@ -176,7 +200,7 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
Row() {
|
|
|
Text(`已选择 ${this.selectedSongs.length} 首歌曲`)
|
|
|
.fontSize(14)
|
|
|
- .fontColor(this.themeColor)
|
|
|
+ .fontColor(this.isDarkMode ? '#FFFFFF' : this.themeColor)
|
|
|
.fontWeight(FontWeight.Medium)
|
|
|
|
|
|
Blank()
|
|
|
@@ -184,7 +208,7 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
Button(this.selectedSongs.length === this.dataSource.dataArray.length
|
|
|
&& this.dataSource.dataArray.length > 0 ? '全不选' : '全选')
|
|
|
.fontSize(12)
|
|
|
- .fontColor($r('app.color.text_color'))
|
|
|
+ .fontColor(this.isDarkMode ? '#FFFFFF' : $r('app.color.text_color'))
|
|
|
.backgroundColor(Color.Transparent)
|
|
|
.height(30)
|
|
|
.padding({ left: 8, right: 8 })
|
|
|
@@ -201,7 +225,7 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
|
|
|
Button('清空')
|
|
|
.fontSize(12)
|
|
|
- .fontColor($r('app.color.text_color'))
|
|
|
+ .fontColor(this.isDarkMode ? '#FFFFFF' : $r('app.color.text_color'))
|
|
|
.backgroundColor(Color.Transparent)
|
|
|
.height(30)
|
|
|
.padding({ left: 8, right: 8 })
|
|
|
@@ -223,7 +247,7 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
|
|
|
Text(this.searchText ? '没有找到匹配的歌曲' : '没有可添加的歌曲')
|
|
|
.fontSize(14)
|
|
|
- .fontColor('#999999')
|
|
|
+ .fontColor(this.isDarkMode ? '#8E8E93' : '#999999')
|
|
|
}
|
|
|
.width('100%')
|
|
|
.height(300)
|
|
|
@@ -249,7 +273,7 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
Button(`添加${this.selectedSongs.length > 0 ? `(${this.selectedSongs.length})` : ''}`)
|
|
|
.width('45%')
|
|
|
.height(40)
|
|
|
- .backgroundColor(this.themeColor)
|
|
|
+ .backgroundColor(this.isDarkMode ? themeColorWithAlpha(this.themeColor, 0.8, this.isDarkMode) : this.themeColor)
|
|
|
.borderRadius(8)
|
|
|
.fontSize(14)
|
|
|
.fontColor(Color.White)
|
|
|
@@ -265,7 +289,7 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
}
|
|
|
.width('100%')
|
|
|
.constraintSize({ maxWidth: 400 })
|
|
|
- .backgroundColor($r('app.color.dialog_background'))
|
|
|
+ .backgroundColor(this.isDarkMode ? '#1C1C1E' : $r('app.color.dialog_background'))
|
|
|
.borderRadius(12)
|
|
|
.padding({ left: 20, right: 20 })
|
|
|
}
|
|
|
@@ -293,7 +317,7 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
Row({ space: 12 }) {
|
|
|
|
|
|
Image(StrUtil.isEmpty(song.pixelMapPath) ? $r('app.media.music_red') : song.pixelMapPath)
|
|
|
- .fillColor(this.themeColor)
|
|
|
+ .fillColor(StrUtil.isEmpty(song.pixelMapPath) ? (this.isDarkMode ? Color.White : this.themeColor) : undefined)
|
|
|
.height(40)
|
|
|
.width(40)
|
|
|
.alt($r('app.media.music_red'))
|
|
|
@@ -307,7 +331,7 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
Column({ space: 4 }) {
|
|
|
Text(song.name || '未知歌曲')
|
|
|
.fontSize(14)
|
|
|
- .fontColor($r('app.color.text_color'))
|
|
|
+ .fontColor(this.isDarkMode ? '#FFFFFF' : $r('app.color.text_color'))
|
|
|
.maxLines(1)
|
|
|
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
|
|
.width('100%')
|
|
|
@@ -316,7 +340,7 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
if (song.artist) {
|
|
|
Text(song.artist+' '+song.duration)
|
|
|
.fontSize(12)
|
|
|
- .fontColor('#999999')
|
|
|
+ .fontColor(this.isDarkMode ? '#8E8E93' : '#999999')
|
|
|
.maxLines(1)
|
|
|
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
|
|
.layoutWeight(1)
|
|
|
@@ -402,7 +426,7 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
.width(20)
|
|
|
Text('加载中...')
|
|
|
.fontSize(12)
|
|
|
- .fontColor('#999999')
|
|
|
+ .fontColor(this.isDarkMode ? '#8E8E93' : '#999999')
|
|
|
.margin({ left: 8 })
|
|
|
}
|
|
|
.width('100%')
|
|
|
@@ -412,7 +436,7 @@ struct AddSongsToPlaylistDialogContent {
|
|
|
Row() {
|
|
|
Text('上拉加载更多')
|
|
|
.fontSize(12)
|
|
|
- .fontColor('#999999')
|
|
|
+ .fontColor(this.isDarkMode ? '#8E8E93' : '#999999')
|
|
|
}
|
|
|
.width('100%')
|
|
|
.height(40)
|