unable to move button to the right - react-native

I have the following return() and am unable to move the last VIEW which contains the button title = 'done' to the right side
return (
<View style={styles.container}>
<Text style={styles.bigFont}>{`${this.state.timer + 'TIMER'}`}</Text>
<Text style={styles.bigFont}>{`${this.state.min + ':' + this.state.sec}`}</Text>
<View style={styles.button}>
<Button title= {this.state.startFlag ? 'PAUSE' : 'START'} onPress={()=>this.startToggle()} />
<Button title='RESET' onPress={()=>this.resetToggle()} />
</View>
<View style={styles.row}>
<Text style={[styles.bold,{marginRight:10},{width:112},
{textAlign:'right'}]}>
Work Timer:</Text>
<Text style={styles.bold}> min:</Text>
<TextInput
value={Math.floor(this.state.workTime / 60).toString()}
style={styles.input}
onChangeText={(text)=>{this.captureInput(text)}}
onSubmitEditing={()=>{(this.update('work-min'))}}
/>
<Text style={styles.bold}> sec:</Text>
<TextInput
value={Math.floor(this.state.workTime % 60).toString()}
style={styles.input}
keyboardType='numeric'
onChangeText={(text) => {this.captureInput(text)}}
onSubmitEditing={()=>{(this.update('work-sec'))}}
/>
</View>
<View style={styles.row}>
<Text style={[styles.bold,{marginRight:10},{width:112},
{textAlign:'right'}]}>
Break Timer:</Text>
<Text style={styles.bold}> min:</Text>
<TextInput
value={Math.floor(this.state.breakTime / 60).toString()}
style={styles.input}
keyboardType='numeric'
onChangeText={(text) => {this.captureInput(text)}}
onSubmitEditing={()=>{(this.update('break-min'))}}
/>
<Text style={styles.bold}> sec:</Text>
<TextInput
value={Math.floor(this.state.breakTime % 60).toString()}
style={styles.input}
keyboardType='numeric'
onChangeText={(text) => {this.captureInput(text)}}
onSubmitEditing={()=>{(this.update('break-sec'))}}
/>
</View>
<View style={{flexDirection:'row',justifyContent:'flex-end',alignItems:'flex-end'}} >
<Text ><Button title='done' onPress={()=>this.resetToggle()} /></Text>
</View>
</View>
)
export default StyleSheet.create({
container: {
flex:1,
flexDirection:'column',
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
marginBottom:150,
},
bigFont:{
fontSize:40,
color:'darkblue'
},
row:{
flexDirection:'row',
marginBottom:15,
},
button:{
flexDirection:'row',
marginTop:30,
marginBottom:30,
},
bold: {
fontWeight: 'bold',
color:'green',
},
input: {
borderWidth: 1,
borderColor: 'black',
marginRight: 10,
paddingHorizontal:15,
minWidth: 50,
},
})

so, interestingly, we need to use alignSelf:'flex-end' or use width:'100%'. flex:1 is definitely wrong as that uses all the available space and shifts everything up.

Below code should work. Last section of return statement.
<View style={{flex: 1, flexDirection: 'row', justifyContent: 'flex-end', alignItems: 'flex-end'}} >
<Text ><Button title='done' onPress={() => this.resetToggle()} /></Text>

Related

What is the possible reason of why react native MapView is lagging?

My app have structure like this,
MapPage.js that contain expo-barcode-scanner wrapped with Modal and MapView.
DetailsPage.js that contain search result/products' details.
User can use the barcode scanner or TextInput(also in MapPage, not wrapped in Modal) to search product ID and the app will navigate to DetailsPage for result. If result is not found, app will automatically navigate.goBack() to MapPage. If result existed, will goto the result and stay in DetailsPage.
User can also navigate to DetailsPage by pressing marker callout on MapView.
Here is situation:
user press on marker callout(navigate to DetailsPage), then press back(navigate.goBack()) to MapPage : No lagging
user search by TextInput, then back to MapPage: No lagging whether search result exist or not
user search by Barcode, result not exist, automatically back to MapPage: not lagging
user search by Barcode, result existed, stay in DetailsPage, user manually press back: LAGGING
Below codes for your references
//MapPage
<MapView
style={{ width: '100%', height: '100%' }}
provider={PROVIDER_GOOGLE}
showsMyLocationButton={true}
showsUserLocation={true}
region={{
latitude: region.latitude,
longitude: region.longitude,
latitudeDelta: region.latitudeDelta,
longitudeDelta: region.longitudeDelta,
}}>
<MapMarker
markerLocation={markers}
countryCode={country.countryCode}
/>
</MapView>
...
<TextInput
placeholder={
i18n.t('SearchId')
}
placeholderTextColor="white"
onSubmitEditing={() =>
handleBarCodeScanned({ data: textSearchData })
}
onChangeText={(text) => {
settextSearchData(text.toUpperCase());
}}
/>
<Pressable onPress={() => setqrcodeModalVisi(true)}>
<Ionicons
name="qr-code-outline"
size={33}
color="white"
/>
</Pressable>
...
<Modal
visible={qrcodeModalVisi}
animationType="slide"
onRequestClose={() => setqrcodeModalVisi(false)}
transparent={true}>
<View>
<Pressable onPress={() => setqrcodeModalVisi(false)}>
<Feather
name="x"
size={24}
color="white"
/>
</Pressable>
{!hasPermission && (
<View>
<Text
style={{
color: colors.text,
}}>
Camera access denied.
</Text>
<Pressable onPress={() => getBarCodeScannerPermissions()}>
<Text style={{ color: colors.secondary }}>
Goto setting page
</Text>
</Pressable>
</View>
)}
{hasPermission && (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}}>
<BarCodeScanner
onBarCodeScanned={
scanned ? undefined : handleBarCodeScanned
}
style={{
width: '100%',
height: '80%',
}}
/>
</View>
)}
</View>
</Modal>
//MapMarker
<View>
{markerLocation.map((array) => (
<Marker
key={array.title}
coordinate={{
latitude: array.latitude,
longitude: array.longitude,
}}
image={require('../../../assets/icons/map_marker.png')}
title={''}
description={''}
onCalloutPress={() => handleMapMarkerPress(array.regionCode)}>
<Callout>
<View
style={{
backgroundColor: 'white',
width: 180,
paddingVertical: 5,
alignItems: 'center',
justifyContent: 'center',
}}>
<Text
style={{
width: '80%',
textAlign: 'center',
color: colors.secondary,
fontWeight: 'bold',
}}>
{array.title}
</Text>
<View
style={{
backgroundColor: colors.secondary,
width: '80%',
height: 25,
alignItems: 'center',
justifyContent: 'center',
marginTop: 2,
flexDirection: 'row',
marginVertical: 5,
}}>
<Text style={{ color: 'white', fontWeight: 'bold' }}>
{i18n.t('MapMarkerBtn')}
</Text>
</View>
</View>
</Callout>
</Marker>
))}
</View>
Thanks!

react-native: absolute Button over TextInput

I try to add a Button to my TextInput and added it using position: absolute like this:
<View style={{width: '100%'}}>
<View
style={{
position: 'absolute',
alignItems: 'center',
justifyContent: 'space-between',
height: '100%',
width: '100%',
flexDirection: 'row',
}}>
<Icon
name="search-outline"
type="ionicon"
size={30}
style={{marginLeft: 8}}
/>
{value != '' && (
<Icon
name="close-outline"
type="ionicon"
size={30}
style={{marginRight: 8}}
onPress={() => this.setState({value: ''})}
/>
)}
</View>
<MyTextInput
placeholder="search"
value={value}
onChange={val => this.setState({value: val.nativeEvent.text})}
inputStyle={{paddingLeft: 46}}
/>
</View>
But whenever I click a Button, the TextInput focusses and I onPress is not getting executed
Render the View after MyTextInput
<View style={{width: '100%'}}>
<MyTextInput
placeholder="search"
value={value}
onChange={val => this.setState({value: val.nativeEvent.text})}
inputStyle={{paddingLeft: 46}}
/>
<View
style={{
position: 'absolute',
alignItems: 'center',
justifyContent: 'space-between',
height: '100%',
width: '100%',
flexDirection: 'row',
}}>
<Icon
name="search-outline"
type="ionicon"
size={30}
style={{marginLeft: 8}}
/>
{value != '' && (
<Icon
name="close-outline"
type="ionicon"
size={30}
style={{marginRight: 8}}
onPress={() => this.setState({value: ''})}
/>
)}
</View>
</View>

