How do I group some parts of flex elements? - reactjs

I'm almost done with my React Native view, but I'm not sure how to group individual items in a page that contains many.
How do I moved Details directly under Header?
view
return (
<View style={s.container}>
<View style={[s.header, s.flexRow]}>
<Text style={s.carRegNr}> CV 515632 </Text>
<Text style={s.insuranceName}> Plus </Text>
</View>
<View style={s.flexColumn}>
<Text style={s.claimNrText}> Claim nr </Text>
<Text style={s.claimNr}> 020202 </Text>
</View>
<View style={s.flexColumn}>
<Text style={s.nextSteps}> Next steps </Text>
<Text style={s.nextStepsDetails}> Goto the repair shop </Text>
</View>
<View style={[s.flexRow, {justifyContent: "flex-end"}]}>
<CarRepairShop
name="Best Auto"
address1="Shiny road 1"
address2="0101 City"
/>
<CarRepairShop name="Rental" address1="Rental included"/>
</View>
<GjeButton
title="Close"
/>
{ /*
<GjeButton
title={"Set DamageClaimReceiptNr"}
onPress={ () => this.props.setDamageClaimReceiptNr("100") }
/>
<GjeButton
title={"Add car registration nr"}
onPress={ () => this.props.setCarRegNr("lkj2") }
/>
*/
}
</View>
)
}
}
styling
export default StyleSheet.create({
container: {
height: 10,
flex: 1,
padding: 30,
flexDirection: "column",
justifyContent: "flex-start"
},
header: {
justifyContent: "space-between",
borderColor: colors.grape,
borderRadius: 2,
},
carRegNr: {
fontWeight: "bold",
color: colors.black,
fontSize: 25,
},
groupTight: {
flexDirection: "column",
flex: 1,
justifyContent: "flex-start"
},
insuranceName: {
color: colors.black,
fontSize: 23
},
flexRow: {
flex: 1,
flexDirection: "row",
justifyContent: "space-between",
},
flexColumn: {
width: "100%",
flex: 1,
flexDirection: "column",
},
nextSteps: {
color: colors.black,
fontSize: 15,
},
nextStepsDetails: {
color: colors.black,
fontSize: 7,
},
bold: {
color: colors.black,
fontWeight: "bold",
},
cont: {
margin: 5,
padding: 3,
},
claimNrText: {
color: colors.black,
margin: 0,
padding: 0,
fontSize: 30,
},
claimNr: {
fontSize: 26,
}
})

You can just add a parent View Element that encloses the Header and the Details Element.
<View>
<View style={...headerStyles}>
</View>
<View style={...detailStyles}>
</View>
</View>
The parent view then can have justifyContent: 'flex-start'

#crispychicken, Thanks for the suggestion to wrap the items in a new View tag.
It didn't work with your CSS suggestion, though.
I got it working after updating my .container styling as seen here.
style
import { colors } from "./colors"
import { fonts } from "./fonts"
import { StyleSheet } from "react-native"
export default StyleSheet.create({
container: {
height: 10,
flex: 1,
padding: 30,
flexDirection: "column",
justifyContent: "space-around"
},
header: {
justifyContent: "space-between",
borderColor: colors.grape,
borderRadius: 2,
},
carRegNr: {
fontWeight: "bold",
color: colors.black,
fontSize: 25,
},
groupTight: {
flexDirection: "column",
justifyContent: "flex-start"
},
insuranceName: {
color: colors.black,
fontSize: 23
},
flexRow: {
flexDirection: "row",
justifyContent: "space-between",
},
flexColumn: {
width: "100%",
flexDirection: "column",
},
nextStepsText: {
color: colors.black,
fontSize: 25,
fontWeight: "bold",
},
nextStepsDetails: {
color: colors.black,
fontSize: 20,
},
bold: {
color: colors.black,
fontWeight: "bold",
},
cont: {
margin: 5,
padding: 3,
},
claimNrText: {
color: colors.black,
margin: 0,
padding: 0,
fontSize: 30,
},
claimNr: {
fontSize: 26,
}
})

Related

Flex value for main view causing all of my content to dissapear

I am working on a react native coffee app and trying to create the lay out where I have
the header
the scrollable container holding my coffee
a footer with a text input
a '+' icon to add the coffees to the container
Currently the flex value of my main 'View' is causing my entire app to push to the top of the screen and i have no idea why. I can set the height and width to 100% without flex and i can fill the screen but then i cannot configure my footer properly (+ i know this is bad practice..)
What am i doing wrong with my styles?
const Main = () => {
return(
<View style={styles.container}>
<View style={styles.header}>
<Text style={styles.headerText}> List of Coffee </Text>
</View>
<ScrollView styles={styles.scrollContainer}>
</ScrollView>
<View styles={styles.footer}>
<TextInput
styles={styles.textInput}
placeholder="add your latest coffee here"
placeholderTextColor="#EEE">
</TextInput>
</View>
<TouchableOpacity style={styles.addButton}>
<Text style={styles.addButtonText}>+</Text>
</TouchableOpacity>
</View>
);};
const styles = StyleSheet.create({
container: {
flex:1,
flexDirection:"column",
backgroundColor: 'grey',
},
footer: {
position: 'absolute',
bottom: 10,
left: 10,
right: 10,
backgroundColor: 'white',
zIndex: 9,
},
header: {
backgroundColor: 'black',
alignItems: 'center',
justifyContent: 'center',
borderBottomWidth: 10,
borderBottomColor: 'yellow' ,
paddingTop: 20,
},
headerText: {
color: 'white',
fontSize: 36,
padding: 26,
fontWeight: "500",
fontFamily: 'Helvetica',
},
scrollContainer:{
marginBottom: 100,
},
textInput: {
alignSelf: 'stretch',
color: 'black',
padding:20,
backgroundColor: 'black',
borderTopWidth: 2,
borderTopColor: 'black',
fontSize: 32,
},
addButton: {
position: 'absolute',
zIndex: 11,
right: 20,
bottom: 100,
backgroundColor: 'black',
width: 80,
height: 80,
borderRadius: 50,
justifyContent: 'center',
alignItems: 'center',
} ,
addButtonText:{
color: '#FFD700',
fontSize: 36,
fontWeight: '700',
},
});
export default Main;

react native video component is not showing?

Problem:
I have created a react component which is including a video that uses react native video library. But unfortunately, it is not showing a video component. This is how my code is.
import React, {createRef, useState} from 'react';
import {
View,
Image,
TouchableOpacity,
TouchableWithoutFeedback,
} from 'react-native';
import Icon from 'react-native-vector-icons/AntDesign';
import AppText from '_components/appText';
import Video, {
OnSeekData,
OnLoadData,
OnProgressData,
} from 'react-native-video';
import {strings} from '_translations/i18n';
import PlayerControls from '_components/playerControls';
const navigateToCameraView = (navigation) => {
navigation.navigate('videorecording');
};
const showControls = (state, setState) => {
state.showControls
? setState({...state, showControls: false})
: setState({...state, showControls: true});
};
const playVideo = (state, setState) => {
console.log('Hiii>>>>>>>>');
setState({...state, showControls: false, play: true});
};
const VideoPreview = (props) => {
const {styles, navigation, fileName} = props;
const [state, setState] = useState({
fullscreen: false,
play: false,
currentTime: 0,
duration: 0,
showControls: true,
});
const player = createRef();
return (
<View style={styles.previewInnerContainer}>
{fileName ? (
<>
<View style={styles.videoContainer}>
<View style={styles.videoInnerContainer}>
<TouchableWithoutFeedback
onPress={() => showControls(state, setState)}>
<View>
<Video
source={{uri: fileName}}
controls={false}
style={styles.backgroundVideo}
ref={player}
resizeMode={'contain'}
paused={!state.play}
/>
{state.showControls && (
<View style={styles.controlsOverlay}>
<View style={styles.wrapper}>
<TouchableOpacity
style={styles.touchable}
onPress={() => playVideo(state, setState)}>
<Image
source={require('_assets/img/play1.png')}
resizeMode="center"
style={styles.playIcon}
/>
</TouchableOpacity>
</View>
</View>
)}
</View>
</TouchableWithoutFeedback>
</View>
</View>
<View style={styles.videoBottomText}>
<TouchableOpacity onPress={() => navigateToCameraView(navigation)}>
<View style={styles.updateAgainContainer}>
<Icon name="reload1" style={styles.reloadIcon} />
<AppText styles={styles.reloadText}>
{strings('assetsment.reload')}
</AppText>
</View>
</TouchableOpacity>
</View>
</>
) : (
<>
<TouchableOpacity onPress={() => navigateToCameraView(navigation)}>
<Image
source={require('_assets/img/cmerap.png')}
resizeMode="center"
style={styles.camPImage}
/>
</TouchableOpacity>
<AppText styles={styles.camPText}>Tap to capture video</AppText>
</>
)}
</View>
);
};
export default VideoPreview;
I have embedded it in another component like this.
<View style={styles.questionsInnerContainer}>
<View style={styles.questionTitleView}>
<AppText styles={styles.questionTitle}>
{strings('assetsment.question', {id: question.questionId})}
</AppText>
</View>
<View style={styles.questionTextContainer}>
<AppText styles={styles.questionText}>{questionTitle}</AppText>
</View>
</View>
<View style={styles.previewContainer}>
<VideoPreview
styles={styles}
navigation={navigation}
fileName={fileName}
/>
</View>
This is my styling sheet.
patientView: {
flex: 1,
backgroundColor: '#ffffff',
flexDirection: 'column',
},
top: {
height: '10%',
},
updateAgainContainer: {
flexDirection: 'row',
// backgroundColor: 'red',
},
reloadIcon: {
fontSize: normalize(15),
color: '#417505',
fontWeight: '600',
textAlign: 'center',
},
questionsContainer: {
height: '78%',
// backgroundColor: '#f2f2f2',
// elevation: 5,
shadowColor: '#000',
shadowOffset: {width: 0, height: 4},
shadowOpacity: 0.8,
shadowRadius: 8,
flex: 1,
},
hr: {
marginTop: '5%',
borderBottomColor: '#c3c3c3',
borderBottomWidth: 2.0,
marginRight: 30,
marginLeft: 30,
justifyContent: 'center',
},
bottom: {
height: '7%',
justifyContent: 'center',
alignItems: 'center',
},
patientBottomView: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
patientBottomContainerText: {
fontSize: normalize(13),
color: '#444444',
fontWeight: '500',
},
bottomLinkText: {
fontSize: normalize(13),
color: '#484848',
borderBottomWidth: 2,
borderBottomColor: '#c3c3c3',
},
imageContainer: {
height: '30%',
justifyContent: 'center',
alignItems: 'center',
paddingTop: '25%',
},
questionsInnerContainer: {
height: '30%',
paddingRight: '5%',
paddingLeft: '3%',
paddingTop: '5%',
},
btnContainer: {
paddingLeft: '5%',
paddingRight: '5%',
marginBottom: '12%',
justifyContent: 'center',
},
emtyView: {
height: '5%',
},
img: {
width: '50%',
resizeMode: 'contain',
},
questionTitleView: {
paddingBottom: '2%',
position: 'relative',
},
questionTitle: {
color: '#444444',
fontSize: normalize(11),
fontWeight: '600',
},
questionTextContainer: {
backgroundColor: '#d1e5ff',
paddingTop: '6%',
paddingBottom: '6%',
paddingLeft: '4%',
borderRadius: 10,
},
questionText: {
fontSize: normalize(13),
color: '#444444',
fontWeight: '700',
},
questionsLodder: {
width: '20%',
height: '20%',
alignSelf: 'center',
justifyContent: 'center',
marginTop: '50%',
},
previewContainer: {
height: '50%',
marginLeft: '10%',
marginRight: '10%',
// alignItems: 'center',
marginBottom: '2%',
},
previewInnerContainer: {
flex: 1,
},
camPImage: {
alignSelf: 'center',
marginTop: '-15%',
},
camPText: {
color: '#444444',
fontSize: normalize(13),
fontWeight: '600',
marginTop: '-25%',
textAlign: 'center',
},
answersContainer: {
flex: 1,
paddingLeft: '8%',
paddingRight: '8%',
},
answerContentContainer: {
flexDirection: 'row',
paddingBottom: '5%',
paddingTop: '2%',
paddingLeft: '5%',
paddingRight: '5%',
},
answerTextContainer: {
flex: 1,
},
sendButton: {
flex: 1,
backgroundColor: '#3e92ff',
paddingTop: 10,
paddingBottom: 10,
alignItems: 'center',
borderRadius: 50,
marginTop: 25,
marginBottom: 20,
justifyContent: 'center',
},
sendButtonText: {
fontFamily: 'Montserrat-Medium',
color: '#ffffff',
fontWeight: '300',
fontSize: normalize(15),
textAlign: 'center',
letterSpacing: 2,
},
bimage: {
width: 25,
height: 25,
},
toggle: {
transform: [{scaleX: 1.6}, {scaleY: 1.6}],
elevation: 90,
shadowColor: '#000000',
shadowOffset: {width: 0, height: 3},
shadowOpacity: 0.9,
shadowRadius: 50,
},
answerText: {
color: '#444444',
fontWeight: '600',
fontSize: normalize(13),
},
backgroundVideo: {
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
},
videoContainer: {
height: '70%',
},
videoInnerContainer: {
flex: 1,
backgroundColor: '#b8b8b8',
},
videoBottomText: {
height: '20%',
alignItems: 'center',
justifyContent: 'center',
},
reloadText: {
textAlign: 'center',
marginLeft: '5%',
color: '#417505',
fontWeight: '600',
fontSize: normalize(14),
},
reloadTextContainer: {
flex: 1,
},
controlOverlay: {
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
justifyContent: 'space-between',
alignItems: 'center',
},
wrapper: {
paddingHorizontal: 5,
marginTop: '28%',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-evenly',
flex: 3,
},
touchable: {
padding: 5,
},
playIcon: {
// backgroundColor: '#b8b8b8',
},
I tried a lot to find out what is wrong with this. But i was unable to do so. Can someone help me to find out a solution to this problem ?. If someone can help me it is really really appreciated as I am completely help less with this.Thank you

Text outside container with Flexbox and React native

With react native and flexbox, I do not understand why the text is outside the container (orange bakcground) ?
<View style={styles.main_container}>
<View style={styles.infos_container}>
<View style={styles.info_item}>
<Text style={styles.info_name}>
Âge
</Text>
<Text style={styles.info_value}>
18
</Text>
</View>
<View style={styles.info_item}>
<Text style={styles.info_name}>
Médias publics
</Text>
<Text style={styles.info_value}>
2
</Text>
</View>
</View>
</View>
const styles = StyleSheet.create({
infos_container: {
backgroundColor: 'orange',
flex: 1,
flexDirection: 'row',
flexWrap: 'wrap',
padding: 5,
},
info_item: {
margin: 5,
alignItems: 'center',
},
info_name: {
color: '#6c757d',
fontSize: 11,
},
info_value: {
color: '#343a40',
},
})
I just want my blocks styles.info_item to be horizontal and orange background
remove flex: 1 from infos_container settings flex: 0 in the main_container shouldn't have an effect on the styling of infos_container
infos_container: {
backgroundColor: 'orange',
flexDirection: 'row',
flexWrap: 'wrap',
padding: 5,
},
You didn't import main_container in your style. Maybe you have flex: 0 inside it
Change your style to this:
main_container: {
flex: 1,
},
infos_container: {
backgroundColor: 'orange',
alignSelf: 'stretch',
flexDirection: 'row',
flexWrap: 'wrap',
padding: 5,
},
info_item: {
margin: 5,
alignItems: 'center',
},
info_name: {
color: '#6c757d',
fontSize: 11,
},
info_value: {
color: '#343a40',
},

React Native. Lagged scroll animation in ScrollView

When I scroll vertically up and down, animation starts lagging in the first two components (CompetitionsList, CampList) after the slider (BannerSwiper). I couldn’t fix it. I tried using Animation.ScrollView with "UseNativeDriver: true", but it didn’t help. Something might be wrong with css.
Here is a gif of screen:
https://i.yapx.ru/DT9CR.gif
This is my code:
export default class HomeComponent extends React.Component {
render() {
return (
<View style={styles.container}>
<ScrollView >
<BannerSwiper/>
<CompetitionsList home={true} {...this.props}/>
<CustomDivider/>
<CampList home={true} {...this.props}/>
<CustomDivider/>
<NewsComponent home={true} {...this.props}/>
<CustomDivider/>
<AthletesBirthdayList {...this.props}/>
<CustomDivider/>
<RatingsBlock/>
<CustomDivider/>
<SocialBlock/>
</ScrollView>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f2f2f2',
}
});
export default class CompetitionsList extends React.Component {
...
render() {
const {
compListForHome
} = this.props.competitions;
return (
<View style={styles.homeContainer}>
<View style={styles.headerContainer}>
<Text style={[styles.header, {marginRight: 'auto'}]}>СОРЕВНОВАНИЯ</Text>
<Text
style={[styles.header, {marginLeft: 'auto', color: '#2f95dc'}]}
onPress={() => this.props.routing('navigate', 'Competitions')}
>ВСЕ</Text>
</View>
<View style={{alignItems: 'center'}}>
<View style={styles.contentContainer}>
<ScrollView
style={{flex: 1}}
horizontal={true}
showsHorizontalScrollIndicator={false}>
<AnimatedComponent>
<View style={styles.cardContainer}>
<View style={styles.cardWrapper}>
{
compListForHome.map(event =>
<TouchableWithoutFeedback key={event.id} onPress={() => console.log(event.id)}>
<Card
containerStyle={styles.cardWidth}
title={
<View style={styles.cardTitleStyleContainer}>
<Text numberOfLines={1} style={styles.cardTitleStyleText}>{event.name}</Text>
</View>
}
imageStyle={styles.image}
image={event.URL_logo? {uri: event.URL_logo} : SP_IMAGE}>
<View style={styles.cardLabeledContainer}>
<Text style={styles.cardTextLabeled} numberOfLines={1}>{dateFormatter(event.start_date)}</Text>
<Text style={styles.cardTextLabeled} numberOfLines={1}>{dateFormatter(event.end_date)}</Text>
</View>
<Text style={styles.cardText} numberOfLines={1}>{getFullCourseNameByCode(event.course)}</Text>
<Text style={styles.cardText} numberOfLines={1}>{getFullCompetitionStatusByCode(event.status)}</Text>
{
event.reg_status
? <Text style={styles.cardText} numberOfLines={1}>Регистрация: {getFullRegistrationStatusByCode(event.reg_status)}</Text>
: null
}
</Card>
</TouchableWithoutFeedback>
)
}
</View>
</View>
</AnimatedComponent>
</ScrollView>
</View>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1
},
spinContainer: {
height: 50
},
overlay: {
flex: 1,
position: 'absolute',
bottom: 10,
width: SCREEN_WIDTH,
justifyContent: 'center',
alignItems: 'center'
},
filterBtn: {
backgroundColor: '#2f95dc',
alignSelf: 'center'
},
homeContainer: {
flex: 1,
marginHorizontal: 50
},
fullListContainer: {
flex:1
},
headerContainer: {
flex: 1,
flexDirection: 'row',
width: SCREEN_WIDTH-80
},
header: {
fontSize: 17,
color: 'rgba(96,100,109, 1)',
lineHeight: 24,
marginTop: 15
},
contentContainer: {
flex: 1,
marginTop: 10,
width: SCREEN_WIDTH
},
cardContainer: {
flex: 1,
flexDirection: 'column',
marginRight: 10
},
cardWrapper: {
flex: 1,
flexDirection: 'row'
},
cardTitleStyleContainer: {
padding: 20,
marginBottom: 15,
borderTopStartRadius: 5,
borderTopEndRadius: 5,
backgroundColor: "#2f95dc",
alignItems: 'center'
},
cardTitleStyleText: {
fontSize: 16,
lineHeight: 24,
color: '#fff',
fontWeight: 'bold'
},
cardWidth: {
width: 250,
height: 360,
borderWidth: 1,
borderRadius: 6,
borderColor: '#ddd',
shadowColor: '#000',
shadowOffset: { width: 5, height: 5 },
shadowOpacity: 0.8,
shadowRadius: 5,
elevation: 4,
marginBottom: 7
},
image: {
width: 100,
height: 100,
borderRadius: 100,
overflow: 'hidden',
alignSelf: 'center'
},
cardText: {
color: 'rgba(96,100,109, 0.8)',
fontSize: 14,
lineHeight: 14,
alignSelf: 'center',
marginBottom: 10
},
cardLabeledContainer: {
backgroundColor: 'rgba(0,0,0,0.05)',
borderRadius: 3,
marginTop: 10,
marginBottom: 20,
marginHorizontal: 30,
padding: 5
},
cardTextLabeled: {
alignSelf: 'center',
fontSize: 15,
color: 'rgba(96,100,109, 0.8)'
}
});
Thank you for your help!

styling of background color in pixel phone

