From 790682f2ba3ef475d60cc154019791c02c3a0eae Mon Sep 17 00:00:00 2001 From: Duncan Robertson Date: Thu, 27 Jan 2022 14:23:16 +0000 Subject: [PATCH] Refactor to use new json format --- KyanBar/Preview Content/exampleTrack.json | 18 +++++++++++------- KyanBar/models/Track.swift | 9 ++++++++- KyanBar/views/TrackView.swift | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/KyanBar/Preview Content/exampleTrack.json b/KyanBar/Preview Content/exampleTrack.json index c392bac..25d84ad 100644 --- a/KyanBar/Preview Content/exampleTrack.json +++ b/KyanBar/Preview Content/exampleTrack.json @@ -1,11 +1,15 @@ { + "spotify": "https://open.spotify.com/track/73H5jxtNuncvfrfBuLcItL", "title": "Hotel California - 2013 Remaster", "artist": "Eagles", - "album": "Hotel California (2013 Remaster) (1976)", - "image": "https://i.scdn.co/image/ab67616d0000b2734637341b9f507521afa9a778", - "rating": "Rating: 2", - "voted_by": "Voted by: 4 users", - "played": "Played: 63 times", - "last_played": "Last Played: 2 days ago", - "added_by": "Added by BRH 10 minutes ago" + "album": "Hotel California (2013 Remaster)", + "year": "1976", + "image": "https://i.scdn.co/image/ab67616d0000b273db01d8ba247c49baaa189935", + "metrics": { + "rating" :-5, + "votes" :0, + "plays" :1}, + "added_by": "Duncan Robertson", + "added_at": "5 minutes ago", + "last_played": null } diff --git a/KyanBar/models/Track.swift b/KyanBar/models/Track.swift index 6bfa2cf..d9e8735 100644 --- a/KyanBar/models/Track.swift +++ b/KyanBar/models/Track.swift @@ -12,10 +12,17 @@ struct Track: Decodable { let artist: String let album: String let image: String + let year: String } extension Track { // A construction of `Track` that can be used when no data has // been loaded. - static let placeholder = Track(title: "Loading...", artist: "", album: "", image: "") + static let placeholder = Track( + title: "Loading...", + artist: "", + album: "", + image: "", + year: "" + ) } diff --git a/KyanBar/views/TrackView.swift b/KyanBar/views/TrackView.swift index 24102e8..ed9fa12 100644 --- a/KyanBar/views/TrackView.swift +++ b/KyanBar/views/TrackView.swift @@ -25,7 +25,7 @@ struct TrackView: View { Text(track.title) .fontWeight(.bold) .fixedSize(horizontal: false, vertical: true) - Text(track.album) + Text("\(track.album) (\(track.year))") Text(track.artist).fontWeight(.light) } .font(.system(.footnote, design: .rounded))