-
Notifications
You must be signed in to change notification settings - Fork 1
/
SwipeCards.js
88 lines (77 loc) · 2.11 KB
/
SwipeCards.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// SwipeCards.js
'use strict';
import React, { Component } from 'react';
import {StyleSheet, Text, View, Image} from 'react-native';
import SwipeCards from 'react-native-swipe-cards';
import Images from './images/heating-cooling';
class Card extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<View style={[styles.card, {backgroundColor: this.props.backgroundColor}]}>
<Text>{this.props.text}</Text>
<Image source{{uri: this.props.source}} style={{width: 40, height: 40}} />
</View>
)
}
}
class NoMoreCards extends Component {
constructor(props) {
super(props);
}
render() {
return (
<View>
<Text style={styles.noMoreCardsText}>No more cards</Text>
</View>
)
}
}
export default class extends React.Component {
constructor(props) {
super(props);
this.state = {
cards: [
{text: "Air Source Heat Pump" , source: 'https://www.alpinehomeair.com/partnernet/photoFiles/LiveCache/imgCache-BMKH_640_0.jpg', backgroundColor: 'red'},
{text: "Ground Source Heat Pump", source: 'http://images.inyopools.com/cloud/images/hayward-hp21404t-01.jpeg?format=jpg&scale=both&anchor=middlecenter&autorotate=true&mode=pad&width=650&height=650', backgroundColor: 'purple'},
]
};
}
handleYup (card) {
console.log(`Yup for ${card.text}`)
}
handleNope (card) {
console.log(`Nope for ${card.text}`)
}
handleMaybe (card) {
console.log(`Maybe for ${card.text}`)
}
render() {
// If you want a stack of cards instead of one-per-one view, activate stack mode
// stack={true}
return (
<SwipeCards
cards={this.state.cards}
renderCard={(cardData) => <Card {...cardData} />}
renderNoMoreCards={() => <NoMoreCards />}
handleYup={this.handleYup}
handleNope={this.handleNope}
handleMaybe={this.handleMaybe}
hasMaybeAction
/>
)
}
}
const styles = StyleSheet.create({
card: {
justifyContent: 'center',
alignItems: 'center',
width: 300,
height: 300,
},
noMoreCardsText: {
fontSize: 22,
}
})