Field.js 868 Bytes
Newer Older
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
const React = require("react-native");
const {
  View,
  Text,
  SliderIOS
} = React;
const styles = {
  field: {
    flexDirection: "row",
    alignItems: "center",
    paddingTop: 10,
    paddingBottom: 10
  },
  title: {
    width: 140,
    textAlign: "right",
    paddingTop: 20,
    paddingBottom: 20,
    paddingLeft: 40,
    paddingRight: 40,
    fontSize: 16,
    fontFamily: "Helvetica"
  },
  range: {
    flex: 1,
    height: 50
  }
};

class Field extends React.Component {
  render () {
    const { min, max, step, onChange, name, width } = this.props;
    return <View style={{...styles.field, width }}>
      <Text style={styles.title}>{name}</Text>
      <SliderIOS
        style={styles.range}
        minimumValue={min}
        maximumValue={max}
        step={step}
        onValueChange={onChange}
      />
  </View>;
  }
}
module.exports = Field;