On adding viewpager videos are not getting displayed - reactjs

I have used a flatlist to list 4 videos getting fetched from an API, however I want them to scroll one at a time, hence added viewpager to render each video as a separate page, however on adding viewpager I do not seem to retrieve the videos on front-end, however they are appearing on my logs.
Code with viewpager:
<ViewPager scrollEnabled={true} orientation={"vertical"} >
<FlatList
data={this.state.data.product}
scrollEventThrottle={1}
onEndThreshold={0}
renderItem={({ item }) => (
<View style = {{alignContent: 'stretch'}} >
<ScrollView scrollEventThrottle={1}>
<ViewportAwareVideo
repeat paused={this.state.videoPaused}
source={{ uri: item.urlVid }}
resizeMode = "cover"
preTriggerRatio={PRE_TRIGGER_RATIO}
retainOnceInViewport={false}
style={{width: width, height:height}}
innerRef={ref => this._videoRef = ref}
onViewportEnter={() => this._videoRef.play()}
onViewportLeave={() => this._videoRef.stop()}
/>
</ScrollView>
<View
style={{
position: 'absolute',
flexDirection: 'column',
alignItems: 'flex-end',
top: '50%',
right: 10,
}}>
<TouchableOpacity
onPress= {() => this.onButtonPress(item)}
style={{
alignItems: 'center',
borderRadius: 60,
padding: 10,
}}>
<Icon
name="heart"
size={30}
color={this.state.likedItemIds.includes(item._id) ? "red" : "white"}
/>
</TouchableOpacity>
<TouchableOpacity
onPress={()=>this.shareProduct(item)}
style={{
alignItems: 'center',
borderRadius: 60,
padding: 10,
}}>
<Icon name="share" size={30} color="white" />
</TouchableOpacity>
<Text style={{ right: 5, color: 'white' }} />
<TouchableOpacity
style={{
alignItems: 'center',
borderRadius: 60,
padding: 10,
}}>
<Icon name="whatsapp" size={30} color="white" />
</TouchableOpacity>
<Text style={{ right: 5, color: 'white' }} />
<TouchableOpacity
onPress= {() => this.download(item)}
style={{
alignItems: 'center',
borderRadius: 60,
padding: 10,
}}>
<Icon name="download" size={30} color="white" />
</TouchableOpacity>
<Text style={{ right: 5, color: 'white' }} />
</View>
<View
style={{
position: 'absolute',
flexDirection: 'column',
top: '90%',
left: 10,
}}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Product', {_id: item._id})}>
<View
style={{
flexDirection: 'row',
}}>
<Text
style={{ fontWeight: 'bold', fontSize: 20, color: 'white' }}>
{item.title} - {item.price}
</Text>
</View>
</TouchableOpacity>
</View>
</View>
)}
keyExtractor={ item => item._id}
/>
</ViewPager>
Please help me, and let me know why is it so?

Related

Vertical scrolling where attribute name row is fixed and horizontal scrolling where left most column is fixed in React Native

