Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@airship/rn-components

Package Overview
Dependencies
Maintainers
4
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@airship/rn-components

React Native components, from basic inputs to animated wrappers, created by Airship to build quality apps.

  • 0.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
decreased by-64.44%
Maintainers
4
Weekly downloads
 
Created
Source

@airship/rn-components


This is a component library created and used by Airship for quickly building out consistent and high quality React Native apps! It is made up of basic inputs and animated wrapper components. This library is included in all Airfoil templates by default.

Features

  • ✨ Easy to use, configurable components
  • 📱 Animations that use the UI thread for a consistent 60fps on iOS and Android
  • ⏳ Saves you from building basic components from scratch every project

Getting Started

To add to your project, run the command

yarn add @airship/rn-components

Directory 📚


API Reference

AnimatedFade

An animated View that can wrap a React Native component fade a component in or fade it out.

Example:

import { AnimatedFade } from '@airship/rn-components';

<AnimatedFade delay={1000}>
  {children}
</AnimatedFade>
PropTypeRequiredDefaultDescription
triggerFadebooleannotrueBy default, animation is triggered on mount. triggerFade allows for controlled triggering.
loopbooleannofalseEnables looping for the animation
opacityStartnumberno0Defaults to 0. Values can range from 0.0 - 1.0
opacityEndnumberno1Defaults to 1. Values can range from 0.0 - 1.0
durationnumberno800Specify in ms how long the fade animation lasts.
delaynumberno0Specify in ms how long to wait until the fade animation occurs.
styleViewStylenoundefinedPass React Native View styles to AnimatedFade.
onEnd() => voidnoundefinedWhen the animation finishes and this function exists, the onEnd function will be called.


AnimatedMove

An animated View that can wrap a React Native component and move its position.

Example:

import { AnimatedMove } from '@airship/rn-components';

<AnimatedMove startY={-50} delay={1000}>
  {children}
</AnimatedMove>
PropTypeRequiredDefaultDescription
moveOnMountbooleannotrueAnimatedMove is set to start animating on render. Setting this to false in conjunction with triggerMove will allow you to control when the animation occurs.
triggerMovebooleannofalseSetting to true will cause the move animation to start.
tensionnumberno18Controls the speed. Reference
frictionnumberno4Controls "bounciness"/overshoot. Reference
toXnumberno0Move your component to a new X position.
toYnumberno0Move your component to a new Y position.
startXnumberno0Move your component to its X origin position (ex. setting to -10 will have the component move from the left to its position you have in your styles).
startYnumberno0Move your component to its Y origin position (ex. setting to -10 will have the component move from the top to its position you have in your styles).
delaynumberno0Specify in ms how long to wait until the animation occurs.
styleViewStylenoundefinedPass React Native View styles to AnimatedMove.
onEnd() => voidnoundefinedWhen the animation finishes and this function exists, the onEnd function will be called.


AnimatedPressable

An animated View that changes its scale on press, and returns to its original position on the press out. It can render out a component with props available to it such as color interpolation based on the pressed state.

Example:

import { AnimatedPressable } from '@airship/rn-components';

<View>
  <AnimatedPressable
    colorStart={'rgb(255, 255, 255)'}
    colorEnd={'rgb(255, 42, 19)'}
    renderComponent={(colorInterpolation) => (
      <ThumbsUpSVG
        height={54}
        width={63}
        stroke={colors.orange}
        fillColor={colorInterpolation}
      />
    )}
  />
  <AnimatedPressable
    toScaleValue={0.8}
    friction={12}
    tension={120}
    onPress={() => Alert.alert('Pressed!')}
    renderComponent={() => (
      <View
        style={{
          marginTop: 32,
          width: 100,
          height: 100,
          backgroundColor: colors.trueBlack,
          borderRadius: 12,
        }}
      />
    )}
  />
  <AnimatedPressable
    toScaleValue={1.5}
    renderComponent={() => (
      <View
        style={{
          marginTop: 32,
          width: 100,
          height: 100,
          backgroundColor: colors.orange,
          borderRadius: 12,
        }}
      />
    )}
  />
</View>
PropTypeRequiredDefaultDescription
toScaleValuenumberno0.5This number controls how much the Animated.View will scale. It can be lower or higher than 1.
tensionnumberno18Controls the speed. Reference
frictionnumberno4Controls "bounciness"/overshoot. Reference
colorStartstringnonullInitial color value, must be given as a rgb string. Color interpolation does not work with hexes. NOTE: Works off of pressed. Think of it as a "like" button. If pressed has a true value, that means the current color is colorEnd.
colorEndstringnonullEnd color value, must be given as a rgb string. Color interpolation does not work with hexes. NOTE: Works off of pressed. Think of it as a "like" button. If pressed has a true value, that means the current color is colorEnd.
isPressedbooleannofalseThe current state of AnimatedPressable. Can be passed a value such as starting with pressed set to true, which means the colorEnd is the starting color.
onPress() => voidnoundefinedWhen the animation finishes (press out) and this function exists, the onPress function will be called.
callFunctionOnPressInbooleannofalseSetting to true will cause the onPress function to call on the press in of the tap instead of the press out default.
renderComponent(colorInterpolation: Animated.AnimatedInterpolation) => React.ReactElementnoundefinedThis render function allows for a child component to be passed with access to the colorInterpolation values IF a colorStart and colorEnd have been set. Otherwise the value will not exist and will render the component without value to colorInterpolation.
styleViewStylenoundefinedPass React Native View styles to AnimatedPressable.


SegmentedControl

An animated tab controller for selections in an app with customizable color schemes.

Example:

import React, { useState } from 'react';
import { StyleSheet } from 'react-native';
import { SegmentedControl } from '@airship/rn-components';

export const App = () => {
  const [currIdx, setCurrIdx] = useState(0);
  const [currIdx2, setCurrIdx2] = useState(0);
  const [currIdx3, setCurrIdx3] = useState(0);

  return (
    <View>
      <SegmentedControl
        tabs={['First', 'Second']}
        onChange={(idx) => setCurrIdx(idx)}
        currentIndex={currIdx}
        activeSegmentBackgroundColor={colors.background}
        containerStyle={styles.segmentContainer}
        textStyle={styles.textStyle}
      />
      <SegmentedControl
        tabs={['First', 'Second', 'Third']}
        onChange={(idx) => setCurrIdx2(idx)}
        currentIndex={currIdx2}
        activeSegmentBackgroundColor={colors.background}
        containerStyle={styles.segmentContainer}
        textStyle={styles.textStyle}
      />
      <SegmentedControl
        tabs={['First', 'Second']}
        onChange={(idx) => setCurrIdx3(idx)}
        currentIndex={currIdx3}
        activeSegmentBackgroundColor={colors.orange}
        containerStyle={styles.segmentContainerCustom}
        textStyle={styles.textStyle}
        activeTextColor={'#FFF'}
        activeContainerStyles={styles.activeContainer}
      />
    </View>
  )

  const styles = StyleSheet.create({
    segmentContainer: {
      backgroundColor: colors.background3,
    },
    segmentContainerCustom: {
      backgroundColor: colors.background3,
      borderRadius: 50,
    },
    textStyle: {
      color: colors.text,
    },
    activeContainer: { borderRadius: 50 },
  })
}
PropTypeRequiredDefaultDescription
tabsstring[]yes[]An array of strings, with each one being a label for each tab.
onChange(index: number) => voidyesnullExposes the current index when changing tabs for state management.
currentIndexnumberyesnullThis is the currently selected tab.
activeSegmentBackgroundColorstringyes''Color for the currently selected tab.
containerStyleViewStylenonullAdd additional/override styling to the segment container.
textStyleTextStylenonullAdd additional/override styling to the text components.
activeTextColorstringno#20242BColor of the text in the active selected tab.
activeContainerStylesViewStylenonullAdd additional/override styling to the active selected tab container.


Keywords

FAQs

Package last updated on 21 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc