Modern Paywall Screen with Lifetime Option
Screen is created using these React Native Core Components: <SafeAreaView />, <View />, <TouchableOpacity />, <Text />, <TouchableWithoutFeedback />
import React, { useState } from 'react';
import {
StyleSheet,
SafeAreaView,
View,
TouchableOpacity,
Text,
TouchableWithoutFeedback,
} from 'react-native';
import FeatherIcon from 'react-native-vector-icons/Feather''@expo/vector-icons/Feather';
const prices = [
{
price: '$99.99',
label: 'Lifetime',
description: 'Pay Once - Access Forever',
},
{ price: '$24.99', label: 'Yearly', description: 'Includes Family Sharing' },
{ price: '$9.99', label: 'Monthly', description: 'Includes Family Sharing' },
];
export default function Example() {
const [selected, setSelected] = useState(0);
return (
<SafeAreaView style={{ flex: 1, backgroundColor: '#F4EFF3' }}>
<View style={styles.header}>
<TouchableOpacity
onPress={() => {
// handle onPress
}}
style={styles.headerAction}>
<FeatherIcon
color="#F82E08"
name="arrow-left"
size={24} />
</TouchableOpacity>
<Text style={styles.title}>👑 Premium Access</Text>
<Text style={styles.subtitle}>
Boost your productivity with premium tools and personalized features.
Subscribe now for unlimited access!
</Text>
</View>
<View style={styles.form}>
<View>
{prices.map((item, index) => {
const isActive = selected === index;
return (
<TouchableWithoutFeedback
key={index}
onPress={() => setSelected(index)}>
<View
style={[
styles.radio,
isActive
? { borderColor: '#F82E08', backgroundColor: '#feeae6' }
: {},
]}>
<FeatherIcon
color={isActive ? '#F82E08' : '#363636'}
name={isActive ? 'check-circle' : 'circle'}
size={24} />
<View style={styles.radioBody}>
<View>
<Text style={styles.radioLabel}>{item.label}</Text>
<Text style={styles.radioText}>{item.description}</Text>
</View>
<Text
style={[
styles.radioPrice,
isActive && styles.radioPriceActive,
]}>
{item.price}
</Text>
</View>
</View>
</TouchableWithoutFeedback>
);
})}
</View>
<View>
<TouchableOpacity
onPress={() => {
// handle onPress
}}>
<View style={styles.btn}>
<Text style={styles.btnText}>Continue</Text>
</View>
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
// handle onPress
}}>
<View style={styles.btnEmpty}>
<Text style={styles.btnEmptyText}>Restore Purchase</Text>
</View>
</TouchableOpacity>
<Text style={styles.formFooterText}>
Plan renews automatically. You can manage and cancel your
subscription in App Store.
</Text>
</View>
</View>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
title: {
fontSize: 34,
fontWeight: 'bold',
color: '#181818',
marginBottom: 12,
},
subtitle: {
fontSize: 15,
lineHeight: 20,
fontWeight: '500',
color: '#889797',
},
/** Header */
header: {
paddingHorizontal: 24,
marginBottom: 28,
},
headerAction: {
width: 40,
height: 40,
borderRadius: 9999,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#ffdada',
marginBottom: 16,
},
/** Form */
form: {
flexGrow: 1,
flexShrink: 1,
flexBasis: 0,
paddingBottom: 24,
justifyContent: 'space-between',
paddingHorizontal: 24,
},
formFooterText: {
marginTop: 12,
fontSize: 14,
fontWeight: '500',
color: '#929292',
textAlign: 'center',
},
/** Radio */
radio: {
padding: 16,
flexDirection: 'row',
alignItems: 'flex-start',
justifyContent: 'flex-start',
borderWidth: 2,
borderColor: 'transparent',
borderStyle: 'solid',
borderRadius: 24,
marginBottom: 16,
backgroundColor: '#fff',
},
radioBody: {
paddingLeft: 10,
flexGrow: 1,
flexShrink: 1,
flexBasis: 0,
flexDirection: 'row',
alignItems: 'flex-start',
justifyContent: 'space-between',
},
radioLabel: {
fontSize: 19,
fontWeight: '700',
color: '#1d1d1d',
},
radioText: {
marginTop: 6,
fontSize: 16,
fontWeight: '500',
color: '#889797',
},
radioPrice: {
fontSize: 16,
fontWeight: '600',
color: '#1d1d1d',
},
radioPriceActive: {
transform: [
{
scale: 1.2,
},
],
},
/** Button */
btn: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
borderRadius: 8,
paddingVertical: 16,
paddingHorizontal: 24,
borderWidth: 1,
backgroundColor: '#F82E08',
borderColor: '#F82E08',
},
btnText: {
fontSize: 17,
lineHeight: 22,
fontWeight: 'bold',
color: '#fff',
},
btnEmpty: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
borderRadius: 8,
paddingVertical: 16,
paddingHorizontal: 24,
borderWidth: 1.5,
backgroundColor: 'transparent',
borderColor: '#F82E08',
marginTop: 12,
},
btnEmptyText: {
fontSize: 17,
lineHeight: 22,
fontWeight: 'bold',
color: '#F82E08',
},
});In-App Purchase Integration 💰
UI/UX implementation of the React Native Component with In-App Purchase integration using the `react-native-iap` package and NodeJS (Express) server.
import React from 'react';
import { StyleSheet, Text, SafeAreaView, ScrollView, StatusBar } from 'react-native';
const App = () => {
return (
<SafeAreaView style={styles.container}>
<ScrollView style={styles.scrollView}>
<Text style={styles.text}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
</Text>
<View>
<Text style={styles.text}>in voluptate velit esse cillum dolore eu fugiat nulla</Text>
</View>
</ScrollView>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: StatusBar.currentHeight,
},
scrollView: {
backgroundColor: 'pink',
marginHorizontal: 20,
},
text: {
fontSize: 42,
},
});
export default App;
Dependencies
Before getting started, make sure you have all the necessary dependencies for this component. Follow the steps below to install any missing dependencies.
-
Install the package.
npm install --save react-native-vector-icons
-
Link the native packages for iOS.
npx pod-install
In React Native 0.60+ the CLI autolink feature links the module while building the app.
-
Add Fonts to the
Info.plistfile.
Open your XCode project, right click on the Info.plist, and select Open As -> Source Code.
Next, copy the fonts below into your Info.plist.
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
<string>Entypo.ttf</string>
<string>EvilIcons.ttf</string>
<string>Feather.ttf</string>
<string>FontAwesome.ttf</string>
<string>FontAwesome5_Brands.ttf</string>
<string>FontAwesome5_Regular.ttf</string>
<string>FontAwesome5_Solid.ttf</string>
<string>FontAwesome6_Brands.ttf</string>
<string>FontAwesome6_Regular.ttf</string>
<string>FontAwesome6_Solid.ttf</string>
<string>Foundation.ttf</string>
<string>Ionicons.ttf</string>
<string>MaterialIcons.ttf</string>
<string>MaterialCommunityIcons.ttf</string>
<string>SimpleLineIcons.ttf</string>
<string>Octicons.ttf</string>
<string>Zocial.ttf</string>
<string>Fontisto.ttf</string>
</array>
Note: You can only select the fonts you would like to use in your React Native Application.
After you added these fonts the Info.plist file should look like this:
![]()
-
Add
fonts.gradlefor Android.
Open android/app/build.gradle (NOT android/build.gradle) and add the following code to the bottom:
apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")
If you want to customize fonts, use:
project.ext.vectoricons = [
iconFontNames: [ 'MaterialIcons.ttf', 'EvilIcons.ttf' ]
]
apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")
Original instructions can be found on Github: https://github.com/oblador/react-native-vector-icons