Skip to content

Instantly share code, notes, and snippets.

@Parassharmaa
Created January 22, 2018 10:46
Show Gist options
  • Select an option

  • Save Parassharmaa/7f73bebdb89b671db34e2db00cf88dbd to your computer and use it in GitHub Desktop.

Select an option

Save Parassharmaa/7f73bebdb89b671db34e2db00cf88dbd to your computer and use it in GitHub Desktop.
React Settings UI/UX
import React, { Component } from 'react';
import { AppRegistry, TextInput, View,Text, StyleSheet, Switch, TouchableOpacity } from 'react-native';
export default class UselessTextInput extends Component {
constructor(props) {
super(props);
this.state = {
emailOpt: true,
pushOpt: true
};
}
render() {
return (
<View style={style.container}>
<View style={style.header}>
<Text style={style.headerText}>
Settings
</Text>
</View>
<Text style={style.section}>
Notification
</Text>
<View style={style.item}>
<Text>
Email
</Text>
<Switch
value={this.state.emailOpt}
onTintColor="red"
onValueChange={() => this.setState({emailOpt: !this.state.emailOpt})}/>
</View>
<View style={style.item}>
<Text>
Push
</Text>
<Switch
value={this.state.pushOpt}
onValueChange={() => this.setState({pushOpt: !this.state.pushOpt})}
/>
</View>
<Text style={style.section}>
Other
</Text>
<TouchableOpacity style={style.item}>
Reset Password
</TouchableOpacity>
<TouchableOpacity style={style.redBtn}>
Sign Out
</TouchableOpacity>
</View>
);
}
}
const style = StyleSheet.create({
container: {
margin:0,
flex:1
},
section: {
fontSize: 10,
paddingTop: 10,
paddingHorizontal: 5,
color: '#aaa',
borderBottomColor: '#eee',
borderBottomWidth: 1,
},
header: {
height: 25,
backgroundColor: '#11B8FF',
},
headerText: {
color: '#fff',
fontSize: '14',
padding: 5,
alignSelf: 'center'
},
item: {
borderRadius: 3,
fontSize:10,
borderBottom: '1 solid red',
lineHeight: 35,
background: 'red',
paddingHorizontal: 10,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
borderBottomColor: '#eee',
borderBottomWidth: 1,
},
rightIcon: {
resizeMode: 'contain',
},
redBtn: {
height: 30,
borderRadius: 3,
margin: 30,
fontSize: 12,
color: '#fff',
fontWeight: 600,
backgroundColor: '#f04201',
justifyContent: 'center',
alignItems: 'center'
}
})
// skip this line if using Create React Native App
AppRegistry.registerComponent('AwesomeProject', () => UselessTextInput);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment