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 */; };
|
3D91FDCD2B2907E800919017 /* JellyfinDateFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D91FDCC2B2907E800919017 /* JellyfinDateFormatter.swift */; };
|
||||||
3DAFA8E82B38AFED00D71AD1 /* ItemInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DAFA8E72B38AFED00D71AD1 /* ItemInfoView.swift */; };
|
3DAFA8E82B38AFED00D71AD1 /* ItemInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DAFA8E72B38AFED00D71AD1 /* ItemInfoView.swift */; };
|
||||||
3DAFA8EA2B39039900D71AD1 /* JellyfinKitExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DAFA8E92B39039900D71AD1 /* JellyfinKitExtensions.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 */; };
|
3DC6BA2D2B2A422300416B9F /* SettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DC6BA2C2B2A422300416B9F /* SettingsController.swift */; };
|
||||||
3DDD67932B293BC40026781E /* DashboardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DDD67922B293BC40026781E /* DashboardView.swift */; };
|
3DDD67932B293BC40026781E /* DashboardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DDD67922B293BC40026781E /* DashboardView.swift */; };
|
||||||
3DDD67962B29E28B0026781E /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DDD67952B29E28B0026781E /* SettingsView.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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
3DDD67922B293BC40026781E /* DashboardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardView.swift; sourceTree = "<group>"; };
|
||||||
@ -169,6 +171,7 @@
|
|||||||
3D8AB2A42B36440D005BD7D0 /* BlurHashDecode.swift */,
|
3D8AB2A42B36440D005BD7D0 /* BlurHashDecode.swift */,
|
||||||
3D13F9682B389FA300E91913 /* ViewOffsetKey.swift */,
|
3D13F9682B389FA300E91913 /* ViewOffsetKey.swift */,
|
||||||
3DAFA8E92B39039900D71AD1 /* JellyfinKitExtensions.swift */,
|
3DAFA8E92B39039900D71AD1 /* JellyfinKitExtensions.swift */,
|
||||||
|
3DAFA8EB2B394F9F00D71AD1 /* ViewConditionalMethod.swift */,
|
||||||
);
|
);
|
||||||
path = Models;
|
path = Models;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -439,6 +442,7 @@
|
|||||||
3D1015D92B27F57400F5C29A /* AddServerView.swift in Sources */,
|
3D1015D92B27F57400F5C29A /* AddServerView.swift in Sources */,
|
||||||
3DAFA8EA2B39039900D71AD1 /* JellyfinKitExtensions.swift in Sources */,
|
3DAFA8EA2B39039900D71AD1 /* JellyfinKitExtensions.swift in Sources */,
|
||||||
3D13F9652B37EC7A00E91913 /* ItemHeaderView.swift in Sources */,
|
3D13F9652B37EC7A00E91913 /* ItemHeaderView.swift in Sources */,
|
||||||
|
3DAFA8EC2B394F9F00D71AD1 /* ViewConditionalMethod.swift in Sources */,
|
||||||
3D9063CB2B279A310063DD2A /* JelApp.swift in Sources */,
|
3D9063CB2B279A310063DD2A /* JelApp.swift in Sources */,
|
||||||
3D13F9692B389FA300E91913 /* ViewOffsetKey.swift in Sources */,
|
3D13F9692B389FA300E91913 /* ViewOffsetKey.swift in Sources */,
|
||||||
3D91FDCD2B2907E800919017 /* JellyfinDateFormatter.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] ?? "" : "")
|
Text(item.taglines?.count ?? 0 > 0 ? item.taglines?[0] ?? "" : "")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
.padding(.bottom)
|
||||||
|
|
||||||
Text(item.overview ?? "---")
|
Text(item.overview ?? "---")
|
||||||
}
|
}
|
||||||
|
@ -57,23 +57,25 @@ struct LibraryDetailView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.searchable(text: $searchText)
|
.if(!loading) {view in
|
||||||
.onChange(of: searchText) {
|
view.searchable(text: $searchText)
|
||||||
Task {
|
.onChange(of: searchText) {
|
||||||
let parameters = Paths.GetParameters(
|
Task {
|
||||||
userID: AuthStateController.shared.userId,
|
let parameters = Paths.GetParameters(
|
||||||
searchTerm: searchText.lowercased(),
|
userID: AuthStateController.shared.userId,
|
||||||
parentID: library.id
|
searchTerm: searchText.lowercased(),
|
||||||
)
|
parentID: library.id
|
||||||
searchResultHints = await jellyfinClient.search(parameters: parameters)
|
)
|
||||||
|
searchResultHints = await jellyfinClient.search(parameters: parameters)
|
||||||
searchResultItems = items?.filter { item in
|
|
||||||
for hint in searchResultHints?.searchHints ?? [] {
|
searchResultItems = items?.filter { item in
|
||||||
if hint.name == item.name {
|
for hint in searchResultHints?.searchHints ?? [] {
|
||||||
return true
|
if hint.name == item.name {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user