Expo crash once put <Text> inside <View> without error - react-native

This is the most weird thing in Expo i never face before. I try to design new UI. but this is the first time i face this kind of issue. If i put any hi at the position i mark "HERE", once i open that screen the app will crash without error. then i remove the hi, open back Expo, its ok
Feel free to test my code. I wonder why is this happen. If i put other than such as it works.
Ive tried few times, it is confirm the error cause by only.
Ive tested on several IOS simulator, already restart the simulator even on my iphone SE 2020, it will result the same. Crashed without error
Please help me
<View
style={{
flex: 1,
}}
>
<View
style={{
flexDirection: "row",
backgroundColor: "#3341B0",
height: screenHeight / 7,
justifyContent: "space-evenly",
}}
>
<View
style={{
flexDirection: "row",
backgroundColor: "transparent",
alignItems: "flex-end",
marginBottom: 20,
width: screenWidth / 2,
}}
>
<View
style={{
width: 20,
alignItems: "flex-start",
justifyContent: "flex-start",
}}
></View>
<View
style={{
width: screenWidth,
alignItems: "stretch",
flexDirection: "column",
}}
>
<Text
style={{
fontSize: 20,
fontWeight: "700",
fontStyle: "normal",
color: "white",
}}
>
{username !== "" && <Text>{`Hello ${username}`}</Text>}
</Text>
<Text
style={{
fontSize: 10,
fontWeight: "700",
fontStyle: "normal",
color: "white",
}}
>
Company : Testing
</Text>
</View>
</View>
<View
style={{
flexDirection: "row",
backgroundColor: "transparent",
alignItems: "flex-end",
marginBottom: 20,
width: screenWidth / 2,
}}
>
<Text
style={{
fontSize: 10,
fontWeight: "700",
fontStyle: "normal",
color: "white",
}}
>
Department : Sales and Marketing
</Text>
</View>
</View>
<View
style={{
flexDirection: "row",
backgroundColor: "#3341B0",
alignItems: "flex-start",
width: screenWidth,
height: 250,
}}
>
<View
style={{
flexDirection: "column",
backgroundColor: "white",
alignItems: "flex-start",
width: screenWidth,
height: 250,
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
}}
>
<View
style={{
flexDirection: "row",
backgroundColor: "transparent",
alignItems: "baseline",
marginBottom: 10,
marginTop: 10,
marginLeft: 20,
}}
>
<Text
style={{
fontSize: 15,
fontWeight: "700",
fontStyle: "normal",
color: "black",
}}
>
Work Orders
</Text>
</View>
<View
style={{
flexDirection: "row",
backgroundColor: "transparent",
alignItems: "baseline",
marginBottom: 10,
marginLeft: 10,
marginRight: 10,
marginTop: 10,
}}
>
<View
style={{
width: screenWidth / 3 - 20,
height: 80,
backgroundColor: "#041FFB",
marginLeft: 10,
borderRadius: 5,
alignItems: "center",
justifyContent: "center",
}}
>HERE</View>
<View
style={{
width: screenWidth / 3 - 20,
height: 80,
backgroundColor: "#FBD15F",
marginLeft: 10,
borderRadius: 5,
}}
>HERE</View>
<View
style={{
width: screenWidth / 3 - 20,
height: 80,
backgroundColor: "pink",
marginLeft: 10,
borderRadius: 5,
}}
>
HERE
</View>
</View>
</View>
</View>
</View>

Related

React native background image not showing

I am showing simple image background on my app but don't know why its not showing
my code
return (
<View style={styles.container} >
<StatusBar translucent={true} backgroundColor="transparent" />
<View>
<ImageBackground
style={{ height: '100%', width: '100%', resizeMode: 'cover', opacity: 1, }}
source={require('../../../public/images/hhh.png')}
>
<View style={{
justifyContent: 'center', alignItems: 'center', marginTop: 'auto',
}}>
<Image
source={require('../../../public/icons/success.png')}
// style={styles.iconStyle}
/>
<Text style={styles.orderPlaceText}>
Order Placed
</Text>
<Text style={{
fontSize: 16,
fontWeight: "bold",
color: "white"
}}>
Order# {route.params.orderNumber}
</Text>
<Text style={styles.heading}>
{route.params.brandName}, {route.params.branchLocation.Address}
</Text>
<Text style={styles.description}>
{route.params.description}
</Text>
<Text style={styles.thanks}>
Thank you !
</Text>
</View>
<View style={{
justifyContent: 'center', alignItems: 'center',
marginTop: 'auto', marginBottom: 40
}}>
<TouchableOpacity
style={{
backgroundColor: '#ff8955',
borderRadius: 8,
alignItems: 'center',
justifyContent: 'center',
width: 300,
height: 50,
}}
onPress={() => {
navigation.dispatch(
StackActions.popToTop()
);
navigation.navigate('Orders');
}}
>
<Text style={{ color: 'white', fontSize: 14, fontWeight: 'bold', lineHeight: 23.5 }}>
TRACK MY ORDER
</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => navigation.navigate('Home')}
style={{
width: 300,
height: 50,
borderWidth: 1.5,
borderColor: 'white',
borderRadius: 8,
marginTop: 16,
alignItems: 'center',
justifyContent: 'center'
}}
>
<Text style={{ fontSize: 15, color: 'white' }}>Back to Home</Text>
</TouchableOpacity>
</View>
</ImageBackground>
</View>
</View>
)
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor:'grey'
},
orderPlaceText: {
fontSize: 28,
color: 'white',
fontWeight: 'bold',
marginTop: 16
},
heading: {
fontSize: 16,
color: 'white',
fontWeight: 'bold',
marginTop: 16
},
description: {
fontSize: 16,
color: 'white',
marginTop: 16,
textAlign: 'center'
},
thanks: {
fontSize: 26,
lineHeight: 31,
color: 'rgb(255, 255, 255)',
fontWeight: 'bold',
marginTop: 16
},
buttonText: {
color: 'white',
fontSize: 18,
fontWeight: 'bold',
lineHeight: 23
}
})
I am facing an unexpected issue if I change the image to another its working fine means only one image and if any other image it's not showing -_-
I try to rename my image and then try to use it also but that image is not showing is there any issue related to image size or something ? because it's not possible only few image is working and others are not.
Here in your image code
<Image source={require('../../../public/icons/success.png')}
// style={styles.iconStyle}
/>
You haven't added width/height, that must be the reason why your image isn't shown
Please do it this way
<Image style={{width:20, height:20}}
source={require('../../../public/icons/success.png')} />

Reactnative make Dialog background transparent

