1.0.5 • Published 6 years ago

react-native-user-score v1.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

react-native-user-score

A flexible, lightweight user score component. The component responds to drags and not just clicks, icon boundaries are computed automatically.

Installation

npm i -S react-native-user-score

or

yarn add react-native-user-score

Usage

import React, { Component } from 'react';

import { View, ScrollView, Text } from 'react-native';

import ScoreView from 'react-native-score-rating';

export class Demo extends Component<*,*> {
  state = {
    value: 2,
    scrollEnabled: true,
  };

  render() {
    return (
      <View
        style={{
          flex: 1,
          justifyContent: 'center',
        }}
      >
        <ScrollView scrollEnabled={this.state.scrollEnabled}>
          <ScoreView
            value={this.state.value}
            maximum={5}
            onChangeValue={value =>
              this.setState({ scrollEnabled: false, value })
            }
            onChangeFinish={() => this.setState({ scrollEnabled: true })}
            renderItem={active => (
              <Text color={active ? Colors.yellow20 : Colors.dark20} icon>
                {Icons.star}
              </Text>
            )}
          />
        </ScrollView>
      </View>
    );
  }
}

Note: Text is a custom component to demonstrate coloring. You have absolute control in the icon rendered -- styling included.

Props

NameDescriptionDefault
valueCurrent score0
maximumMaximum score5
spacingSpacing between each component*10
onChangeValueFunc:bool=>JSX to render a single score componentNot supplied - requires implementation
onChangeFinishFunc:() => void for triggering event after score is finaly changedNot supplied - requires implementation

* Spacing is applied as a right margin of all inner scores.

License

The MIT License.

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago