2020-02-17 02:21:49 +00:00
|
|
|
//
|
|
|
|
// PlaylistRow.swift
|
|
|
|
// Music Tools
|
|
|
|
//
|
2020-02-18 01:44:30 +00:00
|
|
|
// Created by Andy Pack on 17/02/2020.
|
2020-02-17 02:21:49 +00:00
|
|
|
// Copyright © 2020 Sarsoo. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
2020-02-19 23:00:23 +00:00
|
|
|
import SwiftyJSON
|
2020-02-17 02:21:49 +00:00
|
|
|
|
|
|
|
struct PlaylistRow: View {
|
2020-02-19 23:00:23 +00:00
|
|
|
|
|
|
|
@EnvironmentObject var liveUser: LiveUser
|
|
|
|
|
2020-02-17 02:21:49 +00:00
|
|
|
var playlist: Playlist
|
|
|
|
|
|
|
|
var body: some View {
|
2020-02-18 21:43:30 +00:00
|
|
|
NavigationLink(destination: PlaylistView(playlist: playlist)){
|
|
|
|
HStack {
|
|
|
|
Text(playlist.name)
|
2020-02-19 23:00:23 +00:00
|
|
|
.contextMenu {
|
2020-02-20 18:25:28 +00:00
|
|
|
|
|
|
|
// run force touch
|
2020-02-19 23:00:23 +00:00
|
|
|
Button(action: {
|
|
|
|
let api = PlaylistApi.runPlaylist(name: self.playlist.name)
|
|
|
|
RequestBuilder.buildRequest(apiRequest: api).responseJSON{ response in
|
|
|
|
|
|
|
|
}
|
|
|
|
}) {
|
|
|
|
Text("Refresh")
|
|
|
|
Image(systemName: "arrow.clockwise.circle")
|
|
|
|
}
|
2020-02-20 18:25:28 +00:00
|
|
|
|
|
|
|
// open force touch
|
2020-02-19 23:00:23 +00:00
|
|
|
Button(action: {
|
|
|
|
if let url = URL(string: self.playlist.link) {
|
|
|
|
UIApplication.shared.open(url)
|
|
|
|
}
|
|
|
|
}) {
|
|
|
|
Text("Open")
|
|
|
|
Image(systemName: "arrowshape.turn.up.right.circle")
|
|
|
|
}
|
|
|
|
}
|
2020-02-18 21:43:30 +00:00
|
|
|
}
|
2020-02-17 02:21:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct PlaylistRow_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
PlaylistRow(playlist:
|
|
|
|
Playlist(name: "playlist name",
|
|
|
|
uri: "uri",
|
|
|
|
username: "username",
|
|
|
|
|
|
|
|
include_recommendations: true,
|
|
|
|
recommendation_sample: 5,
|
|
|
|
include_library_tracks: true,
|
|
|
|
|
|
|
|
parts: ["name"],
|
|
|
|
playlist_references: ["ref name"],
|
|
|
|
|
|
|
|
shuffle: true)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|