|
@@ -3,11 +3,10 @@ import { Playlist } from '../viewmodel/Playlist';
|
|
|
import { ToastUtil } from '@pura/harmony-utils';
|
|
import { ToastUtil } from '@pura/harmony-utils';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 歌单对话框组件
|
|
|
|
|
- * 用于创建和编辑歌单
|
|
|
|
|
|
|
+ * 歌单对话框内容组件
|
|
|
*/
|
|
*/
|
|
|
@Component
|
|
@Component
|
|
|
-export struct PlaylistDialog {
|
|
|
|
|
|
|
+struct PlaylistDialogContent {
|
|
|
@State playlistName: string = ''
|
|
@State playlistName: string = ''
|
|
|
@State playlistDescription: string = ''
|
|
@State playlistDescription: string = ''
|
|
|
@State isEditMode: boolean = false
|
|
@State isEditMode: boolean = false
|
|
@@ -139,6 +138,78 @@ export struct PlaylistDialog {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 歌单对话框管理器
|
|
|
|
|
+ */
|
|
|
|
|
+@Component
|
|
|
|
|
+export struct PlaylistDialogManager {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 创建歌单对话框构建器
|
|
|
|
|
+ */
|
|
|
|
|
+ @Builder
|
|
|
|
|
+ buildCreatePlaylistDialog(onConfirm: (name: string, description: string) => void, onCancel?: () => void) {
|
|
|
|
|
+ PlaylistDialogContent({
|
|
|
|
|
+ onConfirm: onConfirm,
|
|
|
|
|
+ onCancel: onCancel
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 编辑歌单对话框构建器
|
|
|
|
|
+ */
|
|
|
|
|
+ @Builder
|
|
|
|
|
+ buildEditPlaylistDialog(playlist: Playlist, onConfirm: (name: string, description: string) => void, onCancel?: () => void) {
|
|
|
|
|
+ PlaylistDialogContent({
|
|
|
|
|
+ originalPlaylist: playlist,
|
|
|
|
|
+ onConfirm: onConfirm,
|
|
|
|
|
+ onCancel: onCancel
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 显示创建歌单对话框
|
|
|
|
|
+ */
|
|
|
|
|
+ showCreatePlaylistDialog(
|
|
|
|
|
+ onConfirm: (name: string, description: string) => void,
|
|
|
|
|
+ onCancel?: () => void
|
|
|
|
|
+ ) {
|
|
|
|
|
+ DialogHelper.showCustomContentDialog({
|
|
|
|
|
+ dialogId: 'createPlaylistDialog',
|
|
|
|
|
+ title: '创建歌单',
|
|
|
|
|
+ autoCancel: true,
|
|
|
|
|
+ contentBuilder: () => {
|
|
|
|
|
+ this.buildCreatePlaylistDialog(onConfirm, onCancel)
|
|
|
|
|
+ },
|
|
|
|
|
+ buttons: []
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 显示编辑歌单对话框
|
|
|
|
|
+ */
|
|
|
|
|
+ showEditPlaylistDialog(
|
|
|
|
|
+ playlist: Playlist,
|
|
|
|
|
+ onConfirm: (name: string, description: string) => void,
|
|
|
|
|
+ onCancel?: () => void
|
|
|
|
|
+ ) {
|
|
|
|
|
+ DialogHelper.showCustomContentDialog({
|
|
|
|
|
+ dialogId: 'editPlaylistDialog',
|
|
|
|
|
+ title: '编辑歌单',
|
|
|
|
|
+ autoCancel: true,
|
|
|
|
|
+ contentBuilder: () => {
|
|
|
|
|
+ this.buildEditPlaylistDialog(playlist, onConfirm, onCancel)
|
|
|
|
|
+ },
|
|
|
|
|
+ buttons: []
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ build() {
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 创建全局实例
|
|
|
|
|
+const dialogManager = new PlaylistDialogManager()
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 显示创建歌单对话框
|
|
* 显示创建歌单对话框
|
|
|
*/
|
|
*/
|
|
@@ -146,18 +217,7 @@ export function showCreatePlaylistDialog(
|
|
|
onConfirm: (name: string, description: string) => void,
|
|
onConfirm: (name: string, description: string) => void,
|
|
|
onCancel?: () => void
|
|
onCancel?: () => void
|
|
|
) {
|
|
) {
|
|
|
- DialogHelper.showCustomContentDialog({
|
|
|
|
|
- dialogId: 'createPlaylistDialog',
|
|
|
|
|
- title: '创建歌单',
|
|
|
|
|
- autoCancel: true,
|
|
|
|
|
- contentBuilder: () => {
|
|
|
|
|
- PlaylistDialog({
|
|
|
|
|
- onConfirm: onConfirm,
|
|
|
|
|
- onCancel: onCancel
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- buttons: []
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ dialogManager.showCreatePlaylistDialog(onConfirm, onCancel)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -168,17 +228,5 @@ export function showEditPlaylistDialog(
|
|
|
onConfirm: (name: string, description: string) => void,
|
|
onConfirm: (name: string, description: string) => void,
|
|
|
onCancel?: () => void
|
|
onCancel?: () => void
|
|
|
) {
|
|
) {
|
|
|
- DialogHelper.showCustomContentDialog({
|
|
|
|
|
- dialogId: 'editPlaylistDialog',
|
|
|
|
|
- title: '编辑歌单',
|
|
|
|
|
- autoCancel: true,
|
|
|
|
|
- contentBuilder: () => {
|
|
|
|
|
- PlaylistDialog({
|
|
|
|
|
- originalPlaylist: playlist,
|
|
|
|
|
- onConfirm: onConfirm,
|
|
|
|
|
- onCancel: onCancel
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- buttons: []
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ dialogManager.showEditPlaylistDialog(playlist, onConfirm, onCancel)
|
|
|
}
|
|
}
|