I am using Dialog to show a popup issue is i am not able to change its background color to transparent.
return (
<View style={styles.container}>
{
loading
? <ActivityIndicator color="#10cea8" size="large" />
: brands == null || brands.length < 1
?
<Text style={{ fontSize: 20, fontWeight: 'bold', color: 'grey' }}>
No restaurants found :(
</Text>
:
<ScrollView contentContainerStyle={{ paddingBottom: 24 }} style={{ paddingBottom: 24 }} keyboardShouldPersistTaps="handled">
<Dialog contentStyle={{ margin: 0, padding: 0, marginTop: 0, paddingTop: 0, backgroundColor: 'rgba(52, 52, 52, 0.9)' }}
visible={dialogVisible}
animationType={'slide'}
>
<View style={styles.pop}>
<Image
source={require('../../../public/images/logo.png')}
resizeMode={'contain'}
style={{
width: 200,
height: 130
}}
/>
<View style={{ height: 10 }}></View>
<Text style={{ textAlign: 'center', color: "white", fontSize: 21, }}>Happy to serve you !</Text>
<Text style={{ textAlign: 'center', color: "white", fontSize: 18 }}>Choose your nearest Branch.</Text>
<View style={{ height: 30 }}></View>
<TouchableOpacity onPress={() => setDialogVisible(false)} style={{ backgroundColor: 'white', width: '100%', height: 45, justifyContent: 'center' }}><Text style={{ textAlign: 'center', color: "#10cea8", fontSize: 18 }}>GOT IT</Text></TouchableOpacity>
</View>
</Dialog>
{
brands.length > 0 && brands.map((b, i) => {
return (
<TouchableOpacity key={`brand-${i}`}
onPress={() => {
navigation.navigate('Menus', {
Locations: b.Locations,
brandID: b.BrandID,
brandName: b.Name
})
}}>
<View style={styles.cardStyle} >
<ImageBackground
style={styles.backgroundImgStyle}
imageStyle={{ borderRadius: 15 }}
source={{ uri: b.CompanyURl }}
>
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Image
style={styles.logoStyle}
source={{ uri: b.Image }}
/>
<Text style={styles.title} >
{b.Name}
</Text>
<Text style={styles.description} >
{b.Address}
</Text>
</View>
</ImageBackground>
</View>
</TouchableOpacity>
)
})
}
</ScrollView>
}
</View>
)
}
export default Home;
const styles = StyleSheet.create({
pop: {
borderTopLeftRadius: 30,
borderTopRightRadius: 30,
borderBottomRightRadius: 30,
borderBottomLeftRadius: 30,
overflow: 'hidden',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#10cea8'
},
container: {
flex: 1,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
},
cardStyle: {
borderColor: '#B0A8A6',
width: Dimensions.get('window').width - 30,
height: 185,
borderRadius: 15,
justifyContent: 'center',
alignItems: 'center',
marginTop: 24
},
backgroundImgStyle: {
width: '100%',
height: '100%',
resizeMode: 'cover'
},
logoStyle: {
justifyContent: 'center',
alignItems: 'center',
width: 65,
height: 65
},
title: {
color: 'white',
fontSize: 20,
marginTop: 10,
lineHeight: 28,
fontWeight: 'bold'
},
description: {
color: 'white',
fontSize: 13,
lineHeight: 20,
fontWeight: '400'
}
});
As you can see i have set backgroundColor to rgba(52, 52, 52, 0.9) but its not going to transparent. if i change it to red or blue something it working but transparent not working on this.
[![enter image description here]
you can see the popup behind borderRadius its showing dark grey color. I need to make it full transparent.

how to add a reset state when user deletes text from otp text inputs using React native otp input?

I have created an OTP screen using react-native-otp-input as follows:
when I enter the code the continue button turns pink as code state is set to the value like follows
but when I try emptying the code inputs the continue button is still pink as the code state is not refreshed
My code for the otp input view and continue button is as follows:
<View style={{alignItems: 'center'}}>
<OTPInputView
style={{width: '90%', height: 40}}
pinCount={5}
codeInputFieldStyle={{
width: 30,
height: 45,
borderWidth: 0,
borderBottomWidth: 1,
borderBottomColor: '#808080',
}}
codeInputHighlightStyle={{
borderBottomColor: '#000',
color: '#000',
borderBottomWidth: 1,
borderWidth: 0,
}}
codeInputFieldStyle={{
color: '#000',
borderBottomColor: '#000',
borderBottomWidth: 1,
borderWidth: 0,
}}
onCodeFilled={(code) => {
setCode(code);
}}
/>
</View>
</KeyboardAvoidingView>
<View style={{alignItems: 'center', justifyContent: 'center'}}>
{code == '' ? (
<TouchableOpacity
style={{
backgroundColor: '#C0C0C0',
width: 250,
height: 50,
alignItems: 'center',
justifyContent: 'center',
borderRadius: 20,
marginTop: '10%',
}}
disabled={true}>
<Text style={{color: 'white', fontSize: 18}}>Continue</Text>
</TouchableOpacity>
) : otpresponseLoading == true ? (
<ActivityIndicator
size="large"
color="#FE017E"
style={{marginTop: '10%'}}
/>
) : (
<TouchableOpacity
style={{
backgroundColor: '#FF1493',
width: 250,
height: 50,
alignItems: 'center',
justifyContent: 'center',
borderRadius: 20,
marginTop: '10%',
}}
onPress={() => onContinueHandlePress()}>
<Text style={{color: 'white', fontSize: 18}}>Continue</Text>
</TouchableOpacity>
)}
</View>
Could anyone please let me know how do I handle the backpress in this dependency? and refresh the state of code when user deletes code?
Any lead would be great, do let me know if anything else is required for better understanding
thank you in advance.
let's try :
<KeyboardAvoidingView>
<View style={{ alignItems: 'center' }}>
<OTPInputView
style={{ width: '90%', height: 40 }}
pinCount={5}
codeInputFieldStyle={{
width: 30,
height: 45,
borderWidth: 0,
borderBottomWidth: 1,
borderBottomColor: '#808080',
}}
codeInputHighlightStyle={{
borderBottomColor: '#000',
color: '#000',
borderBottomWidth: 1,
borderWidth: 0,
}}
codeInputFieldStyle={{
color: '#000',
borderBottomColor: '#000',
borderBottomWidth: 1,
borderWidth: 0,
}}
onCodeChanged={(code) => {
setCode(code);
}}
/>
</View>
</KeyboardAvoidingView>
<View style={{ alignItems: 'center', justifyContent: 'center' }}>
{code.length !== 5 ? (
<TouchableOpacity
style={{
backgroundColor: '#C0C0C0',
width: 250,
height: 50,
alignItems: 'center',
justifyContent: 'center',
borderRadius: 20,
marginTop: '10%',
}}
disabled={true}>
<Text style={{ color: 'white', fontSize: 18 }}>Continue</Text>
</TouchableOpacity>
) : otpresponseLoading == true ? (
<ActivityIndicator
size="large"
color="#FE017E"
style={{ marginTop: '10%' }}
/>
) : (
<TouchableOpacity
style={{
backgroundColor: '#FF1493',
width: 250,
height: 50,
alignItems: 'center',
justifyContent: 'center',
borderRadius: 20,
marginTop: '10%',
}}
onPress={() => onContinueHandlePress()}>
<Text style={{ color: 'white', fontSize: 18 }}>Continue</Text>
</TouchableOpacity>
)}
</View>

design functionality React native

I want user profile pic in half on modal and half on outside of modal
i have tried this
height: PROFILE_DIAMETER,
width: PROFILE_DIAMETER,
borderRadius: PROFILE_DIAMETER / 2,
marginLeft: 20,
top: -20,
flex: 0,
resizeMode: 'cover',
overflow: 'hidden',
transform: [{translateY: translateImageY()}, {scale: imgScale()}, {translateX: translateImageX()}]
}}
want to achieve this design functionality to react-native
<Image style={{width: '100%', zIndex: -1}} source={require('../assets/capa.png')} />
<View style={{
width: '90%',
backgroundColor: 'white',
alignSelf: 'center',
borderRadius: 10,
paddingBottom: 20
}}>
<View style={{
marginTop: -100
}}>
<Avatar
rounded
size='xlarge'
containerStyle={{ alignSelf: "center", marginTop: 20 }}
overlayContainerStyle={{
borderWidth: 1,
borderColor: '#00a9cf',
backgroundColor: 'white'
}}
source={{
uri:
'https://s3.amazonaws.com/uifaces/faces/twitter/adhamdannaway/128.jpg',
}}
/>
<Text style={{ color: '#383941', fontSize: 22, alignSelf: "center", fontFamily: 'PTSans-Bold' }}>{this.state.name}</Text>
<Text style={{ color: '#79787b', fontSize: 15, alignSelf: "center", fontFamily: 'PTSans-Italic' }}>{this.state.profession}</Text>
</View>
</View>
Observe the image with zindex -1 and the view containing the avatar with the negative marginTop

