Skip to content

Commit

Permalink
search view improved fr
Browse files Browse the repository at this point in the history
  • Loading branch information
cranci1 committed Feb 2, 2025
1 parent c06fe99 commit 2658f7e
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions Sora/Views/SearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,32 @@ struct SearchView: View {
return moduleManager.modules.first { $0.id.uuidString == id }
}

private var loadingMessages: [String] = [
"Searching the depths...",
"Looking for results...",
"Fetching data...",
"Please wait...",
"Almost there..."
]

var body: some View {
NavigationView {
ScrollView {
VStack(spacing: 0) {
SearchBar(text: $searchText, onSearchButtonClicked: performSearch)
.padding()
.disabled(selectedModule == nil)
HStack {
SearchBar(text: $searchText, onSearchButtonClicked: performSearch)
.padding(.leading)
.padding(.trailing, searchText.isEmpty ? 16 : 0)
.disabled(selectedModule == nil)

if !searchText.isEmpty {
Button("Cancel") {
searchText = ""
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
.padding(.trailing)
}
}

if selectedModule == nil {
VStack(spacing: 8) {
Expand All @@ -57,8 +76,13 @@ struct SearchView: View {
}

if isSearching {
ProgressView()
.padding()
VStack(spacing: 8) {
ProgressView()
Text(loadingMessages.randomElement() ?? "Loading...")
.font(.caption)
.foregroundColor(.secondary)
}
.padding()
} else if hasNoResults {
VStack(spacing: 8) {
Image(systemName: "magnifyingglass")
Expand Down Expand Up @@ -152,6 +176,7 @@ struct SearchView: View {

isSearching = true
hasNoResults = false
searchItems = []

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
Task {
Expand Down

0 comments on commit 2658f7e

Please sign in to comment.