Can a normal page become a Header? - reactjs

I've got a page that I created and I would like to use it as a header.
The issue is that it would push any other page/text that I use to the bottom of the page.
Any solution? I'm new to react native.
Here is my code :
import React from 'react';
import { Image, StyleSheet, Button, View, SafeAreaView, Text, Alert, TouchableOpacity } from 'react-native';
import logo from '../../../assets/logo.png';
export default function App() {
return (
<View style={styles.container}>
<View style = {styles.backgroundContainer}>
<Image source={logo} style={{ width: 190, height: 40 }} />
<Text style={styles.text1}>|</Text>
<Text style={styles.text2}>Welcome to the Team</Text>
<TouchableOpacity style={styles.button}>
<Text style={styles.text3}>A LA CARTE</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.button2}>
<Text style={styles.text3}>PLAY</Text>
</TouchableOpacity>
<Text style={styles.text21}>Teams</Text>
<Text style={styles.text0}>|</Text>
<Text style={styles.text22}>Projets</Text>
<Text style={styles.text00}>|</Text>
<Text style={styles.text23}>Glossaire</Text>
</View>
</View>
);
}
const styles = StyleSheet.create({
backgroundContainer: {
position: 'absolute',
top: 0,
bottom: 0,
left: 10,
right: 0,
},
container: {
flex: 1,
backgroundColor: '#fff',
justifyContent: 'center',
marginTop: 12,
},
code: {
marginTop: 12,
padding: 12,
borderRadius: 8,
color: "#666",
backgroundColor: "#eaeaea"
},
button: {
backgroundColor: "#61C3D7",
position:'absolute',
justifyContent: "center",
alignItems: "center",
borderRadius:3,
height:45,
padding: 15,
width:120,
top:-10,
right:170
},
button2: {
backgroundColor: "#26AA90",
position:'absolute',
justifyContent: "center",
alignItems: "center",
borderRadius:3,
height:45,
padding: 15,
width:120,
top:-10,
right:20
},
text0: {
position: 'absolute',
color:'#D3D3D3',
fontSize: 24,
fontWeight: 300,//Semibold
right: 405
},
text00: {
position: 'absolute',
color:'#D3D3D3',
fontSize: 24,
fontWeight: 300,//Semibold
right: 495
},
text1: {
position: 'absolute',
fontSize: 24,
fontWeight: 300,//Semibold
left: 190
},
text2: {
position: 'absolute',
fontSize: 17,
fontWeight: 600,//Semibold
top: 5,
left: 210
},
text21: {
position: 'absolute',
fontSize: 17,
fontWeight: 600,//Semibold
top: 5,
right: 525
},
text22: {
position: 'absolute',
fontSize: 17,
fontWeight: 600,//Semibold
top: 5,
right: 425
},
text23: {
position: 'absolute',
fontSize: 17,
fontWeight: 600,//Semibold
top: 5,
right: 325
},
text3: {
fontSize: 17,
textAlign: 'center',
fontWeight: 400,
color:'#FFFFFF',
top: 5,
width: 100,
left: 210}
});
This is the index.tsx of my Header directory and I called it with a in my App.tsx.
I wish to make it so that I can call this Header in each of my pages and not have to use "position: 'absolute'" in each of my styles each time I'm using it.

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;

How to pull down to close the modal? React-Native

I have a Problem.
The Problem is that my modal don't closed, when I swipe down. How can I change it?
I tried so many things, but nothing worked.
To see the problem, click here (Video/GIF)
I am new in React and I don't know if the Information that I wrote are much or not. If you need more Information just write it down.
import {
KeyboardAvoidingView,
Platform,
StyleSheet,
Text,
View,
SafeAreaView,
ScrollView,
Image,
TouchableOpacity,
Modal,
} from "react-native";
import { createStackNavigator } from "#react-navigation/stack";
import StundenplanBoxScreen from "../Stundenplan/StundenplanBoxScreen.js";
const Stundenplan = ({ navigation }) => {
const [modalOpen, setModalOpen] = useState(false);
const setConst = () => setModalOpen((previousState) => !previousState);
return (
<SafeAreaView style={styles.container}>
<ScrollView>
<View style={styles.boxlogo}>
<Image source={yourLogo} style={styles.logo} />
</View>
<View style={styles.centeredView}>
<Modal
animationType="slide"
transparent={true}
visible={modalOpen}
presentationStyle="pageSheet"
onSwipeComplete={() => setModalOpen(false)}
swipeDirection="down"
>
<View style={styles.HinzufuegenModal}>
<Text>Hello!</Text>
</View>
</Modal>
</View>
<StundenplanBoxScreen />
</ScrollView>
<KeyboardAvoidingView
behavior={Platform.OS === "ios" ? "padding" : "height"}
style={styles.bottom}
>
<TouchableOpacity onPress={setConst}>
<View style={styles.Hinzufuegen}>
<Text style={styles.HinzufuegenText}>+</Text>
</View>
</TouchableOpacity>
</KeyboardAvoidingView>
</SafeAreaView>
);
};
export default Stundenplan;
const yourLogo = require("../adaptive-icon.png");
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#FEF5E2",
},
centeredView: {
flex: 1,
justifyContent: "center",
alignItems: "center",
marginTop: 22,
},
boxlogo: {
justifyContent: "center",
alignItems: "center",
marginTop: Platform.OS === "ios" ? -10 : 5,
},
logo: {
width: 100,
height: 100,
resizeMode: "contain",
},
box: {
backgroundColor: "#FFF",
paddingBottom: 15,
marginTop: -5,
margin: Platform.OS === "ios" ? 20 : 25,
borderRadius: 6,
//Shadow
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 9,
},
shadowOpacity: 0.48,
shadowRadius: 11.95,
elevation: 18,
},
HinzufuegenModal: {
margin: 20,
borderRadius: 20,
padding: 35,
alignItems: "center",
backgroundColor: "#FFF",
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 9,
},
shadowOpacity: 0.48,
shadowRadius: 11.95,
elevation: 18,
},
inhalt: {
padding: Platform.OS === "ios" ? 20 : 17,
},
uberschrift: {
fontWeight: "500",
fontSize: 19,
},
beschreibungTitle: {
fontSize: 48,
fontWeight: "bold",
marginTop: Platform.OS === "ios" ? -10 : 5,
},
bottom: {
position: "absolute",
bottom: 0,
width: "100%",
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
},
Hinzufuegen: {
width: 60,
height: 60,
backgroundColor: "#FFF",
borderRadius: 10,
bottom: Platform.OS === "ios" ? 125 : 110,
right: Platform.OS === "ios" ? -310 : -325,
justifyContent: "center",
alignItems: "center",
//Shadow
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 9,
},
shadowOpacity: 0.48,
shadowRadius: 11.95,
elevation: 18,
},
HinzufuegenButton: {
width: 60,
height: 60,
backgroundColor: "#FFF",
borderRadius: 10,
bottom: Platform.OS === "ios" ? 125 : 110,
right: Platform.OS === "ios" ? -310 : -325,
justifyContent: "center",
alignItems: "center",
//Shadow
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 9,
},
shadowOpacity: 0.48,
shadowRadius: 11.95,
elevation: 18,
},
HinzufuegenText: {
fontSize: 35,
color: "#02131C",
},
});

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

