} = React;

var groupByEveryN = require('groupByEveryN');
var logError = require('logError');

var propTypes = {
  /**
   * The group where the photos will be fetched from. Possible
   * values are 'Album', 'All', 'Event', 'Faces', 'Library', 'PhotoStream'
   * and SavedPhotos.
   */
  groupTypes: React.PropTypes.oneOf([
    'Album',
    'All',
    'Event',
    'Faces',
    'Library',
    'PhotoStream',
    'SavedPhotos',
  ]),

  /**
   * Number of images that will be fetched in one page.
   */
  batchSize: React.PropTypes.number,

  /**
   * A function that takes a single image as a parameter and renders it.
   */
  renderImage: React.PropTypes.func,
Пример #2
0
var { requireNativeComponent, PropTypes } = require('react-native');

var iface = {
  name: 'ImageView',
  propTypes: {
    src: PropTypes.string,
    borderRadius: PropTypes.number,
    resizeMode: PropTypes.oneOf(['cover', 'contain', 'stretch']),
  },
};

module.exports = requireNativeComponent('RCTCamera', iface);
var React = require('react-native');
var {
  StyleSheet,
  ActivityIndicatorIOS,
  View,
  Text,
  isValidElement,
  createElement
} = React;

var RefreshingIndicator = React.createClass({
  propTypes: {
    description: React.PropTypes.oneOfType([ React.PropTypes.string, React.PropTypes.element ])
  },
  getDefaultProps: function() {
    return {
      activityIndicatorComponent: ActivityIndicatorIOS
    }
  },

  renderActivityIndicator: function(style) {
    var activityIndicator = this.props.activityIndicatorComponent;

    if(isValidElement(activityIndicator)) {
      return activityIndicator;
    } else {
      return createElement(activityIndicator, { style })
    }
  },

  render: function() {
Пример #4
0
                    value={this.state.searchText}
                    style={styles.searchInput}
                    onChangeText={this._onChangeSearchText}
                    selectTextOnFocus={true}
                    placeholder={'Type beer name'}
                    />
            </View>
        );
    }
});

var MapRegionInput = React.createClass({
    propTypes: {
        region: React.PropTypes.shape({
            latitude: React.PropTypes.number.isRequired,
            longitude: React.PropTypes.number.isRequired,
            latitudeDelta: React.PropTypes.number.isRequired,
            longitudeDelta: React.PropTypes.number.isRequired,
        }),
        onChange: React.PropTypes.func.isRequired,
    },

    getInitialState: function () {
        return {
            region: {
                latitude: 0,
                longitude: 0,
                latitudeDelta: 0,
                longitudeDelta: 0,
            }
        };
    },
Пример #5
0
      {...otherProps}/>;
  }
};

PieChart.propTypes = {
  config: React.PropTypes.shape({
    ...globalCommonProps,
    ...pieRadarCommonProps,
    dataSets: React.PropTypes.arrayOf(React.PropTypes.shape({
      ...commonDataSetProps,
      sliceSpace: React.PropTypes.number,
      selectionShift: React.PropTypes.number
    })),
    labels: React.PropTypes.arrayOf(React.PropTypes.string),
    holeColor: React.PropTypes.string,
    holeTransparent: React.PropTypes.bool,
    holeAlpha: React.PropTypes.number,
    drawHoleEnabled: React.PropTypes.bool,
    centerText: React.PropTypes.string,
    drawCenterTextEnabled: React.PropTypes.bool,
    holeRadiusPercent: React.PropTypes.number,
    transparentCircleRadiusPercent: React.PropTypes.number,
    drawSliceTextEnabled: React.PropTypes.bool,
    usePercentValuesEnabled: React.PropTypes.bool,
    centerTextRadiusPercent: React.PropTypes.number,
    maxAngle: React.PropTypes.number
  })
};

export default PieChart;
Пример #6
0
import React, { Component, Image, PropTypes, TouchableOpacity, View } from 'react-native';
import { Set } from 'immutable';
import {
  TOP,
  RIGHT,
  BOTTOM,
  LEFT,
  ALL_SIDES,
} from '../../constants/boxCorners';
import boxBorderSideAllImage from '../../../assets/img/boxBorderSideAll.png';
import boxBorderSideTopImage from '../../../assets/img/boxBorderSideTop.png';
import styles from './styles';

// (Prop type constants)
const sidePropType = PropTypes.oneOf(ALL_SIDES);

