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()
}
.listStyle(.insetGrouped)
.inlinedList(inset: 15)
.safeAreaInset(edge: .top, spacing: 0) {
Spacer()
.frame(height: 15)
}
.task {
if debridManager.enabledDebrids.count > 0 {
let magnets = bookmarks.compactMap {

View file

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

View file

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

View file

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

View file

@ -167,13 +167,17 @@ struct SearchBar<ScopeContent: View>: UIViewControllerRepresentable {
searchController.searchBar.scopeButtonTitles = [""]
(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)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
hostingController.view.backgroundColor = .clear
guard let containerView = searchController.searchBar.value(forKey: "_scopeBarContainerView") as? UIView else {
return
}
containerView.addSubview(hostingController.view)
NSLayoutConstraint.activate([