Last active
August 25, 2020 21:38
-
-
Save Ayyagaries/8efc1f06c6324605bf74eb415a0be763 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import { StyleSheet, View, SafeAreaView } from 'react-native' | |
import Carousel from 'react-native-snap-carousel'; | |
import { Container, Header, Content, Card, CardItem, Thumbnail, Text, Button, Icon, Left, Body, Right, Image } from 'native-base'; | |
class VegRecipes extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
activeIndex: 0, | |
carouselItems: [ | |
{ | |
title: "paneer_butter_masala", | |
array: ["Text 1.1", "Text1.2", "Text1.3"].toString(), | |
}, | |
{ | |
title: "Item 2", | |
array: ["Text 2.1", "Text2.2", "Text2.3"].toString(), | |
} | |
] | |
} | |
} | |
_renderItem({ item, index }) { | |
return ( | |
<View style={{ | |
backgroundColor: 'floralwhite', | |
borderRadius: 5, | |
height: 250, | |
padding: 50, | |
marginLeft: 25, | |
marginRight: 25, | |
}}> | |
<Container> | |
<Content> | |
<Card> | |
<CardItem> | |
<Body> | |
<Image source={require("../config/assets/vg.jpg")} style={{ height: 200, width: null, flex: 1 }} /> | |
</Body> | |
</CardItem> | |
<CardItem> | |
<Body> | |
{item.array.split(",").map(info => <Text>{info}</Text>)} | |
</Body> | |
</CardItem> | |
</Card> | |
</Content> | |
</Container> | |
</View> | |
) | |
} | |
//<Image source={require("../config/assets/vg.jpg")} style={{ height: 200, width: null, flex: 1 }}></Image>); | |
render() { | |
return ( | |
<SafeAreaView style={{ flex: 1, backgroundColor: 'rebeccapurple', paddingTop: 50, }}> | |
<View style={{ flex: 1, flexDirection: 'row', justifyContent: 'center', }}> | |
<Carousel | |
layout={"default"} | |
ref={ref => this.carousel = ref} | |
data={this.state.carouselItems} | |
sliderWidth={300} | |
itemWidth={300} | |
renderItem={this._renderItem} | |
onSnapToItem={index => this.setState({ activeIndex: index })} /> | |
</View> | |
</SafeAreaView> | |
); | |
} | |
} | |
export default VegRecipes; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment