iOS Header overlaps layout for Iphone 11 - ios

I've got a react native app -> I've currently noticed that the text on my screen overlaps on iphone 10+ devices. How would I create a safearea for the new devices?
I've tried to add a tag to wrap my stack.navigator for the home screen but had no luck so far.
Is this something I would target on my react native or in xcode?
enter image description here

use
import { SafeAreaView } from 'react-native';
to handle safe area I have shown in below code how to handle safe area for iPhone 10 plus device
in below code I have divided the safe area in two-part one is for top safe area and another is the bottom safe area and you place your all component in bottom safe area
render() {
return (
<View style={{flex: 1} >
<SafeAreaView style={{flex: 0}} />
<SafeAreaView style={{flex: 1}}>
//here you can place your component
</SafeAreaView>
</View>
)
}

Related

React Native Bottomsheet how to avoid bottom notch area?

I have a simple page component in react native. The issue is when I try to open the bottom sheet, I cannot avoid the bottom notch area in IOS. Any ways I can get over it?
return (
<SafeAreaView
<KeboardAvoidingView />
<BottomSheet
isOpen={isOpen}
onClosed={onClosed}
childComponent={...}
options={[]}
showTopKnob
rounded
/>
</SafeAreaView>
);
Give some extra padding from bottom for the devices that have bottom notch.
you can specify this by using this library.
react-native-iphone-x-helper
Example
import {isIphoneX} from 'react-native-iphone-x-helper';
const BOTTO_PADDING = isIphoneX() ? 44 : 20;
I hope this will help you out.

Handling the status bar on iOS

Is there a goto way to handle the status bar on iOS? For my app, I just want everything to be below the status bar.. but it looks like the only way to do that is to go to every single component and add padding? I would guess theres a way to do it in xcode but I have no clue!
Thanks!
There is already a component in react-native for the StatusBar
You just need to add it as
<YourParentWrapper style={{flex: 1}}>
<View style={{ height, backgroundColor }}>
<StatusBar { ...props } />
</View>
// ... Your navigation or the child components
</YourParentWrapper>
where the height is
Platform.OS === 'ios' ? 20 : StatusBar.currentHeight
This will handle your components below the default status bar for all the devices

React Native: How to make a view stick on screen while the screen changes?

I'm building a podcasting app with react native and I would like to implement the mini player you see at bottom of screen in most podcasting/music apps. See image below. I want to make the mini player stick no matter which screen you navigate to. Any idea how to implement this in react native? I'm using react navigation as the main navigator right now https://reactnavigation.org/.
The best way to do this is use the magic of flexbox.
Think about your app as combination of two major screens.
1) The part with header, navigation menus and the playlist (inside etc.)
2) The player
Try this layout
<View style={styles.container}>
<View style={styles.firstBox}>
1)
</View>
<View style={styles.secondBox}>
2)
</View>
</View>
Now all you have to do is assign proper styles
const styles = {
container: {
flex: 1,
},
firstBox: {
flex: 8
},
secondBox: {
flex: 2
}
}
This is enough for the basic structure. You can design accordingly.

How can I achieve the "View slide-in" effect in react native?

I am currently working on my very first react-native application and am wondering how that slide in effect of a new view can be achieved and where that "hidden" view should be placed.
My Application is currently build like this:
<View style={{flex:1}}>
<View style={{flex:.8, justifyContent:'center'}}>
.. some login Form
</View>
<View style={{flex:.2, justifyContent:'center', alignItems:'center'}}>
<TouchableHighlight onPress={this._toggleRegistryView}>
<Text> or register here </Text>
</TouchableHighlight>
</View>
</View>
As you can see in this basic code I want to slide-in the Registration View as soon as the touchable component is pressed.
Do I need to store the view "invisible" with a width of 0 and height of 100% on one side and then animate it to the full device width?
Right now I have no idea besides a whole new view render when the state changes
render(){
return({this.state.view == 'login' ? <LoginView /> : <RegistryView />});
}
Unfortunately this triggers a "hard" view change and not a smooth right to left or left to right animation where the view slides in.
If my question was unclear please inform me - I'll gladly try to specify it :) Thank you for your help
You should split your application into multiple scenes (screens) and use the Navigator component to transition between the scenes.
Here is a tutorial from the TaskRabbit blog to get you started.
Once you have you scenes set up, you can experiment with different SceneConfigs for different types of transition animations.
A transition from a page to another is nothing else but navigation.
In order to navigate from a page to another in React Native, you will want a navigation library.
The default Navigator component from React Native might work, but it's got a lot of limitations and issues, and the default solution most people turn to (and which after 3yrs of RN I strongly recommend), is React Navigation. If you are using Expo, it also ships by default, so you can jump right into it, and define your screens like so:
import React from 'react';
import { View, Text } from 'react-native';
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
class HomeScreen extends React.Component {
render() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home Screen</Text>
</View>
);
}
}
const AppNavigator = createStackNavigator({
Login: {
screen: LoginView,
},
Register: {
screen: RegisterView,
},
});
export default createAppContainer(AppNavigator);
If not, here's a quick start guid to using it outside of Expo.

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