I am using keyboardavoidingview in the following scroll to move up keyboard so that the submit button is always visible. But it seems to not work on ios properly, despite setting the property behavior to padding, please help me sort this out.
I have already referred to numerous posts on SO and Github but since the use case varies, nothing has been able to help me at all.
As the official documentation for keyboardavoidingview also says to add behaviour, so i did.
But the view is not shifting up, also i cannot use jutifycontent-center since i need the view to start from top only.
refer
///Code
render() {
return (
<SafeAreaView style={{flex:1}}>
<KeyboardAvoidingView
behavior={Platform.OS === "ios" ? "padding" : null}
style={styles.container}
keyboardVerticalOffset={Platform.select({ios: 0, android: Header.HEIGHT + 20})}
>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View>
<StatusBar backgroundColor="#7c8500" barStyle="light-content" />
<View>
<Text style={styles.holdertext}>Name:</Text>
</View>
<TextInput
style={styles.inputBox}
underlineColorAndroid="rgba(0,0,0,0)"
value={this.state.username}
editable={true}
placeholderTextColor="rgba(0,0,0,0.3)"
onChangeText={value => this.setState({ username: value })}
/>
<View style={styles.bottomView}>
<Text style={styles.holdertext}>Phone:</Text>
</View>
<TextInput
style={styles.inputBox}
underlineColorAndroid="rgba(0,0,0,0)"
value={this.state.phonenumber}
placeholder="Phone"
placeholderTextColor="rgba(0,0,0,0.3)"
maxLength={10}
keyboardType="phone-pad"
clearButtonMode="always"
onChangeText={value => this.setState({ phonenumber: value })}
/>
<View>
<Text style={styles.holdertext}>Comment:</Text>
</View>
<TextInput
style={styles.commentbox}
returnKeyType="next"
underlineColorAndroid="rgba(0,0,0,0)"
value={this.state.comment}
placeholder="Comment"
placeholderTextColor="rgba(0,0,0,0.3)"
textAlign={"left"}
numberOfLines={10}
multiline={true}
clearButtonMode="always"
onChangeText={value => this.setState({ comment: value })}
/>
<TouchableOpacity style={styles.button} onPress={this.callFun}>
<Text style={styles.buttonText}>SUBMIT</Text>
</TouchableOpacity>
</View>
</TouchableWithoutFeedback>
</KeyboardAvoidingView>
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#ffffff",
},
holdertext: {
fontSize: 16,
fontWeight: "bold",
marginTop: 5,
marginLeft: 8,
textAlign: "left"
},
inputBox: {
width: null,
height: 40,
backgroundColor: "rgba(229,229,229,0.3)",
color: "#000000",
paddingVertical: 10,
paddingLeft: 10,
margin: 10,
marginLeft: 10,
fontSize: 18,
borderWidth: 0.3,
borderRadius: 20,
borderColor: "rgba(175,180,43,0.8)"
},
commentbox: {
width: null,
height:100,
backgroundColor: "rgba(229,229,229,0.3)",
fontSize: 12,
color: "#000000",
paddingVertical: 10,
paddingLeft: 10,
margin: 10,
marginLeft: 10,
fontSize: 18,
borderWidth: 0.3,
borderRadius: 20,
textAlignVertical: "top",
borderColor: "rgba(175,180,43,0.8)"
},
button: {
width: null,
backgroundColor: "#1c313a",
borderRadius: 25,
margin: 15,
paddingVertical: 15
},
buttonText: {
fontSize: 16,
fontWeight: "500",
color: "#ffffff",
textAlign: "center"
}
});
Forget about the native component, it is very buggy.
Use this one: https://github.com/APSL/react-native-keyboard-aware-scroll-view
Related
I am attempting to make the images scroll horizontally. I downloaded some UI, and added ScrollView horizontal. But instead of it looking the same just with the ability to scroll horizontally, it shrank the image (and also gave it the ability to scroll horizontally). What should I change to make it stretch all the way across (still with the padding)?
Posts.js
import React from "react";
import {
View,
Text,
Image,
ImagBackground,
ImageBackground,
} from "react-native";
import Icon from "#expo/vector-icons/Entypo";
import { ScrollView, TouchableOpacity } from "react-native-gesture-handler";
export default class Posts extends React.Component {
state = {
liked: false,
};
onLike = () => {
this.setState({ liked: !this.state.liked });
};
render() {
const { name, profile, photo, onPress } = this.props;
return (
<View>
<View
style={{
flexDirection: "row",
paddingTop: 25,
alignItems: "center",
}}
>
<View style={{ width: "20%" }}>
<Image
source={profile}
style={{
width: 45,
height: 45,
borderRadius: 13,
}}
/>
</View>
<View
style={{
width: "60%",
}}
>
<Text
style={{
fontFamily: "Bold",
fontSize: 14,
color: "#044244",
}}
>
{name}
</Text>
<Text
style={{
fontFamily: "Medium",
fontSize: 12,
color: "#9ca1a2",
}}
>
2 mins ago
</Text>
</View>
<View
style={{
width: "20%",
alignItems: "flex-end",
}}
>
<Icon name="sound-mix" color="#044244" size={20} />
</View>
</View>
<View
style={{
flexDirection: "row",
width: "100%",
paddingTop: 20,
}}
>
<ScrollView horizontal>
<ImageBackground
source={photo}
style={{
width: "100%",
height: 220,
}}
imageStyle={{
borderRadius: 30,
}}
>
<View
style={{
height: "100%",
flexDirection: "row",
alignItems: "flex-end",
justifyContent: "flex-end",
}}
>
<TouchableOpacity
onPress={onPress}
style={{
marginBottom: 20,
borderRadius: 5,
padding: 5,
backgroundColor: "#e8e8e8",
}}
>
<Icon name="forward" color="#044244" size={20} />
</TouchableOpacity>
<TouchableOpacity
onPress={this.onLike}
style={{
marginBottom: 20,
borderRadius: 5,
padding: 5,
backgroundColor: "#e8e8e8",
marginLeft: 10,
marginRight: 20,
}}
>
<Icon
name={
this.state.liked === true ? "heart" : "heart-outlined"
}
color={this.state.liked === true ? "red" : "#044244"}
size={20}
/>
</TouchableOpacity>
</View>
</ImageBackground>
</ScrollView>
</View>
</View>
);
}
}
Here's me adding more words because the post doesn't have enough words on it's own. When will they finally remove this pointless feature? I feel as if I clearly expressed my question with the few words I used.
I believe your issue is with your View wrapping your ScrollView. There is no need of wrapping ScrollView, that too in row, due to which the remaining space is visible. Just define the ScrollView, and it would work just fine. Give a width of 100% to your ScrollView though.
For any sort of styling to the parent for the ScrollView, do it inside the ScrollView itself, like the way I did in the code.
Please note ScrollView accepts a list of child items, currently I see only a single item, if you've intentionally added this one, then it is fine, else, you need to refactor your code surely. This won't work out for you.
// PLEASE NOTE --> Commented Lines should be removed, and
// only ScrollView should be considered with the styling specified
// <View
// style={{
// flexDirection: "row",
// width: "100%",
// paddingTop: 20,
// }}
// >
<ScrollView horizontal
style={{
width: '100%',
marginTop: 20,
paddingLeft: 16,
paddingRight: 6
}}>
<ImageBackground
source={photo}
style={{
width: "100%",
height: 220,
marginRight: 10
}}
imageStyle={{
borderRadius: 30,
}}
>
<View
style={{
height: "100%",
flexDirection: "row",
alignItems: "flex-end",
justifyContent: "flex-end",
}}
>
<TouchableOpacity
onPress={onPress}
style={{
marginBottom: 20,
borderRadius: 5,
padding: 5,
backgroundColor: "#e8e8e8",
}}
>
<Icon name="forward" color="#044244" size={20} />
</TouchableOpacity>
<TouchableOpacity
onPress={this.onLike}
style={{
marginBottom: 20,
borderRadius: 5,
padding: 5,
backgroundColor: "#e8e8e8",
marginLeft: 10,
marginRight: 20,
}}
>
<Icon
name={
this.state.liked === true ? "heart" : "heart-outlined"
}
color={this.state.liked === true ? "red" : "#044244"}
size={20}
/>
</TouchableOpacity>
</View>
</ImageBackground>
</ScrollView>
// </View>
Good afternoon everyone, I am developing an app in React native, I put the library react-native-maps to show some fixed maps in a scrollview, in android I show the coordinates with the marker but in the map moves when I try do the scroll
I'm trying with staticmap, but where I would have to leave the map in ios I'm left blank.
import React, {Component} from 'react'
import {View, Text, TouchableOpacity, Platform, Image} from 'react-native'
import MapApp from './MapApp'
const staticMapURL = 'https://maps.googleapis.com/maps/api/staticmap'
class PropertyListCard extends Component {
renderMap(){
if(Platform.OS == 'ios'){
console.log(Platform.OS)
return(
<View
style={{
width: 500,
height:500,
backgroundColor: 'red'
}}
>
<Image
source={{uri: "https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Clabel:C%7C40.718217,-73.998284&key=MyGoogleKey"}}
style={{
width: 200,
height: 200
}}
/>
</View>
)
}else{
return(
<MapApp />
)
}
}
render(){
return(
<View style={styles.container}>
<View style={styles.titleContainer}>
<Text style={styles.titleText}>
{this.props.data.direction}
</Text>
</View>
<View style={styles.mapContainer}>
{this.renderMap()}
</View>
<TouchableOpacity
style={styles.btn}
onPress={()=>{}}
>
<Text
style={styles.btnText}
>
Ver Vecinos
</Text>
</TouchableOpacity>
</View>
)
}
}
const styles = {
container: {
flex:1,
backgroundColor: '#fff',
margin: 10,
borderRadius: 10
},
titleContainer:{
height: 40,
justifyContent: 'center',
borderBottomWidth: 1,
borderColor: 'grey'
},
titleText: {
paddingLeft: 20,
fontSize: 17,
fontWeight: 'bold'
},
mapContainer:{
width: '100%',
height: 200
},
btn:{
height: 50,
width: '100%',
backgroundColor: '#008591',
borderBottomLeftRadius: 10,
borderBottomRightRadius: 10,
alignItems: 'center',
justifyContent: 'center',
},
btnText: {
color: '#fff',
fontSize: 17,
fontWeight: 'bold',
}
}
export default PropertyListCard
there is no support for litemode on ios
https://github.com/react-community/react-native-maps/issues/1411#issuecomment-310380854
I am trying to use the KeyboardAvoidingView with behavior="padding".
When I am trying to enter any text in TextInput, the TextInput field is not moving up. I have added a small view in the end which is moving up but the the view above it.
I have also with KeyboardAvoidingView height property with offset. It was working few components like 2 TextInputs. But when I add all the components the UI goes insane and behave jumbled up.
Any any idea whats happening over here?
Here the link of tutorial which I have followed.
render() {
return (
<View style={styles.backgroundContainer}>
<Loader
loading={this.state.isLoading} />
<KeyboardAvoidingView
keyboardVerticalOffset={10}
style={styles.mainContainer}
behavior='padding' >
<View style={styles.formContainer}>
<View style={[styles.centerContainer, { marginTop: 40 }]}>
<Image source={require('./../../Resources/logo.png')} />
<Text style={{ fontWeight: 'bold', color: 'gray', fontSize: 25 }}>AppName</Text>
<Text style={styles.loginMsg}> Login to your Account </Text>
</View>
<View style={styles.inputFieldsContainer}>
<Image style={{ width: 30, height: 30, margin: 5 }} source={require('./../../Resources/logo.png')} />
<TextInput
placeholder='Email'
returnKeyType='next'
keyboardType='email-address'
onChangeText={(value) => this.setState({ userEmail: value })}
onSubmitEditing={() => this.passwordInput.focus()}
style={styles.inputFields} />
</View>
<View style={styles.inputFieldsContainer}>
<Image style={{ width: 30, height: 30, margin: 5, }} source={require('./../../Resources/logo.png')} />
<TextInput
returnKeyType='go'
secureTextEntry
placeholder='Password'
ref={(input) => this.passwordInput = input}
onChangeText={(value) => this.setState({ password: value })}
style={styles.inputFields} />
</View>
<View style={styles.buttonContainer}>
<Button
fontSize='8'
color='gray'
title='Remember Me'
onPress={() => {
console.log('Remember Me Clicked');
}} />
<Button
color='gray'
title='Forgot Password?'
onPress={() => {
console.log('Forgot Password Clicked');
}} />
</View>
<TouchableOpacity
style={styles.buttonLogin}
onPress={() => {
console.log('Login Clicked');
}}
>
<Text style={{ fontSize: 20, fontWeight: 'bold', color: 'white' }}>Login</Text>
</TouchableOpacity>
<View style={{ height: 1, backgroundColor: 'gray', marginTop: 20, marginBottom: 1 }}>
</View>
<View style={[styles.centerContainer, { marginBottom: 10 }]}>
<Text style={styles.loginMsg}>Don't have a Account</Text>
<TouchableOpacity
style={styles.buttonRegister}
onPress={() => navigate('Register')} >
<Text style={styles.buttonRegisterText}>REGISTER NOW</Text>
</TouchableOpacity>
</View>
</View>
<View style={{ height: 10, backgroundColor: '#628499', }}>
</View>
</KeyboardAvoidingView>
</View>
);
}
const styles = StyleSheet.create({
backgroundContainer: {
flex: 1, backgroundColor: 'green'
},
mainContainer: {
flex: 1, margin: 25,
borderWidth: 1, borderRadius: 5, borderColor: 'gray',
backgroundColor: 'white',
justifyContent: 'space-between'
},
formContainer: {
flex: 1, paddingLeft: 25, paddingRight: 25
},
centerContainer: {
alignItems: 'center', marginBottom: 10,
},
loginMsg: {
margin: 10,
fontSize: 20, color: 'gray'
},
inputFieldsContainer: {
flexDirection: 'row', margin: 10,
borderWidth: 1, borderRadius: 5, borderColor: 'gray',
},
inputFields: {
flexGrow: 1,
marginTop: 5, marginBottom: 5,
height: 30,
backgroundColor: 'rgba(255,255,255,0.4)',
paddingHorizontal: 10,
},
buttonContainer: {
flexDirection: 'row',
justifyContent: 'space-between'
},
buttonLogin: {
alignItems: 'center', height: 40, marginTop: 10, marginLeft: 50, marginRight: 50, padding: 5,
backgroundColor: '#2980b9',
borderWidth: 1, borderRadius: 5, borderColor: 'gray'
},
buttonRegister: {
alignItems: 'center', height: 40,
marginLeft: 50, marginRight: 50
},
buttonRegisterText: {
fontSize: 20, fontWeight: 'bold', color: 'gray'
},
loading: {
position: 'absolute',
left: 0, right: 0, top: 0, bottom: 0,
alignItems: 'center', justifyContent: 'center'
}, });
I used KeyboardAvoidingView, it also doesn't work.
I found this solution, You can take the base code.
Installation
npm i react-native-keyboard-aware-scroll-view --save
Usage
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
<KeyboardAwareScrollView>
<View>
<TextInput />
</View>
</KeyboardAwareScrollView>
You can find it here
The way it worked for me was to use position as behavior and -70 as vertical offset. Any non negative integer was creating a huge unused space when the keyboard pops up.
<KeyboardAvoidingView
style={styles.container}
behavior={Platform.OS === 'ios' ? 'position' : 'height'}
keyboardVerticalOffset={Platform.OS === 'ios' ? -70 : 70}
enabled>
<ScrollView>
...
</ScrollView>
</KeyboardAvoidingView>
<KeyboardAvoidingView
style={styles.mainContainer}
behavior="padding"
enabled
>
<View>.......................</View>
</KeyboardAvoidingView>
'Enabled or disabled KeyboardAvoidingView' should be add.
Keep in mind is always your top Parent with flex:1 then the child is then you text input container
<KeyboardAvoidingView style={{ flex: 1 }}
behavior={Platform.OS === "ios" ? "position" : null} enabled>
<ScrollView>
<View>
<View >
<Text maxFontSizeMultiplier={1.5} >
Sign in to your account{" "}
</Text>
<View
behavior="padding"
enabled
>
<TextInput
placeholder="Email address"
placeholderTextColor={Colors.grey}
style={styles.textInput}
onChangeText={(e) => setEmail(e.trim())}
autoCapitalize="none"
returnKeyType={"done"}
/>
</View>
</View>
</ScrollView>
</KeyboardAvoidingView>
// 2nd Solutions use this package
npm i react-native-keyboard-aware-scroll-view --save
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
<KeyboardAwareScrollView>
<View>
<TextInput />
</View>
</KeyboardAwareScrollView>
I'm Trying to input a value using TextInput but the keyboard is blocking the view. I configured KeyboardAvoidingView with padding so the elements are pushed up when the keyboard is active but my input field is still getting blocked entirely by the keyboard. I tried creating a parent view for the entire render method and wrapped my child views with KeyboardAvoidingView however this did not work either. Screenshots show the behavior.
Tested on iOS Emulator.
return (
<KeyboardAvoidingView behavior='padding'>
<View>
<View style={styles.container}>
<View style={styles.header}>
{jsonData}
<TouchableHighlight
underlayColor='transparent'
style={styles.btn}
onPress={this.goToAcibtnTwo}>
<Image source={images.prredbtn}></Image>
</TouchableHighlight>
<Text style={styles.textthingsmall}>{'Must be Paid Immediately'}</Text>
{jsonData2}
<TouchableHighlight
underlayColor='transparent'
style={styles.btn}
onPress={this.goToAcibtnTwo}>
<Image source={images.prgreenbtn}></Image>
</TouchableHighlight>
<Text style={styles.textthingsmall}>{'May include next payment or other fees'}</Text>
{jsonData3}
<TouchableHighlight
underlayColor='transparent'
style={styles.btn}
onPress={this.goToAcibtnTwo}>
<Image source={images.prgreenbtn}></Image>
</TouchableHighlight>
{jsonData4}
<View
style={{
flexDirection: 'row',
paddingBottom: 15
}}>
<TouchableHighlight
underlayColor='transparent'
style={styles.btn}
onPress={this.goToAcibtnTwo}>
<Image source={images.prgreenbtn}></Image>
</TouchableHighlight>
<TextInput
style={{
borderColor: 'white',
borderWidth: 2,
height: 40,
width: 100,
fontSize: 17,
marginLeft: 60,
justifyContent: 'center',
alignSelf: 'center',
color: 'white'
}}
keyboardType='numeric'
placeholder='0.00'
returnKeyType="done"
maxLength={10}
placeholderTextColor='ghostwhite'
onChangeText={(valueMoney) => this.setState({valueMoney})}
value={this.state.valueMoney}
onEndEditing={this.formatedMoneyEnd}/>
</View>
</View>
<View>
<Image style={styles.btmicons} source={images.optionsroundbtn}/>
</View>
</View>
</View>
</KeyboardAvoidingView>
);
}
}
export default Profile;
Here's the CSS
header: {
alignSelf: 'center',
height: window.height * 0.7,
backgroundColor: '#0450A1',
width: 400
},
bottom: {
alignSelf: 'center',
width: 400
},
btmicons: {
flexDirection: 'column'
},
headerthing: {
flex: 1,
alignItems: 'center',
paddingTop: 10
},
textthing: {
alignSelf: 'flex-start',
paddingLeft: 35,
fontFamily: 'SFProText-Regular',
fontSize: 17,
color: '#FFFFFF',
flexDirection: 'row'
},
textthingsmall: {
alignSelf: 'flex-start',
paddingLeft: 35,
fontFamily: 'SFProText-Regular',
fontSize: 12,
paddingTop: 3,
color: '#FFFFFF',
flexDirection: 'row'
},
numberthing: {
alignSelf: 'flex-end',
paddingRight: 10,
fontFamily: 'SFProText-Regular',
fontSize: 35,
color: '#FFFFFF'
},
headerthing2: {
alignItems: 'center',
flex: 1,
padding: 1
},
separator: {
alignSelf: 'center'
},
btn: {
alignSelf: 'flex-start',
paddingLeft: 35,
marginBottom: 0,
paddingBottom: 0
},
headerthing3: {
alignItems: 'center',
flex: 1,
flexDirection: 'row'
},
rowLabelnum: {
fontFamily: 'PTSans-Regular',
fontSize: 24,
color: '#FFFFFF'
},
rowLabelnummain: {
fontFamily: 'PTSans-Regular',
fontSize: 36,
color: '#FFFFFF',
alignSelf: 'center'
},
rowLabelText: {
fontFamily: 'PTSans-Bold',
fontSize: 24,
color: '#FFFFFF'
},
rowLabelTextmain: {
fontFamily: 'PTSans-Bold',
fontSize: 30,
color: '#FFFFFF'
},
rowLabelnumbtn: {
fontFamily: 'PTSans-Regular',
fontSize: 20,
color: '#252525'
},
rowLabelTextbtn: {
fontFamily: 'PTSans-Bold',
fontSize: 25,
color: '#252525'
},
separate: {
alignSelf: 'center',
justifyContent: 'center',
width: 2,
height: 100,
backgroundColor: '#FFFFFF',
marginBottom: 20
},
content: {
flexDirection: 'row',
alignSelf: 'center',
justifyContent: 'center',
width: 357,
height: 2,
backgroundColor: '#FFFFFF',
marginBottom: 30
},
rectangleTop: {
marginTop: 80,
padding: 2
},
rectangleText: {
flex: 1,
flexDirection: 'row'
},
rectangleleft: {
flexDirection: 'row',
alignSelf: 'center',
justifyContent: 'center'
},
keyboardview: {
justifyContent: 'center',
paddingHorizontal: 20,
paddingTop: 20
}
I gave you a suggestion in the comment, but here, I am going to give you a demo that shows how to use KeyboardAvoidingView.
<KeyboardAvoidingView behavior="padding" style={styles.bottomcontainer}>
<View style={styles.mobilecontainer}>
<Text style={styles.getmovingtext}>Get ready with BitFamily</Text>
<View style={styles.mobilenumbercontainer}>
<PhoneInput
ref='phone'
onChangePhoneNumber={(text)=> this.setState({phoneNumber:text})}
onPressFlag={this.onPressFlag}
textProps={{placeholder: 'Enter mobile number',autoFocus:false,}}>
</PhoneInput>
<CountryPicker
ref='countryPicker'
onChange={(value)=> this.selectCountry(value)}
translation='eng'
cca2={this.state.cca2}
>
<View></View>
</CountryPicker>
<View style={styles.horizontalLine}/>
<View style={styles.buttoncontainer}>
<Text style={styles.verifytext} onPress={()=>this.callApi()}>Get confirmation code Now.</Text>
</View>
<View style={styles.socialcontainer}>
<Text style={styles.verifytext} onPress={()=>this.gotoSocoalLogin()}>Or Connect using your social account.</Text>
</View>
</View>
</View>
</KeyboardAvoidingView>
I'm using react-native latest release 0.4.4 and installed react-native-side-menu and react-native-carousel components.
For some reason when I run the app, it's not showing anything.
The code instantiate a view with sidemenu and contentview inside.
contentview is for displaying the main page which contains three buttons and when someone clicks on explore it takes them to search page using navigatorios component.
Is there is some problem with StyleSheet ?
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
Component,
NavigatorIOS,
View,
TouchableHighlight,
TextInput,
} = React;
var SideMenu = require('react-native-side-menu');
var Menu = React.createClass({
about: function() {
this.props.menuActions.close();
},
render: function() {
return (
<View>
<Text>Menu</Text>
<Text onPress={this.about}>About</Text>
</View>
);
}
});
var styles = StyleSheet.create({
searchView: {
flexDirection: 'row',
padding: 25,
marginTop: 100,
},
text: {
color: 'black',
backgroundColor: 'white',
fontSize: 30,
margin: 80
},
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: '#F5FCFF',
},
flowRight: {
flexDirection: 'column',
padding: 25,
alignItems: 'center',
alignSelf: 'stretch',
marginTop: 100,
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
button: {
height: 36,
flex: 1,
flexDirection: 'row',
backgroundColor: '#009D6E',
borderColor: '#008C5D',
borderWidth: 1,
borderRadius: 8,
marginBottom: 10,
alignSelf: 'stretch',
justifyContent: 'center'
},
buttonText: {
fontSize: 18,
color: 'white',
alignSelf: 'center'
},
});
class Search extends Component {
render() {
return (
<View style={styles.searchView}>
<TextInput
style={{ flex: 2, height: 40, borderColor: 'gray', borderWidth: 1, padding: 5, borderRadius: 5}}
onChangeText={(text) => this.setState({input: text})}
placeholder="Search Appointment" />
<TextInput
style={{ flex: 1, height: 40, borderColor: 'gray', borderWidth: 1, padding: 5, borderRadius: 5}}
onChangeText={(text) => this.setState({input: text})}
placeholder="Location" />
</View>
);
}
}
class Welcome extends React.Component {
onExplorePressed() {
this.props.navigator.push({
title: 'Explore',
component: Search,
});
}
render() {
return (
<View style={styles.flowRight}>
<Text style={styles.welcome}>
Welcome to Docit!
</Text>
<TouchableHighlight style={styles.button} underlayColor='#009D3E'>
<Text style={styles.buttonText}>Sign In with Facebook</Text>
</TouchableHighlight>
<TouchableHighlight style={styles.button} underlayColor='#009D3E'>
<Text style={styles.buttonText}>Sign In with Email</Text>
</TouchableHighlight>
<Text style={styles.welcome}>OR</Text>
<TouchableHighlight
onPress={this.onExplorePressed.bind(this)}
style={styles.button}
underlayColor='#009D3E'>
<Text style={styles.buttonText}>Explore Something</Text>
</TouchableHighlight>
</View>
);
}
}
class ContentView extends Component {
render() {
return (
<NavigatorIOS
style={styles.container}
initialRoute={{
component: Welcome,
title: 'Welcome',
}}/>
)
}
}
var Docit = React.createClass({
render: function() {
var menu = <Menu navigator={navigator}/>;
return (
<SideMenu menu={menu}>
<ContentView/>
</SideMenu>
);
}
});
AppRegistry.registerComponent('Something', () => Something);
Am I doing something wrong here ??
I figured out that react-native-carousel component was conflicting with sidebar menu component and showing a blank screen. I posted the issue on their repository.
The simple solution is remove react-native-carousel component from everywhere, even from node_modules/, the folder inside.
Your react versions could be out of sync. I've had this happen to me when the react version bundled with the iOS app is different than the version that the packager is running.
If you're using cocoapods, make sure that the react version in your podfile is the same as your package.json.