export default class BoxBorderSides extends Component {
  static propTypes = {
    onChangeSelectedSides: PropTypes.func.isRequired,
    selectedSides: PropTypes.arrayOf(sidePropType).isRequired,
    style: View.propTypes.style,
  };

  static defaultProps = {
    onChangeSelectedSides: () => {},
    selectedSides: [],
  };

  toggleSelectedSidesMember(side) {
    const {
      onChangeSelectedSides,
Пример #7
0
            <Text style={[styles.text, (position === 'left' ? styles.textLeft : styles.textRight)]}>
                {text}
            </Text>
        );
    }

    render() {
        let flexStyle = {};
        if (this.props.text.length > 40) {
            flexStyle.flex = 1;
        }

        return (
            <View style={[
                styles.bubble,
                (this.props.position === 'left' ? styles.bubbleLeft : styles.bubbleRight),
                (this.props.status === 'ErrorButton' ? styles.bubbleError : null),
                flexStyle]}>
                {this.renderText(this.props.text, this.props.position)}
            </View>
        )
    }
}

Bubble.propTypes = {
    position: React.PropTypes.oneOf(['left', 'right']),
    status: React.PropTypes.string,
    text: React.PropTypes.string,
    renderCustomText: React.PropTypes.func
};
Пример #8
0
    }

    render() {
        const { data: { jars } } = this.props

        // TODO: Repalce with navigator
        return (
            <View style={ styles.container }>
                <JarCarousel
                    jars={ jars }
                    onOrderMore={ this.handleOrderMore }
                />
            </View>
        )
    }
}

App.propTypes = {
    data: PropTypes.shape({
        jars: PropTypes.array.isRequried
    })
}

let styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center'
    }
})
Пример #9
0
  medium: 36,
  large: 72
};

const Button = ({ icon, size='medium', color='#333', borderOpen='none', onPress }) => (
  <TouchableHighlight style={[styles.button, styles[size], styles[borderOpen]]}
                      underlayColor='#ccc'
                      onPress={onPress}
  >
    <Icon name={icon} size={iconSize[size]} color={color}/>
  </TouchableHighlight>
);

Button.propTypes = {
  icon: PropTypes.string.isRequired,
  size: PropTypes.oneOf(['small', 'medium', 'large']),
  color: PropTypes.string,
  borderOpen: PropTypes.oneOf(['all', 'none', 'top', 'right', 'bottom', 'left']),
  onPress: PropTypes.func.isRequired
};

const styles = StyleSheet.create({
  none: {},
  right: {
    borderTopRightRadius: 0,
    borderBottomRightRadius: 0,
    borderRightWidth: 0,
    marginRight: 0
  },
  left: {
    borderTopLeftRadius: 0,
/**
 * Created by wes on 6/9/15.
 */

var React = require('react-native'),
    { requireNativeComponent } = React;

class FlexLabel extends React.Component {
    render() {
        return <RCTFlexLabel {...this.props} />;
    }
}

FlexLabel.propTypes = {
    text: React.PropTypes.string,
    verticalAlign: React.PropTypes.string, //React.PropTypes.oneOf(['top', 'middle', 'bottom']),
    numberOfLines: React.PropTypes.number,
    fontFamily: React.PropTypes.string,
    fontSize: React.PropTypes.number,
    fontWeight: React.PropTypes.oneOf(
        ['normal' /*default*/, 'bold',
            '100', '200', '300', '400', '500', '600', '700', '800', '900']
    ),
    fontStyle: React.PropTypes.oneOf(['normal', 'italic']),
    lineHeight: React.PropTypes.number,
    color: React.PropTypes.string,
}

var RCTFlexLabel = requireNativeComponent('RCTFlexLabel', FlexLabel);

module.exports = FlexLabel;
        },

        getInnerViewNode: function () {
            return this.refs[NATIVE_REF];
        },

        propTypes: {
            ...View.propTypes,
            /**
             * Whether the pull to refresh functionality is enabled
             */
            enabled: React.PropTypes.bool,
            /**
             * The colors (at least one) that will be used to draw the refresh indicator
             */
            colors: React.PropTypes.arrayOf(React.PropTypes.string),
            /**
             * The background color of the refresh indicator
             */
            progressBackgroundColor: React.PropTypes.string,
            /**
             * Whether the view should be indicating an active refresh
             */
            refreshing: React.PropTypes.bool,
            /**
             * Size of the refresh indicator, see PullToRefreshViewAndroid.SIZE
             */
            size: React.PropTypes.oneOf(RefreshLayoutConsts.SIZE.DEFAULT, RefreshLayoutConsts.SIZE.LARGE),
            onLoadMore: PropTypes.func,
            onRefresh: PropTypes.func,
        },
Пример #12
0
  label: {
    fontSize: 20,
    fontWeight: '300',
  },
  doneButton: {
    borderRadius: 5,
    backgroundColor: '#EAEAEA',
    padding: 5,
  },
});

