Fix searchBar jank
This commit is contained in:
parent
8e73b094ba
commit
bd0b6ff491
@ -36,6 +36,7 @@
|
||||
3D91FDCD2B2907E800919017 /* JellyfinDateFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D91FDCC2B2907E800919017 /* JellyfinDateFormatter.swift */; };
|
||||
3DAFA8E82B38AFED00D71AD1 /* ItemInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DAFA8E72B38AFED00D71AD1 /* ItemInfoView.swift */; };
|
||||
3DAFA8EA2B39039900D71AD1 /* JellyfinKitExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DAFA8E92B39039900D71AD1 /* JellyfinKitExtensions.swift */; };
|
||||
3DAFA8EC2B394F9F00D71AD1 /* ViewConditionalMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DAFA8EB2B394F9F00D71AD1 /* ViewConditionalMethod.swift */; };
|
||||
3DC6BA2D2B2A422300416B9F /* SettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DC6BA2C2B2A422300416B9F /* SettingsController.swift */; };
|
||||
3DDD67932B293BC40026781E /* DashboardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DDD67922B293BC40026781E /* DashboardView.swift */; };
|
||||
3DDD67962B29E28B0026781E /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DDD67952B29E28B0026781E /* SettingsView.swift */; };
|
||||
@ -102,6 +103,7 @@
|
||||
3D91FDCC2B2907E800919017 /* JellyfinDateFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JellyfinDateFormatter.swift; sourceTree = "<group>"; };
|
||||
3DAFA8E72B38AFED00D71AD1 /* ItemInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemInfoView.swift; sourceTree = "<group>"; };
|
||||
3DAFA8E92B39039900D71AD1 /* JellyfinKitExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JellyfinKitExtensions.swift; sourceTree = "<group>"; };
|
||||
3DAFA8EB2B394F9F00D71AD1 /* ViewConditionalMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewConditionalMethod.swift; sourceTree = "<group>"; };
|
||||
3DC0E5802B2832B9001CCE96 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
3DC6BA2C2B2A422300416B9F /* SettingsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsController.swift; sourceTree = "<group>"; };
|
||||
3DDD67922B293BC40026781E /* DashboardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardView.swift; sourceTree = "<group>"; };
|
||||
@ -169,6 +171,7 @@
|
||||
3D8AB2A42B36440D005BD7D0 /* BlurHashDecode.swift */,
|
||||
3D13F9682B389FA300E91913 /* ViewOffsetKey.swift */,
|
||||
3DAFA8E92B39039900D71AD1 /* JellyfinKitExtensions.swift */,
|
||||
3DAFA8EB2B394F9F00D71AD1 /* ViewConditionalMethod.swift */,
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
@ -439,6 +442,7 @@
|
||||
3D1015D92B27F57400F5C29A /* AddServerView.swift in Sources */,
|
||||
3DAFA8EA2B39039900D71AD1 /* JellyfinKitExtensions.swift in Sources */,
|
||||
3D13F9652B37EC7A00E91913 /* ItemHeaderView.swift in Sources */,
|
||||
3DAFA8EC2B394F9F00D71AD1 /* ViewConditionalMethod.swift in Sources */,
|
||||
3D9063CB2B279A310063DD2A /* JelApp.swift in Sources */,
|
||||
3D13F9692B389FA300E91913 /* ViewOffsetKey.swift in Sources */,
|
||||
3D91FDCD2B2907E800919017 /* JellyfinDateFormatter.swift in Sources */,
|
||||
|
23
Jel/Models/ViewConditionalMethod.swift
Normal file
23
Jel/Models/ViewConditionalMethod.swift
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// ViewConditionalMethod.swift
|
||||
// Jel
|
||||
//
|
||||
// Created by zerocool on 12/25/23.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
extension View {
|
||||
/// Applies the given transform if the given condition evaluates to `true`.
|
||||
/// - Parameters:
|
||||
/// - condition: The condition to evaluate.
|
||||
/// - transform: The transform to apply to the source `View`.
|
||||
/// - Returns: Either the original `View` or the modified `View` if the condition is `true`.
|
||||
@ViewBuilder func `if`<Content: View>(_ condition: @autoclosure () -> Bool, transform: (Self) -> Content) -> some View {
|
||||
if condition() {
|
||||
transform(self)
|
||||
} else {
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
@ -44,6 +44,7 @@ struct ItemMovieView: View {
|
||||
Text(item.taglines?.count ?? 0 > 0 ? item.taglines?[0] ?? "" : "")
|
||||
.font(.headline)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.bottom)
|
||||
|
||||
Text(item.overview ?? "---")
|
||||
}
|
||||
|
@ -57,23 +57,25 @@ struct LibraryDetailView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.searchable(text: $searchText)
|
||||
.onChange(of: searchText) {
|
||||
Task {
|
||||
let parameters = Paths.GetParameters(
|
||||
userID: AuthStateController.shared.userId,
|
||||
searchTerm: searchText.lowercased(),
|
||||
parentID: library.id
|
||||
)
|
||||
searchResultHints = await jellyfinClient.search(parameters: parameters)
|
||||
.if(!loading) {view in
|
||||
view.searchable(text: $searchText)
|
||||
.onChange(of: searchText) {
|
||||
Task {
|
||||
let parameters = Paths.GetParameters(
|
||||
userID: AuthStateController.shared.userId,
|
||||
searchTerm: searchText.lowercased(),
|
||||
parentID: library.id
|
||||
)
|
||||
searchResultHints = await jellyfinClient.search(parameters: parameters)
|
||||
|
||||
searchResultItems = items?.filter { item in
|
||||
for hint in searchResultHints?.searchHints ?? [] {
|
||||
if hint.name == item.name {
|
||||
return true
|
||||
searchResultItems = items?.filter { item in
|
||||
for hint in searchResultHints?.searchHints ?? [] {
|
||||
if hint.name == item.name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user