How to have fixed header after keyboard is shown on iOS? - ios

The fixed header is scrolling after keyboard is open on iOS device. Is there any possibility to have fixed header after keyboard is open? I do not want to have header scrolling with the content.
Here is explained similar problem:
https://medium.com/#im_rahul/safari-and-position-fixed-978122be5f29
I am facing the problem in the React project using Cordova.
Thank you very much for your help.

use keyboardAvoidingView from 'react-native'
docs
import {
KeyboardAvoidingView
} from 'react-native';
<KeyboardAvoidingView behavior="padding" style={styles.container}>
<View style={styles.inputContainer}>
<TextInput
returnKeyType="next"
placeholder="Mobile No."
placeholderTextColor="powderblue"
keyboardType="number-pad"
onSubmitEditing={() => this.passwordInput.focus()}
style={styles.input}
onChangeText={(value) => this.setState({mobileno:value})}
value={this.state.mobileno}
/>
<TextInput
returnKeyType="go"
placeholder="Password"
placeholderTextColor="powderblue"
style={styles.input}
secureTextEntry
ref={input => (this.passwordInput = input)}
onChangeText={(value) => this.setState({pssd:value})}
value={this.state.pssd}
/>
</View>
</KeyboardAvoidingView>

If you are hiding status bar the KeyboardAvoiding will push everything including the header to top, it’s a bug of KeyboardAvoidingView in react native.
To make your header fixed while keyboard is shown, make your statusbar hidden=false

Related

Text box cover when keyboard open ios system in react native project

Text box cover when keyboard open ios system in react native,but working fine in android part.
You can either use:
KeyboardAvoidingView : https://facebook.github.io/react-native/docs/keyboardavoidingview
<KeyboardAvoidingView
style={{flex: 1}}
behavior={'padding'}
keyboardVerticalOffset={65}>
<FlatList .../>
<TextInput ... />
</KeyboardAvoidingView>
or for Android:
Adjust keyboard using android:windowSoftInputMode="adjustPan" settings in your AndroidManifest.xml :
<application
...
>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
...
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustPan"
...
android:authorities="${applicationId}">
</activity>
</application>
refer: How do not move view when keyboard shows in React Native?

TouchableOpacity only responds with a light touch

I am currently trying to create an app using React native and I have multiple touchable opacity image buttons on different pages. However, whenever I click on any of the touchable opacity image buttons, it will ONLY work with a light tap/touch rather than a normal press on apps. I tried doing hit slop and it still doesn't avoid the issue of a light tap. Can someone please guide me on how to make this work as I have been stuck on this for days.
<TouchableOpacity
onPress={() =>
this.props.navigation.navigate("Track", {
currentDate: this.state.currentDate,
})
}
>
<Image
style={HomeStyles.ovalContainer}
source={require("../../assets/oval.png")}
/>
</TouchableOpacity>
Thank you
You can set the touch opacity
setOpacityTo((value: number), (duration: number));
or you can also try Pressable component for e.g.
<Pressable onPress={onPressFunction}>
<Text>I'm pressable!</Text>
</Pressable>
You can use also TouchableWihoutFeedback
<TouchableWithoutFeedback onPress={() => alert('Pressed!')}>
<MyComponent />
</TouchableWithoutFeedback>;

React Native with ScrollView feels sluggish

Any idea why ScrollView + multiline TextInput + KeyboardAvoidingView feels really sluggish? I'm using react-navigation with the react-native-screen for the native modal look. The screenshot gif below is taken on emulator but it behave similarly even on the real device (notice that there is a flash of blue background just before keyboard showed up)
My code looks something like (I set the KeyboardAvoidingView background to pink so it's easy to spot and ScrollView background is set to blue
<KeyboardAvoidingView behavior={'padding'} style={{flex: 1, backgroundColor: 'pink'}} keyboardVerticalOffset={48}>
<View style={{flex: 1}}>
<View style={styles.header}>
<Text>{date}</Text>
<Button title="Delete"/>
<Button title="Save"/>
</View>
<ScrollView keyboardDismissMode={'interactive'} style={{flex:1, backgroundColor: 'blue'}}>
<TextInput onChangeText={(text) => setNote(text)}
placeholder='Note'
value={note}
multiline={true}
scrollEnabled={false}
style={{flex: 1, backgroundColor: '#fff'}}
/>
</ScrollView>
</View>
</KeyboardAvoidingView>
I'm also using react-native-elements, react-navigation+react-native-screens for the native modal look
PS - I tried not using ScrollView and simply using TextInput with scrollable={true} which seems to be working but the problem with that is I can't dismiss the keyboard once the keyboard is shown

iOS TextInput styles in React Native

Elements such as <Button/> and <TextInput/> get rendered with default styles on Android but on iOS they are pretty much unstyled. Is there a way to get platform styles (e.g. borders and padding) applied on iOS without reproducing them in CSS?
For example
<View style={{flex:1, justifyContent: 'center'}}>
<Text>Please sign in</Text>
<TextInput placeholder="Username"/>
<TextInput placeholder="Password"/>
<Button onPress={() => {}} title="Sign in"/>
</View>
https://github.com/tombenner/nui
to apply them you can use platform.select

React Native sticky footer with TextInput

The problems statement is similar to this question
But I am looking for some pointers to implement the same with react-native.
I am building a chat window (like iMessage, whatsapp) where messages(ListView) come on top with a sticky footer containing a TextInput.
I am able to get a sticky footer, but when someone tries to enter text with TextInput in footer, the keyboard hides the TextInput. I tried approaches mentioned in this post, but none seem to work because of presence of ListView above.
Here is what my current layout code looks like:
<View style={styles.container}>
<ListView
automaticallyAdjustContentInsets={false}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps={true}
showsVerticalScrollIndicator={false}
/>
<View style={styles.textContainer}>
<TextInput/>
</View>
</View>

Resources