mirror of
https://github.com/Ferrite-iOS/Ferrite.git
synced 2026-04-21 00:42:07 +00:00
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:
parent
df534327e5
commit
dc3014095c
5 changed files with 18 additions and 7 deletions
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,6 @@ struct PluginAggregateView<P: Plugin, PJ: PluginJson>: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.inlinedList(inset: 0)
|
|
||||||
.listStyle(.insetGrouped)
|
.listStyle(.insetGrouped)
|
||||||
.onAppear {
|
.onAppear {
|
||||||
fetchPredicate()
|
fetchPredicate()
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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([
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue