Skip to content

Commit 16f296a

Browse files
authored
Merge pull request #64 from percy-g2/main
[iOS] Show progress view while loading countries and UI fixes
2 parents f7f17e0 + fee37c6 commit 16f296a

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

iosApp/iosApp/ContentView.swift

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,44 @@ struct CountryListView: View {
5252
@State var query: String = ""
5353

5454
var body: some View {
55-
NavigationView {
56-
List {
57-
ForEach(viewModel.countryList.filter { query.isEmpty || $0.name.contains(query)}, id: \.self) { country in
58-
NavigationLink(destination: CountryInfoDetailedViewShared(country: country)) {
59-
HStack {
60-
Text(country.name).font(.headline)
55+
NavigationView {
56+
ZStack {
57+
List {
58+
ForEach(viewModel.countryList.filter { query.isEmpty || $0.name.contains(query) }, id: \.self) { country in
59+
NavigationLink(destination: CountryInfoDetailedViewShared(country: country)) {
60+
HStack {
61+
Text(country.name).font(.headline)
62+
}
63+
}
6164
}
6265
}
66+
.searchable(text: $query)
67+
.disableAutocorrection(true)
68+
69+
// Conditional display of the ProgressView
70+
if let isLoading = viewModel.isLoadingCountries.value_ as? Bool, isLoading {
71+
ProgressView()
72+
.progressViewStyle(CircularProgressViewStyle())
73+
.scaleEffect(1.5)
74+
.frame(maxWidth: .infinity, maxHeight: .infinity)
75+
} else if viewModel.countryList.filter({ query.isEmpty || $0.name.contains(query) }).isEmpty {
76+
// Conditional display of text when query result is empty from search bar
77+
Text("No Countries Found!")
78+
.font(.headline)
79+
.foregroundColor(.gray)
80+
.frame(maxWidth: .infinity, maxHeight: .infinity)
81+
}
6382
}
64-
}
65-
.searchable(text: $query)
66-
.navigationBarTitleDisplayMode(.inline)
67-
.toolbar {
68-
ToolbarItem(placement: .principal) {
69-
VStack {
70-
Text("ClimateTrace").font(.headline)
83+
.navigationBarTitleDisplayMode(.inline)
84+
.toolbar {
85+
ToolbarItem(placement: .principal) {
86+
VStack {
87+
Text("ClimateTrace").font(.headline)
88+
}
7189
}
7290
}
7391
}
7492
}
75-
}
7693
}
7794

7895

0 commit comments

Comments
 (0)