react native dynamic image slider transition opacity - react-native

I'm looking to implement in react native , slider with dynamic images with fading transition (play with opacity).
what I did is
changeBackgroundImageNew = ()=>{
const TIME_TRANSITION = 4500
let images_length = this.props.AppStore.barbershop_details.images.length
let index_image = 0;
setInterval(()=>{
if(this.state.index_image == images_length-1){
index_image = 0
}else{
index_image= index_image+1
}
this.setState({index_image})
},4000)
Animated.loop(
Animated.sequence([
Animated.delay(1500),
Animated.parallel([
Animated.timing(this.state.img_background_opacity, {
toValue: 0,
duration: TIME_TRANSITION
}),
Animated.timing(this.state.img_background_opacity2, {
toValue: 1,
duration: TIME_TRANSITION
})
]),
Animated.delay(1500),
Animated.parallel([
Animated.timing(this.state.img_background_opacity2, {
toValue: 0,
duration: TIME_TRANSITION
}),
Animated.timing(this.state.img_background_opacity, {
toValue: 1,
duration: TIME_TRANSITION
})
])
])
).start(() => {
});
}
the render code
{AppStore.barbershop_details && AppStore.barbershop_details.images.map((image,i)=>(
<AnimatedImageBackground
key={i}
resizeMode="cover"
resizeMethod="resize"
style={[
style.img_background,
{ opacity: i == this.state.index_image?this.state.img_background_opacity:this.state.img_background_opacity2 }
]}
source={{uri:image}}
/>
))}
I'm trying to change the images with automatically animated fading transition,
kind of this example, but I want it in react native
example for images transition

