From 501a3da48f56eab12cf64e7d2018fe52911e9f2f Mon Sep 17 00:00:00 2001 From: cranci1 <100066266+cranci1@users.noreply.github.com> Date: Mon, 7 Jul 2025 10:15:36 +0200 Subject: [PATCH] fixed recent search issues --- .../Extensions/Notification+Name.swift | 1 + Sora/Utlis & Misc/TabBar/TabBar.swift | 11 +++++++-- Sora/Views/SearchView/SearchView.swift | 6 +++++ .../SettingsSubViews/SettingsViewPlayer.swift | 23 ------------------- 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/Sora/Utlis & Misc/Extensions/Notification+Name.swift b/Sora/Utlis & Misc/Extensions/Notification+Name.swift index 2f82dad..33b3d4d 100644 --- a/Sora/Utlis & Misc/Extensions/Notification+Name.swift +++ b/Sora/Utlis & Misc/Extensions/Notification+Name.swift @@ -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") } diff --git a/Sora/Utlis & Misc/TabBar/TabBar.swift b/Sora/Utlis & Misc/TabBar/TabBar.swift index 52acb8d..0b383c0 100644 --- a/Sora/Utlis & Misc/TabBar/TabBar.swift +++ b/Sora/Utlis & Misc/TabBar/TabBar.swift @@ -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) } } diff --git a/Sora/Views/SearchView/SearchView.swift b/Sora/Views/SearchView/SearchView.swift index 5a468e8..e251581 100644 --- a/Sora/Views/SearchView/SearchView.swift +++ b/Sora/Views/SearchView/SearchView.swift @@ -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) diff --git a/Sora/Views/SettingsView/SettingsSubViews/SettingsViewPlayer.swift b/Sora/Views/SettingsView/SettingsSubViews/SettingsViewPlayer.swift index f34e5a3..6b13746 100644 --- a/Sora/Views/SettingsView/SettingsSubViews/SettingsViewPlayer.swift +++ b/Sora/Views/SettingsView/SettingsSubViews/SettingsViewPlayer.swift @@ -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: "")