how do I make tabs on React-Native in the middle position of the screen

how do I make tabs on React-Native in the middle position of the screen. if I use tabs it means I can only put it on the screen up or down while I want to be in the middle of the screen. I tried using Navigation but it didn't appear. can anyone help me? thank you
import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, Image, ScrollView,
ImageBackground, Button } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
import { createStackNavigator, createAppContainer } from 'react-navigation';
import IndividuScreen from './src/individu';
import UnitScreen from './src/unit';
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
export default class App extends Component {
render() {
const Appss = createAppContainer(Apps);
return (
<ScrollView>
<View>
<View style={{ width: '100%', height: 60, backgroundColor: '#ed1c24', flexDirection: 'row' }}>
<Icon name="chevron-left" size={15} color={'white'} style={{ marginTop: 25, marginLeft: '3%' }} />
<Image
style={styles.logo}
source={require('./assets/img/icon.png')}
/>
<Icon name="check-square" size={20} color={'white'} style={{ marginTop: 20, marginLeft: '30%' }} />
<Icon name="bell" size={20} color={'white'} style={{ marginTop: 20, marginLeft: '4%' }} />
<Icon name="ellipsis-v" size={20} color={'white'} style={{ marginTop: 20, marginLeft: '4%' }} />
</View>
<ImageBackground
source={require('./assets/img/gedung.png')}
style={{ width: '100%', height: 300, marginBottom: 0, marginTop: 0 }}>
<View style={{ marginTop: 230 }}>
<ScrollView horizontal={true}>
<Text style={{ fontSize: 20, color: 'white', marginTop: 40, marginRight: 10, marginLeft: 10, height: 30, opacity: 0.8 }}>Beranda</Text>
<Text style={{ fontSize: 20, color: 'white', marginTop: 40, marginRight: 10, marginLeft: 10, height: 30, opacity: 0.8 }}>Training Saya</Text>
<Text style={{ fontSize: 20, color: 'white', marginTop: 40, marginRight: 10, marginLeft: 10, height: 30, opacity: 0.8 }}>Katalog</Text>
<Text style={{ fontSize: 20, color: 'white', marginTop: 40, marginRight: 10, marginLeft: 10, height: 30, opacity: 0.8 }}>Jadwal</Text>
<Text style={{ fontSize: 20, color: 'white', marginTop: 40, marginRight: 10, marginLeft: 10, height: 30, opacity: 0.8 }}>XXXXXX</Text>
<Text style={{ fontSize: 20, color: 'white', marginTop: 40, marginRight: 10, marginLeft: 10, height: 30, opacity: 0.8 }}>XXXXXX</Text>
</ScrollView>
</View>
</ImageBackground>
<Appss />
{/* Appss Not Show*/}
<View style={{ textAlign: 'left', padding: 15, flexDirection: 'row', marginTop: 20 }}>
<Image source={require('./assets/img/medal.png')} style={{ width: 30, height: 35, marginRight: "5%", }} />
<View style={{ flexDirection: 'column' }}>
<Text style={{ fontSize: 20, paddingBottom: 10, fontWeight: 'bold' }}>Point CPD Anda: <Text style={{ color: 'red', fontSize: 30, }}>2</Text></Text>
<Text style={{ fontSize: 14, color: 'red' }}>LIHAT RINCIAN POINT CPD > </Text>
</View>
</View>
<View style={{ borderBottomColor: 'black', borderBottomWidth: 1, }} />
<View style={{ textAlign: 'left', padding: 15, flexDirection: 'row' }}>
<Image source={require('./assets/img/book.png')} style={{ width: 30, height: 30, marginRight: "5%", }} />
<Text style={{ fontSize: 20, fontWeight: 'bold' }}>Training Saya</Text>
</View>
<View style={{ textAlign: 'left', padding: 15, flexDirection: 'row' }}>
<View style={{ marginLeft: "5%", marginRight: "15%", textAlignVertical: 'center' }}>
<Text style={{ height: 60, width: 60, borderWidth: 1.5, borderRadius: 50, fontSize: 30, textAlignVertical: 'center', textAlign: 'center', color: 'maroon', fontWeight: 'bold' }}>07</Text>
</View>
<View style={{ flexDirection: 'column' }}>
<Text style={{ fontSize: 14 }}>KALENDER</Text>
<Text style={{ fontSize: 25, color: 'maroon', fontWeight: 'bold' }}>Selasa</Text>
<Text style={{ fontSize: 14 }}>SEPTEMBER 2018</Text>
</View>
</View>
<View style={{ borderBottomColor: 'black', borderBottomWidth: 1, }} />
<View style={{ textAlign: 'left', paddingLeft: 15, paddingTop: 10, flexDirection: 'row' }}>
<Text style={{ fontSize: 16, fontWeight: 'bold' }}>PRUprime healthcare</Text>
</View>
<View style={{ textAlign: 'left', padding: 15, flexDirection: 'row' }}>
<View style={{ flexDirection: 'column' }}>
<Text style={{ fontSize: 14 }}>09:00 - 12:00</Text>
<Text style={{ fontSize: 14 }}>Prudential Learning Academy, Lt. 1</Text>
<Text style={{ fontSize: 14 }}>Jakarta</Text>
</View>
<Icon name="angle-right" size={30} style={{ textAlignVertical: "center", marginLeft: '40%' }} />
</View>
<View style={{ borderBottomColor: 'black', borderBottomWidth: 1, }} />
<View style={{ textAlign: 'left', paddingLeft: 15, paddingTop: 10, flexDirection: 'row' }}>
<Text style={{ fontSize: 16, fontWeight: 'bold' }}>PRUfast Start</Text>
</View>
<View style={{ textAlign: 'left', padding: 15, flexDirection: 'row' }}>
<View style={{ flexDirection: 'column' }}>
<Text style={{ fontSize: 14 }}>14:00 - 17:30</Text>
<Text style={{ fontSize: 14 }}>Prudential Learning Academy, Lt. 1</Text>
<Text style={{ fontSize: 14 }}>Jakarta</Text>
</View>
<Icon name="angle-right" size={30} style={{ textAlignVertical: "center", marginLeft: '40%' }} />
</View>
<View style={{ borderBottomColor: 'black', borderBottomWidth: 1, }} />
<View style={{ textAlign: 'left', padding: 15, flexDirection: 'row' }}>
<Image source={require('./assets/img/book.png')} style={{ width: 30, height: 30, marginRight: "5%", }} />
<Text style={{ fontSize: 20, fontWeight: 'bold' }}>Status Belajar</Text>
</View>
<View style={{ textAlign: 'left', paddingLeft: 15 }}>
<Text>TECHNICAL SKILLS</Text>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<Text style={{ fontWeight: 'bold' }}>Syariah Basic Training</Text>
<Text style={{ marginLeft: 15, backgroundColor: 'orange', paddingLeft: 4, paddingRight: 4, color: 'white', fontStyle: 'italic' }}>e-learning</Text>
</View>
</View>
<View style={{ marginTop: 20, flexDirection: 'row' }}>
<Image source={require('./assets/img/progress4.png')} style={{ width: '100%', height: 60, }} />
<Icon name="angle-right" size={30} style={{ textAlignVertical: "center", marginLeft: 10 }} />
</View>
</View >
</ScrollView>
);
}
}
const Apps = createStackNavigator({
Individu: {
screen: IndividuScreen,
navigationOptions: {
header: null
}
}, Unit: {
screen: UnitScreen,
navigationOptions: {
header: null
}
}
});
const styles = StyleSheet.create({
logo: {
width: '35%',
height: 40,
marginTop: 10,
marginLeft: '3%',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
for IndividuScreen and UnitScreen which will be displayed on the App but not displayed. if I only return Apps for Individuals and Units to appear. but if I enter it into TAG IndividuScreen and UnitScreen does not appear. maybe you have a way to show two screens in one component. thank you