Fix navigation tabs

This commit is contained in:
Arkadiusz Fal 2021-06-11 23:54:00 +02:00
parent 417ed0a8ee
commit 4af395d788
6 changed files with 24 additions and 20 deletions

View File

@ -8,11 +8,6 @@ struct ChannelView: View {
var body: some View {
VideosView(state: state, tabSelection: $tabSelection, videos: videos)
.task {
async {
provider.load()
}
}
}
var listRowInsets: EdgeInsets {

View File

@ -13,7 +13,7 @@ struct VideosView: View {
ForEach(videos) { video in
VideoThumbnailView(video: video)
.contextMenu {
if state.showingChannel {
if tabSelection == .channel {
closeChannelButton(name: video.author)
} else {
openChannelButton(from: video)
@ -26,13 +26,6 @@ struct VideosView: View {
}
}
func closeChannelButton(name: String) -> some View {
Button("Close \(name) Channel", action: {
state.closeChannel()
tabSelection = .popular
})
}
func openChannelButton(from video: Video) -> some View {
Button("\(video.author) Channel", action: {
state.openChannel(from: video)
@ -40,6 +33,13 @@ struct VideosView: View {
})
}
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)
}

View File

@ -16,7 +16,16 @@ final class Video: Identifiable, ObservableObject {
@Published var url: URL?
@Published var error: Bool = false
init(id: String, title: String, thumbnailURL: URL?, author: String, length: TimeInterval, published: String, channelID: String, views: Int = 0) {
init(
id: String,
title: String,
thumbnailURL: URL?,
author: String,
length: TimeInterval,
published: String,
channelID: String,
views: Int = 0
) {
self.id = id
self.title = title
self.thumbnailURL = thumbnailURL

View File

@ -243,10 +243,10 @@
37AAF28F26740715007FC770 /* AppState.swift */,
37D4B19626717E1500C925CA /* Video.swift */,
37D4B19226717CE100C925CA /* PopularVideosProvider.swift */,
37AAF28B2673ABD3007FC770 /* ChannelVideosProvider.swift */,
37AAF2812673791F007FC770 /* SearchedVideosProvider.swift */,
37D4B1B32672A30700C925CA /* VideoDetailsProvider.swift */,
37D4B1AF2672A01000C925CA /* DataProvider.swift */,
37AAF2812673791F007FC770 /* SearchedVideosProvider.swift */,
37AAF28B2673ABD3007FC770 /* ChannelVideosProvider.swift */,
);
path = Model;
sourceTree = "<group>";