React Native progress fill screen - react-native

In my app, I am trying to display a progress bar using the ActivityIndicator upon a click event on a TouchableHightlight element. The problem is that I would like to have my progress bar fill up the whole screen (even filling up the spaces occupied by the navigation bar). Or if it is possible, a progress bar that takes up all the touch events on the screen while it is being displayed.
render()
{
let progress;
if (this.state.isLoading) {
progress = <ActivityIndicator style={[progressStyle.container, progressStyle.horizontal]}/>
}
return (
<ScrollView>
<View style={{
zIndex: 1,
flex: 1,
alignItems: 'center',
justifyContent: "flex-start",
}}>
<View style={{
flex: 1,
alignItems: 'flex-end',
paddingTop: 5,
paddingHorizontal: 10,
marginBottom: 10
}}>
<View style={{
flex: 1,
flexDirection: 'row',
alignItems: 'center',
marginTop: 8,
marginBottom: 8
}}>
<Text style={labelStyle}>Name: </Text>
<TextInput
style={ textInputStyle }
value={ this.state.name }
onChangeText={(text) => {
this.setState({
name: text
});
}} />
</View>
<View style={{
flex: 1,
flexDirection: 'row',
alignItems: 'center',
marginBottom: 8
}}>
<Text style={labelStyle}>Start Date: </Text>
<DatePicker
style={ datePickerStyle }
date={this.state.startDate}
mode="date"
placeholder="select start date"
format="YYYY-MM-DD"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
onDateChange={(date) => {
this.setState({startDate: date});
}} />
</View>
<View style={{
flex: 1,
flexDirection: 'row',
alignItems: 'center',
marginBottom: 8
}}>
<Text style={labelStyle}>End Date: </Text>
<DatePicker
style={ datePickerStyle }
date={this.state.endDate}
mode="date"
placeholder="select end date"
format="YYYY-MM-DD"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
onDateChange={(date) => {
this.setState({endDate: date});
}} />
</View>
<View style={{
flex: 1,
flexDirection: 'row',
alignItems: 'center',
marginBottom: 8
}}>
<Text style={labelStyle}>Max members: </Text>
<TextInput
style={ textInputStyle }
keyboardType="numeric"
value={ this.state.maxMembers }
onChangeText={(text) => {
this.setState({
maxMembers: text
});
}} />
</View>
<View style={{
flex: 1,
flexDirection: 'row',
alignItems: 'center',
marginBottom: 8
}}>
<Text style={labelStyle}>Available Until: </Text>
<DatePicker
style={ datePickerStyle }
date={this.state.availabilityDeadLine}
mode="date"
placeholder="select date til when this space is available"
format="YYYY-MM-DD"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
customStyles={{
placeholderText:{
textAlign: 'center'
}
}}
onDateChange={(date) => {
this.setState({availabilityDeadLine: date});
}} />
</View>
</View>
<ListOption
text="Create Room"
style={{
backgroundColor: (this.state.name!='' && this.state.startDate!=''
&& this.state.endDate!='' && this.state.maxMembers!=''
&& this.state.availabilityDeadLine!='')? Colors.tintColor : '#232323',
textColor: Colors.tintTextColor,
}}
onClick={
() => {
this.state.isLoading=true; this.setState({});
var tDate = new Date();
tDate.setHours(0,0,0,0);
if(this.state.name != '' && this.state.startDate != '' &&
this.state.endDate != '' && this.state.maxMembers != '' &&
this.state.availabilityDeadLine != ''){
if(new Date(this.state.startDate) > new Date(this.state.endDate)){
Alert.alert("start date cannot be after end date");
} else if(new Date(this.state.endDate) < tDate) {
Alert.alert("end date cannot be before today");
} else if(new Date(this.state.availabilityDeadLine) < tDate) {
Alert.alert("space has to be available at least up until today");
} else {
// this.state.isLoading = false;
// this.props.navigation.goBack();
}
}
}
} />
</View>
{progress}
</ScrollView>
);
}
const progressStyle = StyleSheet.create({
container: {
zIndex: 4,
justifyContent: 'center',
backgroundColor: '#565656',
position: 'absolute',
top:0, left: 0, right: 0, bottom: 0
},
horizontal: {
flexDirection: 'row',
justifyContent: 'space-around',
padding: 10
}
})
I've tried giving contentContainerStyle={{flex:1}} to my ScrollView but I don't want my ListOption element to take up all the leftover space on screen and look fat. Right now, my ActivityIndicator takes up the whole of ScrollView, which is not taking up the whole screen.
So, will there be any way for me to give different flex abilities to the children of ScrollView element such that I can have my ActivityIndicator take up the whole screen while my View takes up as much as its contents?

You would need to wrap it inside a modal if you want it to fill the entire and set {width: "100%", height: "100%"}

Related

how to use inline flex property in react native

Here's what I'm trying to achieve:
I want to display inline all these three elements inside each Block.
Here's what I have done so far:
export default function App() {
const cheers = [
'cheers',
'high five'
]
return (
<Block style={{ flex: 1,
flexDirection: "row",
alignContent: "space-between",
marginTop: 50}}
>
<Block style={{ flex: 2, justifyContent: 'center'}}>
<Text style={{marginRight: 5}}>Send a</Text>
</Block>
<Block style={[styles.dropdownsRow, {flex: 2}]}>
<SelectDropdownMenu
data={cheers}
onSelect={(selectedItem, index) => {
console.log(selectedItem, index);
}}
defaultButtonText={'Cheers'}
buttonTextAfterSelection={(selectedItem, index) => {
return selectedItem.name;
}}
rowTextForSelection={(item, index) => {
return item.name;
}}
buttonStyle={styles.dropdown1BtnStyle}
buttonTextStyle={styles.dropdown1BtnTxtStyle}
renderDropdownIcon={isOpened => {
return <FontAwesome name={isOpened ? 'chevron-up' : 'chevron-down'} color={'#8898aa'} size={10} />;
}}
dropdownIconPosition={'right'}
dropdownStyle={styles.dropdown1DropdownStyle}
rowStyle={styles.dropdown1RowStyle}
rowTextStyle={styles.dropdown1RowTxtStyle}
/>
</Block>
<Block style={{flex: 2, justifyContent: 'center' }}>
<Text style={{marginLeft: 5, marginRight: 5}}>to</Text>
</Block>
<Block style={{ justifyContent: 'center'}}>
<Input
right placeholder="Type your custom question here."
iconContent={<Block />}
/>
</Block>
);
}
const styles = StyleSheet.create({
dropdownsRow: {justifyContent: 'center', maxWidth: '10%'},
dropdown1BtnStyle: {
height: 45,
backgroundColor: '#edeff2',
borderRadius: 5,
borderColor: '#444',
},
dropdown1BtnTxtStyle: {color: '#8898aa', textAlign: 'left', fontSize: 14},
dropdown1DropdownStyle: {backgroundColor: '#EFEFEF'},
dropdown1RowStyle: {backgroundColor: '#EFEFEF', borderBottomColor: '#C5C5C5'},
dropdown1RowTxtStyle: {color: '#444', textAlign: 'left'}
});
I'm new to react native and don't know how flex property works.
Here's my sample output:
The whole code found here whole code
You can use Yoga layout website to find your desired UI and then migrate your styles to your code.

