1 | var __rest = (this && this.__rest) || function (s, e) {
|
2 | var t = {};
|
3 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
4 | t[p] = s[p];
|
5 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
6 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
7 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
8 | t[p[i]] = s[p[i]];
|
9 | }
|
10 | return t;
|
11 | };
|
12 | import React from 'react';
|
13 | import { View, Platform, StyleSheet, } from 'react-native';
|
14 | import { normalizeText } from '../helpers';
|
15 | import { fonts, withTheme } from '../config';
|
16 | import Text from '../text/Text';
|
17 | import Button from '../buttons/Button';
|
18 | import Icon from '../icons/Icon';
|
19 | const PricingCard = (props) => {
|
20 | var _a, _b, _c;
|
21 | const { theme } = props, rest = __rest(props, ["theme"]);
|
22 | const { containerStyle, wrapperStyle, title, price, info, button, color = (_a = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _a === void 0 ? void 0 : _a.primary, titleStyle, pricingStyle, infoStyle, onButtonPress } = rest, attributes = __rest(rest, ["containerStyle", "wrapperStyle", "title", "price", "info", "button", "color", "titleStyle", "pricingStyle", "infoStyle", "onButtonPress"]);
|
23 | return (<View {...attributes} style={StyleSheet.flatten([
|
24 | Object.assign({ margin: 15, marginBottom: 15, backgroundColor: (_b = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _b === void 0 ? void 0 : _b.white, borderWidth: 1, padding: 15, borderColor: (_c = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _c === void 0 ? void 0 : _c.grey5 }, Platform.select({
|
25 | android: {
|
26 | elevation: 1,
|
27 | },
|
28 | default: {
|
29 | shadowColor: 'rgba(0,0,0, .2)',
|
30 | shadowOffset: { height: 1, width: 0 },
|
31 | shadowOpacity: 0.5,
|
32 | shadowRadius: 0.5,
|
33 | },
|
34 | })),
|
35 | containerStyle && containerStyle,
|
36 | ])}>
|
37 | <View style={StyleSheet.flatten([
|
38 | styles.wrapper,
|
39 | wrapperStyle && wrapperStyle,
|
40 | ])}>
|
41 | <Text testID="pricingCardTitle" style={StyleSheet.flatten([
|
42 | styles.pricingTitle,
|
43 | titleStyle,
|
44 | { color },
|
45 | ])}>
|
46 | {title}
|
47 | </Text>
|
48 |
|
49 | <Text style={StyleSheet.flatten([styles.pricingPrice, pricingStyle])}>
|
50 | {price}
|
51 | </Text>
|
52 |
|
53 | {info === null || info === void 0 ? void 0 : info.map((item) => {
|
54 | var _a;
|
55 | return (<Text key={item} style={StyleSheet.flatten([
|
56 | Object.assign({ textAlign: 'center', marginTop: 5, marginBottom: 5, color: (_a = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _a === void 0 ? void 0 : _a.grey3 }, Platform.select({
|
57 | android: Object.assign({}, fonts.android.bold),
|
58 | default: {
|
59 | fontWeight: '600',
|
60 | },
|
61 | })),
|
62 | infoStyle,
|
63 | ])}>
|
64 | {item}
|
65 | </Text>);
|
66 | })}
|
67 |
|
68 | {React.isValidElement(button) ? (button) : (<PricingButton color={color} onButtonPress={onButtonPress} {...button}/>)}
|
69 | </View>
|
70 | </View>);
|
71 | };
|
72 | const PricingButton = (props) => {
|
73 | const { title, buttonStyle, color, titleStyle, onButtonPress, icon } = props, buttonProps = __rest(props, ["title", "buttonStyle", "color", "titleStyle", "onButtonPress", "icon"]);
|
74 | return (<Button title={title} buttonStyle={StyleSheet.flatten([
|
75 | styles.button,
|
76 | buttonStyle,
|
77 | { backgroundColor: color },
|
78 | ])} titleStyle={titleStyle} onPress={onButtonPress} icon={React.isValidElement(icon) ? (icon) : typeof icon === 'string' ? (<Icon name={icon} size={15} color="white"/>) : (<Icon {...icon}/>)} {...buttonProps}/>);
|
79 | };
|
80 | PricingCard.defaultProps = {
|
81 | info: [],
|
82 | };
|
83 | const styles = StyleSheet.create({
|
84 | wrapper: {
|
85 | backgroundColor: 'transparent',
|
86 | },
|
87 | pricingTitle: Object.assign({ textAlign: 'center', fontSize: normalizeText(30) }, Platform.select({
|
88 | android: Object.assign({}, fonts.android.black),
|
89 | default: {
|
90 | fontWeight: '800',
|
91 | },
|
92 | })),
|
93 | pricingPrice: Object.assign({ textAlign: 'center', marginTop: 10, marginBottom: 10, fontSize: normalizeText(40) }, Platform.select({
|
94 | android: Object.assign({}, fonts.android.bold),
|
95 | default: {
|
96 | fontWeight: '700',
|
97 | },
|
98 | })),
|
99 | button: {
|
100 | marginTop: 15,
|
101 | marginBottom: 10,
|
102 | },
|
103 | });
|
104 | export { PricingCard, PricingButton };
|
105 | export default withTheme(PricingCard, 'PricingCard');
|