class TaskRow extends React.Component {
  onDonePressed() {
    this.props.onDone(this.props.todo);
  }

  render() {
    return Render.bind(this)(styles);
  }

}

TaskRow.propTypes = {
  onDone: React.PropTypes.func.isRequired,
  todo: React.PropTypes.shape({
    task: React.PropTypes.string.isRequired,
  }).isRequired,
};

export default TaskRow;
Пример #13
0
      </View>
    );
  }
}

NewMessage.propTypes = {
  postMessage: React.PropTypes.func.isRequired,
  onPickImagePressed: React.PropTypes.func.isRequired,
  setNewMessageText: React.PropTypes.func.isRequired,
  newMessageText: React.PropTypes.string,
  setUsername: React.PropTypes.func.isRequired,
  username: React.PropTypes.string,
  error: React.PropTypes.string,
  image: React.PropTypes.shape({
    source: React.PropTypes.shape({
      uri: React.PropTypes.string.isRequired
    })
  })
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
    marginTop: 60
  },
  textinput: {
    height: 35
  }
});
Пример #14
0
    icon: {
        height: 24,
        width: 24
    }
});

export default class CardAction extends React.Component {
    setNativeProps(nativeProps) {
        this._root.setNativeProps(nativeProps);
    }

    render() {
        return (
            <View {...this.props}>
                <Icon
                    ref={c => this._root = c}
                    name={this.props.name}
                    size={24}
                    color={this.props.color}
                    style={styles.icon}
                />
            </View>
        );
    }
}

CardAction.propTypes = {
    name: React.PropTypes.string.isRequired,
    color: React.PropTypes.oneOf([ "white", "black" ]).isRequired
};
function createIconSet(glyphMap : Object, fontFamily : string) : Function {
  var styles = StyleSheet.create({
    container: {
      overflow:         'hidden',
      backgroundColor:  'transparent',
      flexDirection:    'row',
      justifyContent:   'flex-start',
      alignItems:       'center',
    },
    text: {
      fontFamily,
    }
  });

  var Icon = React.createClass({
    propTypes:{
      name: React.PropTypes.oneOf(Object.keys(glyphMap)).isRequired,
      size: React.PropTypes.number,
      color: React.PropTypes.string,
      style: React.PropTypes.oneOfType([
        React.PropTypes.number, // References to style sheets are numbers
        React.PropTypes.object, // Inline style declaration
        React.PropTypes.array,  // Multiple styles to be merged
      ])
    },
    render: function() {

      var name = this.props.name;
      var glyph = glyphMap[name] || '?';
      if(typeof glyph === 'number') {
        glyph = String.fromCharCode(glyph);
      }

      var containerStyle = _.pick(flattenStyle([styles.container, this.props.style]), Object.keys(ViewStylePropTypes));

      var textStyle = _.pick(
        flattenStyle([this.props.style, styles.text]),
        Object.keys(TextStylePropTypes)
      );

      var size = this.props.size || textStyle.fontSize || DEFAULT_ICON_SIZE;
      var color = this.props.color || textStyle.color || DEFAULT_ICON_COLOR;

      textStyle.fontSize    = size;
      textStyle.lineHeight  = size;
      textStyle.height      = size;
      textStyle.color       = color;

      return (
        <View {...this.props} style={containerStyle}>
          <Text style={textStyle}>{glyph}</Text>
          {this.props.children}
        </View>
      );
    }
  });

  var imageSourceCache = {};

  var getImageSource = function(name : string, size? : number, color? : string) : Promise {
    invariant(RNVectorIconsManager, 'RNVectorIconsManager not available, did you add the library to your project and link with libRNVectorIcons.a?');

    var glyph = glyphMap[name] || '?';
    if(typeof glyph === 'number') {
      glyph = String.fromCharCode(glyph);
    }
    size = size || DEFAULT_ICON_SIZE;
    color = color || DEFAULT_ICON_COLOR;

    var cacheKey = glyph + ':' + size + ':' + color;

    return new Promise((resolve, reject) => {
      var cached = imageSourceCache[cacheKey];
      if(typeof cached !== 'undefined') {
        if(!cached || cached instanceof Error ) { reject(cached); }
        return resolve({ uri: cached });
      }
      RNVectorIconsManager.getImageForFont(fontFamily, glyph, size, color, function(err, image) {
        if(typeof err === 'string') {
          err = new Error(err);
        }
        imageSourceCache[cacheKey] = image || err || false;
        if(!err && image) {
          return resolve({ uri: image });
        }
        reject(err);
      });
    });
  };


  var TabBarItem = React.createClass({
    componentDidMount: function() {
      var size = this.props.iconSize || TAB_BAR_ICON_SIZE;
      if(this.props.iconName) {
        getImageSource(this.props.iconName, size).then((image) => this.setState({ icon: image }));
      }
      if(this.props.selectedIconName) {
        getImageSource(this.props.selectedIconName, size).then((image) => this.setState({ selectedIcon: image }));
      }
    },

    render: function() {
      return <TabBarIOS.Item {...this.props} {...this.state} />;
    }
  });

  Icon.TabBarItem = TabBarItem;
  Icon.getImageSource = getImageSource;

  return Icon;
};
Пример #16
0
      <Text style={styles.labelValue}>{this.props.children}</Text>
    );
  }
});

