78 lines
No EOL
1.6 KiB
JavaScript
Executable file
78 lines
No EOL
1.6 KiB
JavaScript
Executable file
import React from 'react';
|
|
import {
|
|
View,
|
|
Text,
|
|
TextInput,
|
|
} from 'react-native';
|
|
import {
|
|
Header,
|
|
Button,
|
|
} from 'react-native-elements';
|
|
|
|
|
|
class SettingsScreen extends React.Component {
|
|
// 1
|
|
constructor(props) {
|
|
super(props);
|
|
let initv = this.getMyStringValue;
|
|
this.state = { value : initv };
|
|
|
|
}
|
|
|
|
setStringValue = async (value) => {
|
|
try {
|
|
await AsyncStorage.setItem('key', value)
|
|
} catch(e) {
|
|
// save error
|
|
}
|
|
|
|
//console.log('Done.')
|
|
}
|
|
|
|
getMyStringValue = async () => {
|
|
try {
|
|
return await AsyncStorage.getItem('@key')
|
|
} catch(e) {
|
|
// read error
|
|
}
|
|
|
|
//console.log('Done.')
|
|
//this.state.value =rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static navigationOptions = ({ navigation }) => {
|
|
return {
|
|
title: navigation.getParam('otherParam', 'Settings'),
|
|
headerStyle: {
|
|
backgroundColor: '#3333ff',
|
|
},
|
|
headerTintColor: '#fff',
|
|
};
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
let value = this.state.value;
|
|
|
|
return (
|
|
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center'}}>
|
|
<Text>Settings Screen{"\n"}{"\n"}
|
|
RPI Media Center Control v 1.0 beta Settings{"\n"}</Text>
|
|
<Text>{"\n"}server IP/hostname: </Text>
|
|
<TextInput onChangeText={newValue => this.setStringValue(newValue)} style={{borderWidth: 1, width: 100}} >{value}</TextInput>
|
|
<Text>{"\n"}</Text>
|
|
|
|
|
|
|
|
|
|
</View>
|
|
|
|
);
|
|
}
|
|
}
|
|
|
|
export default SettingsScreen; |