React native Accordion animation Bug

So, I am trying to make accordion in react-native.
When I am opening & closing the acccordion.
The is getting mounted/unmounted taking the space required & then animation is happening over the layout.
How can I fix this using react-native-reanimated ?
My code is like this
<Accordion layout={Layout.duration(1500)} style={{borderBottomWidth:1}}>
<Header onPress={setOpenedMonths}/>
{isOpen && <Content/>}
</Accordion>
Please try this.
import React, {PureComponent} from 'react';
import {
Text,
View,
StyleSheet,
LayoutAnimation,
Platform,
UIManager,
TouchableOpacity,
} from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';
export default class ExpandCollapse extends PureComponent {
constructor() {
super();
if (Platform.OS === 'android') {
UIManager.setLayoutAnimationEnabledExperimental(true);
}
}
changeLayout = () => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
this.props.onOpenBond();
};
render() {
let {data} = this.props;
return (
<View style={styles.container}>
<View style={styles.btnTextHolder}>
<TouchableOpacity
activeOpacity={0.8}
onPress={this.changeLayout}
style={styles.Btn}>
<View
style={{
height: 30,
width: 30,
borderRadius: 15,
backgroundColor: 'green',
alignItems: 'center',
justifyContent: 'center',
}}>
<Icon
name={
this.props.isOpen
? 'chevron-up-outline'
: 'chevron-down-outline'
}
size={24}
color="#fff"
/>
</View>
<View style={{flex: 1, flexDirection: 'row'}}>
<Text style={styles.titleText}>Rating Agency</Text>
<Text style={styles.contentText}>
{typeof data.agency == 'string'
? data.agency
: data.agency.agency_name}
</Text>
</View>
</TouchableOpacity>
<View
style={{
height: this.props.isOpen ? null : 0,
overflow: 'hidden',
}}>
<View style={[styles.Btn, {paddingVertical: 0}]}>
<View
style={{
height: 30,
width: 30,
borderRadius: 15,
}}></View>
<View style={{flex: 1, flexDirection: 'row'}}>
<Text style={styles.titleText}>Rating</Text>
<Text style={styles.contentText}>
{data.rating_name != undefined
? data.rating_name
: data.rating}{' '}
{data.outlook == 1
? 'Positive'
: data.outlook == 2
? 'Stable'
: data.outlook == 3
? 'Negative'
: ''}
</Text>
</View>
</View>
<View style={[styles.Btn, {paddingVertical: 0, marginTop: 10}]}>
<View
style={{
height: 30,
width: 30,
borderRadius: 15,
}}></View>
<View style={{flex: 1, flexDirection: 'row'}}>
<Text style={styles.titleText}>Remarks</Text>
<Text style={styles.contentText}>
{data.remark == '' ? '-' : data.remark}
</Text>
</View>
</View>
<View
style={[styles.Btn, {paddingVertical: 0, marginVertical: 10}]}>
<View
style={{
height: 30,
width: 30,
borderRadius: 15,
}}></View>
<View style={{flex: 1, flexDirection: 'row'}}>
<Text style={styles.titleText}>Rating Rationale</Text>
<Text
onPress={() => {
if (
data.filename == '' ||
data.filename == undefined ||
data.filename == null
) {
return;
}
this.props.openPdfView();
}}
style={[
styles.contentText,
{
color: 'green',
textDecorationLine:
data.filename == '' ? 'none' : 'underline',
},
]}>
{data.filename == '' ? '-' : 'Pdf File'}
</Text>
</View>
</View>
</View>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
titleText: {
fontSize: 16,
color: '#AAA',
marginLeft: 10,
flex: 1,
},
contentText: {
fontSize: 16,
color: '#aaa',
marginLeft: 10,
flex: 1,
},
btnTextHolder: {
borderWidth: 0.5,
borderColor: 'rgba(0,0,0,0.2)',
},
Btn: {
paddingHorizontal: 20,
paddingVertical: 10,
flexDirection: 'row',
alignItems: 'center',
},
});

I want to change the width of the KeyboardAvoidingView movement with custom TextInput