export const Wine = connect(mapStateToProps)(React.createClass({
  propTypes: {
    dispatch: PropTypes.func.isRequired,
    httpState: PropTypes.string,
    liked: PropTypes.bool,
    region: PropTypes.string,
    wine: PropTypes.shape({
      id: PropTypes.string,
      name: PropTypes.string,
      type: PropTypes.oneOf(['Rouge', 'Blanc', 'Rosé', 'Effervescent', 'Moelleux']),
      appellation: PropTypes.shape({
        name: PropTypes.string,
        region: PropTypes.string
      }),
      grapes: PropTypes.arrayOf(PropTypes.string)
    })
  },
  componentDidMount() {
    this.props.dispatch(fetchWine(this.props.wine.id)).then(() => {
      this.props.dispatch(setTitle(this.props.wine.name));
      this.props.dispatch(fetchWineLiked(this.props.wine.id));
    });
  },

  handleToggleLike() {
    this.props.dispatch(toggleWineLiked(this.props.wine.id));
  },
Пример #17
0
function createIconSet(glyphMap : Object, fontFamily : string, fontFile : string) : Function {
  var fontReference = fontFamily;
  // Android doesn't care about actual fontFamily name, it will only look in fonts folder.
  if(Platform.OS === 'android' && fontFile) {
    fontReference = fontFile.replace(/\.(otf|ttf)$/, '');
  }

  var IconNamePropType = React.PropTypes.oneOf(Object.keys(glyphMap));

  var Icon = React.createClass({
    propTypes: {
      name: IconNamePropType.isRequired,
      size: React.PropTypes.number,
      color: React.PropTypes.string,
    },
    _root: (null:?Object),

    setNativeProps: function(nativeProps) {
      if (this._root == null) {
        throw new Error("Ref must have been set before calling setNativeProps");
      }
      this._root.setNativeProps(nativeProps);
    },

    render: function() {
      var { name, size, color, style, ...props } = this.props;

      var glyph = glyphMap[name] || '?';
      if(typeof glyph === 'number') {
        glyph = String.fromCharCode(glyph);
      }

      size = size || DEFAULT_ICON_SIZE;

      var styleDefaults:Object = {
        fontSize: size,
        fontWeight: 'normal',
        fontStyle: 'normal',
        color,
      };

      props.style = [styleDefaults, style];
      props.ref = (component) => this._root = component;

      styleDefaults.fontFamily = fontReference;

      return (<Text {...props}>{glyph}{this.props.children}</Text>);
    }
  });

  var styles = StyleSheet.create({
    container: {
      flexDirection: 'row',
      justifyContent: 'flex-start',
      alignItems: 'center',
      padding: 8,
    },
    touchable: {
      overflow: 'hidden',
    },
    icon: {
      marginRight: 10,
    },
    text: {
      fontWeight: '600',
      backgroundColor: 'transparent',
    },
  });

  var IconButton = React.createClass({
    getDefaultProps: function() {
      return {
        size: DEFAULT_BUTTON_ICON_SIZE,
        color: DEFAULT_BUTTON_ICON_COLOR,
        backgroundColor: DEFAULT_BUTTON_BACKGROUND,
        borderRadius: DEFAULT_BUTTON_RADIUS,
      };
    },

    render: function() {
      var {
        style,
        iconStyle,
        children,
        ...props
      } = this.props;

      var iconProps = pick(props, Object.keys(Text.propTypes), 'style', 'name', 'size', 'color');
      var touchableProps = pick(props, Object.keys(TouchableHighlight.propTypes));
      props = omit(
        props,
        Object.keys(iconProps),
        Object.keys(touchableProps),
        'iconStyle',
        'borderRadius',
        'backgroundColor'
      );
      iconProps.style = (this.props.iconStyle ? [styles.icon, this.props.iconStyle]: styles.icon);

      var colorStyle = pick(this.props, 'color');
      var blockStyle = pick(this.props, 'backgroundColor', 'borderRadius');

      if(isString(children)) {
        children = (<Text style={[styles.text, colorStyle]}>{children}</Text>);
      }

      return (
        <TouchableHighlight style={[styles.touchable, blockStyle]} {...touchableProps}>
          <View
            style={[styles.container, blockStyle, style]}
            {...props}
          >
            <Icon {...iconProps} />
            {children}
          </View>
        </TouchableHighlight>
      );
    }
  });

  var imageSourceCache = {};

  var getImageSource = function(name : string, size? : number, color? : string) : Promise {
    if(!NativeIconAPI) {
      if(Platform.OS === 'android') {
        throw new Error('RNVectorIconsModule not available, did you properly integrate the module?');
      }
      throw new Error('RNVectorIconsManager not available, did you add the library to your project and link with libRNVectorIcons.a?');
    }

    var glyph = glyphMap[name] || '?';
    if(typeof glyph === 'number') {
      glyph = String.fromCharCode(glyph);
    }
    size = size || DEFAULT_ICON_SIZE;
    color = color || DEFAULT_ICON_COLOR;

    if(processColor) {
      color = processColor(color);
    }

    var cacheKey = glyph + ':' + size + ':' + color;
    var scale = PixelRatio.get();

    return new Promise((resolve, reject) => {
      var cached = imageSourceCache[cacheKey];
      if(typeof cached !== 'undefined') {
        if(!cached || cached instanceof Error ) { reject(cached); }
        return resolve({ uri: cached, scale });
      }
      NativeIconAPI.getImageForFont(fontReference, glyph, size, color, function(err, image) {
        if(typeof err === 'string') {
          err = new Error(err);
        }
        imageSourceCache[cacheKey] = image || err || false;
        if(!err && image) {
          return resolve({ uri: image, scale });
        }
        reject(err);
      });
    });
  };


  var TabBarItemIOS = React.createClass({
    propTypes: {
      iconName: IconNamePropType.isRequired,
      selectedIconName: IconNamePropType,
      iconSize: React.PropTypes.number,
    },

    updateIconSources: function(props) {
      var size = this.props.iconSize || TAB_BAR_ICON_SIZE;
      if(props.iconName) {
        getImageSource(props.iconName, size).then(icon => this.setState({ icon }));
      }
      if(props.selectedIconName) {
        getImageSource(props.selectedIconName, size).then(selectedIcon => this.setState({ selectedIcon }));
      }
    },

    componentWillMount: function() {
      this.updateIconSources(this.props);
    },

    componentWillReceiveProps: function(nextProps) {
      var keys = Object.keys(TabBarItemIOS.propTypes);
      if(!isEqual(pick(nextProps, keys), pick(this.props, keys))) {
        this.updateIconSources(nextProps);
      }
    },

    render: function() {
      return <TabBarIOS.Item {...this.props} {...this.state} />;
    }
  });

  var IconToolbarAndroid = React.createClass({
    propTypes: {
      navIconName: IconNamePropType,
      overflowIconName: IconNamePropType,
      actions: React.PropTypes.arrayOf(React.PropTypes.shape({
        title: React.PropTypes.string.isRequired,
        iconName: IconNamePropType,
        iconSize: React.PropTypes.number,
        iconColor: React.PropTypes.string,
        show: React.PropTypes.oneOf(['always', 'ifRoom', 'never']),
        showWithText: React.PropTypes.bool
      })),
      iconSize: React.PropTypes.number,
      iconColor: React.PropTypes.string,
    },

    updateIconSources: function(props) {
      var size = this.props.iconSize || TOOLBAR_ICON_SIZE;
      var color = props.iconColor || props.titleColor;
      if(props.navIconName) {
        getImageSource(props.navIconName, size, color).then(navIcon => this.setState({ navIcon }));
      }
      if(props.overflowIconName) {
        getImageSource(props.overflowIconName, size, color).then(overflowIcon => this.setState({ overflowIcon }));
      }

      Promise.all((props.actions || []).map(action => {
        if (action.iconName) {
          return getImageSource(action.iconName, action.iconSize || size, action.iconColor || color).then(icon => ({
            ...action,
            icon
          }));
        }
        return Promise.resolve(action);
      })).then(actions => this.setState({ actions }));
    },

    componentWillMount: function() {
      this.updateIconSources(this.props);
    },

    componentWillReceiveProps: function(nextProps) {
      var keys = Object.keys(IconToolbarAndroid.propTypes);
      if(!isEqual(pick(nextProps, keys), pick(this.props, keys))) {
        var stateToEvict = [];
        if (!nextProps.navIconName) {
          stateToEvict.push('navIcon');
        }
        if (!nextProps.iconName) {
          stateToEvict.push('icon');
        }
        if (this.state && stateToEvict.length) {
          this.replaceState(omit(this.state, stateToEvict), () => this.updateIconSources(nextProps));
        } else {
          this.updateIconSources(nextProps);
        }
      }
    },

    render: function() {
      return <ToolbarAndroid {...this.props} {...this.state} />;
    }
  });

  Icon.Button = IconButton;
  Icon.TabBarItem = TabBarItemIOS;
  Icon.TabBarItemIOS = TabBarItemIOS;
  Icon.ToolbarAndroid = IconToolbarAndroid;
  Icon.getImageSource = getImageSource;

  return Icon;
};
Пример #18
0
      return (
        <Image style={{width: 100, height: 40, top: 0}} source={btnBack} resizeMode={Image.resizeMode.contain}/>
      );
    }
  }

  render() {
    return (
      <ScrollView>
        <View style={styles.heading}>
          <Text style={styles.headingTitle}>KIỂM TRA KHỐI LƯỢNG</Text>
          <TouchableOpacity onPress={this._handleButtonBack.bind(this)} style={styles.btnBack}>
            {this._renderButtonBack()}
          </TouchableOpacity>
        </View>
        {this._renderTop()}
        <View style={styles.mainContainer}>
          <ScrollView scrollEnabled={true} onScroll={() => { console.log('onScroll!'); }} scrollEventThrottle={200} style={styles.scrollView}>
            {this._renderChild()}
          </ScrollView>
        </View>
        {this._renderRight()}
      </ScrollView>
    );
  }
}