React native react-native-google-places-autocomplete VirtualizedLists warning

I created a form in which I have a field called address. Where I implemented 'react-native-google-places-autocomplete' plugin. It's working fine if I don't add scrollView. But I need to add scrollView just because I have so many input fields inside that form. but then I got a warning "VirtualizedLists should never be nested inside plain ScrollViews with the same orientation".
Here is my code:
Add.js
<SafeAreaView style={{ flex: 1, paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0, backgroundColor: 'white' }}>
<View style={{ flex: 1 }}>
<ScrollView scrollEventThrottle={16}>
<View style={{ flex: 1 }}>
<Text style={{ fontSize: 20, marginTop: 5, marginBottom: 10, paddingHorizontal: 15, fontFamily: 'Mulish-SemiBold' }}>Add Ground</Text>
<TouchableWithoutFeedback style={styles.button} onPress={(e) => this.chooseFile()}>
<Image source={this.state.avatarSource ? this.state.avatarSource : require('./../../assets/images/default-cover.jpg')} style={{ width: '100%', height: 150 }} />
</TouchableWithoutFeedback>
<View style={styles.inputWrapper}>
<Text style={styles.inputLabel}>Name</Text>
<TextInput
style={styles.input}
placeholder="e.g Drealit Stadium"
onChangeText={name => this.setState({ name })}
value={this.state.name}
autoCorrect={false}
/>
</View>
<View style={styles.inputWrapper}>
<Text style={styles.inputLabel}>Address</Text>
{/*
onChangeText={address => this.setState({ address })}
value={this.state.address}
*/}
<ScrollView>
<GooglePlacesInput />
</ScrollView>
</View>
<View style={styles.inputWrapper}>
<Text style={styles.inputLabel}>Contact Person Name</Text>
<TextInput
style={styles.input}
placeholder="e.g David Johnson"
onChangeText={organizer_name => this.setState({ organizer_name })}
value={this.state.organizer_name}
autoCorrect={false}
/>
</View>
<View style={styles.inputWrapper}>
<Text style={styles.inputLabel}>Contact Person Number</Text>
<TextInputMask
type={'cel-phone'}
options={{
maskType: 'INTERNATIONAL',
}}
placeholder="e.g 509-962-9014"
style={styles.input}
value={this.state.organizer_number}
onChangeText={organizer_number => this.setState({ organizer_number })}
/>
</View>
<View style={styles.inputWrapper}>
<Text style={styles.inputLabel}>Description</Text>
<TextInput
placeholder="e.g A Ground suitable for small side cricket tournament. Ideal for some fast paced cricket and lot of fun."
onChangeText={description => this.setState({ description })}
value={this.state.description}
autoCorrect={false}
multiline={true}
numberOfLines={4}
style={[styles.input, { height: 'auto', textAlignVertical: 'top' }]}
/>
</View>
<View style={styles.inputWrapper}>
<Text style={styles.inputLabel}>Rate per hour / day</Text>
<TextInput
style={styles.input}
placeholder="e.g 3500"
keyboardType="numeric"
onChangeText={ratePerHourDay => this.setState({ ratePerHourDay })}
value={this.state.ratePerHourDay}
autoCorrect={false}
/>
</View>
<View style={styles.inputWrapper}>
<Text style={styles.inputLabel}>Rate per hour / night</Text>
<TextInput
style={styles.input}
placeholder="e.g 4500"
keyboardType="numeric"
onChangeText={ratePerHourNight => this.setState({ ratePerHourNight })}
value={this.state.ratePerHourNight}
autoCorrect={false}
/>
</View>
<View style={{ marginHorizontal: 15, marginVertical: 10 }}>
<TouchableWithoutFeedback style={styles.button} onPress={(e) => this.manageAddGround(e)}>
<LinearGradient
colors={["#4678f6", "#4475ee", "#5053eb"]}
start={{ x: 0, y: 0 }}
end={{ x: 0, y: 0 }}
locations={[0, 0.5, 0.6]}
style={styles.appButtonContainer}
>
<Text style={styles.buttonText}>Save</Text>
</LinearGradient>
</TouchableWithoutFeedback>
</View>
</View>
</ScrollView>
</View>
</SafeAreaView>
GooglePlacesInput.js
<View style={{ flex: 1 }}>
<GooglePlacesAutocomplete
placeholder='e.g 640 Cross Creek Dr, Ellensburg, WA, 98926'
query={{
key: GOOGLE_PLACES_API_KEY,
language: 'en',
}}
enablePoweredByContainer={false}
onPress={(data, details = null) => {
console.log("GooglePlacesInput -> data", data)
}}
debounce={200}
styles={{
textInputContainer: {
backgroundColor: '#fff',
borderTopWidth: 0,
borderBottomWidth: 0,
},
textInput: {
marginLeft: 0,
marginRight: 0,
height: 40,
borderBottomWidth: 1,
color: '#000',
borderBottomColor: '#dedede'
},
predefinedPlacesDescription: {
color: '#1faadb',
},
listView: {
backgroundColor: '#fff',
borderWidth: 0.5,
borderColor: '#dedede',
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 6,
},
shadowOpacity: 0.05,
shadowRadius: 10,
elevation: 4
}
}}
/>
</View>
You are receiving this warning because react-native-google-places-autocomplete renders a component to show results, and you have wrapped in a .
It's a warning, not an error. If it works for you can leave it as is.