I am developing iOS apps in React Native Expo.
To display the image icon and placeholder in the Input column, I set it to Image icon and TextInput in the View.
When using KeyboardAvoidingView, the keyboard scrolls to the bottom of TextInput as shown in the attached image (1), but does anyone know if it is possible to scroll to the bottom of the description of the input field as shown in image (2)?
Image(1)
Image(2)
The article is based on the following.
https://reactnative.dev/docs/keyboardavoidingview
Parent function code.
<KeyboardAvoidingView behavior="padding" style={styles.containerStyle}>
<SafeAreaView style={styles.containerStyle}>
<ScrollView style={styles.containerStyle}>
<View style={styles.headContainerStyle}></View>
<View style={styles.mainContainerStyle}></View>
<View style={styles.headMessageContainerStyle}>
<Text style={styles.headMessageTextStyle}>Sign Up</Text>
</View>
{/* Email */}
<MailForm
inputAccessoryViewID={inputAccessoryViewID}
isCorrectMail={isCorrectMail}
setIsCorrectMail={setIsCorrectMail}
/>
{/* Password */}
<PasswordForm
inputAccessoryViewID={inputAccessoryViewID}
isCorrectPassewordSymbol={isCorrectPassewordSymbol}
setIsCorrectPassewordSymbol={setIsCorrectPassewordSymbol}
isCorrectPassewordStringCount={isCorrectPassewordStringCount}
setIsCorrectPassewordStringCount={setIsCorrectPassewordStringCount}
/>
{/* UserId */}
<UserIdForm
inputAccessoryViewID={inputAccessoryViewID}
isCorrectUserIdSymbol={isCorrectUserIdSymbol}
setIsCorrectUserIdSymbol={setIsCorrectUserIdSymbol}
isCorrectUserIdStringCount={isCorrectUserIdStringCount}
setIsCorrectUserIdStringCount={setIsCorrectUserIdStringCount}
isAvailableUserId={isAvailableUserId}
setIsAvailableUserId={setIsAvailableUserId}
/>
{/* Screen Bottom */}
<View style={styles.bottomStyle}>
{isCorrectMail && isCorrectPassewordSymbol && isCorrectPassewordStringCount && isCorrectUserIdSymbol && isCorrectUserIdStringCount && isAvailableUserId ?
(
<TouchableOpacity
style={styles.buttonContainerStyle}>
<Text style={styles.buttonTextStyle}>Sign Up</Text>
</TouchableOpacity>
) : (
<TouchableOpacity
style={[styles.buttonContainerStyle, styles.buttonContainerInvalidStyle]}
onPress={() => navigation.navigate('SignUp')}>
<Text style={styles.buttonTextStyle}>Sign Up</Text>
</TouchableOpacity>
)}
<View style={styles.toLoginStyle}>
<Text style={styles.toLoginTextStyle}>Do you have an account?</Text>
<Text style={[styles.toLoginTextStyle, styles.toLoginTextLinkStyle]}>Login here</Text>
</View>
</View>
</ScrollView>
</SafeAreaView>
</KeyboardAvoidingView>
The code for the <UserId/> component, which we want to support scrolling for this time.
<View>
<View style={styles.searchBoxStyle}>
<View style={styles.searchWrapperStyle}>
<Pressable style={styles.searchContainerStyle} onPress={() => textInputUserId.focus()}>
<Text style={styles.searchTitleStyle}>UserId</Text>
{/* <KeyboardAvoidingView behavior="padding"> */}
<View style={defaultUserIdBorderColor ? isCorrectUserIdSymbol && isCorrectUserIdStringCount ? styles.searchViewStyle : [styles.searchViewStyle, styles.inputIncorrectBorderColorStyle]: styles.searchViewStyle}>
<Image source={require("../../../assets/profile.png")} style={styles.searchIconStyle}/>
{/* <KeyboardAvoidingView behavior="padding"> */}
<TextInput
onChangeText={onChangeUserIdText}
style={styles.searchContentStyle}
value={userIdText}
placeholder="test1234"
inputAccessoryViewID={inputAccessoryViewID}
ref={(input) => textInputUserId = input}
autoCapitalize="none"
maxLength={100}
textContentType="username"
onFocus={() => {
…
}}
onEndEditing={() => {
…
}}
/>
</View>
</Pressable>
</View>
</View>
{/* UserId Description */}
{displayUserIdDescription ? !isCorrectUserIdSymbol || !isCorrectUserIdStringCount || !isAvailableUserId ? (
<View style={styles.descriptionBoxStyle}>
<View style={styles.descriptionWrapperStyle}>
<View style={styles.descriptionContainerStyle}>
{!defaultDisplayUserIcons ? isCorrectUserIdSymbol ? <Image source={require("../../../assets/correct.png")} style={styles.descriptionIconStyle}/>: <Image source={require("../../../assets/incorrect.png")} style={styles.descriptionIconStyle}/>: null}
<Text style={styles.descriptionTextStyle}>Half-width alphanumeric characters only.</Text>
</View>
<View style={styles.descriptionContainerStyle}>
{!defaultDisplayUserIcons ? isCorrectUserIdStringCount ? <Image source={require("../../../assets/correct.png")} style={styles.descriptionIconStyle}/>: <Image source={require("../../../assets/incorrect.png")} style={styles.descriptionIconStyle}/>: null}
<Text style={styles.descriptionTextStyle} >More than 4 words and less than 100 words.</Text>
</View>
<View style={styles.descriptionContainerStyle}>
{!defaultDisplayUserIcons ? isAvailableUserId ? <Image source={require("../../../assets/correct.png")} style={styles.descriptionIconStyle}/>: <Image source={require("../../../assets/incorrect.png")} style={styles.descriptionIconStyle}/>: null}
<Text style={styles.descriptionTextStyle} >Available.</Text>
</View>
</View>
</View>
) : null: null}
</View>
Style sheet code.
import { StyleSheet } from 'react-native';
export const styles = StyleSheet.create({
containerStyle: {
flex: 1,
backgroundColor: "#1B1C56",
},
headContainerStyle: {
width: "100%",
height: "10%",
height: 40,
backgroundColor: "#1B1C56",
},
headMessageContainerStyle: {
backgroundColor: "#feffff",
alignItems: 'center',
},
headMessageTextStyle: {
fontSize: 50,
fontFamily: "AlfaSlabOne_400Regular",
color: "#1B1C56",
marginBottom: 32,
},
mainContainerStyle: {
width: "100%",
height: "15%",
backgroundColor: "#feffff",
borderTopLeftRadius: 50,
alignItems: 'center',
},
searchBoxStyle: {
flex: 1,
backgroundColor: "#feffff",
},
searchWrapperStyle: {
flex: 1,
alignItems: "center",
paddingBottom: 10,
},
searchContainerStyle: {
},
searchTitleStyle: {
fontFamily: "ABeeZee_400Regular_Italic",
color: "#262626",
marginBottom: 5,
},
searchIconStyle: {
width: 24,
height: 24,
marginRight: 10,
marginLeft: 10,
},
searchViewStyle: {
flexDirection: 'row',
alignItems: 'center',
backgroundColor: '#F6F7FB',
borderWidth: 0.5,
height: 60,
borderRadius: 5,
width: 300,
borderColor: "#F6F7FB",
},
searchContentStyle: {
flex: 1
},
inputIncorrectBorderColorStyle:{
borderWidth: 2,
borderColor: "#ED195E",
},
completeBoxStyle: {
width: 60,
alignItems: "center",
padding: 10,
},
completeTextStyle: {
fontSize: 18,
fontWeight: "bold",
color: "hsl(210, 100%, 60%)"
},
passwordIconStyle: {
marginRight: 10
},
descriptionBoxStyle:{
display: "flex",
alignItems: "center",
backgroundColor: "#feffff",
paddingBottom: 10,
},
descriptionWrapperStyle: {
},
descriptionContainerStyle: {
flexDirection: "row",
width: 300,
},
descriptionTextStyle: {
color: "#262626",
fontSize: 12,
overflow: "visible"
},
descriptionIconStyle:{
marginRight: 10,
width: 12,
height: 12,
},
bottomStyle: {
display: "flex",
alignItems: "center",
height: "100%",
backgroundColor: "#feffff",
},
buttonContainerStyle: {
alignItems: "center",
justifyContent: "center",
backgroundColor: "#1B1C56",
width: 300,
height: 60,
borderRadius: 10,
fontSize: 18,
},
buttonContainerInvalidStyle:{
backgroundColor: "#C5C5C7",
},
buttonTextStyle: {
color: "#feffff",
fontFamily: "ABeeZee_400Regular_Italic",
},
toLoginStyle: {
marginTop: 10,
height: "5%",
flexDirection: "row"
},
toLoginTextStyle: {
fontFamily: "ABeeZee_400Regular_Italic",
},
toLoginTextLinkStyle: {
color: "#ED195E",
marginLeft: 10,
},
});
Swapped the positions of KeyboardAvoidingView, SafeAreaView and ScrollView. I have tried to set the keyboardVerticalOffset and the keyboardVerticalOffset, but each had its own problems, and the current code was the closest to the ideal.

