@@ -9,14 +9,17 @@ import {
99 Switch ,
1010 Alert ,
1111 Linking ,
12+ Modal ,
13+ FlatList ,
1214} from 'react-native' ;
1315import AsyncStorage from '@react-native-async-storage/async-storage' ;
1416import { colors , spacing , typography , borderRadius } from '../utils/constants' ;
15- import { useWalletStore } from '../store' ;
17+ import { useWalletStore , useNetworkStore } from '../store' ;
1618import { Card } from '../components/common/Card' ;
1719import { useNavigation } from '@react-navigation/native' ;
1820import { NativeStackNavigationProp } from '@react-navigation/native-stack' ;
1921import { RootStackParamList } from '../navigation/types' ;
22+ import { Network } from '../config/networks' ;
2023
2124const APP_VERSION = '1.0.0' ;
2225interface Settings {
@@ -28,13 +31,16 @@ const SETTINGS_KEY = '@subtrackr_settings';
2831const SettingsScreen : React . FC = ( ) => {
2932 const navigation = useNavigation < NativeStackNavigationProp < RootStackParamList > > ( ) ;
3033 const { address, network, disconnect } = useWalletStore ( ) ;
34+ const { currentNetwork, availableNetworks, setNetwork, initialize } = useNetworkStore ( ) ;
3135 const [ settings , setSettings ] = useState < Settings > ( {
3236 notificationsEnabled : true ,
3337 defaultCurrency : 'USD' ,
3438 } ) ;
39+ const [ networkModalVisible , setNetworkModalVisible ] = useState ( false ) ;
3540
3641 useEffect ( ( ) => {
3742 loadSettings ( ) ;
43+ initialize ( ) ;
3844 } , [ ] ) ;
3945
4046 const loadSettings = async ( ) => {
@@ -101,12 +107,20 @@ const SettingsScreen: React.FC = () => {
101107 < Text style = { styles . settingValue } > { shortenAddress ( address || '' ) } </ Text >
102108 </ View >
103109 </ View >
104- < View style = { styles . settingRow } >
110+ < TouchableOpacity
111+ style = { styles . settingRow }
112+ onPress = { ( ) => setNetworkModalVisible ( true ) }
113+ accessibilityRole = "button"
114+ accessibilityLabel = "Select network"
115+ accessibilityHint = "Opens network selection modal" >
105116 < View style = { styles . settingInfo } >
106117 < Text style = { styles . settingLabel } > Network</ Text >
107- < Text style = { styles . settingValue } > { network || 'Not connected' } </ Text >
118+ < Text style = { styles . settingValue } >
119+ { currentNetwork ? currentNetwork . name : 'Select Network' }
120+ </ Text >
108121 </ View >
109- </ View >
122+ < Text style = { styles . linkArrow } accessibilityElementsHidden = { true } > →</ Text >
123+ </ TouchableOpacity >
110124 { address && (
111125 < TouchableOpacity
112126 style = { styles . dangerButton }
@@ -218,6 +232,54 @@ const SettingsScreen: React.FC = () => {
218232 < Text style = { styles . linkArrow } accessibilityElementsHidden = { true } > →</ Text >
219233 </ TouchableOpacity >
220234 </ Card >
235+
236+ { /* Network Selection Modal */ }
237+ < Modal
238+ visible = { networkModalVisible }
239+ animationType = "slide"
240+ presentationStyle = "pageSheet"
241+ onRequestClose = { ( ) => setNetworkModalVisible ( false ) } >
242+ < SafeAreaView style = { styles . modalContainer } >
243+ < View style = { styles . modalHeader } >
244+ < TouchableOpacity
245+ onPress = { ( ) => setNetworkModalVisible ( false ) }
246+ accessibilityRole = "button"
247+ accessibilityLabel = "Close network selection" >
248+ < Text style = { styles . closeButton } > Cancel</ Text >
249+ </ TouchableOpacity >
250+ < Text style = { styles . modalTitle } > Select Network</ Text >
251+ < View style = { { width : 50 } } />
252+ </ View >
253+ < FlatList
254+ data = { availableNetworks }
255+ keyExtractor = { ( item ) => item . id }
256+ renderItem = { ( { item } ) => (
257+ < TouchableOpacity
258+ style = { [
259+ styles . networkItem ,
260+ currentNetwork ?. id === item . id && styles . networkItemSelected ,
261+ ] }
262+ onPress = { async ( ) => {
263+ await setNetwork ( item . id ) ;
264+ setNetworkModalVisible ( false ) ;
265+ } }
266+ accessibilityRole = "radio"
267+ accessibilityLabel = { `Select ${ item . name } ` }
268+ accessibilityState = { { checked : currentNetwork ?. id === item . id } } >
269+ < View style = { styles . networkInfo } >
270+ < Text style = { styles . networkName } > { item . name } </ Text >
271+ < Text style = { styles . networkType } >
272+ { item . type . toUpperCase ( ) } { item . isTestnet ? '(Testnet)' : '(Mainnet)' }
273+ </ Text >
274+ </ View >
275+ { currentNetwork ?. id === item . id && (
276+ < Text style = { styles . checkmark } > ✓</ Text >
277+ ) }
278+ </ TouchableOpacity >
279+ ) }
280+ />
281+ </ SafeAreaView >
282+ </ Modal >
221283 </ ScrollView >
222284 </ SafeAreaView >
223285 ) ;
@@ -274,6 +336,30 @@ const styles = StyleSheet.create({
274336 linkRowLast : { borderBottomWidth : 0 } ,
275337 linkText : { ...typography . body , color : colors . text } ,
276338 linkArrow : { ...typography . body , color : colors . textSecondary } ,
339+ modalContainer : { flex : 1 , backgroundColor : colors . background } ,
340+ modalHeader : {
341+ flexDirection : 'row' ,
342+ justifyContent : 'space-between' ,
343+ alignItems : 'center' ,
344+ padding : spacing . lg ,
345+ borderBottomWidth : 1 ,
346+ borderBottomColor : colors . border ,
347+ } ,
348+ modalTitle : { ...typography . h2 , color : colors . text } ,
349+ closeButton : { ...typography . body , color : colors . primary } ,
350+ networkItem : {
351+ flexDirection : 'row' ,
352+ justifyContent : 'space-between' ,
353+ alignItems : 'center' ,
354+ padding : spacing . lg ,
355+ borderBottomWidth : 1 ,
356+ borderBottomColor : colors . border ,
357+ } ,
358+ networkItemSelected : { backgroundColor : colors . primary + '10' } ,
359+ networkInfo : { flex : 1 } ,
360+ networkName : { ...typography . body , color : colors . text , fontWeight : '600' } ,
361+ networkType : { ...typography . caption , color : colors . textSecondary , marginTop : spacing . xs } ,
362+ checkmark : { ...typography . h3 , color : colors . primary } ,
277363} ) ;
278364
279365export default SettingsScreen ;
0 commit comments