mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
tvOS History improvements
This commit is contained in:
parent
70c089e696
commit
2c275d9353
@ -127,6 +127,16 @@ extension PlayerModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func playHistory(_ item: PlayerQueueItem) {
|
||||||
|
let newItem = enqueueVideo(item.video, prepending: true)
|
||||||
|
|
||||||
|
advanceToItem(newItem!)
|
||||||
|
|
||||||
|
if let historyItemIndex = history.firstIndex(of: item) {
|
||||||
|
history.remove(at: historyItemIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@discardableResult func removeHistory(_ item: PlayerQueueItem) -> PlayerQueueItem? {
|
@discardableResult func removeHistory(_ item: PlayerQueueItem) -> PlayerQueueItem? {
|
||||||
if let index = history.firstIndex(where: { $0 == item }) {
|
if let index = history.firstIndex(where: { $0 == item }) {
|
||||||
return history.remove(at: index)
|
return history.remove(at: index)
|
||||||
|
@ -14,11 +14,7 @@ struct PlayerQueueRow: View {
|
|||||||
player.addCurrentItemToHistory()
|
player.addCurrentItemToHistory()
|
||||||
|
|
||||||
if history {
|
if history {
|
||||||
let newItem = player.enqueueVideo(item.video, prepending: true)
|
player.playHistory(item)
|
||||||
player.advanceToItem(newItem!)
|
|
||||||
if let historyItemIndex = player.history.firstIndex(of: item) {
|
|
||||||
player.history.remove(at: historyItemIndex)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
player.advanceToItem(item)
|
player.advanceToItem(item)
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ final class PlayerViewController: UIViewController {
|
|||||||
let controller = UIHostingController(rootView:
|
let controller = UIHostingController(rootView:
|
||||||
AnyView(
|
AnyView(
|
||||||
NowPlayingView(infoViewController: true)
|
NowPlayingView(infoViewController: true)
|
||||||
|
.frame(maxHeight: 600)
|
||||||
.environmentObject(playerModel)
|
.environmentObject(playerModel)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -33,15 +33,13 @@ struct NowPlayingView: View {
|
|||||||
.padding(.bottom, 20)
|
.padding(.bottom, 20)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !infoViewController {
|
header("Playing Next")
|
||||||
header("Playing Next")
|
|
||||||
}
|
|
||||||
|
|
||||||
if player.queue.isEmpty {
|
if player.queue.isEmpty {
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
Text("Playback queue is empty")
|
Text("Playback queue is empty")
|
||||||
.padding(.leading, 40)
|
.padding([.vertical, .leading], 40)
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +56,34 @@ struct NowPlayingView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
header("Played Previously")
|
||||||
|
|
||||||
|
if player.history.isEmpty {
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
Text("History is empty")
|
||||||
|
.padding([.vertical, .leading], 40)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
|
||||||
|
ForEach(player.history) { item in
|
||||||
|
Button {
|
||||||
|
player.playHistory(item)
|
||||||
|
player.presentPlayer()
|
||||||
|
} label: {
|
||||||
|
VideoBanner(video: item.video)
|
||||||
|
}
|
||||||
|
.contextMenu {
|
||||||
|
Button("Delete", role: .destructive) {
|
||||||
|
player.removeHistory(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
Button("Delete History", role: .destructive) {
|
||||||
|
player.removeHistoryItems()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.padding(.vertical)
|
.padding(.vertical)
|
||||||
.padding(.horizontal, 40)
|
.padding(.horizontal, 40)
|
||||||
|
Loading…
Reference in New Issue
Block a user