2021-06-28 20:57:53 +05:30
|
|
|
import Defaults
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct VideoContextMenuView: View {
|
|
|
|
@Default(.tabSelection) var tabSelection
|
|
|
|
|
|
|
|
let video: Video
|
|
|
|
|
2021-07-08 04:09:18 +05:30
|
|
|
@Default(.openVideoID) var openVideoID
|
|
|
|
@Default(.showingVideoDetails) var showDetails
|
|
|
|
|
2021-06-28 20:57:53 +05:30
|
|
|
var body: some View {
|
|
|
|
if tabSelection == .channel {
|
|
|
|
closeChannelButton(from: video)
|
|
|
|
} else {
|
|
|
|
openChannelButton(from: video)
|
|
|
|
}
|
2021-07-08 04:09:18 +05:30
|
|
|
|
|
|
|
Button("Open video details") {
|
|
|
|
openVideoID = video.id
|
|
|
|
showDetails = true
|
|
|
|
}
|
2021-06-28 20:57:53 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
func openChannelButton(from video: Video) -> some View {
|
|
|
|
Button("\(video.author) Channel") {
|
|
|
|
Defaults[.openChannel] = Channel.from(video: video)
|
|
|
|
tabSelection = .channel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func closeChannelButton(from video: Video) -> some View {
|
|
|
|
Button("Close \(Channel.from(video: video).name) Channel") {
|
|
|
|
Defaults.reset(.openChannel)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|