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

@@ -3,7 +3,7 @@ import SwiftUI
struct PopularVideosView: View {
@ObservedObject private var provider = PopularVideosProvider()
@ObservedObject var state: AppState
@Binding var tabSelection: TabSelection
var body: some View {

View File

@@ -12,7 +12,7 @@ struct SearchView: View {
VideosView(state: state, tabSelection: $tabSelection, videos: videos)
.searchable(text: $query)
}
var videos: [Video] {
var newQuery = query

View File

@@ -2,7 +2,7 @@ import SwiftUI
struct VideosView: View {
@ObservedObject var state: AppState
@Binding var tabSelection: TabSelection
var videos: [Video]
@@ -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)
@@ -25,14 +25,7 @@ struct VideosView: View {
.listStyle(GroupedListStyle())
}
}
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)
}