Sum.propTypes = { navigator: React.PropTypes.instanceOf(React.Navigator) };

export default Sum;
Пример #19
0
    return style; //StyleSheet.create(style);
  };

  render () {
    return (
      <View style={{...this.state.style, ...this.props.style}}>
        {this.props.children}
      </View>
    );
  }

}

Box.propTypes = {
  a11yTitle: PropTypes.string,
  align: PropTypes.oneOf(['start', 'center', 'end', 'stretch']),
  backgroundImage: PropTypes.string,
  colorIndex: PropTypes.string,
  direction: PropTypes.oneOf(['row', 'column']),
  full: PropTypes.oneOf([true, 'horizontal', 'vertical', false]),
  justify: PropTypes.oneOf(['start', 'center', 'between', 'end']),
  pad: PropTypes.oneOfType([
    PropTypes.oneOf(['none', 'small', 'medium', 'large']),
    PropTypes.shape({
      between: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
      horizontal: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
      vertical: PropTypes.oneOf(['none', 'small', 'medium', 'large'])
    })
  ]),
  primary: PropTypes.bool,
  reverse: PropTypes.bool,
Пример #20
0
  View,
  Text,
  Modal,
  ActivityIndicatorIOS,
  ProgressBarAndroid
} = React;

import Portal from 'react-native/Libraries/Portal/Portal.js';

