Skip to content

Commit 7dd7d34

Browse files
committed
Country map mobile search
1 parent 2d47067 commit 7dd7d34

File tree

1 file changed

+56
-22
lines changed

1 file changed

+56
-22
lines changed

mobile/app/(tabs)/maps.tsx

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -349,28 +349,62 @@ export default function MapsScreen() {
349349
}
350350
>
351351
{isSearching ? (
352-
// Search results
353-
searchLoading ? (
354-
<View style={styles.centered}>
355-
<ActivityIndicator size="large" color="white" />
356-
<Text style={styles.loadingText}>Searching...</Text>
357-
</View>
358-
) : searchResults.length > 0 ? (
359-
<MapSection
360-
title="Search Results"
361-
maps={searchResults}
362-
onMapPress={handleMapPress}
363-
numCols={numCols}
364-
/>
365-
) : (
366-
<View style={styles.emptyState}>
367-
<Ionicons name="map-outline" size={48} color="rgba(255,255,255,0.3)" />
368-
<Text style={styles.emptyTitle}>No results found</Text>
369-
<Text style={styles.emptySubtext}>
370-
Try adjusting your search terms
371-
</Text>
372-
</View>
373-
)
352+
// Search results — include matching country maps + API results
353+
(() => {
354+
const queryLower = searchQuery.trim().toLowerCase();
355+
const matchingCountryMaps = (mapHome.countryMaps || []).filter(
356+
(m) => m.name?.toLowerCase().includes(queryLower)
357+
);
358+
const hasCountry = matchingCountryMaps.length > 0;
359+
const hasCommunity = searchResults.length > 0;
360+
const hasAny = hasCountry || hasCommunity;
361+
362+
if (searchLoading && !hasAny) {
363+
return (
364+
<View style={styles.centered}>
365+
<ActivityIndicator size="large" color="white" />
366+
<Text style={styles.loadingText}>Searching...</Text>
367+
</View>
368+
);
369+
}
370+
371+
if (!hasAny && !searchLoading) {
372+
return (
373+
<View style={styles.emptyState}>
374+
<Ionicons name="map-outline" size={48} color="rgba(255,255,255,0.3)" />
375+
<Text style={styles.emptyTitle}>No results found</Text>
376+
<Text style={styles.emptySubtext}>
377+
Try adjusting your search terms
378+
</Text>
379+
</View>
380+
);
381+
}
382+
383+
return (
384+
<>
385+
{hasCountry && (
386+
<MapSection
387+
title="Country Maps"
388+
maps={matchingCountryMaps}
389+
isCountry
390+
onMapPress={handleMapPress}
391+
numCols={numCols}
392+
/>
393+
)}
394+
{hasCommunity && (
395+
<MapSection
396+
title="Search Results"
397+
maps={searchResults}
398+
onMapPress={handleMapPress}
399+
numCols={numCols}
400+
/>
401+
)}
402+
{searchLoading && (
403+
<ActivityIndicator size="small" color="white" style={{ marginTop: 12 }} />
404+
)}
405+
</>
406+
);
407+
})()
374408
) : (
375409
// Map home sections
376410
<>

0 commit comments

Comments
 (0)