@@ -52,27 +52,44 @@ struct CountryListView: View {
52
52
@State var query : String = " "
53
53
54
54
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
+ }
61
64
}
62
65
}
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
+ }
63
82
}
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
+ }
71
89
}
72
90
}
73
91
}
74
92
}
75
- }
76
93
}
77
94
78
95
0 commit comments