Skip to content

Commit

Permalink
Refactor to use new json format
Browse files Browse the repository at this point in the history
  • Loading branch information
whomwah committed Jan 27, 2022
1 parent 091b307 commit 790682f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
18 changes: 11 additions & 7 deletions KyanBar/Preview Content/exampleTrack.json
Original file line number Diff line number Diff line change
@@ -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
}
9 changes: 8 additions & 1 deletion KyanBar/models/Track.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
)
}
2 changes: 1 addition & 1 deletion KyanBar/views/TrackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 790682f

Please sign in to comment.