react native Modal opening from last object in array

I am creating a render method where it displays information from a state array, and I want it so that when a user touches a Card a Modal will open presenting the same information.
My code is as follows:
this.state = {
fontLoaded: false,
feed: [{
username: ["Jeff", "Kyle", "David"],
caption: ["Great", "Amazing", "Not so Good"],
comments: ["Comment 1", "Comment 2", "No Comment"],
photo:[Pic1,Pic2,Pic3],
}]
}
state = {
isModalVisible: false,
};
toggleModal = () => {
this.setState({ isModalVisible: !this.state.isModalVisible });
};
renderFeed = () => {
return this.state.feed.map((card, index) => {
return card.username.map((username, i) => {
if(card.caption[i])
return (
<View>
<TouchableHighlight onPress={this.toggleModal} underlayColor="white">
<Card
key={`${i}_${index}`}
image={card.photo[i]}
containerStyle={{borderRadius:10, marginRight:1, marginLeft:1,}}>
<View
style={{ flex: 1, flexDirection: 'row', justifyContent: 'space-between' }}
>
<View style={{ flexDirection: 'row'}}>
<Avatar
size="small"
rounded
source={card.photo[i]}
/>
</View>
<View style={{flexDirection:'row'}}>
<Avatar
rounded
icon={{ name:'heart-multiple-outline', type:'material-community', color: '#ff4284'}}
overlayContainerStyle={{marginLeft:5}}
reverse
size='small'/>
<Avatar
reverse
rounded
icon={{ name:'comment-processing-outline', type:'material-community' }}
overlayContainerStyle={{backgroundColor: '#dbdbdb',marginLeft:5}}
size='small'/>
</View>
</View>
{ this.state.fontLoaded == true ? (
<View style={{flexDirection:'row'}}>
<Text style={{fontFamily: 'MontserratB', color:'#bf00b9', marginTop:10}}>{username}</Text>
<Text style={{fontFamily:'Montserrat', marginTop:10}}>{card.caption[i]}</Text>
</View>
) : (<Text> Loading...</Text>)
}
<Text style={{marginTop:4, color:'#878787'}}>{card.comments[i]}</Text>
</Card>
</TouchableHighlight>
<Modal
animationIn="zoomInDown"
animationOut="zoomOutDown"
animationInTiming={700}
animationOutTiming={600}
backdropTransitionInTiming={600}
backdropTransitionOutTiming={600}
isVisible={this.state.isModalVisible}>
<Image source={card.photo[i]}
style={{width: SCREEN_WIDTH - 20,
height: 300, justifyContent: 'center', alignSelf:
'center' }}/>
<Card
containerStyle={{ width: SCREEN_WIDTH - 20, marginTop: 0, justifyContent: 'center', alignSelf:
'center' }}>
<View style={{ flexDirection:'row' }}>
<Avatar
size="small"
rounded
source={card.photo[i]}
/>
<View style={{ flex:2, flexDirection:'row', justifyContent:'flex-end' }}>
<Avatar
rounded
icon={{ name:'heart-multiple-outline', type:'material-community'}}
overlayContainerStyle={{backgroundColor: '#ff4284',marginLeft:5}}
reverse
size='small'/>
<Avatar
reverse
rounded
icon={{ name:'comment-processing-outline', type:'material-community' }}
overlayContainerStyle={{backgroundColor: '#dbdbdb',marginLeft:5}}
size='small'/>
</View>
</View>
<View style={{ flexDirection:'row' }}>
<Text style={{fontFamily: 'MontserratB', color:'#bf00b9', marginTop:10}}>{username}</Text>
<Text style={{fontFamily:'Montserrat', marginTop:10}}>{card.caption[i]}</Text>
</View>
<Text style={{marginTop:4, color:'#878787'}}>{card.comments[i]}</Text>
</Card>
<Button style={{marginTop:0, borderBottomRightRadius: 20, borderBottomLeftRadius: 20, borderTopLeftRadius: 0, borderTopRightRadius: 0, width: SCREEN_WIDTH - 20, alignSelf: 'center', justifyContent: 'center'}} title="Close" onPress={this.toggleModal} />
</Modal>
</View>
);
return <React.Fragment />;
});
})
}
everything works perfectly except that no matter which Card is touched a Modal is opened presenting the last objects in the array. So no matter which of the three cards are pressed, a Modal will always open with the information regarding David
Modified snack version of your sample:
https://snack.expo.io/H1yHPQQdr

