mirror of
https://github.com/yattee/yattee.git
synced 2025-10-29 11:41:54 +00:00
Fix navigation tabs
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -12,7 +12,7 @@ struct SearchView: View {
|
||||
VideosView(state: state, tabSelection: $tabSelection, videos: videos)
|
||||
.searchable(text: $query)
|
||||
}
|
||||
|
||||
|
||||
var videos: [Video] {
|
||||
var newQuery = query
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user