@@ -3,20 +3,11 @@ import { type Href, router } from 'expo-router';
33import { useColorScheme } from 'nativewind' ;
44import React , { useCallback , useMemo , useState } from 'react' ;
55import { useTranslation } from 'react-i18next' ;
6- import {
7- ActivityIndicator ,
8- FlatList ,
9- Pressable ,
10- RefreshControl ,
11- ScrollView ,
12- StyleSheet ,
13- Text as RNText ,
14- View ,
15- } from 'react-native' ;
6+ import { ActivityIndicator , FlatList , Pressable , RefreshControl , ScrollView , StyleSheet , Text as RNText , View } from 'react-native' ;
167
17- import { WeatherAlertCard } from '@/components/weatherAlerts/weather-alert-card' ;
188import { Text } from '@/components/ui/text' ;
199import { VStack } from '@/components/ui/vstack' ;
10+ import { WeatherAlertCard } from '@/components/weatherAlerts/weather-alert-card' ;
2011import { WeatherAlertSeverity } from '@/models/v4/weatherAlerts/weatherAlertEnums' ;
2112import { type WeatherAlertResultData } from '@/models/v4/weatherAlerts/weatherAlertResultData' ;
2213import { useWeatherAlertsStore } from '@/stores/weatherAlerts/store' ;
@@ -84,29 +75,8 @@ export default function WeatherAlertsListScreen() {
8475 const renderFilterButton = ( key : FilterType , label : string ) => {
8576 const isActive = filter === key ;
8677 return (
87- < Pressable
88- key = { key }
89- onPress = { ( ) => setFilter ( key ) }
90- style = { [
91- styles . filterPill ,
92- isActive
93- ? styles . filterPillActive
94- : isDark
95- ? styles . filterPillDark
96- : styles . filterPillLight ,
97- ] }
98- >
99- < RNText
100- style = { [
101- styles . filterPillText ,
102- isActive
103- ? styles . filterPillTextActive
104- : isDark
105- ? styles . filterPillTextDark
106- : styles . filterPillTextLight ,
107- ] }
108- numberOfLines = { 1 }
109- >
78+ < Pressable key = { key } onPress = { ( ) => setFilter ( key ) } style = { [ styles . filterPill , isActive ? styles . filterPillActive : isDark ? styles . filterPillDark : styles . filterPillLight ] } >
79+ < RNText style = { [ styles . filterPillText , isActive ? styles . filterPillTextActive : isDark ? styles . filterPillTextDark : styles . filterPillTextLight ] } numberOfLines = { 1 } >
11080 { label }
11181 </ RNText >
11282 </ Pressable >
@@ -116,25 +86,8 @@ export default function WeatherAlertsListScreen() {
11686 const renderSortButton = ( key : SortType , label : string ) => {
11787 const isActive = sort === key ;
11888 return (
119- < Pressable
120- key = { key }
121- onPress = { ( ) => setSort ( key ) }
122- style = { [ styles . sortPill , isActive && styles . sortPillActive ] }
123- >
124- < RNText
125- style = { [
126- styles . sortPillText ,
127- isActive
128- ? isDark
129- ? styles . sortPillTextActiveDark
130- : styles . sortPillTextActive
131- : isDark
132- ? styles . sortPillTextDark
133- : styles . sortPillTextLight ,
134- ] }
135- >
136- { label }
137- </ RNText >
89+ < Pressable key = { key } onPress = { ( ) => setSort ( key ) } style = { [ styles . sortPill , isActive && styles . sortPillActive ] } >
90+ < RNText style = { [ styles . sortPillText , isActive ? ( isDark ? styles . sortPillTextActiveDark : styles . sortPillTextActive ) : isDark ? styles . sortPillTextDark : styles . sortPillTextLight ] } > { label } </ RNText >
13891 </ Pressable >
13992 ) ;
14093 } ;
@@ -143,34 +96,20 @@ export default function WeatherAlertsListScreen() {
14396 if ( isLoading ) return null ;
14497 return (
14598 < VStack className = "flex-1 items-center justify-center py-12" space = "sm" >
146- < Text className = "text-base text-gray-500 dark:text-gray-400" >
147- { t ( 'weatherAlerts.noActiveAlerts' ) }
148- </ Text >
99+ < Text className = "text-base text-gray-500 dark:text-gray-400" > { t ( 'weatherAlerts.noActiveAlerts' ) } </ Text >
149100 </ VStack >
150101 ) ;
151102 } ;
152103
153- const renderItem = useCallback (
154- ( { item } : { item : WeatherAlertResultData } ) => (
155- < WeatherAlertCard alert = { item } onPress = { handleAlertPress } />
156- ) ,
157- [ ]
158- ) ;
104+ const renderItem = useCallback ( ( { item } : { item : WeatherAlertResultData } ) => < WeatherAlertCard alert = { item } onPress = { handleAlertPress } /> , [ ] ) ;
159105
160106 return (
161107 < View style = { [ styles . container , isDark ? styles . containerDark : styles . containerLight ] } >
162108 { /* Header */ }
163- < RNText style = { [ styles . title , isDark ? styles . titleDark : styles . titleLight ] } >
164- { t ( 'weatherAlerts.title' ) }
165- </ RNText >
109+ < RNText style = { [ styles . title , isDark ? styles . titleDark : styles . titleLight ] } > { t ( 'weatherAlerts.title' ) } </ RNText >
166110
167111 { /* Filter pills */ }
168- < ScrollView
169- horizontal
170- showsHorizontalScrollIndicator = { false }
171- style = { styles . filterScroll }
172- contentContainerStyle = { styles . filterRow }
173- >
112+ < ScrollView horizontal showsHorizontalScrollIndicator = { false } style = { styles . filterScroll } contentContainerStyle = { styles . filterRow } >
174113 { renderFilterButton ( 'all' , t ( 'weatherAlerts.filter.all' ) ) }
175114 { renderFilterButton ( 'extreme' , t ( 'weatherAlerts.severity.extreme' ) ) }
176115 { renderFilterButton ( 'severe' , t ( 'weatherAlerts.severity.severe' ) ) }
@@ -195,9 +134,7 @@ export default function WeatherAlertsListScreen() {
195134 renderItem = { renderItem }
196135 contentContainerStyle = { styles . listContent }
197136 ListEmptyComponent = { renderEmpty }
198- refreshControl = {
199- < RefreshControl refreshing = { isLoading } onRefresh = { fetchActiveAlerts } />
200- }
137+ refreshControl = { < RefreshControl refreshing = { isLoading } onRefresh = { fetchActiveAlerts } /> }
201138 />
202139 ) }
203140 </ View >
0 commit comments