Invariant violation: Text strings must be rendered within a <Text> component React native

I basically copied the ingredients portion which works and am trying to duplicate it with the tag section. I get error on line that says
<View style={styles.section}>
which is opening view container for the tag section. Everything is identical to the ingredients section so in my mind it should be working.
There is *** on line where error is being flagged just for the sake of finding it easier. Those stars are not actually in my code.
render() {
return (
<View style={{ flex: 1 }}>
<View>
<ActionNavbar title="Add Recipe"
leftAction={this.cancelRecipe}
leftIcon={require("app/assets/icons/cancel.png")}
rightAction={this.saveRecipe}
rightIcon={require("app/assets/icons/check.png")} />
</View>
<ScrollView style={{ flex: 1, maxHeight: this.state.height }} contentContainerStyle={{ paddingBottom: 1000}}>
<View>
<AddImage />
<Input label="Name of Recipe"
value={this.state.name}
onChangeText={name => this.setState({name})}
style={styles.nameInput}/>
<View style={{ width: "100%", flexDirection: "row", justifyContent: "space-evenly", marginTop: 30}}>
<View style={{ alignItems: "center"}}>
<Text style={styles.title}>TOTAL COOK TIME</Text>
<TouchableOpacity onPress={() => {
this.props.navigation.navigate("DurationPicker", {
hours: this.state.hours,
minutes: this.state.minutes,
});
}}>
<View style={styles.secondaryButton}>
<Text style={styles.textStyle}>{this.state.durationLabel}</Text>
</View>
</TouchableOpacity>
</View>
<View style={{ alignItems: "center"}}>
<Text style={styles.title}>Total Servings</Text>
<TouchableOpacity onPress={() => {
this.props.navigation.navigate("ServingsPicker", {
servings: this.state.servings,
});
}}>
<View style={styles.secondaryButton}>
<Text style={styles.textStyle}>{this.state.servingsLabel}</Text>
</View>
</TouchableOpacity>
</View>
</View>
<View style={styles.section}>
<Text style={styles.sectionHeader}>Ingredients</Text>
<Divider style={styles.sectionDivider} />
{
this.state.ingredients.map((ingredient, index) => (
<View style={{ marginBottom: 3, flexDirection: 'row', alignItems: 'center'}} key={'ingredient-' + index}>
<View style={styles.ingredientSize}>
<Text style={{ padding: 10}}>{ingredient.number} {fractionMap[ingredient.fraction]} {ingredient.unitLabel}</Text>
</View>
<Text style={{ fontSize: 18 }}>{ingredient.name}</Text>
<Divider></Divider>
</View>
))
}
<ActionButton icon={require("app/assets/icons/whiteAdd.png")}
text="Add Ingredient"
onPress={() => {
this.props.navigation.navigate("AddIngredients", {
ingredients: this.state.ingredients,
units: this.props.units,
});
}} />
</View>
{
this.state.steps.map((step, index) => (
<View style={styles.section} key={step-${index}}>
<Text style={styles.sectionHeader}>Step {index + 1}</Text>
<Divider style={styles.sectionDivider}/>
<Text>{step}</Text>
</View>
))
}
<View style={styles.section}>
<Text style={styles.sectionHeader}>Step {this.state.steps.length + 1}</Text>
<Divider style={styles.sectionDivider} />
<ActionButton icon={require("app/assets/icons/whiteAdd.png")}
text="Add Step"
onPress={() => {
this.props.navigation.navigate("AddStep", {
ingredients: this.state.ingredients
});
}} />
</View>
<View style={styles.section}>
<Text style={styles.sectionHeader}>Notes</Text>
<Divider style={styles.sectionDivider} />
{
this.state.notes === '' ?
<ActionButton icon={require("app/assets/icons/whiteAdd.png")}
text="Add Note"
onPress={() => {
this.props.navigation.navigate("AddNote", {
note: this.state.note
});
}} /> :
<Text>{this.state.notes}</Text>
}
</View>
***<View style={styles.section}>***
<Text style={styles.sectionHeader}>Tags</Text>
<Divider style={styles.sectionDivider} />
{
this.state.tag.map((tag, index) => (
<View style={{ marginBottom: 3, flexDirection: 'row', alignItems: 'center'}} key={'tag-' + index}>
<Text style={{ fontSize: 18 }}>{ tag }</Text>
<Divider></Divider>
</View>
))
}
<ActionButton icon={require("app/assets/icons/whiteAdd.png")}
text="Add Tag"
onPress={() => {
this.props.navigation.navigate("AddTag", {
tag: this.state.tag
});
}} /> :
<Text>{this.state.tag}</Text>
}
</View>
<View style={{ flexDirection: "row", margin: 10, justifyContent: "center", alignItems: "center" }}>
<Text style={{ flex: 1, fontSize: 16 }}>
Private Recipe?
</Text>
<Switch
value={this.state.isPrivate}
onValueChange={priv => this.setState({ isPrivate : priv })}
/>
</View>
</View>
</ScrollView>
</View>);
}
}
It looks like you have an additional } in your code. I have marked it with <- this shouldn't be here. The reason it is saying that the error is at that line, is because that is where the View opens where the error is contained within.
render () {
return (
<View style={{ flex: 1 }}>
<View>
<ActionNavbar title="Add Recipe"
leftAction={this.cancelRecipe}
leftIcon={require('app/assets/icons/cancel.png')}
rightAction={this.saveRecipe}
rightIcon={require('app/assets/icons/check.png')} />
</View>
<ScrollView style={{ flex: 1, maxHeight: this.state.height }} contentContainerStyle={{ paddingBottom: 1000 }}>
<View>
<AddImage />
<Input label="Name of Recipe"
value={this.state.name}
onChangeText={name => this.setState({ name })}
style={styles.nameInput}/>
<View style={{ width: '100%', flexDirection: 'row', justifyContent: 'space-evenly', marginTop: 30 }}>
<View style={{ alignItems: 'center' }}>
<Text style={styles.title}>TOTAL COOK TIME</Text>
<TouchableOpacity onPress={() => {
this.props.navigation.navigate('DurationPicker', {
hours: this.state.hours,
minutes: this.state.minutes
});
}}>
<View style={styles.secondaryButton}>
<Text style={styles.textStyle}>{this.state.durationLabel}</Text>
</View>
</TouchableOpacity>
</View>
<View style={{ alignItems: 'center' }}>
<Text style={styles.title}>Total Servings</Text>
<TouchableOpacity onPress={() => {
this.props.navigation.navigate('ServingsPicker', {
servings: this.state.servings
});
}}>
<View style={styles.secondaryButton}>
<Text style={styles.textStyle}>{this.state.servingsLabel}</Text>
</View>
</TouchableOpacity>
</View>
</View>
<View style={styles.section}>
<Text style={styles.sectionHeader}>Ingredients</Text>
<Divider style={styles.sectionDivider} />
{
this.state.ingredients.map((ingredient, index) => (
<View style={{ marginBottom: 3, flexDirection: 'row', alignItems: 'center' }} key={'ingredient-' + index}>
<View style={styles.ingredientSize}>
<Text style={{ padding: 10 }}>{ingredient.number} {fractionMap[ingredient.fraction]} {ingredient.unitLabel}</Text>
</View>
<Text style={{ fontSize: 18 }}>{ingredient.name}</Text>
<Divider></Divider>
</View>
))
}
<ActionButton icon={require('app/assets/icons/whiteAdd.png')}
text="Add Ingredient"
onPress={() => {
this.props.navigation.navigate('AddIngredients', {
ingredients: this.state.ingredients,
units: this.props.units
});
}} />
</View>
{
this.state.steps.map((step, index) => (
<View style={styles.section} key={`step-${index}`}>
<Text style={styles.sectionHeader}>Step {index + 1}</Text>
<Divider style={styles.sectionDivider}/>
<Text>{step}</Text>
</View>
))
}
<View style={styles.section}>
<Text style={styles.sectionHeader}>Step {this.state.steps.length + 1}</Text>
<Divider style={styles.sectionDivider} />
<ActionButton icon={require('app/assets/icons/whiteAdd.png')}
text="Add Step"
onPress={() => {
this.props.navigation.navigate('AddStep', {
ingredients: this.state.ingredients
});
}} />
</View>
<View style={styles.section}>
<Text style={styles.sectionHeader}>Notes</Text>
<Divider style={styles.sectionDivider} />
{
this.state.notes === ''
? <ActionButton icon={require('app/assets/icons/whiteAdd.png')}
text="Add Note"
onPress={() => {
this.props.navigation.navigate('AddNote', {
note: this.state.note
});
}} />
: <Text>{this.state.notes}</Text>
}
</View>
***<View style={styles.section}>***
<Text style={styles.sectionHeader}>Tags</Text>
<Divider style={styles.sectionDivider} />
{
this.state.tag.map((tag, index) => (
<View style={{ marginBottom: 3, flexDirection: 'row', alignItems: 'center' }} key={'tag-' + index}>
<Text style={{ fontSize: 18 }}>{ tag }</Text>
<Divider></Divider>
</View>
))
}
<ActionButton icon={require('app/assets/icons/whiteAdd.png')}
text="Add Tag"
onPress={() => {
this.props.navigation.navigate('AddTag', {
tag: this.state.tag
});
}} /> :
<Text>{this.state.tag}</Text>
} <- this shouldn't be here
</View>
<View style={{ flexDirection: 'row', margin: 10, justifyContent: 'center', alignItems: 'center' }}>
<Text style={{ flex: 1, fontSize: 16 }}>
Private Recipe?
</Text>
<Switch
value={this.state.isPrivate}
onValueChange={priv => this.setState({ isPrivate: priv })}
/>
</View>
</View>
</ScrollView>
</View>);
}
I suggest you set up linting so that you can catch errors like this.