import * as React from "react"; import { Image, Linking, Modal, Platform, ScrollView, StyleSheet, Text, TouchableOpacity, View, } from "react-native"; import * as RNIap from "react-native-iap"; import { IAPProps } from "../iap-type"; import { Plan } from "../types/plan"; import { DimensionUtils } from "../utils/DimensionUtils"; import InformationComponent from "./components/information.component"; import PlanComponent from "./components/plan.component"; import images from "./res/images"; interface State {} export default class RowPopup extends React.PureComponent { static defaultProps: any = { benefits: [], plans: [], }; constructor(props: IAPProps) { super(props); this.state = {}; } private onPlanPressed = (plan: Plan) => async () => { if (plan.type === "subs") { try { await RNIap.requestSubscription(plan.sku); } catch (err) { console.warn(err.code, err.message); } } else if (plan.type === "product") { try { await RNIap.requestPurchase(plan.sku, false); } catch (err) { console.warn(err.code, err.message); } } }; private onTermsPressed = async () => { const supported = await Linking.canOpenURL(this.props.termsUrl); if (supported) { await Linking.openURL(this.props.termsUrl); } }; private onPrivacyPressed = async () => { const supported = await Linking.canOpenURL(this.props.privacyUrl); if (supported) { await Linking.openURL(this.props.privacyUrl); } }; private getNote = () => { let note = `Payment will be charged to your ${ Platform.OS === "android" ? "Google Play" : "iTunes" } account at the end of your free trial or confirmation of purchase if you are not starting a trial.`; if (this.props.existSubs) { note = `Payment will be charged to your ${ Platform.OS === "android" ? "Google Play" : "iTunes" } account at the end of your free trial or confirmation of purchase if you are not starting a trial. Subscription will automatically renew unless it is cancelled at least 24 hours before the end of your trial or current period. Your account will be charged for renewal within 24 hours prior to the end of the current period. You can manage or cancel the subscriptions at any time in ${ Platform.OS === "android" ? "Google Play" : "iTunes" } settings on your device. By tapping "Continue" you confirm that you have read the Terms of Use and Privacy Policy and agree to be bound by their terms.`; } return note; }; private renderView() { const note = this.getNote(); return ( Restore {note} Terms of use Privacy Policy ); } public render(): React.ReactNode { return ( {this.renderView()} ); } } const styles = StyleSheet.create({ labelStyle: { color: "white", fontWeight: "600", fontSize: 15, }, ctaWrapper: { backgroundColor: "rgb(255, 148, 27)", marginHorizontal: 30, height: 40, marginTop: 30, borderRadius: 20, justifyContent: "center", alignItems: "center", }, dividerStyle: { marginHorizontal: 35, height: 1, marginVertical: 20, backgroundColor: "#e2e2e2", }, container: { flex: 1, backgroundColor: "white", paddingTop: DimensionUtils.getStatusBarHeight(), }, });