const SIZES = ['small', 'normal', 'large'];
let tag;

const propTypes = {
	visible: React.PropTypes.bool,
	color: React.PropTypes.string,
	size: React.PropTypes.oneOf(SIZES),
	overlayColor: React.PropTypes.string
}

class Loading extends React.Component {
	constructor(props) {
    super(props);
    this.renderLoading = this.renderLoading.bind(this);
    this.renderSpinner = this.renderSpinner.bind(this);
  }

	componentWillMount() {
		if (Platform.OS === 'android') {
			tag = Portal.allocateTag();
		}
	}
Пример #21
0
  render() {
    const { category } = this.props;
    const assets = {
      girls: require('../Assets/noun_387165_cc.png'),
      heroes: require('../Assets/noun_105374_cc.png'),
      tributes: require('../Assets/noun_41430_cc.png'),
      open: require('../Assets/noun_129660_cc.png')
    };

    return (
      <Image
        source={assets[category]}
        style={styles.icon}
        resizeMode={Image.resizeMode.contain}
      />
    );
  }
}

WodIcon.propTypes = {
  category: React.PropTypes.oneOf(['girls', 'heroes', 'tributes', 'open'])
};

const styles = StyleSheet.create({
  icon: {
    height: 100,
    width: 100
  }
});

export default WodIcon;
Пример #22
0
/** The native chart view */


