Fix: My problem was that I didn't know what I should use. And this is which I want.
If you want to make it yourself, see ksav's answer
I have a component which acts as a Picker in React Native.
<Modal
transparent
visible={editVisible}
animationType="fade"
onRequestClose={modalChange}>
<Pressable style={styles.modalView} onPressOut={modalChange}>
<View style={styles.modalContainer}>
<TouchableOpacity style={styles.button} onPressOut={modalChange}>
<Text>Edit button</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.button} onPressOut={modalChange}>
<Text>Delete button</Text>
</TouchableOpacity>
</View>
</Pressable>
</Modal>
<TouchableOpacity onPress={modalChange}>
<Ionicons name="ios-ellipsis-horizontal-sharp" size={20} />
</TouchableOpacity>
I want to set the modalContainer to always be at the bottom of TouchableOpacity (Ionicons). But I set TouchableOpacity's css: position: 'relative' and
modalContainer: {
position: absolute,
bottom: 0,
right: 0,
}
It's not working as expected. Because:
position in React Native is similar to regular CSS, but everything is set to relative by default, so absolute positioning is always relative to the parent.
To simplify the problem, I want some View is always under the button which will show the view when I onPress
My demo
Ensure the parent View is flexing vertically and that your style is position: 'absolute',
import * as React from 'react';
import { Text, View, StyleSheet, TouchableOpacity, Modal, Pressable } from 'react-native';
export default function App() {
const [modalVisible, setModalVisible] = React.useState(false);
return (
<View style={styles.centeredView}>
<Modal
animationType="slide"
transparent={true}
visible={modalVisible}
onRequestClose={() => {
setModalVisible(!modalVisible);
}}
>
<View style={styles.modalContainer}>
<View style={styles.modalView}>
<Text style={styles.modalText}>Hello World!</Text>
<Pressable
style={[styles.button, styles.buttonClose]}
onPress={() => setModalVisible(!modalVisible)}
>
<Text style={styles.textStyle}>Hide Modal</Text>
</Pressable>
</View>
</View>
</Modal>
<Pressable
style={[styles.button, styles.buttonOpen]}
onPress={() => setModalVisible(true)}
>
<Text style={styles.textStyle}>Show Modal</Text>
</Pressable>
</View>
);
}
const styles = StyleSheet.create({
modalContainer: {
position: 'absolute',
bottom: 0,
right: 0,
},
centeredView: {
flex: 1,
justifyContent: "center",
alignItems: "center",
marginTop: 22
},
modalView: {
margin: 20,
backgroundColor: "white",
borderRadius: 20,
padding: 35,
alignItems: "center",
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5
},
});
After discussion, I think what you want would better be described as a tooltip or a popover rather than modal. E.g it is positioned at the bottom of the button that opens it, but doesnt take up any space in the flow.
import * as React from 'react';
import {
Text,
View,
StyleSheet,
TouchableOpacity,
Modal,
Pressable,
SafeAreaView,
} from 'react-native';
export default function App() {
const [tooltipVisible, settooltipVisible] = React.useState(false);
const [buttonHeight, setButtonHeight] = React.useState(0);
const handleLayout = (event) => {
const { x, y, height, width } = event.nativeEvent.layout;
setButtonHeight(height)
};
const handlePress = () => {
settooltipVisible(!tooltipVisible);
};
return (
<SafeAreaView style={styles.centeredView}>
<Pressable
onLayout={handleLayout}
style={[styles.button, styles.buttonOpen]}
onPress={() => settooltipVisible(true)}>
<Text style={styles.textStyle}>Show Thing</Text>
</Pressable>
{tooltipVisible && (
<View style={[styles.tooltipView, {top: buttonHeight}]}>
<Text style={styles.modalText}>Hello World!</Text>
<Pressable
style={[styles.button, styles.buttonClose]}
onPress={handlePress}>
<Text style={styles.textStyle}>Hide Thing</Text>
</Pressable>
</View>
)}
<Text>Some other content</Text>
<Text>Some other content</Text>
<Text>Some other content</Text>
<Text>Some other content</Text>
<Text>Some other content</Text>
<Text>Some other content</Text>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
button: {
padding: 20,
backgroundColor: 'blue',
color: 'white',
},
centeredView: {
justifyContent: 'center',
alignItems: 'center',
marginTop: 60,
},
tooltipView: {
zIndex:1,
padding: 20,
position: 'absolute',
backgroundColor: 'white',
borderRadius: 20,
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5,
},
});
Demo
Related
import React, { useState, useEffect, Component} from 'react';
import { StyleSheet, Text, TouchableOpacity, View, SafeAreaView, Image } from 'react-native';
import Ionicons from 'react-native-vector-icons/Ionicons';
import { Permissions } from 'expo';
import { Container, Content, Header, Item, Icon, Input, Button } from 'native-base';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import { Camera,CameraType } from 'expo-camera';
export default function VideoScreen() {
const [hasCameraPermission, sethasCameraPermission] = useState(null);
const [camera, setCamera] = useState(null);
const [image, setImage] = useState(null);
const [type, setType] = useState(Camera.Constants.Type.front);
useEffect(() => {
(async () => {
const cameraStatus = await Camera.requestCameraPermissionsAsync();
sethasCameraPermission(cameraStatus.status === 'granted');
})();
}, []);
const takePicture = async () => {
if (Camera) {
const data = await camera.takePictureAsync(null)
setImage(data.uri);
}
}
if (hasCameraPermission === false) {
return <Text>No Camera Access</Text>;
}
return (
<View style={{ flex: 1 }}>
<Camera ref={ref => setCamera(ref)} style={{ flex: 1, justifyContent:'space-between' }}>
<Header
searchBar rounded
style={{position: 'absolute', backgroundColor: 'transparent',
left:0, top: 0, right: 0, zIndex:100}}>
<View style={{flexDirection:'row', flex:4}}>
<Icon name="campfire" style={{ color: 'white' }} />
<Item style={{ backgroundColor: 'transparent' }}>
<Icon name="ios-search" style={{color:'white',fontSize:24, fontWeight:'bold'}}></Icon>
<Input placeholder="Search"
placeholderTextColor="white"/>
</Item>
</View>
<View style={{flexDirection:'row', flex:2,justifyContent:'space-around'}}>
<Icon name="ios-flash" style={{ color: 'white', fontWeight:'bold'}} />
<Icon
name="ios-reverse-camera"
style={{ color: 'white', fontWeight: 'bold' }}
onPress={() => {
setType(type ===
Camera.Constants.Type.front ?
Camera.Constants.Type.back :
Camera.Constants.Type.front)
}} />
</View>
</Header>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', paddingHorizontal: 10, marginBottom: 15,alignItems:'flex-end'}} >
<MaterialCommunityIcons name="message-reply"
style={{ color: 'white', fontSize: 36 }}>
</MaterialCommunityIcons>
<View style={{ alignItems: 'center' }}>
<MaterialCommunityIcons name="circle-outline"
style={{ color: 'white', fontSize: 100 }}
onPress={() => takePicture()}>
{image && <Image source={{uri:image}} style={{flex:1}}/>}
</MaterialCommunityIcons>
<Icon name="ios-images" style={{ color: 'white', fontSize: 36 }} />
</View>
<MaterialCommunityIcons name="google-circles-communities"
style={{ color: 'white', fontSize: 36 }}>
</MaterialCommunityIcons>
</View>
</Camera>
</View>
);
};
I am trying to Add a camera page like snapchat camera when you open the app the camera shows up,and you can take the picture or record a video on that, I have try my best to write the code and check agian, and I still keep getting the mistakes saying Rendor Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed
up default and named imports.
Check the render method of VideoScreen.
any suggestions on how to style my touchable opacity buttons to look like in the picture of the right?
so far this is my code and my result is the image of the left..
I know I need to apply justify-content: space-between but somehow I can't figure out how..
import {StyleSheet, View} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {Text} from 'react-native-elements';
const _positionTable = () => {
return (
<View style={styles.tabsContainer}>
<TouchableOpacity style={styles.tab}>
<Text style={styles.text}>MERCADO DE CAPITALES</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.tab}>
<Text style={styles.text}>FONDOS DE INVERSIÓN</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.tab}>
<Text style={styles.text}>MERCADO DE DINERO</Text>
</TouchableOpacity>
</View>
);
};
const styles = StyleSheet.create({
tabsContainer: {
flexDirection: 'row',
marginHorizontal: 20,
marginTop: 20,
maxWidth: '100%',
alignContent: 'center',
borderWidth: 1,
},
tab: {
maxWidth: '30%',
justifyContent: 'space-between',
backgroundColor: 'orange',
},
text: {
fontSize: 14,
color: 'white',
textAlign: 'center',
},
});
export default _positionTable;
You can use flex:1 or set width by calculating, but i guess flex will do it better.
I'm having some issues with FlexBox of an Item in React Native my wish is to have a table using a row with this look:
(Sorry for my poor Paint Skills but all the text Name and numbers should be center vertical and Horizontally)
How it Currently looks:
Now the issue is that as you can see the image gets out of the Card Look and also it is not complete from the Sides.
Also there are other team Data which the images are bigger or the names are bigger and therefore the images is even further to the left :S
Example:
Finally here is the Code of the Item where I create the Row:
import React from 'react';
import { View, Text, Image, StyleSheet } from 'react-native';
import Card from '../UI/Card';
import Colors from '../../constants/Colors';
const TablaItem = props => {
return (
<Card style={styles.product}>
<View style={styles.touchable}>
<View style={styles.container}>
<View style={styles.flexItem}>
<View style={styles.imageContainer}>
<Image style={styles.image} source={{ uri: props.image}} />
</View>
</View>
<View style={styles.flexItem}>
<Text>{props.name}</Text>
</View>
<View style={styles.flexItem}>
<Text>{props.games}</Text>
</View>
<View style={styles.flexItem}>
<Text>{props.win}</Text>
</View>
<View style={styles.flexItem}>
<Text>{props.draw}</Text>
</View>
<View style={styles.flexItem}>
<Text>{props.loose}</Text>
</View>
<View style={styles.flexItem}>
<Text>{props.infavor}</Text>
</View>
<View style={styles.flexItem}>
<Text>{props.against}</Text>
</View>
<View style={styles.flexItem}>
<Text>{props.points}</Text>
</View>
</View>
</View>
</Card>
);
};
const styles = StyleSheet.create({
product: {
height: 50,
margin: 20,
justifyContent: 'center',
alignItems: 'center'
},
container: {
flex: 5,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
display: 'flex',
flexWrap: 'nowrap'
},
flexItem: {
flexGrow: 0,
flexShrink: 1,
flexBasis: 'auto',
alignSelf:'auto',
marginHorizontal: 10,
},
imageContainer: {
alignSelf: 'flex-end',
width: '200%',
height: '100%',
borderTopLeftRadius: 10,
borderTopRightRadius: 10,
marginHorizontal: 10,
},
image: {
width: '100%',
height: '100%'
},
});
export default TablaItem;
And Here the code of the page where I render those items in a FlatList:
import React, { useState, useEffect, useCallback } from 'react';
import { FlatList, Button, ActivityIndicator, View, StyleSheet, Text } from 'react-native';
import { useSelector, useDispatch } from 'react-redux';
import * as tablaActions from '../store/actions/tabla';
import Colors from '../constants/Colors';
import Tabla from '../components/tablas/TablaItem';
import Encabezado from '../components/tablas/TablaEncabecado';
const TablaScreen = props => {
const [isLoading, setIsLoading] = useState(false);
const [isRefreshing, setIsRefreshing] = useState(false);
const [error, setError] = useState();
const tabla1 = useSelector(state => state.tabla.tabla1);
const tabla2 = useSelector(state => state.tabla.tabla2);
const dispatch = useDispatch();
//Aqui se llama a Load Tabla para llamar partidos desde el API
const loadTablas = useCallback(async () => {
setError(null);
setIsRefreshing(true);
try {
await dispatch(tablaActions.fetchTabla());
} catch (err) {
setError(err.message);
}
setIsRefreshing(false);
}, [dispatch, setIsLoading, setError]);
//unsuscribe de Tablas
useEffect(() => {
const unsubscribeTablas = props.navigation.addListener('focus', loadTablas);
return () => {
unsubscribeTablas();
};
}, [loadTablas]);
//useEffect (carga inicial) de Tablas
useEffect(() => {
setIsLoading(true);
loadTablas().then(() => {
setIsLoading(false);
});
}, [dispatch, loadTablas]);
if (error) {
return <View style={styles.centered} >
<Text>Ah Ocurrido un Error {error}</Text>
<Button title='Probar de Nuevo' onPress={loadTablas} color={Colors.secondary} />
</View>
}
if (isLoading) {
return <View style={styles.centered} >
<ActivityIndicator size='large' color={Colors.secondary} />
</View>
}
//Checkeo de Partidos no Vacio.
if (!isLoading && tabla1 === 0 || tabla2 === 0) {
return <View style={styles.centered} >
<ActivityIndicator size='large' color={Colors.secondary} />
</View>
}
return(
<>
<Text style={styles.grupo}>Grupo A</Text>
<FlatList
onRefresh={loadTablas}
refreshing={isRefreshing}
data={tabla1}
keyExtractor={item => item.teamId.toString()}
renderItem={
itemData => <Tabla
image={itemData.item.logo}
name={itemData.item.teamName}
games={itemData.item.matchsPlayed}
win={itemData.item.win}
draw={itemData.item.draw}
loose={itemData.item.lose}
infavor={itemData.item.goalsFor}
against={itemData.item.goalsAgainst}
points={itemData.item.points}
/>
}
/>
<Text style={styles.grupo}>Grupo B</Text>
<FlatList
onRefresh={loadTablas}
refreshing={isRefreshing}
data={tabla2}
keyExtractor={item => item.teamId.toString()}
renderItem={
itemData => <Tabla
image={itemData.item.logo}
name={itemData.item.teamName}
games={itemData.item.matchsPlayed}
win={itemData.item.win}
draw={itemData.item.draw}
loose={itemData.item.lose}
infavor={itemData.item.goalsFor}
against={itemData.item.goalsAgainst}
points={itemData.item.points}
/>
}
/>
</>
);
};
export const screenOptions = navData => {
return {
headerTitle: 'Tabla de Clasificacion',
// headerLeft: () => (<HeaderButtons HeaderButtonComponent={HeaderButton}>
// <Item
// title='Menu'
// iconName={Platform.OS === 'android' ? 'md-menu' : 'ios-menu'}
// onPress={() => {
// navData.navigation.toggleDrawer();
// }} />
// </HeaderButtons>),
// headerRight: () => (<HeaderButtons HeaderButtonComponent={HeaderButton}>
// <Item
// title='Carretilla'
// iconName={Platform.OS === 'android' ? 'md-cart' : 'ios-cart'}
// onPress={() => {
// navData.navigation.navigate('Cart');
// }} />
// </HeaderButtons>)
}
};
const styles = StyleSheet.create({
centered: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
grupo: {
alignSelf: 'center',
fontWeight: 'bold',
fontSize: 16,
color: Colors.primary,
marginTop: 10,
}
});
export default TablaScreen;
I will also like to render the lines of the Flatlist one beneath the other with just a minimum gap currently it looks like this:
And will also like to add to the top something like this:
Which is basically a Header with the same style, and it will have the titles:
Equipo (which will be the length of the Image and Name), Juegos, Ganados, Empates, Perdidos, Afavor, Encontra, Puntos.
This Last part is just a wish to know.
Any Ideas?
Give your Image resizeMode of "contain" or "cover"
<Image
resizeMode="contain"
style={{ flex: 1 }}
source={{ uri: 'https://ezgif.com/images/insert-image.png' }}
/>
Working Example: Expo Snack
Sample Output:
Sample App Source Code:
import React from 'react';
import { View, Text, Image, StyleSheet } from 'react-native';
import { Card } from 'react-native-paper';
export default TablaItem = (props) => {
return (
<View style={{ flex: 1, backgroundColor: '#212121' }}>
<View style={styles.card}>
<View>
<View style={styles.imageCircle}>
<Image
resizeMode="cover"
style={{ flex: 1 }}
source={{ uri: 'https://ezgif.com/images/insert-image.png' }}
/>
</View>
</View>
<View style={{ marginLeft: 10, flex: 2 }}>
<Text style={styles.text}>{'Alianza Alianza'}</Text>
</View>
<View
style={{
flexDirection: 'row',
flex: 7,
justifyContent: 'space-evenly',
}}>
<View>
<Text style={styles.text}>{10}</Text>
</View>
<View>
<Text style={styles.text}>{6}</Text>
</View>
<View>
<Text style={styles.text}>{4}</Text>
</View>
<View>
<Text style={styles.text}>{0}</Text>
</View>
<View>
<Text style={styles.text}>{15}</Text>
</View>
<View>
<Text style={styles.text}>{9}</Text>
</View>
<View>
<Text style={styles.text}>{20}</Text>
</View>
</View>
</View>
</View>
);
};
const styles = StyleSheet.create({
imageCircle: {
width: 50,
height: 50,
backgroundColor: 'white',
borderRadius: 25,
padding: 8,
borderWidth: 2,
borderColor: 'rgba(21,21,21,0.2)',
justifyContent: 'center',
alignContent: 'center',
},
card: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: 'white',
borderRadius: 10,
margin: 10,
paddingHorizontal: 5,
padding: 2,
marginTop: 30,
},
text: {
fontSize: 14,
fontWeight: '600',
},
});
Im building an autocomplete feature in react-native .
Here the problem is when i wrap the flatlist with styling position 'absolute' onpress not responding.
return ( <View style={styles.userNameSearchContainer}>{searchUserName()}</View>
<View style={styles.sendInviteContainer}>{sendInvite()}</View>)
const searchUserName = () => {
let searchUser = (
<KeyboardAvoidingView>
<View>
<Text style={styles.searhUserTitle}>Search by username</Text>
</View>
<View style={styles.searchUserInputWrapper}>
<Image
style={styles.searchIcon}
source={require("../../../assets/Images/search.png")}
/>
<TextInput
style={{ flex: 1 }}
placeholder={"#user114"}
value={searchText}
onChangeText={(text) => onSearchTextChanged(text)}
/>
</View>
<View>
<FlatList
style={{ position:'absolute', width: "100%" }}
data={filteredUsers}
renderItem={renderItem}
keyExtractor={(item) => item.id}
/>
</View>
</KeyboardAvoidingView>
);
return searchUser;
};
const renderItem = ({ item }) => (
<TouchableOpacity onPress={(item) => console.log(item)}>
<View style={styles.item}>
<Text style={styles.title}>{item.title}</Text>
</View>
</TouchableOpacity> );
I have tried importing touchableOpacity from gesture-handler and touchablewithoutfeedback.
Heres is an example
snack: https://snack.expo.io/#ashwith00/ranting-bubblegum
import * as React from 'react';
import {
Text,
View,
StyleSheet,
FlatList,
TextInput,
TouchableOpacity,
} from 'react-native';
import Constants from 'expo-constants';
// You can import from local files
import AssetExample from './components/AssetExample';
// or any pure javascript modules available in npm
import { Card } from 'react-native-paper';
const searchResult = ['data1', 'data2', 'data3', 'data4', 'data5'];
export default function App() {
const [str, setStr] = React.useState('');
return (
<View style={styles.container}>
<TextInput style={styles.input} onChangeText={(st) => setStr(st)} />
<View style={[styles.list, ]}>
{str.length > 0 && <FlatList
data={searchResult}
renderItem={({ item }) => (
<TouchableOpacity
style={styles.item}
onPress={() => console.log(item)}>
<Text style={styles}>{item}</Text>
</TouchableOpacity>
)}
/>}
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: Constants.statusBarHeight || 10,
backgroundColor: '#ecf0f1',
padding: 8,
},
paragraph: {
margin: 24,
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
},
input: {
alignSelf: 'stretch',
height: 50,
backgroundColor: 'white',
},
item: {
alignSelf: 'stretch',
justifyContent: 'center',
alignItems: 'center',
height: 50,
backgroundColor: 'white',
},
list: {
position: 'absolute',
top: 60,
left: 0,
right: 0,
paddingHorizontal: 10,
height: 200,
},
});
I discovered flexbox recently and I'm struggling to make it work, I'm surely missed some concept that make me hard time to understands it's mechanics so here is what I have:
It's a preview camera screen
with a back button on the top right
A text in the middle
and a record button to shoot some images
Here is what I have at the moment:
this is done with this React native component (style included)
import React from "react";
import { RNCamera } from "react-native-camera";
import { StyleSheet, TouchableOpacity, View, Platform} from "react-native";
import {Icon, Text} from "native-base";
import RequestPermissions from "../components/Permissions/RequestPermissions";
import I18n from "../i18n/i18n";
/**
* This is the component which allows the user to film his own film
*/
export default class CameraScreen extends React.Component
{
constructor(props) {
super(props);
this.camera = null;
}
state = {
isRecording: false,
iconVid: "record",
iconMode: null,
overlay: true
};
/**
* With RNCamera, it seems that permission is always asked to the user... Maybe this code is then irrelevant
*/
componentWillMount() {
if (Platform.OS === "android") {
RequestPermissions().then(() => {
console.log("granted");
}).then((err) => {
console.log(err)
});
}
}
componentWillUnmount() {
this.stopRecording();
};
stopRecording = () => {
if (this.camera) {
this.camera.stopRecording();
this.setState({
isRecording: false,
iconVid: "record"
});
}
};
renderCamera = () => {
return (
<View style={styles.container}>
<RNCamera
ref={cam => {
this.camera = cam;
}}
style={styles.preview}
>
<View style={styles.controlsContainer}>
<View style={styles.topRightButton}>
<TouchableOpacity onPress={() => this.props.navigation.goBack()}>
<Icon name={"arrow-left"} type={"Feather"} style={styles.iconFurtive}/>
</TouchableOpacity>
</View>
<View style={styles.middleContainer}>
<Text style={styles.actionText}>{I18n.t("action_text").toUpperCase()}</Text>
</View>
<View style={styles.leftContainer}>
<TouchableOpacity onPress={() => this.recordVideo()}>
<Icon name={this.state.iconVid} type={"MaterialCommunityIcons"} style={styles.iconCamera}/>
</TouchableOpacity>
</View>
</View>
</RNCamera>
</View>
);
};
/**
* For more options
* https://github.com/react-native-community/react-native-camera/blob/master/docs/RNCamera.md#recordasyncoptions-promise
*/
recordVideo = () => {
if (this.camera) {
this.setState({ isRecording: true, iconVid: "stop" });
// Show the overlay
console.log("Device is Recording");
this.camera.recordAsync({maxDuration: 15}).then(data => {
this.stopRecording();
console.log("Stop Recording");
console.log(data);
}).catch((err) => {
console.log(err);
this.stopRecording();
});
}
};
render() {
return this.renderCamera()
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop:30,
},
controlsContainer: {
flex: 1,
flexDirection: "column"
},
topRightButton: {
flex: 1,
justifyContent: 'flex-start',
alignItems: 'flex-start',
},
middleContainer: {
flex: 0.5,
justifyContent: 'center',
alignItems: 'center',
},
leftContainer: {
flex: 0.5,
justifyContent: 'center',
alignItems: 'flex-end',
},
actionText: {
color: "#fff",
fontSize: 72
},
preview: {
flex: 1,
},
iconCamera: {
color: "#ff4459",
marginBottom: 50,
padding: 25,
backgroundColor: "#fff",
borderRadius: 50,
},
iconFurtive: {
color: "#fff",
marginTop: 50,
marginLeft: 50,
}
});
Here is what I want:
How to do that with flexbox? What am I missing?
Code changed at View with {styles.topRightButton}
return (
<View style={styles.container}>
<RNCamera
ref={cam => {
this.camera = cam;
}}
style={styles.preview}
>
<View style={styles.controlsContainer}>
<View style={{justifyContent: 'flex-start', alignItems: 'flex-start',}}>
<TouchableOpacity onPress={() => this.props.navigation.goBack()}>
<Icon name={"arrow-left"} type={"Feather"} style={styles.iconFurtive}/>
</TouchableOpacity>
</View>
<View style={{flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-around'}}>
<View style ={{height: 50, width: 50, backgroundColor: 'transparent'}} />
<Text style={styles.actionText}>{I18n.t("action_text").toUpperCase()}</Text>
<TouchableOpacity onPress={() => this.recordVideo()}>
<Icon name={this.state.iconVid} type={"MaterialCommunityIcons"}/>
</TouchableOpacity>
</View>
</View>
</RNCamera>
</View>
);
For middle and left the content should be in the same div with that div having a flexDrirection: 'row'. This puts them in the same row.
The controls container can have justifyContent: 'center', and alignItems: 'center'.
The topRightButton should override the parents style.