The image displayed in marker callout is cut

In my app, I want to display callout on a user clicks on the marker. I read that there are problems with displaying images in callout and a lot of people suggest placing the image in <Text> component [1,2,3]. For smaller images/icons this solution works, but I want to display one more "bigger" image, and here is an effect:
I don't know why this image has this "top margin" and why it is cut in the half. I was trying a lot of changes in the style of this Image and it's resizeMode but nothing is working. My other images in callout - like this icon on the bottom - had the same problem but adding a bigger size to the component in which there are placed help and everything looks fine. I was trying this solution on this big top image but it isn't working.
I will be grateful for any help and suggestions.
He is the Callout component code:
import { Dimensions, Image, StyleSheet, Text, View } from 'react-native'
import React, { Component } from 'react'
import { FontAwesome } from '#expo/vector-icons'
import PropTypes from 'prop-types'
import { colors } from '../constants/Colors'
const { width, height } = Dimensions.get('screen')
function getSpotDifficulty(spot) {
switch (spot.difficulty) {
case 0:
return 'DLA KAŻDEGO'
case 1:
return 'UMIARKOWANA'
case 2:
return 'DUŻA'
case 3:
return 'TYLKO DLA PROSÓW'
default:
return ' - '
}
}
function getSpotPopularity(spot) {
switch (spot.popularity) {
case 0:
return 'MALE'
case 1:
return 'SREDNIE'
case 2:
return 'DUŻE'
default:
return ' - '
}
}
const WATER_TYPE_FLAT_IC = require('../assets/images/ic_flat.png')
const WATER_TYPE_WAVE_IC = require('../assets/images/ic_wave.png')
const DIFFICULTY_EASY_IC = require('../assets/images/ic_flag_white_24.png')
const DIFFICULTY_HARD_IC = require('../assets/images/ic_flag_red_24.png')
export default class SpotMarkerCallout extends Component {
render() {
const marker = this.props.marker
const waterTypeIcon = marker.waterType === 0 ? WATER_TYPE_FLAT_IC : WATER_TYPE_WAVE_IC
const difficultyIcon = marker.waterType === 0 ? DIFFICULTY_EASY_IC : DIFFICULTY_HARD_IC
return (
<View style={styles.markerCallout}>
<Text >
<Image style={{flex: 1, height: 200}}
resizeMode={'cover'}
source={require('../assets/images/example_spot_photo.jpg')}/>
</Text>
<View style={{ flex: 1, flexDirection: 'column', justifyContent: 'center' }}>
<View style={styles.markerHeader}>
<Text style={styles.spotNameText}>
{marker.name}
</Text>
<View style={{ flex: 1, justifyContent: 'space-between' }}>
<View style={styles.sportsIconsContainer}>
<View style={styles.singleInfo}>
<Text style={styles.textViewForIcon}>
<Image style={styles.sportIcon}
source={marker.windsurfing ? require('../assets/images/windsurfing_icon.png') : null}/>
</Text>
</View>
<Text style={styles.textViewForIcon}>
<Image style={styles.sportIcon}
source={marker.kitesurfing ? require('../assets/images/kitesurfing_icon.png') : null}/>
</Text>
<Text style={styles.textViewForIcon}>
<Image style={styles.sportIcon}
source={marker.surfing ? require('../assets/images/surfing_icon.png') : null}/>
</Text>
</View>
<View style={{ flex: 1, flexDirection: 'row', justifyContent: 'flex-end' }}>
<View style={[styles.singleInfo, { marginRight: 8 }]}>
<FontAwesome name="star" color={colors.ratingColor} size={10}/>
<Text style={{ marginRight: 4, color: colors.ratingColor }}>{marker.rating}</Text>
</View>
<View style={[styles.singleInfo, { marginRight: 8 }]}>
<FontAwesome name="location-arrow" color={colors.secondaryColor} size={10}/>
<Text style={{ marginRight: 4, color: colors.secondaryColor }}>{marker.distance} km</Text>
</View>
</View>
</View>
</View>
<Text style={styles.descriptionText} numberOfLines={3} ellipsizeMode='tail'>
{marker.description}
</Text>
</View>
<View style={{ flex: 1, flexDirection: 'row', marginVertical: 8 }}>
<View style={{ flex: 1, flexDirection: 'column', marginLeft: 4, }}>
<View style={styles.singleInfo}>
<Text style={styles.infoIconTextView}>
<Image style={styles.infoIcon} source={waterTypeIcon}/>
</Text>
<Text style={styles.infoText}>{marker.waterType === 0 ? 'FLAT' : 'WAVE'}</Text>
</View>
<View style={styles.singleInfo}>
<Text style={styles.infoIconTextView}>
<Image style={styles.infoIcon} source={require('../assets/images/ic_shaka_128.png')}/>
</Text>
<Text style={styles.infoText}>{marker.schools ? ' SZKOLENIA DOSTĘPNE' : 'BRAK SZKOLEN'}</Text>
</View>
</View>
<View style={{ flex: 1, flexDirection: 'column', marginLeft: 16, }}>
<View style={styles.singleInfo}>
<Text style={styles.infoIconTextView}>
<Image style={styles.infoIcon} source={difficultyIcon}/>
</Text>
<Text style={styles.infoText}>{getSpotDifficulty(marker)}</Text>
</View>
<View style={styles.singleInfo}>
<Text style={styles.infoIconTextView}>
<Image style={styles.infoIcon} source={require('../assets/images/ic_peoples.png')}/>
</Text>
<Text style={styles.infoText}>{getSpotPopularity(marker)}</Text>
</View>
</View>
</View>
</View>
)
}
}
SpotMarkerCallout.propTypes = {
marker: PropTypes.object.isRequired,
}
const styles = StyleSheet.create({
markerCallout: {
flex: 1,
width: width * 0.8,
flexDirection: 'column',
paddingLeft: 12,
justifyContent: 'space-around',
},
markerHeader: {
flexDirection: 'row',
justifyContent: 'space-between',
},
spotNameText: {
fontSize: 22,
fontFamily: 'dosis_light',
textTransform: 'uppercase',
alignSelf: 'center',
},
sportsIconsContainer: {
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-end',
alignItems: 'center',
marginRight: 8,
},
singleInfo: {
flexDirection: 'row',
alignItems: 'center',
},
infoIcon: {
height: 18,
width: 18,
justifyContent: 'center',
alignItems: 'center',
},
infoIconTextView: {
height: 24,
justifyContent: 'center',
alignItems: 'center',
},
descriptionText: {
fontSize: 12,
color: colors.textBlackSecondaryColor,
paddingTop: 5,
},
sportIcon: {
height: 24,
width: 24,
},
textViewForIcon: {
height: 32,
},
infoText: {
fontSize: 10,
paddingLeft: 8,
justifyContent: 'center',
alignSelf: 'center',
},
})
And here is the code of usage:
<MapView.Callout onPress={() => this.props.navigation.navigate('SpotInfo', { chosenSpot: spot })}>
<TouchableHighlight>
<SpotMarkerCallout
marker={spot}/>
</TouchableHighlight>
</MapView.Callout>
</Marker>
i have notices you are using component change that to view
like
const newWidth = Dimensions.get('window').width
<View style={{ width: newWidth * 0.18, height: newWidth * 0.18 }}>
<Image style={{ width: newWidth * 0.18, height: newWidth * 0.18 }} source={require('your image path')} />
</View>
newWidth * 0.18 is the 18% width is the screen, change 0.18 to your desired percentage

Play youtube video in react-native-video

How can i play youtube video on react-native-video,
i don't want to play video in react-native-youtube or in webview,
Another option that I have checked and used is the WebView. To use it make sure you put the component in a View with a flex. Ex:
<View style={{flex: 1}}>
<WebView
style={ { marginTop: (Platform.OS == 'ios') ? 20 : 0,} }
javaScriptEnabled={true}
domStorageEnabled={true}
source={{uri: 'https://www.youtube.com/embed/'+this.state.pictureData.idVideo }}
/>
</View>
in my case, what I did was to obtain the identifying part of the YouTube video that would be for example: https://www.youtube.com/watch?v=KQ6zr6kCPj8
this.state.pictureData.idVideo would contain only: KQ6zr6kCPj8
To use it install:
$ npm install --save react-native-webview
link react-native-webview
and if you want more information:
https://github.com/react-native-community/react-native-webview
react-native-video does not support YouTube playback. This is something we have been investigating in our own projects. While it will support playback of Vimeo pro videos due to the direct HLS and MP4 files being exposed, YouTube does not provide this reliably. It used to be sometimes possible to get the direct video URL from some YouTube videos but that is not reliable anymore and might not even be possible with the latest API.
Currently, we have been dumping out to the YouTube app or the YouTube site in order to avoid having to implement the official react-native-youtube repository, but we will be eventually integrating with that repo in order to provide a more seamless user experience.
I understand that you don't want to use this solution, but, unfortunately, using react-native-video is not an option for you for this issue right now, and likely never will be. See this SO question for more.
A solution to your question is to use react-native youtube.
react-native-youtube
Here is an example I tried :
import React, { Component } from 'react';
import { StyleSheet, View, Text, ScrollView, TouchableOpacity, PixelRatio, Platform, Button, Dimensions, } from 'react-native';
import YouTube, { YouTubeStandaloneIOS, YouTubeStandaloneAndroid } from 'react-native-youtube';
export default class YouTubeExample extends Component {
state = {
isReady: false,
status: null,
quality: null,
error: null,
isPlaying: true,
isLooping: true,
duration: 0,
currentTime: 0,
fullscreen: false,
playerWidth: Dimensions.get('window').width,
};
constructor(props){
super(props);
}
_youTubeRef = React.createRef();
render(){
const YOUR_API_KEY = "paste yout api key here";
return (<View>
<ScrollView style={styles.container}>
<Text style={styles.welcome}>{'<YouTube /> component for React Native.'} </Text>
<YouTube
ref={this._youTubeRef}
// You must have an API Key for the player to load in Android
apiKey = {YOUR_API_KEY}
// Un-comment one of videoId / videoIds / playlist.
// You can also edit these props while Hot-Loading in development mode to see how
// it affects the loaded native module
//videoId="ncw4ISEU5ik"
// videoIds={['uMK0prafzw0', 'qzYgSecGQww', 'XXlZfc1TrD0', 'czcjU1w-c6k']}
playlistId="PL3c6c2pNE7cLc5a0zpz7xZOW38H7lzzKM"
play={this.state.isPlaying}
loop={this.state.isLooping}
fullscreen={this.state.fullscreen}
controls={1}
style={[
{ height: PixelRatio.roundToNearestPixel(this.state.playerWidth / (16 / 9)) },
styles.player,
]}
onError={e => {
this.setState({ error: e.error });
}}
onReady={e => {
this.setState({ isReady: true });
}}
onChangeState={e => {
this.setState({ status: e.state });
}}
onChangeQuality={e => {
this.setState({ quality: e.quality });
}}
onChangeFullscreen={e => {
this.setState({ fullscreen: e.isFullscreen });
}}
onProgress={e => {
this.setState({ currentTime: e.currentTime });
}}
/>
{/* Playing / Looping */}
<View style={styles.buttonGroup}>
<Button
title={this.state.status == 'playing' ? 'Pause' : 'Play'}
color={this.state.status == 'playing' ? 'red' : undefined}
onPress={() => {
this.setState(state => ({ isPlaying: !state.isPlaying }));
}}
/>
<Text> </Text>
<Button
title={this.state.isLooping ? 'Looping' : 'Not Looping'}
color={this.state.isLooping ? 'green' : undefined}
onPress={() => {
this.setState(state => ({ isLooping: !state.isLooping }));
}}
/>
</View>
{/* Previous / Next video */}
<View style={styles.buttonGroup}>
<Button
title="Previous Video"
onPress={() => {
if (this._youTubeRef.current) {
this._youTubeRef.current.previousVideo();
}
}}
/>
<Text> </Text>
<Button
title="Next Video"
onPress={() => {
if (this._youTubeRef.current) {
this._youTubeRef.current.nextVideo();
}
}}
/>
</View>
{/* Go To Specific time in played video with seekTo() */}
<View style={styles.buttonGroup}>
<Button
title="15 Seconds"
onPress={() => {
if (this._youTubeRef.current) {
this._youTubeRef.current.seekTo(15);
}
}}
/>
<Text> </Text>
<Button
title="2 Minutes"
onPress={() => {
if (this._youTubeRef.current) {
this._youTubeRef.current.seekTo(2 * 60);
}
}}
/>
<Text> </Text>
<Button
title="15 Minutes"
onPress={() => {
if (this._youTubeRef.current) {
this._youTubeRef.current.seekTo(15 * 60);
}
}}
/>
</View>
{/* Play specific video in a videoIds array by index */}
{this._youTubeRef.current &&
this._youTubeRef.current.props.videoIds &&
Array.isArray(this._youTubeRef.current.props.videoIds) && (
<View style={styles.buttonGroup}>
{this._youTubeRef.current.props.videoIds.map((videoId, i) => (
<React.Fragment key={i}>
<Button
title={`Video ${i}`}
onPress={() => {
if (this._youTubeRef.current) {
this._youTubeRef.current.playVideoAt(i);
}
}}
/>
<Text> </Text>
</React.Fragment>
))}
</View>
)}
{/* Get current played video's position index when playing videoIds (and playlist in iOS) */}
<View style={styles.buttonGroup}>
<Button
title={'Get Videos Index: ' + this.state.videosIndex}
onPress={() => {
if (this._youTubeRef.current) {
this._youTubeRef.current
.getVideosIndex()
.then(index => this.setState({ videosIndex: index }))
.catch(errorMessage => this.setState({ error: errorMessage }));
}
}}
/>
</View>
{/* Fullscreen */}
{!this.state.fullscreen && (
<View style={styles.buttonGroup}>
<Button
title="Set Fullscreen"
onPress={() => {
this.setState({ fullscreen: true });
}}
/>
</View>
)}
{/* Get Duration (iOS) */}
{Platform.OS === 'ios' && (
<View style={styles.buttonGroup}>
<Button
title="Get Duration (iOS)"
onPress={() => {
if (this._youTubeRef.current) {
this._youTubeRef.current
.getDuration()
.then(duration => this.setState({ duration }))
.catch(errorMessage => this.setState({ error: errorMessage }));
}
}}
/>
</View>
)}
{/* Get Progress & Duration (Android) */}
{Platform.OS === 'android' && (
<View style={styles.buttonGroup}>
<Button
title="Get Progress & Duration (Android)"
onPress={() => {
if (this._youTubeRef.current) {
this._youTubeRef.current
.getCurrentTime()
.then(currentTime => this.setState({ currentTime }))
.catch(errorMessage => this.setState({ error: errorMessage }));
this._youTubeRef.current
.getDuration()
.then(duration => this.setState({ duration }))
.catch(errorMessage => this.setState({ error: errorMessage }));
}
}}
/>
</View>
)}
{/* Standalone Player (iOS) */}
{Platform.OS === 'ios' && YouTubeStandaloneIOS && (
<View style={styles.buttonGroup}>
<Button
title="Launch Standalone Player"
onPress={() => {
YouTubeStandaloneIOS.playVideo('KVZ-P-ZI6W4')
.then(() => console.log('iOS Standalone Player Finished'))
.catch(errorMessage => this.setState({ error: errorMessage }));
}}
/>
</View>
)}
{/* Standalone Player (Android) */}
{Platform.OS === 'android' && YouTubeStandaloneAndroid && (
<View style={styles.buttonGroup}>
<Button
style={styles.button}
title="Standalone: One Video"
onPress={() => {
YouTubeStandaloneAndroid.playVideo({
apiKey: 'YOUR_API_KEY',
videoId: 'KVZ-P-ZI6W4',
autoplay: true,
lightboxMode: false,
startTime: 124.5,
})
.then(() => {
console.log('Android Standalone Player Finished');
})
.catch(errorMessage => {
this.setState({ error: errorMessage });
});
}}
/>
<Text> </Text>
<Button
title="Videos"
onPress={() => {
YouTubeStandaloneAndroid.playVideos({
apiKey: 'YOUR_API_KEY',
videoIds: ['HcXNPI-IPPM', 'XXlZfc1TrD0', 'czcjU1w-c6k', 'uMK0prafzw0'],
autoplay: false,
lightboxMode: true,
startIndex: 1,
startTime: 99.5,
})
.then(() => {
console.log('Android Standalone Player Finished');
})
.catch(errorMessage => {
this.setState({ error: errorMessage });
});
}}
/>
<Text> </Text>
<Button
title="Playlist"
onPress={() => {
YouTubeStandaloneAndroid.playPlaylist({
apiKey: 'YOUR_API_KEY',
playlistId: 'PLF797E961509B4EB5',
autoplay: false,
lightboxMode: false,
startIndex: 2,
startTime: 100.5,
})
.then(() => {
console.log('Android Standalone Player Finished');
})
.catch(errorMessage => {
this.setState({ error: errorMessage });
});
}}
/>
</View>
)}
{/* Reload iFrame for updated props (Only needed for iOS) */}
{Platform.OS === 'ios' && (
<View style={styles.buttonGroup}>
<Button
title="Reload iFrame (iOS)"
onPress={() => {
if (this._youTubeRef.current) {
this._youTubeRef.current.reloadIframe();
}
}}
/>
</View>
)}
<Text style={styles.instructions}>
{this.state.isReady ? 'Player is ready' : 'Player setting up...'}
</Text>
<Text style={styles.instructions}>Status: {this.state.status}</Text>
<Text style={styles.instructions}>Quality: {this.state.quality}</Text>
{/* Show Progress */}
<Text style={styles.instructions}>
Progress: {Math.trunc(this.state.currentTime)}s ({Math.trunc(this.state.duration / 60)}:
{Math.trunc(this.state.duration % 60)}s)
{Platform.OS !== 'ios' && <Text> (Click Update Progress & Duration)</Text>}
</Text>
<Text style={styles.instructions}>
{this.state.error ? 'Error: ' + this.state.error : ''}
</Text>
</ScrollView>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
backgroundColor: 'grey',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
buttonGroup: {
flexDirection: 'row',
alignSelf: 'center',
paddingBottom: 5,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
player: {
alignSelf: 'stretch',
marginVertical: 10,
},
});
For the API Key, follow this link :
API Key
You have the id of the playlist in the address :
Install the component like this :
npm install react-native-youtube -S
I had errors with '#Nullable', if you have the same problem, go to
node_modules\react-native-youtube\android\build.gradle
and in 'dependencies' section, add this line :
implementation 'androidx.annotation:annotation:1.1.0'
Maybe you'll need to clean gradle:
cd android
gradlew clean (or .\gradlew clean)
This is a snapshot of my actual android emulator :
React native video doesn't have the feature to play a youtube video for that you have to use external libraries as mentioned above like webView or react native youtube.
I personally used Youtube Iframe Visit https://www.npmjs.com/package/react-native-youtube-iframe, it is a much newer library compared to others and has some wonderful features like you can hide controls and also alter the state of the displayed video
I have listed the code example below on how to use it in your component(functional).
import React, { useState, useCallback } from "react";
import { View, Text, SafeAreaView, TouchableOpacity, Image, ScrollView,
StatusBar, StyleSheet, Button, Linking } from 'react-native';
import { scale, verticalScale, moderateScale, scaleFont, fullHeight,
fullWidth, constants, colors } from './utils'
import Video from 'react-native-video';
import YoutubePlayer from "react-native-youtube-iframe";
import Modal from "react-native-modal";
import { Mute, Unmute, DashBoardLogo, Truck, Gift, MMtLogo } from "./assets/images";
const Dashboard = (props) => {
const [mute, setMute] = useState(true);
const video = require('./assets/Video/video.mp4')
const [mute2, setMute2] = useState(false);
const [isVisible, setisvisible] = useState(false)
const togglemute = useCallback(() => {
setMute((prev) => !prev);
}, [])
const togglemute2 = useCallback(() => {
setMute2((prev) => !prev);
}, [])
return (
<View style={{ flex: 1, backgroundColor: '#fff' }}>
<SafeAreaView style={{ flex: 0, backgroundColor: '#fff' }} />
<StatusBar
hidden={false} translucent={false}
networkActivityIndicatorVisible={true}
backgroundColor={"#fff"}
barStyle={"dark-content"}
/>
<Modal
deviceHeight={fullHeight}
deviceWidth={fullWidth}
isVisible={isVisible}
animationIn="slideInRight"
animationOut="slideOutRight"
><SafeAreaView style={{ flex: 0, backgroundColor: '#fff' }} />
<StatusBar
hidden={false} translucent={false}
networkActivityIndicatorVisible={true}
backgroundColor={"#fff"}
barStyle={"dark-content"}
/>
<ScrollView showsVerticalScrollIndicator={false} style={{ flex: 1, backgroundColor: '#fff', width: fullWidth, alignSelf: 'center', height: fullHeight, position: 'absolute' }}>
<TouchableOpacity onPress={() => setisvisible(false)} >
<Text style={{ color: 'red', alignSelf: 'center', fontWeight: '700', marginTop: verticalScale(20), fontSize: scaleFont(24), width: scale(100), textAlign: 'center' }}>Close</Text>
</TouchableOpacity>
<Text style={{ color: '#000', fontSize: scaleFont(20), fontWeight: '600', marginLeft: scale(20), marginTop: verticalScale(30) }} >Libraries Used:</Text>
<View style={{ flexDirection: 'row', width: scale(340), alignSelf: 'center' }}>
<View style={{ color: 'grey', marginTop: verticalScale(10) }} >
<Text style={{ color: 'grey' }} >react-native-youtube-iframe</Text>
<Text style={{ color: 'grey' }} >react-native-video</Text>
<Text style={{ color: 'grey' }} >react-native-modal </Text>
<Text style={{ color: 'grey' }} >react-native-svg and</Text>
<Text style={{ color: 'grey' }} >react-native-svg-transformer</Text>
</View>
<View style={{ color: 'grey', marginTop: verticalScale(10) }} >
<Text style={{ color: 'grey' }} > : To play the first video</Text>
<Text style={{ color: 'grey' }} > : To play the second video</Text>
<Text style={{ color: 'grey' }} > : For Showing this modal</Text>
<Text style={{ color: 'grey', }} > : To use svg images for</Text>
<Text style={{ color: 'grey', }} > better clarity</Text>
</View>
</View>
<View style={{ width: scale(330), alignSelf: 'center' }}>
<Text style={{ color: '#000', fontSize: scaleFont(20), fontWeight: '600', marginTop: verticalScale(30) }} >Description</Text>
<Text style={{ color: 'grey', width: scale(330), alignSelf: 'center' }} >This project is designed using react-native --version 0.68, I have a two seperate cards to play the videos, the first video is being played using youtube Iframe , the second video is present in the local file and being played through the react-native-video library, also used svg libraries to enhance the quality of icons and images used in the project</Text>
</View>
<View style={{ width: scale(330), alignSelf: 'center', }}>
<Text style={{ color: 'red', fontSize: scaleFont(20), fontWeight: '600', marginTop: verticalScale(30) }} >Note</Text>
<Text style={{ color: 'grey', }} >I have tried to make the functionalities similar to the figma file but for any sugesstion or review please feel free to contact me at <Text onPress={() => Linking.openURL('mailto:hpratap97#gmail.com')} style={{ color: colors.primary }} >hpratap97#gmail.com</Text>, <Text style={{ color: '#000', fontWeight: '700' }}>8958460383</Text></Text>
</View>
<View style={{ alignSelf: 'center', width: scale(330), marginTop: verticalScale(50), marginBottom: verticalScale(100) }}>
<Text style={{ color: '#000', fontSize: scale(20), marginTop: verticalScale(30), fontWeight: '700' }}>Regards,</Text>
<Text style={{ color: '#000' }}>Harsh Pratap Singh</Text>
</View>
</ScrollView>
</Modal >
<ScrollView overScrollMode="never">
<View style={{}}>
{/* Header */}
<View style={{ alignSelf: 'center', flexDirection: 'row', justifyContent: "space-between", alignItems: 'center', width: scale(329), height: verticalScale(47.96), marginTop: verticalScale(10) }}>
<View>
<Text style={{
fontSize: scaleFont(12), fontWeight: "500", color: 'rgba(17, 20, 45, 0.65)'
}}>
Welcome Back
</Text>
<Text style={{
fontSize: scaleFont(24), fontWeight: "600", color: '#11142D'
}}
>
Rahul Kumar
</Text>
</View>
<TouchableOpacity
onPress={() => setisvisible(true)}
style={{
width: verticalScale(38), height: verticalScale(38), borderRadius: verticalScale(100), shadowColor: 'green', shadowOffset: { width: 0.25, height: 0.25 }, shadowOpacity: 0.15, shadowRadius: 8, elevation: 4, backgroundColor: '#fff', justifyContent: 'center', alignItems: 'center',
}}>
<DashBoardLogo />
</TouchableOpacity>
</View>
{/* First Card */}
<View style={{ width: scale(332), height: verticalScale(480.29), marginTop: verticalScale(28.72), borderRadius: verticalScale(17), alignSelf: 'center', shadowColor: colors.shadowColor, shadowOffset: { width: 0, height: 0.25 }, shadowOpacity: 0.15, shadowRadius: 8, elevation: 4, backgroundColor: '#fff', }}>
<View style={{ height: verticalScale(255), backgroundColor: '#000', borderTopLeftRadius: verticalScale(17.71), borderTopRightRadius: verticalScale(17.71), justifyContent: 'center', alignItems: 'center' }}>
<YoutubePlayer
height={verticalScale(255)}
width={scale(320)}
play={true}
playList={["kV__iZuxDGE"]}
mute={mute}
initialPlayerParams={{ controls: false, loop: true, rel: false, iv_load_policy: 3 }}
/>
{
mute ? (<TouchableOpacity
activeOpacity={1}
onPress={togglemute}
style={{
width: scale(49),
height: verticalScale(31),
backgroundColor: 'grey',
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'flex-end',
marginTop: verticalScale(-40),
marginRight: scale(11),
borderRadius: verticalScale(6),
}}>
<Mute />
</TouchableOpacity>) : (<TouchableOpacity
onPress={togglemute}
activeOpacity={1}
style={{
width: scale(49),
height: verticalScale(31),
backgroundColor: 'grey',
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'flex-end',
marginTop: verticalScale(-40),
marginRight: scale(11),
borderRadius: verticalScale(6),
}}
>
<Unmute />
</TouchableOpacity>)
}
</View>
<View>
<Text
style={{ marginTop: verticalScale(13.68), fontSize: scaleFont(12), color: '#6F767E', fontWeight: "600", marginLeft: scale(19) }}
>
IPHONE SAVINGS PLAN
</Text>
<Text style={{ fontSize: scaleFont(23), fontWeight: '700', marginTop: verticalScale(5.5), width: scale(290), color: '#001B19', marginLeft: scale(19), }}>
Save up for the next iPhone and <Text style={{ color: 'green' }}>get 10% Cashback!</Text>
</Text>
<View style={{ flexDirection: 'row', alignSelf: 'center', marginTop: verticalScale(14.11), alignItems: 'center', justifyContent: 'space-between', width: scale(293.27) }}>
<View>
<TouchableOpacity style={{
width: scale(79.26), height: verticalScale(59.45), backgroundColor: 'rgba(239, 239, 239, 1)', borderRadius: verticalScale(4), justifyContent: 'center', alignItems: 'center'
}}>
<Truck />
</TouchableOpacity>
<Text style={{ alignSelf: 'center', fontSize: scaleFont(10), fontWeight: '600', color: 'rgba(0, 0, 0, 0.5)' }}>Priority Delivery</Text>
</View>
<View>
<TouchableOpacity style={{
width: scale(79.26), height: verticalScale(59.45), backgroundColor: 'rgba(239, 239, 239, 1)', borderRadius: verticalScale(4), justifyContent: 'center', alignItems: 'center'
}}>
<Image source={require('./assets/images/Charger1.png')} style={{ marginTop: verticalScale(6) }} />
</TouchableOpacity>
<Text style={{ alignSelf: 'center', fontSize: scaleFont(10), fontWeight: '600', color: 'rgba(0, 0, 0, 0.5)' }}>Free Charger</Text>
</View>
<View>
<TouchableOpacity style={{
width: scale(79.26), height: verticalScale(59.45), backgroundColor: 'rgba(239, 239, 239, 1)', borderRadius: verticalScale(4), justifyContent: 'center', alignItems: 'center'
}}>
<Gift />
</TouchableOpacity>
<Text style={{ alignSelf: 'center', fontSize: scaleFont(10), fontWeight: '600', color: 'rgba(0, 0, 0, 0.5)' }}>Tortoise Merch</Text>
</View>
</View>
</View>
</View>
{/* Second Card */}
<View style={{ width: scale(332), height: verticalScale(531), marginTop: verticalScale(28.72), borderRadius: verticalScale(17), alignSelf: 'center', shadowColor: colors.shadowColor, shadowOffset: { width: 0, height: 0.25 }, shadowOpacity: 0.15, shadowRadius: 8, elevation: 4, backgroundColor: '#fff', marginBottom: verticalScale(100) }}>
<View style={{ height: verticalScale(420), borderTopLeftRadius: verticalScale(17), borderTopRightRadius: verticalScale(17), }}>
<Video source={video}
play={true}
repeat={true}
style={{ height: verticalScale(415), borderTopLeftRadius: verticalScale(17), borderTopRightRadius: verticalScale(17) }}
/>
{
mute2 ? (<TouchableOpacity
activeOpacity={1}
onPress={togglemute2}
style={{
width: scale(49),
height: verticalScale(31),
backgroundColor: 'grey',
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'flex-end',
marginTop: verticalScale(-40),
marginRight: scale(11),
borderRadius: verticalScale(6),
}}>
<Mute />
</TouchableOpacity>) : (<TouchableOpacity
onPress={togglemute2}
activeOpacity={1}
style={{
width: scale(49),
height: verticalScale(31),
backgroundColor: 'grey',
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'flex-end',
marginTop: verticalScale(-40),
marginRight: scale(11),
borderRadius: verticalScale(6),
}}
>
<Unmute />
</TouchableOpacity>)
}
<MMtLogo style={{ marginTop: verticalScale(-55), marginLeft: scale(18) }} />
</View>
<View>
<Text
style={{ marginTop: verticalScale(13.68), fontSize: scaleFont(12), color: '#6F767E', fontWeight: "600", marginLeft: scale(19) }}
>
MAKE MY TRIP SAVINGS PLAN
</Text>
<Text style={{ fontSize: scaleFont(20), fontWeight: '700', marginTop: verticalScale(5.5), width: scale(290), color: '#001B19', marginLeft: scale(19), }}>
Save up for the next Vacation and <Text style={{ color: 'green' }}>get 10% Cashback!</Text>
</Text>
</View>
</View>
</View>
</ScrollView>
</View >
);
}
export default Dashboard;
But if still you doesn't want to use any library and use the react native video component then you have to host your videos on a different server to use them in your application
You can't play Youtube video with react-native-video module. It is not supported at this moment and never was. Also it doesn't seem to be in their roadmap. So you should discuss other options and i recommend latest version of react-native-webview. I have tested it myself and works great. Especially i love the thing that they added fullscreen mode for android.
Well, I haven't tried it yet, but I will need it in my project. As I read there is a package called: react-native-youtube
Here some information about the package: https://www.npmjs.com/package/react-native-youtube
If you wait for tomorrow I check and I tell you, if you do and I left if you could tell how it went ... ^^