Skip to content

Instantly share code, notes, and snippets.

@youneshenniwrites
Last active January 4, 2019 12:32
Show Gist options
  • Save youneshenniwrites/48596817d1b07743cd7c6f1ccf77813a to your computer and use it in GitHub Desktop.
Save youneshenniwrites/48596817d1b07743cd7c6f1ccf77813a to your computer and use it in GitHub Desktop.
Phone input basic level with keyboard avoiding view
import React from 'react'
import {
View,
StyleSheet,
SafeAreaView,
Keyboard,
KeyboardAvoidingView,
TouchableWithoutFeedback
} from 'react-native'
// native base imports
import {
Container,
Item,
Input,
Icon
} from 'native-base'
export default class App extends React.Component {
render() {
return (
<SafeAreaView style={styles.container}>
<KeyboardAvoidingView style={styles.container} behavior='padding' enabled>
<TouchableWithoutFeedback style={styles.container} onPress={Keyboard.dismiss}>
<View style={styles.container}>
<Container style={styles.infoContainer}>
{/* Phone input with native-base */}
<Item rounded style={styles.itemStyle}>
<Icon
active
name='call'
style={styles.iconStyle}
/>
<Icon
active
name='md-arrow-dropdown'
style={[styles.iconStyle, { marginLeft: 0 }]}
/>
<Input
placeholder='+44766554433'
placeholderTextColor='#adb4bc'
keyboardType={'phone-pad'}
returnKeyType='done'
autoCapitalize='none'
autoCorrect={false}
secureTextEntry={false}
style={styles.inputStyle}
/>
</Item>
</Container>
</View>
</TouchableWithoutFeedback>
</KeyboardAvoidingView>
</SafeAreaView>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#aa73b7',
justifyContent: 'center',
flexDirection: 'column'
},
infoContainer: {
position: 'absolute',
left: 0,
right: 0,
height: 200,
bottom: 250,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
paddingHorizontal: 30,
backgroundColor: '#aa73b7',
},
iconStyle: {
color: '#5a52a5',
fontSize: 28,
marginLeft: 15
},
itemStyle: {
marginBottom: 10,
},
inputStyle: {
flex: 1,
fontSize: 17,
fontWeight: 'bold',
color: '#5a52a5',
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment