blob: 8fbca755e4933fd2bfa9ede49954f97308fab9a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
//
// NapsterSongListItemView.swift
// MusicConverter
//
// Created by Finn Behrens on 02.04.21.
//
import SwiftUI
import MediaPlayer
struct NapsterSongListItemView: View {
@ObservedObject var napsterPlaylist: Napster
@State var choice: Napster.AppleChoice
@State var image: Image
func getImage() -> some View {
/*print("mediaItem: \(self.choice.song.mediaItem == nil ? "no" : "yes")")
if let image = choice.song.mediaItem?.artwork?.image(at: CGSize(width: 50, height: 50)) {
return Image(uiImage: image)
} else {
return Image(systemName: "photo")
}*/
print("id: \(self.choice.song.attributes.playParams.id)")
let mpContentItem = MPContentItem(identifier: self.choice.song.attributes.playParams.id)
print("mpContentItem: \(mpContentItem)")
return Text(mpContentItem.title ?? "error")
}
var body: some View {
HStack {
getImage()
/*image
.resizable()
.frame(width: 50, height: 50)
.cornerRadius(5)*/
VStack(alignment: .leading) {
Text(choice.song.name)
.bold()
HStack {
Text(choice.song.albumName)
Text(" - ")
//.padding(.horizontal)
Text(choice.song.artistName)
.foregroundColor(.gray)
}
.font(.caption)
}
}
}
}
struct NapsterSongListItemView_Previews: PreviewProvider {
static var previews: some View {
Text("ToDo")
//NapsterSongListItemView()
}
}
|