How to fix "KeyboardAvoidingView" in IOS when use Native Base Content structure - react-native

I use the KeyboardAvoidingView, to display the input focused, but when the KeyBoard is showing, the scrollView paddingBottom changes and overlaps the Form.
<Container style={styles.container}>
<Content contentContainerStyle={{flex:1}} scrollEnabled={false} enableOnAndroid >{/* styles.content */}
<ScrollView style={{flex: 1}} automaticallyAdjustContentInsets={true} indicatorStyle="white" >
<KeyboardAvoidingView behavior="padding" enabled={Platform.OS === 'android' ? true : false} style={styles.keyboardAvoidingView} keyboardVerticalOffset={60} >
<Form style={{margin:20,marginRight:35}}>
<Input>
{/*... Some Inputs*/}
</Input>
</Form>
</KeyboardAvoidingView>
</ScrollView>
</Content>
</Container>
Image 1:
Image 2:
Image 3:

Related

react-native-gifted-chat Can't show keyboard when have other text input in same screen

If I have another text input on the same screen with react-native-gifted-chat component, the keyboard won't work correctly. It will appear in a sec then be dismissed immediately. Happens on both Android and IOS, physical devices and emulator.
I handled keyboard by myself, inside a KeyboardAvoidingView
Demo:
Here my code
<View style={styles.container}>
<View style={styles.container}>
{renderVideo()}
<KeyboardAvoidingView
behavior={Platform.OS === "ios" ? "padding" : undefined}
style={{ flex: 1, justifyContent: "flex-end" }}
>
<View style={{ height: 350 }}>
<GiftedChat
textInputProps={{ onFocus: onFocusHandler, onBlur: onBlurHandler }} //
isKeyboardInternallyHandled={false}
wrapInSafeArea={false}
keyboardShouldPersistTaps="handled"
onSend={onSendMessage}
alwaysShowSend
messages={messages}
infiniteScroll
scrollToBottom={false}
inverted
/>
</View>
</KeyboardAvoidingView>
</View>
<AlertModal ref={alertRef} /> // This modal contain another input
</View>
Need some help making Keyboard for second text input works fine

React Native View below Flatlist is flickering

I have a view below flatlist. I want the view to be always at bottom of screen and it is wrapped inside KeyboardAvoidingView. Check video for more details
https://drive.google.com/file/d/1eeMfpH3AV7AqLNqAhlhQX5JmOQSRLbtp/view?usp=sharing
As soon as I comment my FlatList code then the bottom view does not flicker.
Below is my code
<View>
<FlatList ..../>
<KeyboardAvoidingView
behavior={Platform.OS == "ios" ? "padding" : "height"}
>
<SafeAreaView style={styles.bottomViewStyle}>
<TouchableOpacity>
<Image source={CAMERA_CHAT_ICON} />
</TouchableOpacity>
<View style={styles.textAreaViewStyle}>
<TextInput
placeholder="Start Typing..."
placeholderTextColor="#9b9b9b"
style={styles.textInputStyle}
/>
</View>
<TouchableOpacity>
<Image source={CHAT_SEND_ICON} />
</TouchableOpacity>
</SafeAreaView>
</KeyboardAvoidingView>
</View>
All components including the FlatList component should be wrapped inside the KeyboardAvoidingView. Also, SafeAreaViews should be placed at the root of the screen because it provides padding for SafeAreas.
<KeyboardAvoidingView behavior={Platform.OS == "ios" ? "padding" : "height"}>
<SafeAreaView>
<FlatList ... />
<View>
<TextInput ... />
</View>
</SafeAreaView>
</KeyboardAvoidingView>
See https://reactnative.dev/docs/keyboardavoidingview and https://reactnative.dev/docs/safeareaview for more examples.

React Native Grid with Webview crashes

I am using Grid with a View of fixed height 150 and a Row with the rest of the height
In the view i am showing a text input and in the Row i am showing a Webview
When i touch the input the keyboard opens and if i press the back button the app crashes
If i remove the webview and do the same the app is not crashing
<Grid>
<View style={styles.screenView}>
<ImageBackground
source={size(course.image_url) > 0 ? { uri: course.image_url } : logo}
resizeMode="cover"
style={styles.imageBackground}
>
......
</ImageBackground>
</View>
<View style={styles.screenView}>
<View style={styles.container}>
<TextInput
style={styles.reviewInput}
onChangeText={addReview.bind(props)}
placeholder="Your reviews about the course"
value={review}
multiline={true}
/>
</View>
<LoadingButton
isLoading={isLoading}
isFormDirty={size(review) > 0 ? false : true}
loadingText="Saving"
text="Save Review"
block={true}
color={Color.primaryText}
loaderColor="#FFFFFF"
textColor={styles.lightText}
style={styles.reviewButton}
onPress={saveReview.bind(props)}
/>
</View>
<Row>
<View style={styles.scroller}>
<WebView originWhitelist={['*']} source={{ html: courseDescription }} />
</View>
</Row>
</Grid>
Styles for webview:
scroller: {
flex: 1,
overflow: 'hidden',
},
There is only one Row area in your code. It means the whole thing. You should mark the area separately.
<Grid>
<Row size={9}>
<View>
...
</Row>
<Row size={1}>
<View style={styles.scroller}>
<WebView originWhitelist={['*']} source={{ html: courseDescription }} />
</View>
</Row>
</Grid>

How can I achieve this modal design with react native

I am trying design like below image with react native.If anyone have worked like this modal design over the toolbar then please help me.
1
You will need a Modal with a embedded TouchableOpacity combined with some styling for positioning.
Please refer this
https://snack.expo.io/SJrDAC8Qr
render() {
return (
<>
<View>
<Appbar.Header>
<Appbar.Content title="Title" subtitle="Subtitle" />
<Appbar.Action icon="search" onPress={() => this.setState({displayModal: true})} />
</Appbar.Header>
<View>
<Text>Main content!</Text>
</View>
</View>
{/*Modal code*/}
<Modal transparent={true} visible={this.state.displayModal}>
{/*Container .. clicking this closes the modal*/}
<TouchableOpacity style={{flex:1}} onPress={() => this.setState({displayModal:false})}>
<View style={{backgroundColor:'blue', position:'absolute', right:0, width:200, height: 200}}>
<Text style={{color:'#ffffff'}}>Hello World!</Text>
</View>
</TouchableOpacity>
</Modal>
</>
);
}
Not very nicely styled but I guess it does what you want

how to overlap one view on another view in react native android

I want to put Search Input between two View border,but half input hides behind another View.
Click Here To Show Image.
There are two views. One View's backgroundColor is purple and another view's backgroundColor is white.And half Input type is hide behind another view.
<Container>
<Header style={{ backgroundColor: "#635DB7" }}>
<Left>
<Button
transparent
onPress={() => this.props.navigation.navigate("DrawerOpen")}
>
<Icon name="ios-menu" />
</Button>
</Left>
<Right />
</Header>
<View style={{flex:1,zIndex:2}}>
<View style={{height:192,backgroundColor: "#635DB7"}}>
<View style={{position:'absolute',opacity: 1,flex:1,flexDirection:"row",marginTop:160}}>
<Input style={{flexDirection:"row",borderRadius:20,marginLeft:30,marginRight:30,backgroundColor:"#434353", zIndex: 2,opacity: 1}} placeholder="Search" />
</View>
</View>
<View style={{height:448,backgroundColor: "#ffffff",zIndex:1}}>
</View>
</View>
</Container>
Try to put the search bar as a last item in the container, and with absolute position. If that does not work, then you might have hit a bug in RN android, which does not support overflow:
https://github.com/facebook/react-native/issues/6802
https://github.com/facebook/react-native/issues/3198