How to use react-native-linear-gradient - 6 common examples

To help you get started, we’ve selected a few react-native-linear-gradient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github react-native-community / react-native-linear-gradient / Examples / AnimatedGradientTransition / src / AnimatedGradientTransition.js View on Github external
import React, {Component} from 'react';
import {PropTypes} from 'prop-types';
import {Animated, Easing} from 'react-native';
import _ from 'lodash';

import NativeLinearGradient from 'react-native-linear-gradient';

class LinearGradient extends Component {
  static propTypes = {
    ...NativeLinearGradient.propTypes,
  };

  // Generate back the colors array with all transformed props
  _generateColorsArray(props) {
    const propsKeys = Object.keys(props);
    const colorsArray = [];

    propsKeys.forEach(key => {
      if (
        key.indexOf('animatedColor') !== -1 &&
        props[key] &&
        typeof props[key] === 'string'
      ) {
        colorsArray.push(props[key]);
      }
    });
github react-native-community / react-native-linear-gradient / Examples / AnimatedGradientTransition / src / AnimatedGradientTransition.js View on Github external
const colorsArray = this._generateColorsArray(props);
    const nativeLinearProps = _.omit(props, Object.keys(colorsArray));

    return (
      
        {children}
      
    );
  }
}

Animated.LinearGradient = Animated.createAnimatedComponent(LinearGradient);

class AnimatedGradientTransition extends Component {
  static propTypes = {
    ...NativeLinearGradient.propTypes,
    animation: PropTypes.shape({
      toValue: PropTypes.number,
      duration: PropTypes.number,
      easing: PropTypes.func,
    }),
  };

  static defaultProps = {
    animation: {
      toValue: 1,
      duration: 500,
      easing: Easing.linear,
    },
  };

  constructor(props) {
github Skjutsgruppen / skjutsgruppen-reactnative / app / components / common / circle.js View on Github external
if (animatable && params.animatedValue) {
      top = params.animatedValue.interpolate({
        inputRange: [0, 1000],
        outputRange: [yOffset, -1000],
      });
    }
    return (
      
    );
  }
}


Circle.propTypes = {
  style: LinearGradient.propTypes.style,
  animatable: PropTypes.bool,
  navigation: PropTypes.shape(),
};

Circle.defaultProps = {
  style: {},
  animatable: false,
  navigation: null,
};

export default withNavigation(Circle);
github mozilla-magnet / magnet-client / lib / views / list-item.js View on Github external
'use strict';

/**
 * Dependencies
 */

const LinearGradient = require('react-native-linear-gradient').default;
const debug = require('../debug')('ListItem');
const theme = require('../../config').theme;
const tinycolor = require('tinycolor2');
const React = require('react');

/**
 * Locals
 */

const {
  PanResponder,
  StyleSheet,
  Animated,
  Image,
  Text,
  View,
github guns2410 / react-native-components / lib / View / index.js View on Github external
import React from 'react';
import PropTypes from 'prop-types';
import { Platform } from 'react-native';
import { View as RNView, KeyboardAvoidingView } from 'react-native';
import { renderChildren } from '../helpers';
import { MergeTheme } from '../theme';

const LinearGradient = Platform.OS === 'ios' ?
  require('react-native-linear-gradient/index.ios').default :
  require('react-native-linear-gradient/index.android').default;

export default class View extends React.PureComponent {

  constructor (props) {
    super(props);
    this.theme = MergeTheme(props.theme);
  }

  componentWillReceiveProps (nextProps) {
    if (this.props.theme !== nextProps.theme) this.theme = MergeTheme(nextProps.theme)
  }

  render () {
    let Component = RNView;
    if (this.props.keyboardaware) Component = KeyboardAvoidingView;
github guns2410 / react-native-components / lib / View / index.js View on Github external
import React from 'react';
import PropTypes from 'prop-types';
import { Platform } from 'react-native';
import { View as RNView, KeyboardAvoidingView } from 'react-native';
import { renderChildren } from '../helpers';
import { MergeTheme } from '../theme';

const LinearGradient = Platform.OS === 'ios' ?
  require('react-native-linear-gradient/index.ios').default :
  require('react-native-linear-gradient/index.android').default;

export default class View extends React.PureComponent {

  constructor (props) {
    super(props);
    this.theme = MergeTheme(props.theme);
  }

  componentWillReceiveProps (nextProps) {
    if (this.props.theme !== nextProps.theme) this.theme = MergeTheme(nextProps.theme)
  }

  render () {
    let Component = RNView;
    if (this.props.keyboardaware) Component = KeyboardAvoidingView;

react-native-linear-gradient

A <LinearGradient> element for React Native

MIT
Latest version published 7 months ago

Package Health Score

75 / 100
Full package analysis

Similar packages