1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 22:30:32 +05:30
yattee/Apple TV/VideosView.swift
2021-06-12 10:59:52 +02:00

47 lines
1.3 KiB
Swift

import SwiftUI
struct VideosView: View {
@ObservedObject var state: AppState
@Binding var tabSelection: TabSelection
var videos: [Video]
var body: some View {
Section {
List {
ForEach(videos) { video in
VideoThumbnailView(video: video)
.contextMenu {
if tabSelection == .channel {
closeChannelButton(name: video.author)
} else {
openChannelButton(from: video)
}
}
.listRowInsets(listRowInsets)
}
}
.listStyle(GroupedListStyle())
}
}
func openChannelButton(from video: Video) -> some View {
Button("\(video.author) Channel", action: {
state.openChannel(from: video)
tabSelection = .channel
})
}
func closeChannelButton(name: String) -> some View {
Button("Close \(name) Channel", action: {
tabSelection = .popular
state.closeChannel()
})
}
var listRowInsets: EdgeInsets {
EdgeInsets(top: .zero, leading: .zero, bottom: .zero, trailing: 30)
}
}