Add single file audio player, introduce blocks
This commit is contained in:
49
CHDataManagement/Model/Settings/AudioPlayerSettings.swift
Normal file
49
CHDataManagement/Model/Settings/AudioPlayerSettings.swift
Normal file
@ -0,0 +1,49 @@
|
||||
import Foundation
|
||||
|
||||
final class AudioPlayerSettings: ObservableObject {
|
||||
|
||||
@Published
|
||||
var playlistCoverImageSize: Int
|
||||
|
||||
@Published
|
||||
var smallCoverImageSize: Int
|
||||
|
||||
@Published
|
||||
var audioPlayerJsFile: FileResource?
|
||||
|
||||
@Published
|
||||
var audioPlayerCssFile: FileResource?
|
||||
|
||||
init(playlistCoverImageSize: Int,
|
||||
smallCoverImageSize: Int,
|
||||
audioPlayerJsFile: FileResource?,
|
||||
audioPlayerCssFile: FileResource?) {
|
||||
self.playlistCoverImageSize = playlistCoverImageSize
|
||||
self.smallCoverImageSize = smallCoverImageSize
|
||||
self.audioPlayerJsFile = audioPlayerJsFile
|
||||
self.audioPlayerCssFile = audioPlayerCssFile
|
||||
}
|
||||
|
||||
init(file: AudioPlayerSettingsFile, files: [String : FileResource]) {
|
||||
self.playlistCoverImageSize = file.playlistCoverImageSize
|
||||
self.smallCoverImageSize = file.smallCoverImageSize
|
||||
self.audioPlayerJsFile = file.audioPlayerJsFile.map { files[$0] }
|
||||
self.audioPlayerCssFile = file.audioPlayerCssFile.map { files[$0] }
|
||||
}
|
||||
|
||||
var file: AudioPlayerSettingsFile {
|
||||
.init(playlistCoverImageSize: playlistCoverImageSize,
|
||||
smallCoverImageSize: smallCoverImageSize,
|
||||
audioPlayerJsFile: audioPlayerJsFile?.id,
|
||||
audioPlayerCssFile: audioPlayerCssFile?.id)
|
||||
}
|
||||
}
|
||||
|
||||
extension AudioPlayerSettings {
|
||||
|
||||
static let `default`: AudioPlayerSettings = .init(
|
||||
playlistCoverImageSize: 280,
|
||||
smallCoverImageSize: 78,
|
||||
audioPlayerJsFile: nil,
|
||||
audioPlayerCssFile: nil)
|
||||
}
|
Reference in New Issue
Block a user