I have implemented react-native-snap-carousel
Code:
import React, { Component } from "react";
import Carousel, { ParallaxImage } from 'react-native-snap-carousel';
import { Dimensions, StyleSheet,View,Text } from 'react-native';
const { width: screenWidth } = Dimensions.get('window')
export default class App extends Component {
constructor() {
super();
this.state = {
entries: [
{
"ID": "001",
"Name": "001",
"thumbnail": "https://wallpapercave.com/wp/KaNO7Ya.jpg"
},
{
"ID": "002",
"Name": "002",
"thumbnail": "https://wallpapercave.com/wp/ZxV8qRo.jpg"
},
{
"ID": "003",
"Name": "003",
"thumbnail": "https://wallpapercave.com/wp/ytM5xOy.jpg"
}
,
{
"ID": "004",
"Name": "004",
"thumbnail": "https://wallpapercave.com/wp/STgHPst.jpg"
}
,
{
"ID": "005",
"Name": "005",
"thumbnail": "https://wallpapercave.com/wp/vg5q7pY.jpg"
}
,
{
"ID": "006",
"Name": "006",
"thumbnail": "https://wallpapercave.com/wp/b2HsGgL.jpg"
}
],
}
}
_renderItem ({item, index}, parallaxProps) {
return (
<View style={styles.item}>
<ParallaxImage
source={{ uri: item.thumbnail }}
containerStyle={styles.imageContainer}
style={styles.image}
parallaxFactor={0.4}
{...parallaxProps}
/>
<Text style={styles.title} numberOfLines={2}>
{ item.Name }
</Text>
</View>
);
}
render () {
return (
<View style={styles.container}>
<Carousel
sliderWidth={screenWidth}
sliderHeight={screenWidth}
itemWidth={screenWidth - 60}
data={this.state.entries}
renderItem={this._renderItem}
hasParallaxImages={true}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container:{
marginTop:50
},
item: {
width: screenWidth - 60,
height: screenWidth - 60,
},
imageContainer: {
flex: 1,
marginBottom: Platform.select({ ios: 0, android: 1 }), // Prevent a random Android rendering issue
backgroundColor: 'white',
borderRadius: 8,
},
image: {
...StyleSheet.absoluteFillObject,
resizeMode: 'cover',
},
})
Output:
https://gph.is/g/ZdoYdWw
You can play with this component and get your desired output rather than creating your own custom component. You can create your custom image container and also set fade duration, etc. For more details, go through with its documentation.
English is not my mother language; please excuse any errors on my part.

please try this code as per your example:
try with View tag style backgroundColor:'#5f9ea0',//change color and without Image set background for it.
imoprt { ScrollView, Dimensions} from 'react-native';
render(){
let screenWidth = Dimensions.get('window').width;
let screenHeight = Dimensions.get('window').height;
return(
<ScrollView
horizontal={true}
pagingEnabled= {true}
showHorizontalScrollIndicator={true}
>
<View style={{
flex:1,
marginTop:20,
width: screenWidth,
justifyContent: 'center',
alignItems: 'center'
}}>
<Image source={} style={{ flex: 1, resizeMode: 'cover', // or 'stretch'}} />
// add your UI code for create like
<Text> Screen 1</Text>
</View>
<View style={{
flex:1,
marginTop:20,
width: screenWidth,
justifyContent: 'center',
alignItems: 'center'
}}>
<Image source={} style={{ flex: 1, resizeMode: 'cover', // or 'stretch'}} />
// add your UI code for create like
<Text> Screen 2</Text>
</View>
<View style={{
flex:1,
marginTop:20,
width: screenWidth,
justifyContent: 'center',
alignItems: 'center'
}}>
<Image source={} style={{ flex: 1, resizeMode: 'cover', // or 'stretch'}} />
// add your UI code for create like
<Text> Screen 3</Text>
</View>
);
}
I hope it will help you. On fad Effect see the link: https://www.youtube.com/watch?v=K2B0vVIHV_A

try used this package react-native-image-slider-show hear example example for how to used it

Related

FlatList with ScrollTo in React Native

I'm new to React Native, I'm trying to make a FlatList in an application with Expo that will pull some categories of products from a Json, I managed to make the FlatList and also a Json simulation for testing, however I wish that by clicking on any item in the FlatList it directs the Scroll to the respective section, the same when using anchor with id in HTML.
For example: FlatList will display the categories: Combo, Side Dishes, Hot Dog, etc. For each category that is displayed by FlatList I have already created a View that will display products in this category.
What I want to do:
When you click on a category displayed by FlatList the Scroll scrolls to the View that displays the products of this category, that is, if you click on Combo the page scrolls to the View that displays the products of the Combo category, if you click on Side Dishes the page scrolls until the View that displays the products in the Side Dishes category, follows my code:
Follow my code: (it can be simulated here: https://snack.expo.io/#wendell_chrys/06944b)
import React, { useEffect, useState } from 'react';
import { View, Image, ImageBackground, Text, StyleSheet, ScrollView, Dimensions, FlatList, SafeAreaView, TouchableOpacity } from 'react-native';
import { AppLoading } from 'expo';
import Constants from 'expo-constants';
const DATA = [
{
id: "1",
title: "Combos",
categorie: "section1",
},
{
id: "2",
title: "Side Dishes",
categorie: "section2",
},
{
id: "3",
title: "Hot Dog",
categorie: "section3",
},
{
id: "4",
title: "Desserts",
categorie: "section4",
},
{
id: "5",
title: "Drinks",
categorie: "section5",
},
];
const renderItem = ({ item }) => {
return (
<Item
item={item}
/>
);
};
const Item = ({ item, onPress, style }) => (
<TouchableOpacity onPress={onPress} >
<Text style={styles.itenscategoria}>{item.title}</Text>
</TouchableOpacity>
);
export default function App() {
return (
<View style={styles.container}>
<View style={styles.categories}>
<FlatList
data={DATA}
horizontal
showsHorizontalScrollIndicator={false}
renderItem={renderItem}
keyExtractor={(item) => item.id}
/>
</View>
<ScrollView>
<View style={styles.section1}>
<Text>Combos</Text>
</View>
<View style={styles.section2}>
<Text>Side Dishes</Text>
</View>
<View style={styles.section3}>
<Text>Hot Dog</Text>
</View>
<View style={styles.section4}>
<Text>Desserts</Text>
</View>
<View style={styles.section5}>
<Text>Drinks</Text>
</View>
</ ScrollView>
</View >
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
backgroundColor: '#000',
padding: 8,
},
categories: {
backgroundColor: '#FFFFFF',
width: '100%',
height: 50,
top: 10,
marginBottom:20,
},
itenscategoria: {
padding:15,
border: 1,
borderRadius:25,
marginRight:10,
},
section1: {
marginTop: 10,
backgroundColor: '#ccc',
width: '100%',
height: 200,
borderRadius: 10,
},
section2: {
marginTop: 10,
backgroundColor: '#ccc',
width: '100%',
height: 200,
borderRadius: 10,
},
section3: {
marginTop: 10,
backgroundColor: '#ccc',
width: '100%',
height: 200,
borderRadius: 10,
},
section4: {
marginTop: 10,
backgroundColor: '#ccc',
width: '100%',
height: 200,
borderRadius: 10,
},
section5: {
marginTop: 10,
backgroundColor: '#ccc',
width: '100%',
height: 200,
borderRadius: 10,
},
});
You can make use of scrollToIndex of FlatList
See complete code below, or the snack here.
import React, { useEffect, useState, useRef } from 'react';
import { View, Image, ImageBackground, Text, StyleSheet, ScrollView, Dimensions, FlatList, SafeAreaView, TouchableOpacity } from 'react-native';
import { AppLoading } from 'expo';
import Constants from 'expo-constants';
const DATA = [
{
id: "1",
title: "Combos",
categorie: "section1",
},
{
id: "2",
title: "Side Dishes",
categorie: "section2",
},
{
id: "3",
title: "Hot Dog",
categorie: "section3",
},
{
id: "4",
title: "Desserts",
categorie: "section4",
},
{
id: "5",
title: "Drinks",
categorie: "section5",
},
];
export default function App() {
const flatListRef = useRef();
const handleItemPress = (index) => {
flatListRef.current.scrollToIndex({ animated: true, index });
};
const renderItem = ({ item, index }) => {
return (
<Item
item={item}
onPress={() => handleItemPress(index)}
/>
);
};
const Item = ({ item, onPress, style }) => (
<TouchableOpacity onPress={onPress} >
<Text style={styles.itenscategoria}>{item.title}</Text>
</TouchableOpacity>
);
const renderDetails = ({ item, index }) => (
<View style={styles.section}>
<Text>{item.title}</Text>
</View>
);
return (
<View style={styles.container}>
<View style={styles.categories}>
<FlatList
data={DATA}
horizontal
showsHorizontalScrollIndicator={false}
renderItem={renderItem}
keyExtractor={(item) => item.id}
/>
</View>
<FlatList
ref={flatListRef}
data={DATA}
renderItem={renderDetails}
keyExtractor={(item) => item.id}
/>
</View >
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
backgroundColor: '#000',
padding: 8,
},
categories: {
backgroundColor: '#FFFFFF',
width: '100%',
height: 50,
top: 10,
marginBottom:20,
},
itenscategoria: {
padding:15,
border: 1,
borderRadius:25,
marginRight:10,
},
section: {
marginTop: 10,
backgroundColor: '#ccc',
width: '100%',
height: 200,
borderRadius: 10,
},
});

how to fetch objects in array in react native using swiper flatlist

___Here is My Code____
import React, { PureComponent } from 'react';
import { Text, Dimensions, Image, StyleSheet, View ,FlatList} from 'react-native';
import SwiperFlatList from 'react-native-swiper-flatlist';
import { Icon } from 'react-native-elements';
const URI = 'some Url';
export default class ProductDetailsSwiper extends PureComponent {
constructor(props) {
super(props);
//this.params = this.props.navigation.state.params;
this.state = {
achhamall: []
};
}
componentDidMount() {
this.fetchData();
}
async fetchData() {
//let AccessToken = this.params.AccessToken;
try {
let response = await fetch(URI ,{
method: 'Post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
},
body: 'product_id=83',
});
let responseJson = await response.json();
if (response.status >= 200 && response.status < 300) {
this.setState({
achhamall : responseJson.images
})
console.log('data fetch ' + responseJson.products);
let images = responseJson.images;
console.log('data' + images);
}else{
console.log('responseJson');
}
} catch(error) {
console.log("error response: " + error);
}
}
render() {
return (
<View style={styles.container}>
<SwiperFlatList
paginationStyle={styles.dotStyle}
// autoplay
//autoplayDelay={2}
// autoplayLoop
//index={2}
showPagination
>
<FlatList
data={this.state.achhamall}
keyExtractor= {(item) => {
return item.id.toString();
}}
renderItem={(post) => {
const item = post.item;
return(
<View style={[styles.child, { }]}>
<View
style={{
height: 30,
width: 30,
backgroundColor: 'red',
borderRadius: 15,
justifyContent: 'center',
alignItems: 'center',
top:-70,
right:10,
}}>
<Text style={{fontSize: 12, color: '#FFFFFF'}}>20%</Text>
<Text style={{fontSize: 10, color: '#FFFFFF'}}>OFF</Text>
</View>
<Image
style={{height:height/4, width:width/2, resizeMode: 'cover'}}
source={{uri: item.src}}
/>
<View style={{ top:-70,left:10}}>
<Icon name="favorite" />
</View>
</View>
)
}}/>
</SwiperFlatList>
</View>
);
}
}
export const { width, height } = Dimensions.get('window');
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent:"center",
alignItems:"center",
backgroundColor: 'white',
},
dotStyle:{
// width:0,
// height:height/4,
color:"green",
//backgroundColor:"red",
top:180
},
child: {
// height: height * 0.5,
width,
justifyContent:"center",
alignItems:"center",
flexDirection:"row"
},
text: {
// fontSize: width * 0.5,
textAlign: 'center',
},
});
my response in json to show in react native ___
"product": {
"id_product": "83",
"quantity": "0",
"allow_out_of_stock": 0,
"name": "Mini USB Cable - Android",
"price": "₹109.00",
"discount_price": "",
"discount_percentage": "",
"minimal_quantity": "1",
"images": [
{
"src": "https://www.achhamall.com/staging-achhamall.com/image/cache/catalog/usbcable/DSC_8902-200x200.jpg"
},
{
"src": "https://www.achhamall.com/staging-achhamall.com/image/cache/catalog/microusb/MiniUSBGreeAThumbnail-200x200.jpg"
},
{
"src": "https://www.achhamall.com/staging-achhamall.com/image/cache/catalog/microusb/DSC_8904-200x200.jpg"
},
{
"src": "https://www.achhamall.com/staging-achhamall.com/image/cache/catalog/microusb/DSC_8903-200x200.jpg"
},
{
"src": "https://www.achhamall.com/staging-achhamall.com/image/cache/catalog/microusb/DSC_8902-200x200.png"
}
],
how to use Flatlist condition in swiperflatlist and fetch the image and make it swipeable...
and how to asign key in and in swiperflatlist to fetch coz while searching many ways i found but while implementing it shows the error
Invariant Violation: Tried to get frame for out of range index NaN
so how to fix this?
There is some error in your code , while setting the image in state.
In your response, image is coming as responseJson.product.image but you are using it as responseJson.image.
Here is your code
this.setState({
achhamall : responseJson.images
})
It should be like below
this.setState({
achhamall : responseJson.product.images
})
achhamall : responseJson.product.images
response is in products ? so add this ....
<View style={styles.container}>
<SwiperFlatList
autoplay
autoplayDelay={2}
autoplayLoop
data={this.state.achhamall}
renderItem={({item}) => // Standard Image
<View style={[styles.child, { }]}>
<View
style={{
height: 30,
width: 30,
backgroundColor: 'red',
borderRadius: 15,
justifyContent: 'center',
alignItems: 'center',
top:-70,
right:10,
}}>
<Text style={{fontSize: 12, color: '#FFFFFF'}}>20%</Text>
<Text style={{fontSize: 10, color: '#FFFFFF'}}>OFF</Text>
</View>
<Image
style={{height:height/4, width:width/2, resizeMode: 'cover'}}
source={{uri: item.src}}
/>
<View style={{ top:-70,left:10}}>
<Icon name="favorite" />
</View>
</View>
}
showPagination
/>
</View>
u can use data as state in swiper flatlist and fetch the images

Change color after click on TouchableHighlight in react native

I have done a many research on the color change after press/click. Finally
I got this script for change the state and put it in the TouchableHighlight. But When i clicked on that, only the "underlayColor={'gray'}" is working. Can i get some idea ?
here is my code
import React, { Component } from 'react';
import {
StyleSheet,
Text,
StatusBar ,
TouchableOpacity,
View,
FlatList,
ActivityIndicator,
TouchableHighlight,
PropTypes,
Image,
Alert
} from 'react-native';
import Logo from '../components/Logo';
import Form from '../components/Front';
import {Actions} from 'react-native-router-flux';
export default class Login extends Component<{}> {
constructor() {
super();
this.state = {
dataSource: {},
pressed: false
};
}
izijackpotconfirm() {
Actions.izijackpotconfirm()
}
componentDidMount() {
var that = this;
let items = Array.apply(null, Array(25)).map((v, i) => {
return { id: i+1 };
});
that.setState({
dataSource: items,
});
}
static navigationOptions = {
title: "Izi Jackpot",
headerStyle: {
backgroundColor: "#354247"
},
headerTintColor: "#fff",
headerTitleStyle: {
fontWeight: "bold"
}
};
render() {
var jackpotNumbers = [];
let btn_class = this.state.black ? "NormalSet" : "SelectedSet";
return(
<View style={styles.container}>
<View style={styles.middlecontainer}>
<Text style={styles.logoText}>Please Select 5 Numbers and Submit</Text>
</View>
<FlatList
data={this.state.dataSource}
renderItem={({ item }) => (
<View style={{ flex: 1, flexDirection: 'column', margin: 1 }}>
<TouchableHighlight
onPress={() => { Alert.alert(this.state.pressed) }}
style={[
styles.iziPizi,
this.state.pressed ? { backgroundColor: "blue" } : {}
]}
onHideUnderlay={() => {
this.setState({ pressed: false });
}}
onShowUnderlay={() => {
this.setState({ pressed: true });
}}
underlayColor={'gray'}
>
<Text style={styles.buttonText}>{ item.id}</Text></TouchableHighlight>
</View>
)}
//Setting the number of column
numColumns={5}
keyExtractor={(item, index) => index}
/>
<View style={styles.middlecontainer}>
<TouchableOpacity style={styles.button} onPress={this.izijackpotconfirm} >
<Text style={styles.buttonText}>Submit</Text>
</TouchableOpacity>
</View>
</View>
)
}
}
const styles = StyleSheet.create({
container : {
backgroundColor:'#6F9000',
justifyContent: 'center',
flex: 1,
paddingTop: 30,
},
middlecontainer: {
textAlign: 'center',
alignItems: 'center',
justifyContent :'center',
flex:1
},
signupTextCont : {
flexGrow: 1,
alignItems:'flex-end',
justifyContent :'center',
paddingVertical:16,
flexDirection:'row'
},
signupText: {
color:'rgba(255,255,255,0.6)',
fontSize:16
},
signupButton: {
color:'#ffffff',
fontSize:16,
fontWeight:'500'
},
iziPizi: {
width: 55,
padding: 15,
margin: 5,
borderRadius: 80,
borderWidth: 2,
borderColor: '#FFFFFF',
flex:1
},
iziPiziPress: {
width: 55,
padding: 15,
margin: 5,
backgroundColor:'#1c313a',
borderRadius: 80,
borderWidth: 2,
borderColor: '#FFFFFF',
flex:1
},
button: {
width:300,
backgroundColor:'#1c313a',
borderRadius: 25,
marginVertical: 10,
paddingVertical: 13
},
buttonText: {
fontSize:16,
fontWeight:'500',
color:'#ffffff',
textAlign:'center'
},
logoText : {
color:'#FFFFFF',
fontSize: 16,
fontWeight: '500',
alignItems: 'center',
justifyContent:'center',
},
imageThumbnail: {
justifyContent: 'center',
alignItems: 'center',
height: 100,
},
});
One more thing to say that, i have used FlatList here. Please help on this. Thanks in advance.
The problem is in how you work with the styles inside the Touchable. My advice is to create 2 styles that contain the changes:
style={
this.state.pressed ? styles.pressed : styles.iziPizi
}
Inside the touchable of course:
<TouchableHighlight
onPress={() => { Alert.alert(this.state.pressed) }}
style={
this.state.pressed ? styles.pressed : styles.iziPizi
}
onHideUnderlay={() => {
this.setState({ pressed: false });
}}
onShowUnderlay={() => {
this.setState({ pressed: true });
}}
underlayColor={'gray'}
>
yes. there was a problem in FlatList. but i dont know what is its problem.
use ListItem of native-base instead.
remember that if you want to use ListItem, in constructor change
this.state = {
dataSource: {},
...
}
to
this.state = {
dataSource: [],
}
use array insead. here is a sample code for you.
<View style={{ flex: 1, flexDirection: 'column', margin: 1 }}>
<List>
{this.state.dataSource.map( item =>
<ListItem>
<TouchableHighlight
onPress={() => {}}
onShowUnderlay={this.onPress.bind(this)}
>
<Text style={styles.buttonText}>{ item.id}</Text>
</TouchableHighlight>
</ListItem> )
}
</List>
</View>
Also define onPress method.
another problem in your code is this that you setState of pressed.
it results that all of your element style will be changed. so all of your button backgroundColor will be changed.
so you must define pressed flag for every element in your array and change this flag

Type Error : Method.bind is not a function

I am new to React Native. I try to create pie chart using 'react-native-pathjs-charts' library, but I got an error mentioning method.bind is not a function.
Here is my code:
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, Animated, Easing, TouchableOpacity, Image, Linking} from 'react-native';
import { Bar } from 'react-native-pathjs-charts'
import { Pie } from 'react-native-pathjs-charts'
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
type Props = {
};
export default class App extends Component<Props> {
constructor(){
super()
this.state = {
Default_Rating: 2,
Max_Rating : 5,
}
this.Star = 'https://aboutreact.com/wp-content/uploads/2018/08/star_filled.png';
this.Star_With_Border = 'https://aboutreact.com/wp-content/uploads/2018/08/star_corner.png';
this.animatedValue = new Animated.Value(0)
}
UpdateRating( key )
{
this.setState({ Default_Rating: key });
}
componentDidMount(){
this.animate()
}
animate(){
this.animatedValue.setValue(0)
Animated.timing(
this.animatedValue,
{
toValue: 1,
duration: 2000,
easing: Easing.linear
}
).start(() => this.animate())
}
render() {
let data = [{
"name": "Washington",
"population": 7694980
}, {
"name": "Oregon",
"population": 2584160
}, {
"name": "Minnesota",
"population": 6590667,
"color": {'r':223,'g':154,'b':20}
}, {
"name": "Alaska",
"population": 7284698
}]
let options = {
margin: {
top: 20,
left: 20,
right: 20,
bottom: 20
},
width: 350,
height: 350,
color: '#2980B9',
r: 50,
R: 150,
legendPosition: 'topLeft',
animate: {
type: 'oneByOne',
duration: 200,
fillTransition: 3
},
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
color: '#ECF0F1'
}
}
let React_Native_Rating_Bar = [];
for( var i = 1; i <= this.state.Max_Rating; i++ )
{
React_Native_Rating_Bar.push(
<TouchableOpacity
activeOpacity = { 0.7 }
key = { i }
onPress = { this.UpdateRating.bind( this, i ) }>
<Image
style = { styles.StarImage }
source = { ( i <= this.state.Default_Rating ) ? { uri: this.Star } : { uri: this.Star_With_Border } } />
</TouchableOpacity>
);
}
const marginLeft = this.animatedValue.interpolate({
inputRange: [0, 1],
outputRange: [0, 150]
})
return (
<View style={styles.container}>
<View>
<Text style={styles.title}>Merchant Dashboard</Text>
</View>
<View style = { styles.childView }>
{
React_Native_Rating_Bar
}
</View>
<Text style = { styles.textStyle1 }>
Rating for your shop :
{ this.state.Default_Rating } / { this.state.Max_Rating }
</Text>
<View style={styles.box}>
<Animated.Text
style={{
marginLeft,
color: 'green'}} >
Possitive Reviews!
</Animated.Text>
<Animated.Text
style={{
marginLeft,
color: 'red'
}}>
Negative Reviews!
</Animated.Text>
<View style={styles.btnStyle}>
<TouchableOpacity style={styles.FacebookStyle} activeOpacity={0.5}>
<Image
source={{
uri:
'https://image.flaticon.com/icons/png/512/8/8816.png',
}}
style={styles.ImageIconStyle}
/>
</TouchableOpacity>
<TouchableOpacity style={styles.FacebookStyle} activeOpacity={0.5}>
<Image
source={{
uri:
'https://cdn3.iconfinder.com/data/icons/google-material-design-icons/48/ic_play_circle_outline_48px-512.png',
}}
style={styles.ImageIconStyle}
/>
</TouchableOpacity>
<TouchableOpacity style={styles.FacebookStyle} activeOpacity={0.5}>
<Image
source={{
uri:
'https://image.flaticon.com/icons/png/512/56/56616.png',
}}
style={styles.ImageIconStyle}
/>
</TouchableOpacity>
</View>
</View>
<View style={styles.container1}>
<Pie data={data}
options={options}
accessorKey="population"
margin={{top: 20, left: 20, right: 20, bottom: 20}}
color="#2980B9"
pallete={
[
{'r':25,'g':99,'b':201},
{'r':24,'g':175,'b':35},
{'r':190,'g':31,'b':69},
{'r':100,'g':36,'b':199},
{'r':214,'g':207,'b':32},
{'r':198,'g':84,'b':45}
]
}
r={50}
R={150}
legendPosition="topLeft"
label={{
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
color: '#ECF0F1'
}}
/>
</View>
<View>
<Text style={styles.LinkStyle} onPress={ ()=> Linking.openURL('https://google.com') } >Click Here To view Suggetions for improvement of the shop.</Text>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
container1: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
childView:{
justifyContent: 'center',
flexDirection: 'row',
},
StarImage:{
width: 40,
height: 40,
resizeMode: 'cover'
},
textStyle1:
{
textAlign: 'center',
color: '#000',
marginTop: 15
},
title:{
fontSize: 23,
color: '#000'
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
box: {
marginTop: 10,
height:80,
width: 300,
backgroundColor: '#b2beb5',
},
btnStyle:{
justifyContent: 'center',
flexDirection: 'row',
},
btn2Style:{
alignItems: 'flex-end'
},
ImageIconStyle: {
padding: 10,
margin: 5,
height: 25,
width: 25,
resizeMode: 'stretch',
},
TextStyle: {
color: '#fff',
marginBottom: 4,
marginRight: 20,
},
SeparatorLine: {
backgroundColor: '#fff',
width: 1,
height: 40,
},
LinkStyle: {
color: '#E91E63',
textDecorationLine: 'underline'
},
});
In my case the error was due to react-native-d3multiline-chart which occured after upgrading react-native version from 0.54.6 to 0.59.1 because internally react-native-d3multiline-chart was using react-native-svg.
I solved this error by forking this repository and changing the react-native-svg version to 9.3.3 in package.json of react-native-d3multiline-chart.
Pointing to this updated commit id in my project package.json for react-native-d3multiline-chart solved this error for me.
I think you need to use arrow function. Like this,
onPress={() => this.UpdateRating.bind(this, i)}
If this not working, pls share your error log to understand error clearly.
I'm running into this exact issue (after a RN upgrade, 0.57.8 -> 0.59.1) and am almost certain is it because the react-native-pathjs-charts library is no longer maintained, and is pointing at an old / wrong version of react-native-svg.
While I haven't solved it yet (will update), my suspicion is that updating react-native-svg & updating the package.json of react-native-pathjs-charts to not explicitly use v~5.5.1 will get us in the right direction.
UPDATE: I was able to fix it (temporarily, will need to fork the charts repo) by manually updating the module's package.json to point at my own local react-native-svg module:
"dependencies": {
"lodash": "^4.12.0",
"paths-js": "^0.4.5"
},
"peerDependencies": {
"react-native-svg": "9.3.3"
},
Just make sure you're properly adding react-native-svg to your project.

Make React Native Modal appear from top to bottom

I noticed that the Modal component's animationType property only allows for it to slide from bottom to top. How could I change the animation and make the modal appear from top to bottom?
Thanks for your time.
It doesn't look like that component allows for that type of configuration.
One thing you could do is use the Animated library to create your own modal. You would set the translateY property to negative of of the height of the device, then animate the translateY value to 0:
openModal() {
Animated.timing(this.state.modalY, {
duration: 300,
toValue: 0
}).start();
},
closeModal() {
Animated.timing(this.state.modalY, {
duration: 300,
toValue: -deviceHeight
}).start();
},
A full implementation is below:
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
TouchableHighlight,
Animated,
Dimensions
} = React;
let deviceHeight = Dimensions.get('window').height
var deviceWidth = Dimensions.get('window').width
var SampleApp = React.createClass({
openModal() {
Animated.timing(this.state.modalY, {
duration: 300,
toValue: 0
}).start();
},
closeModal() {
Animated.timing(this.state.modalY, {
duration: 300,
toValue: -deviceHeight
}).start();
},
getInitialState(){
return {
modalY: new Animated.Value(-deviceHeight)
}
},
render() {
var Modal = <Animated.View style={[ styles.modal, { transform: [ {translateY: this.state.modalY}] }]}>
<TouchableHighlight onPress={ this.closeModal } underlayColor="green" style={ styles.button }>
<Text style={ styles.buttonText }>Close Modal</Text>
</TouchableHighlight>
</Animated.View>
return (
<View style={styles.container}>
<TouchableHighlight onPress={ this.openModal } underlayColor="green" style={ styles.button }>
<Text style={ styles.buttonText }>Show Modal</Text>
</TouchableHighlight>
{ Modal }
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center'
},
button: {
backgroundColor: 'green',
alignItems: 'center',
height: 60,
justifyContent: 'center',
},
buttonText: {
color: 'white'
},
modal: {
height: deviceHeight,
width: deviceWidth,
position: 'absolute',
top:0,
left:0,
backgroundColor: '#ededed',
justifyContent: 'center',
}
});
AppRegistry.registerComponent('SampleApp', () => SampleApp);
Use react-native-modal community package. It has built in this feature. Set animationIn={'slideInDown'}, animationInTiming={300} properties.