React Native Scrollview keyboardshouldpersisttaps not working for ios

I have a Login screen where I wrap the entire component with ScrollView and apply keyboardshouldpersisttaps prop as always. The prop seems to work fine on android but not on ios, on tapping the textInput, it gets hidden under keyboard.
Below is my code for the login screen
<View>
<ScrollView
style={styles.scrollviewStyle}
keyboardShouldPersistTaps="always">
<View style={styles.topContainerStyle}>
<View style={styles.padding}>
<Text style={styles.skipTextStyle}>SKIP</Text>
<Image source={BlackLogo} style={styles.logoStyle} />
</View>
</View>
<Image source={PreLoginImage} style={styles.preLoginImageStyle} />
<View style={styles.padding}>
<Text style={styles.getStartedTextStyle}>Let's Get started</Text>
<View style={styles.bottomContainer}>
<TextInput
// onChangeText={mobile => this.onMobileEnter(mobile)}
style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
value={this.state.mobile}
maxLength={10}
onCodeChange={this.onCodeChange}
/>
<TouchableHighlight
disabled={!this.state.mobile ? true : false}
onPress={() => this.onProceedPress()}
style={
!this.state.mobile
? styles.disabledContinueButtonStyles
: styles.continueButtonStyles
}>
<Text
style={{
alignSelf: 'center',
fontFamily: 'Roboto-Medium',
fontSize: 16,
marginTop: 18,
color: '#FFFFFF',
}}>
CONTINUE
</Text>
</TouchableHighlight>
</View>
<Text style={styles.termsStyle}>
By continuing, you agree to Remedico's terms of use and privacy
Policy.
</Text>
</View>
</ScrollView>
</View>
);
}
}
const styles = StyleSheet.create({
topContainerStyle: {
backgroundColor: '#F4EBE4',
height: deviceHeight * 0.4,
},
logoStyle: {
width: 139,
height: 45,
resizeMode: 'contain',
top: 123,
},
padding: {
padding: 24,
},
preLoginImageStyle: {
width: 178,
height: 167,
position: 'absolute',
top: deviceHeight * 0.2,
left: deviceWidth * 0.5,
},
getStartedTextStyle: {
paddingTop: 60,
fontFamily: 'Ubuntu-Medium',
fontSize: 20,
},
skipTextStyle: {
left: deviceWidth - 80,
fontFamily: 'Roboto-Medium',
fontSize: 16,
},
bottomContainer: {
paddingTop: 32,
},
continueButtonStyles: {
marginTop: 84.5,
borderRadius: 25,
backgroundColor: '#00ACC1',
height: 55,
},
disabledContinueButtonStyles: {
marginTop: 84.5,
borderRadius: 25,
backgroundColor: '#CCCCCC',
height: 55,
},
termsStyle: {
fontFamily: 'Roboto-Regular',
fontSize: 12,
paddingTop: 32,
color: '#808080',
},
scrollviewStyle: {
backgroundColor: '#FFF',
height: deviceHeight,
},
// activityIndicatorStyle:{
// marginTop: 84.5
// },
});
Please do suggest why is it so, and how will it be working on ios, any suggestion would be a help,thanks in advance.
I don't think keyboardshouldpersisttaps props of ScrollView will solve your problem. This props will only dismiss the keyboard when you press on the container view.
Please check ref: https://reactnative.dev/docs/scrollview#keyboardshouldpersisttaps
I suggest you to use https://github.com/APSL/react-native-keyboard-aware-scroll-view for your problem.
Hope that 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