Improve open videos layouts

This commit is contained in:
Arkadiusz Fal
2022-11-11 18:50:13 +01:00
parent 6ca6a40aa1
commit 730ba1ea2e
9 changed files with 216 additions and 107 deletions

View File

@@ -10,24 +10,34 @@ struct HistoryView: View {
var body: some View {
LazyVStack {
ForEach(visibleWatches, id: \.videoID) { watch in
PlayerQueueRow(
item: PlayerQueueItem.from(watch, video: player.historyVideo(watch.videoID)),
history: true
)
.onAppear {
player.loadHistoryVideoDetails(watch.videoID)
if visibleWatches.isEmpty {
VStack(alignment: .center, spacing: 20) {
HStack {
Image(systemName: "clock")
Text("Playback history is empty")
}.foregroundColor(.secondary)
}
.contextMenu {
VideoContextMenuView(video: player.historyVideo(watch.videoID) ?? watch.video)
} else {
ForEach(visibleWatches, id: \.videoID) { watch in
PlayerQueueRow(
item: PlayerQueueItem.from(watch, video: player.historyVideo(watch.videoID)),
history: true
)
.onAppear {
player.loadHistoryVideoDetails(watch.videoID)
}
.contextMenu {
VideoContextMenuView(video: player.historyVideo(watch.videoID) ?? watch.video)
}
}
}
#if os(tvOS)
.padding(.horizontal, 40)
#else
.padding(.horizontal, 15)
#endif
}
#if os(tvOS)
.padding(.horizontal, 40)
#else
.padding(.horizontal, 15)
#endif
}
private var visibleWatches: [Watch] {

View File

@@ -24,6 +24,36 @@ struct HomeView: View {
var body: some View {
BrowserPlayerControls {
ScrollView(.vertical, showsIndicators: false) {
HStack {
#if os(tvOS)
OpenVideosButton(text: "Open Video", imageSystemName: "globe") {
NavigationModel.shared.presentingOpenVideos = true
}
.frame(maxWidth: 600)
#else
OpenVideosButton(text: "Files", imageSystemName: "folder") {
NavigationModel.shared.presentingFileImporter = true
}
OpenVideosButton(text: "Paste", imageSystemName: "doc.on.clipboard.fill") {
OpenVideosModel.shared.openURLsFromClipboard(playbackMode: .playNow)
}
OpenVideosButton(imageSystemName: "ellipsis") {
NavigationModel.shared.presentingOpenVideos = true
}
.frame(maxWidth: 40)
#endif
}
#if os(iOS)
.padding(.top, RefreshControl.navigationBarTitleDisplayMode == .inline ? 15 : 0)
#else
.padding(.top, 15)
#endif
#if os(tvOS)
.padding(.horizontal, 40)
#else
.padding(.horizontal, 15)
#endif
if !accounts.current.isNil {
#if os(tvOS)
ForEach(Defaults[.favorites]) { item in
@@ -60,18 +90,7 @@ struct HomeView: View {
HistoryView(limit: homeHistoryItems)
}
#if os(tvOS)
HStack {
Button {
navigation.presentingOpenVideos = true
} label: {
Label("Open Videos...", systemImage: "folder")
.padding(.horizontal, 20)
.padding(.vertical, 10)
}
.buttonStyle(.plain)
}
#else
#if !os(tvOS)
Color.clear.padding(.bottom, 60)
#endif
}