import * as React from "react"; import { View, StyleSheet, Text, TouchableOpacity } from "react-native"; import { Plan } from "../../types/plan"; interface Props { plans: Plan[]; skuSelected?: string; onPlanPressed: (plan: Plan) => () => void; } interface State {} export default class PlanComponent extends React.PureComponent { constructor(props: Props) { super(props); this.state = {}; } private renderRecommend = () => { return ( Recommend ); }; public render(): React.ReactNode { const selected = this.props.plans.find( (it) => it.sku === this.props.skuSelected ); return ( Choose a plan {this.props.plans.map((plan) => { const isSelected = plan.sku === this.props.skuSelected; return ( {plan.name} {plan.price} {plan.isRecommend && this.renderRecommend()} ); })} {selected.trial > 0 && ( Trial period:{" "} {selected.trial} days for FREE )} ); } } const styles = StyleSheet.create({ recommendWrapper: { position: "absolute", top: -10, backgroundColor: "rgb(255, 148, 27)", paddingHorizontal: 13, height: 20, justifyContent: "center", alignItems: "center", borderRadius: 10, }, container: { justifyContent: "center", alignItems: "center", height: 120, borderRadius: 12, marginHorizontal: 8, shadowColor: "#383838", shadowOffset: { width: 0, height: 2, }, shadowOpacity: 0.15, shadowRadius: 5, backgroundColor: "white", elevation: 5, }, planWrapper: { marginTop: 15, flexDirection: "row", justifyContent: "space-between", marginHorizontal: 20, alignItems: "center", }, titleStyle: { fontSize: 18, marginBottom: 8, fontWeight: "600", textTransform: "uppercase", }, wrapper: { width: "100%", justifyContent: "center", alignItems: "center", }, });