Search/Lists: Fix UI issues and appearance

The search bar sometimes had the scope bar added twice if a toolbar
was present (probably caused a refresh of the navigationTitle).

Rather than figuring out a hacky swiftUI solution to solve this,
add a check to enforce only one HostingViewController in the
scope bar.

Also migrate the inlinedList modifier to use safeAreaInsets from
native SwiftUI. Keep the introspected modifier for negative values.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2023-04-12 23:25:17 -04:00
parent df534327e5
commit dc3014095c
5 changed files with 18 additions and 7 deletions

View file

@ -51,7 +51,10 @@ struct BookmarksView: View {
fetchPredicate() fetchPredicate()
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.inlinedList(inset: 15) .safeAreaInset(edge: .top, spacing: 0) {
Spacer()
.frame(height: 15)
}
.task { .task {
if debridManager.enabledDebrids.count > 0 { if debridManager.enabledDebrids.count > 0 {
let magnets = bookmarks.compactMap { let magnets = bookmarks.compactMap {

View file

@ -8,6 +8,8 @@
import SwiftUI import SwiftUI
struct PluginCatalogButtonView<PJ: PluginJson>: View { struct PluginCatalogButtonView<PJ: PluginJson>: View {
@Environment(\.colorScheme) var colorScheme
@EnvironmentObject var pluginManager: PluginManager @EnvironmentObject var pluginManager: PluginManager
let availablePlugin: PJ let availablePlugin: PJ
@ -58,7 +60,7 @@ struct PluginCatalogButtonView<PJ: PluginJson>: View {
) )
.padding(.horizontal, 7) .padding(.horizontal, 7)
.padding(.vertical, 5) .padding(.vertical, 5)
.background(Color(uiColor: .tertiarySystemBackground)) .background(colorScheme == .light ? Color(uiColor: .secondarySystemBackground) : Color(uiColor: .tertiarySystemBackground))
.clipShape(RoundedRectangle(cornerRadius: 10)) .clipShape(RoundedRectangle(cornerRadius: 10))
} }
.buttonStyle(.borderless) .buttonStyle(.borderless)

View file

@ -71,7 +71,6 @@ struct PluginAggregateView<P: Plugin, PJ: PluginJson>: View {
} }
} }
} }
.inlinedList(inset: 0)
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.onAppear { .onAppear {
fetchPredicate() fetchPredicate()

View file

@ -32,7 +32,10 @@ struct ContentView: View {
SearchResultsView(searchText: $searchText) SearchResultsView(searchText: $searchText)
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.inlinedList(inset: 20) .safeAreaInset(edge: .top, spacing: 0) {
Spacer()
.frame(height: 20)
}
.navigationTitle("Search") .navigationTitle("Search")
.overlay { .overlay {
if if

View file

@ -167,13 +167,17 @@ struct SearchBar<ScopeContent: View>: UIViewControllerRepresentable {
searchController.searchBar.scopeButtonTitles = [""] searchController.searchBar.scopeButtonTitles = [""]
(searchController.searchBar.value(forKey: "_scopeBar") as? UIView)?.isHidden = true (searchController.searchBar.value(forKey: "_scopeBar") as? UIView)?.isHidden = true
guard
let containerView = searchController.searchBar.value(forKey: "_scopeBarContainerView") as? UIView,
!containerView.subviews.contains(where: { String(describing: $0.classForCoder).contains("UIHostingView") })
else {
return
}
let hostingController = UIHostingController(rootView: content) let hostingController = UIHostingController(rootView: content)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false hostingController.view.translatesAutoresizingMaskIntoConstraints = false
hostingController.view.backgroundColor = .clear hostingController.view.backgroundColor = .clear
guard let containerView = searchController.searchBar.value(forKey: "_scopeBarContainerView") as? UIView else {
return
}
containerView.addSubview(hostingController.view) containerView.addSubview(hostingController.view)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([