Skip to content

Commit

Permalink
more button on now playing screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Halpin committed Oct 27, 2023
1 parent 52c18ca commit 1ad28c4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions HalpoPlayer/HalpoPlayerApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ struct halpoplayerApp: App {
}
}, goToArtist: { artistId, artistName in
self.coordinatorForTab(tab: self.selectedTab).goToArtist(artistId: artistId, artistName: artistName)
}, addToPlaylist: { song in
self.coordinatorForTab(tab: self.selectedTab).selectPlaylist(songs: [song])
})
})

Expand Down
23 changes: 21 additions & 2 deletions HalpoPlayer/Views/NowPlayingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct NowPlayingView: View {
@State var volume: Float = AudioManager.shared.queue.volume
var goToAlbum: (((albumId: String, songId: String?)) -> Void)?
var goToArtist: (((artistId: String, artistName: String)) -> Void)?
var addToPlaylist: ((Song) -> Void)?
var buttonSize: CGFloat = 32
var playButtonName: String {
if player.isPlaying {
Expand All @@ -31,13 +32,28 @@ struct NowPlayingView: View {
}
var body: some View {
VStack {
HStack {
HStack(spacing: 16) {
Spacer()
if let song = self.player.currentSong {
Menu {
Button("Add to playlist...") {
self.dismiss()
self.addToPlaylist?(song)
}
if Database.shared.musicCache[song.id] == nil {
Button("Download") {
self.downloadSong(song: song)
}
}
} label: {
Image(systemName: "ellipsis.circle").imageScale(.large)
}
}
Button("Close") {
dismiss()
}
.padding()
}
.padding()
Spacer()
.frame(height: 64)
Button {
Expand Down Expand Up @@ -197,4 +213,7 @@ struct NowPlayingView: View {
return negative + String(format:"%02i:%02i", minutes, seconds)
}
}
func downloadSong(song: Song) {
Database.shared.cacheSong(song: song) {}
}
}

0 comments on commit 1ad28c4

Please sign in to comment.