I want to put the logo of the company so that it stretches out from top left corner to the top right corner with width of 10. Below is my code. My image is not showing properly. It shows in the middle of the screen with width going outside of the phone.If I put position: absolute then the image disappears from the phone.
/**
* Sample React Native App
* https://github.com/facebook/react-native
* #flow
*/
import React, { Component } from 'react';
import { Text, View, StyleSheet, Image, ScrollView, TouchableOpacity, Linking, Button } from 'react-native';
import { connect } from 'react-redux';
import { getTheme } from 'react-native-material-kit';
import EvilIcon from 'react-native-vector-icons/EvilIcons';
import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
import SimpleIcon from 'react-native-vector-icons/SimpleLineIcons';
import * as actions from '../actions';
import getDirections from 'react-native-google-maps-directions'
const theme = getTheme();
const styles = StyleSheet.create({
card: {
marginTop: 10,
paddingBottom: 20,
marginBottom: 20,
borderColor: 'lightgrey',
borderWidth: 0.5,
},
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#4F6D7A',
height: 550,
alignSelf:'center',
width:500,
position: 'relative',
},
title1: {
top: 10,
left: 80,
fontSize: 24,
},
title2: {
top: 35,
left: 82,
fontSize: 18,
},
image: {
flex: 0,
height: 100,
width: 333,
backgroundColor: 'transparent',
justifyContent: 'center',
alignItems: 'center',
},
closeIcon: {
position: 'absolute',
top: 5,
left: 295,
color: 'rgba(233,166,154,0.8)',
backgroundColor: 'rgba(255,255,255,0)',
},
icon: {
position: 'absolute',
top: 15,
left: 0,
color: 'white',
backgroundColor: 'rgba(255,255,255,0)',
},
textArea: {
flexDirection: 'row',
paddingLeft: 20,
paddingTop: 10,
width: 260,
},
textIcons: {
color: '#26a69a',
},
actionArea: {
paddingTop: 10,
flexDirection: 'row',
justifyContent: 'space-around',
alignItems: 'center',
},
title:{
justifyContent: 'center',
paddingTop: 10,
alignItems: 'center',
alignSelf: 'center',
fontWeight: 'bold',
fontSize: 22,
color: '#F5FCFF',
},
SerContent:{
fontWeight: 'bold',
fontSize: 16,
paddingTop: 10,
alignSelf: 'center',
color: '#F5FCFF'
},
underLineText: {
fontSize: 17,
textDecorationLine: 'underline',
color: '#F5FCFF',
fontWeight: 'bold',
textAlign: 'center',
},
dir:{
flexDirection:'row',
paddingTop: 30,
textAlign: 'center',
fontSize: 17,
alignSelf: 'center'
} ,
Address1:{
alignSelf: 'center',
marginRight: 20,
fontSize: 17,
fontWeight: 'bold',
color: '#F5FCFF',
},
toolbar: {
flexDirection: 'row', //Step 1
},
toolbarTitle:{
width: 10,
top: 0,
left: 0,
bottom: 0,
right: 0,
flex:1 ,
position:'absolute' //Step 3
},
});
class ServiceDetail extends Component {
handleClick = (link) => {
Linking.canOpenURL(link).then(suppported => {
if (supported) {
Linking.openURL(link);
} else {
console.log('Don\'t know how to open URI: ' + link);
}
});
};
render() {
var destUrl = 'https://www.google.com/maps/search/?api=1&query=' + this.props.services.destAddr1 + '+' + 'field'
var destUrl1 = 'https://www.google.com/maps/search/?api=1&query=' + this.props.services.destAddr2 + '+' + 'field'
return (
<ScrollView showsVerticalScrollIndicator={false}>
<View style={styles.container}>
<View style={styles.toolbar}>
<Image
resizeMode='contain'
style={styles.toolbarTitle}
source={require('../Resources/LogoWithDesc.jpg')} />
</View>
<SimpleIcon name={'close'} size={30} style={styles.closeIcon}
onPress={() => this.props.noneSelected()} />
<Text style={styles.title}>{this.props.services.ser}</Text>
<Text style={styles.SerContent} >Service is available in the following locations:</Text>
<View style={styles.dir}>
<Text style={styles.Address1}> {this.props.services.Location}:</Text>
<TouchableOpacity onPress={() => Linking.openURL(destUrl)}>
<Text style={styles.underLineText}>Directions</Text>
</TouchableOpacity>
</View>
<View style={styles.dir}>
<Text style={styles.Address1}>{this.props.services.SecondLoc}:</Text>
<TouchableOpacity onPress={() => Linking.openURL(destUrl1)}></TouchableOpacity>
<TouchableOpacity onPress={() => Linking.openURL(destUrl1)}>
<Text style={styles.underLineText}>Directions</Text>
</TouchableOpacity>
</View>
</View>
</ScrollView>
);
}
}
const mapStateToProps = state => {
return {
services: state.serviceSelected
};
};
export default connect(mapStateToProps, actions)(ServiceDetail);
any help will be highly appreciated.
Please try increasing flex to Image and add the position property.
image: {
flex: 1,
height: 200,
backgroundColor: 'transparent',
justifyContent: 'center',
alignItems: 'center',
width: 333,
position: 'absolute',
},
Please apply the width of the container and add the position property.
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#4F6D7A',
height: 200,
alignSelf:'center'
width: 333,
position: 'relative',
},
you can also edit the layout using flexbox
https://facebook.github.io/react-native/docs/flexbox.html

Resources