Search UI fixes

This commit is contained in:
Arkadiusz Fal
2021-09-13 22:41:16 +02:00
parent b00b54ad2a
commit 5e403c7f15
20 changed files with 188 additions and 50 deletions

View File

@@ -90,7 +90,7 @@ struct ChannelVideosView: View {
var subscriptionToolbarItemPlacement: ToolbarItemPlacement {
#if os(iOS)
if horizontalSizeClass == .regular {
return .primaryAction
return .primaryAction // swiftlint:disable:this implicit_return
}
#endif

View File

@@ -0,0 +1,13 @@
import Foundation
import SwiftUI
struct LazyView<Content: View>: View {
let build: () -> Content
init(_ build: @autoclosure @escaping () -> Content) {
self.build = build
}
var body: Content {
build()
}
}

View File

@@ -26,7 +26,6 @@ struct SearchView: View {
Spacer()
}
}
.searchable(text: $queryText)
.onAppear {
state.changeQuery { query in
query.query = queryText
@@ -35,7 +34,7 @@ struct SearchView: View {
query.duration = searchDuration
}
}
.onChange(of: queryText) { queryText in
.onChange(of: state.query.query) { queryText in
state.changeQuery { query in query.query = queryText }
}
.onChange(of: searchSortOrder) { order in
@@ -48,10 +47,14 @@ struct SearchView: View {
state.changeQuery { query in query.duration = duration }
}
#if !os(tvOS)
.navigationTitle("Search")
.navigationTitle(navigationTitle)
#endif
}
var navigationTitle: String {
state.query.query.isEmpty ? "Search" : "Search: \"\(state.query.query)\""
}
var searchFiltersActive: Bool {
searchDate != nil || searchDuration != nil
}

View File

@@ -34,6 +34,7 @@ struct VideoContextMenuView: View {
var openChannelButton: some View {
Button("\(video.author) Channel") {
navigationState.openChannel(video.channel)
navigationState.tabSelection = .channel(video.channel.id)
navigationState.sidebarSectionChanged.toggle()
}
}