London Paywall

The London Paywall component provides a visually distinct layout with multiple subscription plans, making it easy for users to select their preferred option. This component is designed to handle dynamic product lists and is fully customizable to match your app's branding.


Features

  • Dynamic Product Selection
    Display subscription plans dynamically with titles and prices.

  • User Interaction
    Allow users to select a plan and confirm their choice.

  • Customizable Appearance
    Adjust colors, buttons, and text styles to fit your design.


Props

PropTypeDefaultDescription
visiblebooleanfalseControls the visibility of the paywall.
onContinue(index: number)RequiredCallback triggered when the user presses the continue button.
onClose() => voidRequiredCallback triggered when the close button is pressed.
headerTextstring''The main title of the paywall.
descriptionTextstring''The subtitle or description of the paywall.
imageComponentReact.ReactNodeRequiredA custom image component to display at the top of the paywall.
productsArray[]Array of product plans to display, each with a title and price.
buttonTextstring'Continue'Text displayed on the main button.
backgroundColorstring'#FFFFFF'Background color of the paywall.
closeButtonBgColorstring'rgba(0, 0, 0, 0.5)'Background color of the close button.
closeButtonTextColorstring'#FFFFFF'Text color of the close button.
closeButtonDelaynumber0Delay in milliseconds before the close button appears.
displayCloseButtonbooleantrueControls whether the close button is displayed.
buttonBgColorstring'#4CAF50'Background color of the main button.
buttonTextColorstring'#FFFFFF'Text color of the main button.
buttonRadiusnumber55Corner radius of the main button.
buttonWidthPercentagenumber80Width of the button as a percentage of the screen width.
textButtonColorstring'#666666'Text color for additional link buttons.
textButtonUnderlinebooleantrueControls whether additional link buttons are underlined.

Example Usage

Here’s an example of how to use the London Paywall component:

import React from 'react';
import { View, Button } from 'react-native';
import { usePaywall } from 'react-native-paywall';

const App = () => {
  // Initialize the usePaywall hook
  const { showPaywall, hidePaywall, PaywallComponent } = usePaywall();

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      {/* Button to trigger the paywall */}
      <Button title="Show Paywall" onPress={() => showPaywall('london')} />

      {/* Render the paywall component */}
      <PaywallComponent
        onContinue={(selectedIndex) => {
          console.log(`User continued with plan index: ${selectedIndex}`);
          hidePaywall(); // Hide the paywall after selection
        }}
        headerText="Choose Your Plan"
        descriptionText="Access premium features with one of our subscription plans."
        products={[
          {
            identifier: '$rc_monthly',
            product: {
              title: 'Monthly Plan',
              priceString: '$4.99',
            },
          },
          {
            identifier: '$rc_annual',
            product: {
              title: 'Annual Plan',
              priceString: '$39.99',
            },
          },
        ]}
        backgroundColor="#f0f0f0"
        buttonBgColor="#008CBA"
        buttonTextColor="#FFFFFF"
      />
    </View>
  );
};

export default App;

Styling the Component

The London Paywall provides a default style, but you can customize it through the following props:

  • Plan Selection: Highlight selected plans with custom colors and borders.
  • Button Styling: Adjust colors, text, and dimensions with buttonBgColor, buttonTextColor, buttonRadius, and buttonWidthPercentage.
  • Background: Use the backgroundColor prop for a custom background.