@@ -29,65 +29,63 @@ struct SearchForWebMapView: View {
2929 @State private var error : Error ?
3030
3131 var body : some View {
32- NavigationStack {
33- ScrollView {
34- LazyVStack {
35- ForEach ( model. portalItems, id: \. id) { item in
36- NavigationLink {
37- SafeMapView ( map: Map ( item: item) )
38- . navigationTitle ( item. title)
39- } label: {
40- PortalItemRowView ( item: item)
41- }
42- . buttonStyle ( . plain)
43- . task {
44- // Load the next results when the last item is reached.
45- guard item. id == model. portalItems. last? . id else { return }
46-
47- resultsAreLoading = true
48- defer { resultsAreLoading = false }
49-
50- do {
51- try await model. findNextItems ( )
52- } catch {
53- self . error = error
54- }
55- }
32+ ScrollView {
33+ LazyVStack {
34+ ForEach ( model. portalItems, id: \. id) { item in
35+ NavigationLink {
36+ SafeMapView ( map: Map ( item: item) )
37+ . navigationTitle ( item. title)
38+ } label: {
39+ PortalItemRowView ( item: item)
5640 }
57-
58- if resultsAreLoading {
59- ProgressView ( )
60- . padding ( )
61- } else if !query. isEmpty && model. portalItems. isEmpty {
62- VStack {
63- Text ( " No Results " )
64- . font ( . headline)
65- Text ( " Check spelling or try a new search. " )
66- . font ( . footnote)
41+ . buttonStyle ( . plain)
42+ . task {
43+ // Load the next results when the last item is reached.
44+ guard item. id == model. portalItems. last? . id else { return }
45+
46+ resultsAreLoading = true
47+ defer { resultsAreLoading = false }
48+
49+ do {
50+ try await model. findNextItems ( )
51+ } catch {
52+ self . error = error
6753 }
68- . padding ( )
6954 }
7055 }
71- }
72- . background ( Color ( . secondarySystemBackground) )
73- . searchable (
74- text: $query,
75- placement: . navigationBarDrawer( displayMode: . always) ,
76- prompt: " Web Maps "
77- )
78- . task ( id: query) {
79- // Load new results when the query changes.
80- resultsAreLoading = true
81- defer { resultsAreLoading = false }
8256
83- do {
84- try await model. findItems ( for: query)
85- } catch {
86- self . error = error
57+ if resultsAreLoading {
58+ ProgressView ( )
59+ . padding ( )
60+ } else if !query. isEmpty && model. portalItems. isEmpty {
61+ VStack {
62+ Text ( " No Results " )
63+ . font ( . headline)
64+ Text ( " Check spelling or try a new search. " )
65+ . font ( . footnote)
66+ }
67+ . padding ( )
8768 }
8869 }
89- . errorAlert ( presentingError: $error)
9070 }
71+ . background ( Color ( . secondarySystemBackground) )
72+ . searchable (
73+ text: $query,
74+ placement: . navigationBarDrawer( displayMode: . always) ,
75+ prompt: " Web Maps "
76+ )
77+ . task ( id: query) {
78+ // Load new results when the query changes.
79+ resultsAreLoading = true
80+ defer { resultsAreLoading = false }
81+
82+ do {
83+ try await model. findItems ( for: query)
84+ } catch {
85+ self . error = error
86+ }
87+ }
88+ . errorAlert ( presentingError: $error)
9189 }
9290}
9391
0 commit comments