So far I've achieved this:
//code on data listing screen with a vertical flatlist
const DataListing = props => {
const memoizedValue = useMemo(() => renderItem, [props.coinData]);
const renderItem = ({item}) => {
return (
<View
style={{
flexDirection: 'row',
backgroundColor: item?.id % 2 ? '#ffffff' : '#f9f9f9f9',
height: 40,
alignItems: 'center',
}}>
{/* coin */}
{item.coin ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.coin}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* open time */}
{item.openTime ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.openTime}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* open */}
{item.open ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.open}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* high */}
{item.high ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.high}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* low */}
{item.low ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.low}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* close */}
{item.close ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.close}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* quote asset volume */}
{item.quoteAssetVolume ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.quoteAssetVolume}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* trade number */}
{item.tradeNumber ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.tradeNumber}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* tracker buy base */}
{item.takerBuyBase ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.takerBuyBase}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* tracker buy quote */}
{item.takerBuyQuote ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.takerBuyQuote}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* price change */}
{item.priceChange ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.priceChange}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* price change % */}
{item.priceChangePercent ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.priceChangePercent}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* previos close price */}
{item.prevClosePrice ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.prevClosePrice}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* last price */}
{item.lastPrice ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.lastPrice}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* open price */}
{item.openPrice ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.openPrice}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* low price */}
{item.lowPrice ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.lowPrice}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* price volume */}
{item.pricevolume ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.pricevolume}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* quote volume */}
{item.quoteVolume ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.quoteVolume}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* price open time */}
{item.priceopenTime ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.priceopenTime}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* price close time */}
{item.pricecloseTime ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.pricecloseTime}
</Text>
) : (
<View style={{width: 150}} />
)}
{/* created at */}
{item.created_at ? (
<Text style={{width: 150, textAlign: 'center', color: '#000000'}}>
{item.created_at}
</Text>
) : (
<View style={{width: 150}} />
)}
</View>
);
};
return (
<FlatList
showsVerticalScrollIndicator={false}
data={props.coinData}
keyExtractor={(item, index) => index}
renderItem={renderItem}
/>
);
};
export default DataListing;
// code on data attributes page
const DataAttributes = props => {
return (
// container
<View style={{flexDirection: 'row'}}>
{/* coin name */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
COIN
</Text>
</TouchableOpacity>
{/* open time */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
OPEN TIME
</Text>
</TouchableOpacity>
{/* open */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
OPEN
</Text>
</TouchableOpacity>
{/* high */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
HIGH
</Text>
</TouchableOpacity>
{/* low */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
LOW
</Text>
</TouchableOpacity>
{/* close */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
CLOSE
</Text>
</TouchableOpacity>
{/* quote asset volume */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
VOLUME
</Text>
</TouchableOpacity>
{/* trade number */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
TRADE NUMBER
</Text>
</TouchableOpacity>
{/* taker buy base */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
TAKER BUY BASE
</Text>
</TouchableOpacity>
{/* taker buy quote */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
TAKER BUY QUOTE
</Text>
</TouchableOpacity>
{/* price change */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
PRICE CHANGE
</Text>
</TouchableOpacity>
{/* price change percent */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
PRICE CHANGE %
</Text>
</TouchableOpacity>
{/* previos close price */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
PREVIOUS CLOSE PRICE
</Text>
</TouchableOpacity>
{/* last price */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
LAST PRICE
</Text>
</TouchableOpacity>
{/* open price */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
OPEN PRICE
</Text>
</TouchableOpacity>
{/* low price */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
LOW PRICE
</Text>
</TouchableOpacity>
{/* price volume */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
PRICE VOLUME
</Text>
</TouchableOpacity>
{/* quote volume */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
QUOTE VOLUME
</Text>
</TouchableOpacity>
{/* price open time */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
PRICE OPEN TIME
</Text>
</TouchableOpacity>
{/* price close time */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
borderColor: '#31313199',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
PRICE CLOSE TIME
</Text>
</TouchableOpacity>
{/* created at */}
<TouchableOpacity
style={{
flexDirection: 'row',
backgroundColor: '#FDE047',
height: 40,
width: 150,
alignItems: 'center',
justifyContent: 'center',
}}
onPress={() => {}}>
<Text
style={{
fontSize: 10,
fontWeight: '400',
color: '#000000',
}}>
CREATED AT
</Text>
</TouchableOpacity>
</View>
);
};
export default DataAttributes;
// then they are imported to home and put inside a horizontal scrollview
import DataAttributes from '../Components/HomeScreen/DataAttributes';
import DataListing from '../Components/HomeScreen/DataListing';
const HomeScreen = ({navigation}) => {
const [coinData, setCoinData] = useState([]);
useEffect(() => {
coinStastics();
}, []);
// fetching coin statistics
const coinStastics = async () => {
const header = {
'Content-Type': 'application/json',
};
await axios
.post(baseUrl + coin_statistics, '', {headers: header})
.then(res => {
setCoinData(res.data.data);
})
.catch(function (error) {
// handle error
console.log(error);
});
};
return (
<SafeAreaView
style={{
flex: 1,
alignItems: 'center',
}}>
<Header/>
{/* DATA */}
<ScrollView horizontal showsHorizontalScrollIndicator={false}>
<View>
{/* attributes for data */}
<DataAttributes coinData={coinData} setCoinData={setCoinData} />
{/* data section */}
<DataListing coinData={coinData} />
</View>
</ScrollView>
<Footer />
</>
)}
</SafeAreaView>
);
};
export default HomeScreen;
I am expecting something like this, where I can scroll the data portion vertically where the the column names / attribute names stay fixed but as soon I start scrolling horizontally all the columns should start to respond except the left most one, it should stay fixed along with it's COLUMN NAME on top

KeyboardAvoidingView is not adjusting height

Im trying to get my text view and button to center when the Keyboard is summoned.
I tried wrapping my SafeArea with KeyboardAvoidingView but that did not seem to work.
I also tried setting the KeyBoardAvoidingView behavior to position which also did not work.
Any guidance would be appreciated.
KeyboardAvoidingView does not seem to work as expected.
**Whats happening : **
**Heres my code : **
<SafeAreaView style={{ flex: 1, backgroundColor: '#376772' }}>
<KeyboardAvoidingView
style={{ flex: 1 }}
behavior={Platform.Os == 'ios' ? 'padding' : null}
>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View style={{ flex: 1 }}>
<MapView
style={{ flex: 0.6 }}
showsMyLocationButton={true}
showsUserLocation={true}
followsUserLocation={lock}
onTouchStart={() => {
set(false)
}}
onPress={(loc) => {
setLocation(loc.nativeEvent.coordinate)
}}
>
<Marker coordinate={location} />
</MapView>
<Fragment>
<View
style={{
alignSelf: 'center',
alignContent: 'center',
backgroundColor: '#202B35',
padding: 10,
paddingHorizontal: 35,
margin: 5,
borderRadius: 5,
alignItems: 'center',
position: 'absolute',
}}
>
<View style={{ flexDirection: 'row' }}>
<Badge
status="error"
containerStyle={{ padding: 5 }}
/>
<Text
style={{
color: '#fff',
fontSize: 16,
marginBottom: 5,
}}
>
New Crossing
</Text>
<Text
style={{
color: '#fff',
fontSize: 10,
padding: 5,
}}
>
(Tap to add)
</Text>
</View>
<View style={{ flexDirection: 'row' }}>
<Badge
status="primary"
containerStyle={{ padding: 5 }}
/>
<Text
style={{
color: '#fff',
fontSize: 16,
}}
>
{'Existing Crossings'}
</Text>
</View>
</View>
</Fragment>
<View
style={{
flex: 0.4,
backgroundColor: '#376772',
margin: 5,
borderRadius: 5,
}}
>
<Input
placeholder="Enter Crossing name here"
inputStyle={{ color: 'orange' }}
rightIcon={
<Icon
name="edit"
size={25}
color="orange"
/>
}
placeholderTextColor={'orange'}
errorStyle={{ color: 'red' }}
/>
<Button
buttonStyle={{
margin: 10,
top: scale(10),
padding: 15,
backgroundColor: '#5cb85c',
borderRadius: 4,
}}
icon={
<Icon name="send" size={15} color="white" />
}
iconRight
titleStyle={{ fontWeight: 'bold' }}
title="Submit "
/>
</View>
</View>
</TouchableWithoutFeedback>
</KeyboardAvoidingView>
</SafeAreaView>
Setting behavior to "position" worked for me by removing flex: 1 from styles, like
<KeyboardAvoidingView behavior="position">
{children}
</KeyboardAvoidingView>
Cheers!

How do I remove the status bar and overlap icons over the video?

[![enter image description here][2]][2]
I require the icons on the video, however I want them to stick when one scrolls down, I have inserted the icons outside the flatlist but am not able to remove the white space, can anyone help?
The follwing is the return function where I have implemented the icons:
<View style={{flex:1}}>
<View style={{flexDirection:'row', justifyContent: 'flex-end', position:'absolute', zIndex:1}}>
<TouchableOpacity>
<Icon
name="shopping-cart"
size={24}
style={{ paddingRight: 40 }}
color="black"
/>
</TouchableOpacity>
<TouchableOpacity>
<Icon
name="user-circle"
size={24}
style={{ paddingRight: 20 }}
color="black"
/>
</TouchableOpacity>
</View>
<FlatList
data={this.state.data.product}
renderItem={({ item }) => (
<View style = {{alignContent: 'stretch'}}>
{/* {this.header} */}
<ViewportAwareVideo
source={{ uri: item.urlVid }}
visible={this.state.visible}
resizeMode = "cover"
style={{width: width, height:height}}
innerRef={ref => this._videoRef = ref}
onViewportEnter={() => this._videoRef.play()}
onViewportLeave={() => this._videoRef.stop()}
/>
<View
style={{
position: 'absolute',
flexDirection: 'column',
alignItems: 'flex-end',
top: '50%',
right: 10,
}}>
<TouchableOpacity
onPress={this.handleClick}
style={{
alignItems: 'center',
borderRadius: 60,
padding: 10,
}}>
<Icon
name="heart"
size={30}
color={this.state.buttonColor}
onPress={this.onButtonPress}
/>
</TouchableOpacity>
<TouchableOpacity
style={{
alignItems: 'center',
borderRadius: 60,
padding: 10,
}}>
<Icon name="share" size={30} color="white" />
</TouchableOpacity>
<Text style={{ right: 5, color: 'white' }} />
<TouchableOpacity
style={{
alignItems: 'center',
borderRadius: 60,
padding: 10,
}}>
<Icon name="whatsapp" size={30} color="white" />
</TouchableOpacity>
<Text style={{ right: 5, color: 'white' }} />
<TouchableOpacity
style={{
alignItems: 'center',
borderRadius: 60,
padding: 10,
}}>
<Icon name="download" size={30} color="white" />
</TouchableOpacity>
<Text style={{ right: 5, color: 'white' }} />
</View>
<View
style={{
position: 'absolute',
flexDirection: 'column',
top: '90%',
left: 10,
}}>
<View
style={{
flexDirection: 'row',
}}>
<Text
style={{ fontWeight: 'bold', fontSize: 20, color: 'white' }}>
{item.title} - {item.price}
</Text>
</View>
</View>
</View>
)}
keyExtractor={ item => item.id}
/>
</View>
After adding Zindex and making the position absolute am still having this white space on top, please tell me how to remove it completely
<TouchableOpacity
style={{
position: 'absolute',
top:10,
left:10,
z-index:100
}}>
<Icon
name="shopping-cart"
size={24}
style={{ paddingRight: 40 }}
color="black"
/>
</TouchableOpacity>
<TouchableOpacity
style={{
position: 'absolute',
top:10,
left:30,
z-index:100
}}
>
<Icon
name="user-circle"
size={24}
style={{ paddingRight: 20 }}
color="black"
/>
</TouchableOpacity>
For status bar: you can use StatusBar
<StatusBar hidden /> // import from react-native and use it in your component
For Overlap you can use style position :- absolute to your icons
position : "absolute" // also you can set top , bottom , right to your icons
Use zIndex : 500 to show your icon on top of other view

react native touchable click for Android and ios conditional

I am trying to create multiple instances with touchable-click for Android and ios and I'm having trouble figuring out where to place the conditional I keep getting errors for unexpected token. I want to set a conditional where if the app is on android switch to touchablenativefeedback and if not stay with touchableopacity.
{Platform.OS === 'android' ?
<TouchableNativeFeedback
onPress={gotoedit}
style={{ justifyContent: 'center'}}
>
<View>
<Entypo
name={'edit'}
size={22}
color={Colors.offWhite}
style={{ paddingHorizontal: 10 }}
/>
{/* <View
style={{
marginLeft: 0,
width: 20,
height: 20,
borderRadius: 10,
backgroundColor: Colors.red,
justifyContent: 'left',
alignItems: 'left',
}}
>
<Text style={{ color: Colors.offWhite, fontWeight: '600' }}>{UnreadNotifications && UnreadNotifications.length}</Text>
</View> */}
</View>
</TouchableNativeFeedback>
:
<TouchableOpacity
onPress={gotoedit}
style={{ justifyContent: 'center'}}
>
<View>
<Entypo
name={'edit'}
size={22}
color={Colors.offWhite}
style={{ paddingHorizontal: 10 }}
/>
{/* <View
style={{
marginLeft: 0,
width: 20,
height: 20,
borderRadius: 10,
backgroundColor: Colors.red,
justifyContent: 'left',
alignItems: 'left',
}}
>
<Text style={{ color: Colors.offWhite, fontWeight: '600' }}>{UnreadNotifications && UnreadNotifications.length}</Text>
</View> */}
</View>
</TouchableOpacity>
}
);

React Native FlexLayout: Alignment item right

I have a list of products and want to display the text "ITEM UNIT" at the right end of my infobox. It is however affected by the position of the text above it.
How do I solve this and put "ITEM UNIT" to the right end of the display?
<TouchableOpacity
onPress={() => this.props.onItemClicked(this.props.item)}
style={{ marginRight: 130 }}
>
<View style={styles.itemContent}>
<View>
<FadeIn>
<Image
resizeMode="contain"
style={{
height: 100,
width: 100,
marginTop: 10,
marginLeft: 10
}}
source={{ uri: url }}
/>
</FadeIn>
</View>
<View style={{ justifyContent: "space-around" }}>
<Text style={{ fontSize: 16, fontFamily: "System" }}>
{articleName}
</Text>
<View
style={{
flexDirection: "row",
justifyContent: "space-between"
}}
>
<View style={{ flexDirection: "row" }}>
<Text style={styles.itemPrice}>{originalprice} </Text>
<Text style={styles.itemPriceReduced}>{specialprice}€</Text>
</View>
<View>
<Text>ITEMUNIT</Text>
</View>
</View>
</View>
</View>
</TouchableOpacity>;
I crated a small demo for you. Please check it here:
https://snack.expo.io/#tarikfojnica/layout (Click Tap To Play on the right side)
Here are the code parts you should check:
<TouchableOpacity style={styles.container} onPress={() => this.props.onItemClicked(this.props.item)}>
<View style={styles.itemContent}>
<View style={styles.iconContainer}>
<Image source={Icon} style={styles.icon} />
</View>
<View style={styles.textContainer}>
<Text>This is the title </Text>
<View style={styles.downText}>
<View style={styles.priceText}>
<Text style={{marginRight: 10}}>$99.9</Text>
<Text>$99.9</Text>
</View>
<View style={styles.label}>
<Text>Label</Text>
</View>
</View>
</View>
</View>
</TouchableOpacity>
const styles = StyleSheet.create({
container: {
marginTop: 24,
},
itemContent: {
flexDirection: 'row',
borderBottomWidth: 1,
borderColor: 'e5e5e5'
},
iconContainer: {
padding: 10,
flex: 1,
},
icon: {
width: 40,
heigth: 40
},
textContainer: {
backgroundColor: 'whitesmoke',
flex: 7,
padding: 5
},
downText: {
marginTop: 10,
flexDirection: 'row',
justifyContent: 'space-between'
},
priceText: {
flexDirection: 'row',
},
label: {
textAlign: 'right',
backgroundColor: 'yellow',
padding: 3
}
});
For a reference, here is how it looks like:
PS: I would avoid writing inline styles.

Resources