fixed recent search issues

This commit is contained in:
cranci1 2025-07-07 10:15:36 +02:00
parent b9523c259f
commit 501a3da48f
4 changed files with 16 additions and 25 deletions

View file

@ -22,4 +22,5 @@ extension Notification.Name {
static let hideTabBar = Notification.Name("hideTabBar")
static let showTabBar = Notification.Name("showTabBar")
static let searchQueryChanged = Notification.Name("searchQueryChanged")
static let tabBarSearchQueryUpdated = Notification.Name("tabBarSearchQueryUpdated")
}

View file

@ -24,7 +24,7 @@ extension Color {
default:
(r, g, b, a) = (1, 1, 1, 1)
}
self.init(
.sRGB,
red: Double(r) / 255,
@ -180,7 +180,7 @@ struct TabBar: View {
.padding(.bottom, -100)
.padding(.top, -10)
}
.offset(y: keyboardFocus ? -keyboardHeight + 40 : 0)
.offset(y: keyboardFocus ? -keyboardHeight + 40 : 0)
.animation(.spring(response: 0.3, dampingFraction: 0.8), value: keyboardHeight)
.animation(.spring(response: 0.3, dampingFraction: 0.8), value: keyboardFocus)
.onChange(of: keyboardHeight) { newValue in
@ -197,10 +197,17 @@ struct TabBar: View {
NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillHideNotification, object: nil, queue: .main) { _ in
keyboardHeight = 0
}
NotificationCenter.default.addObserver(forName: .tabBarSearchQueryUpdated, object: nil, queue: .main) { notification in
if let query = notification.userInfo?["searchQuery"] as? String {
searchQuery = query
}
}
}
.onDisappear {
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: .tabBarSearchQueryUpdated, object: nil)
}
}

View file

@ -108,6 +108,12 @@ struct SearchView: View {
cellWidth: cellWidth,
onHistoryItemSelected: { query in
searchQuery = query
searchDebounceTimer?.invalidate()
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
NotificationCenter.default.post(name: .tabBarSearchQueryUpdated, object: nil, userInfo: ["searchQuery": query])
performSearch()
},
onHistoryItemDeleted: { index in
removeFromHistory(at: index)

View file

@ -304,29 +304,6 @@ struct SettingsViewPlayer: View {
)
}
SettingsSection(title: NSLocalizedString("Progress bar Marker Color", comment: "")) {
ColorPicker(NSLocalizedString("Segments Color", comment: ""), selection: Binding(
get: {
if let data = UserDefaults.standard.data(forKey: "segmentsColorData"),
let uiColor = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? UIColor {
return Color(uiColor)
}
return .yellow
},
set: { newColor in
let uiColor = UIColor(newColor)
if let data = try? NSKeyedArchiver.archivedData(
withRootObject: uiColor,
requiringSecureCoding: false
) {
UserDefaults.standard.set(data, forKey: "segmentsColorData")
}
}
))
.padding(.horizontal, 16)
.padding(.vertical, 12)
}
SettingsSection(
title: NSLocalizedString("Skip Settings", comment: ""),
footer: NSLocalizedString("Double tapping the screen on it's sides will skip with the short tap setting.", comment: "")