RNChart.propTypes = {

	chartData: _reactNative.PropTypes.arrayOf(_reactNative.PropTypes.shape({
		data: _reactNative.PropTypes.arrayOf(_reactNative.PropTypes.number).isRequired,
		name: _reactNative.PropTypes.string,
		type: _reactNative.PropTypes.oneOf(['line', 'bar', 'pie']),
		fillColor: _reactNative.PropTypes.oneOfType([_reactNative.PropTypes.number, _reactNative.PropTypes.string]),
		fillGradient: _reactNative.PropTypes.arrayOf(_reactNative.PropTypes.oneOfType([_reactNative.PropTypes.number, _reactNative.PropTypes.string])),
		cornerRadius: _reactNative.PropTypes.number,
		lineWidth: _reactNative.PropTypes.number,
		highlightColor: _reactNative.PropTypes.oneOfType([_reactNative.PropTypes.number, _reactNative.PropTypes.string]),
		highlightIndices: _reactNative.PropTypes.arrayOf(_reactNative.PropTypes.number),
		highlightRadius: _reactNative.PropTypes.number,
		widthPercent: _reactNative.PropTypes.number,
		showDataPoint: _reactNative.PropTypes.bool,
		dataPointColor: _reactNative.PropTypes.oneOfType([_reactNative.PropTypes.number, _reactNative.PropTypes.string]),
		dataPointFillColor: _reactNative.PropTypes.oneOfType([_reactNative.PropTypes.number, _reactNative.PropTypes.string]),
		dataPointRadius: _reactNative.PropTypes.number,
		pieAngle: _reactNative.PropTypes.number,
		pieCenterRatio: _reactNative.PropTypes.number,
		sliceColors: _reactNative.PropTypes.arrayOf(_reactNative.PropTypes.oneOfType([_reactNative.PropTypes.number, _reactNative.PropTypes.string]))
	})).isRequired,

	animationDuration: _reactNative.PropTypes.number,
	axisColor: _reactNative.PropTypes.oneOfType([_reactNative.PropTypes.number, _reactNative.PropTypes.string]),
	axisLineWidth: _reactNative.PropTypes.number,
	axisTitleColor: _reactNative.PropTypes.oneOfType([_reactNative.PropTypes.number, _reactNative.PropTypes.string]),
	axisTitleFontSize: _reactNative.PropTypes.number,
Пример #23
0
        return (
            <View style={styles.productItem}>
                <Product title={product.title} price={product.price} />
                <TouchableOpacity style={styles.addButton} onPress={onAddToCartClicked}>
                    <Text style={styles.addButtonText}>{product.inventory > 0 ? '添加到购物车' : '卖完了'}</Text>
                </TouchableOpacity>
            </View>
        )
    }

}

ProductItem.propTypes = {
    product: PropTypes.shape({
        title: PropTypes.string.isRequired,
        price: PropTypes.number.isRequired,
        inventory: PropTypes.number.isRequired
    }).isRequired,
    onAddToCartClicked: PropTypes.func.isRequired
}

const styles = StyleSheet.create({

    productItem: {
        flex: 1,
        height: 53,
        flexDirection: 'row',
        borderBottomWidth: 1,
        backgroundColor: '#FFF',
        borderBottomColor: '#d9d9d9'
    },
Пример #24
0
import React, {
    Component,
    PropTypes
} from 'react-native';
import Ellipse from './Ellipse';
import strokeFilter from '../lib/strokeFilter';
let propType = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
class Circle extends Component{
    static displayName = 'Circle';
    static propTypes = {
        cx: propType,
        cy: propType,
        r: propType
    };
    static defaultProps = {
        cx: 0,
        cy: 0
    };

    render() {
        return <Ellipse
            {...this.props}
            r={null}
            rx={+this.props.r}
            ry={+this.props.r}
        />
    }
}

export default Circle;
		if (data.length === 1) {
			if (this.props.data[0] === 'missing') {
				return <PageLoading />;
			}

			if (data[0] === 'failed') {
				return <PageEmpty label='Failed to load notifications' image='sad' />;
			}
		}

		return (
			<ListView
				dataSource={this._getDataSource()}
				renderRow={this._renderRow}
			/>
		);
	}
}

NotificationCenter.propTypes = {
	data: React.PropTypes.arrayOf(React.PropTypes.oneOfType([
		React.PropTypes.oneOf([ 'missing', 'failed' ]),
		React.PropTypes.shape({
			id: React.PropTypes.string
		})
	])).isRequired,
	dismissNote: React.PropTypes.func.isRequired,
	refreshData: React.PropTypes.func,
	onNavigation: React.PropTypes.func.isRequired
};
let React = require('react-native');
let { requireNativeComponent, NativeAppEventEmitter } = React;

let CardIOView = React.createClass({
  displayName: 'CardIOView',

  propTypes: {
    languageOrLocale: React.PropTypes.oneOf([
      'ar','da','de','en','en_AU','en_GB','es','es_MX','fr','he','is','it','ja','ko','ms',
      'nb','nl','pl','pt','pt_BR','ru','sv','th','tr','zh-Hans','zh-Hant','zh-Hant_TW',
    ]),
    guideColor: React.PropTypes.string,
    useCardIOLogo: React.PropTypes.bool,
    hideCardIOLogo: React.PropTypes.bool,
    allowFreelyRotatingCardGuide: React.PropTypes.bool,
    scanInstructions: React.PropTypes.string,
    scanOverlayView: React.PropTypes.element,
    scanExpiry: React.PropTypes.bool,
    scannedImageDuration: React.PropTypes.number,
    detectionMode: React.PropTypes.oneOf([
      'cardImageAndNumber', 
      'cardImageOnly',
      'automatic',
    ]),
    didScanCard: React.PropTypes.func,
    hidden: React.PropTypes.bool,
  },

  statics: {
    cardImageAndNumber: 'cardImageAndNumber',
    cardImageOnly: 'cardImageOnly',
Пример #27
0
                cell={cell.toString()}
                onAddPiece={() => { this.props.onAddPiece(y, board.nextPlayer); }} />
            );
          })}
        </View>
      );
    });

    return (
      <View style={styles.board}>

        <View style={styles.columns}>
          {columns}
        </View>

        <BoardStatus board={board} />

      </View>
    );
  }
}

/**
 * Props this component needs to receive
 * @type {Object}
 */
Board.propTypes = {
  board: React.PropTypes.instanceOf(Connect4.Board).isRequired,
  onAddPiece: React.PropTypes.func.isRequired
};
Пример #28
0
      );
    }
    return (
      <Button style={{color: 'blue'}} onPress={() => { this.props.onFilterChange(filter)}}>
        {name}
      </Button>
    )
  },

  render(){
    return(
      <View>
        {this.renderFilter('SHOW_ALL', 'All')}
        {this.renderFilter('SHOW_COMPLETED', 'Completed')}
        {this.renderFilter('SHOW_ACTIVE', 'Active')}
      </View>
    );
  }
});

Footer.propTypes = {
  onFilterChange: PropTypes.func.isRequired,
  filter: PropTypes.oneOf([
    'SHOW_ALL',
    'SHOW_COMPLETED',
    'SHOW_ACTIVE'
  ]).isRequired
}

export default Footer;
Пример #29
0
import React, {
  PropTypes,
  StyleSheet,
  TouchableHighlight,
  View,
} from 'react-native';

import {
  carbonStyles,
} from '../styles';

const cs = StyleSheet.create(carbonStyles);

const propTypes = {
  children: PropTypes.oneOfType([
    PropTypes.arrayOf(PropTypes.node),
    PropTypes.node,
  ]),
  onPress: PropTypes.func,
  style: PropTypes.any,
};

const defaultProps = {};

export default function Item(props) {
  if (props.onPress) {
    return (
      <TouchableHighlight
        {...props}
        underlayColor={'#DADADA'}
        onPress={props.onPress}
      >
          borderRightWidth: 0,
          borderLeftColor: this.props.color
        };
        break;
    }

    return (
        <View
          style={[customStyle, {
            //flex: 4,
            borderColor: 'transparent',
            borderWidth: this.props.width,
            marginTop: 10
          }]}
        />
    );
  }
}

Angle.propTypes = {
  direction: React.PropTypes.oneOf(['left', 'right', 'up', 'down']),
  color: React.PropTypes.string,
  width: React.PropTypes.number
};

Angle.defaultProps = {
  direction: 'left',
  color: 'white',
  width: 6
};