Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CustomSlider.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // @flow
  2. import * as React from 'react';
  3. import {Text, withTheme} from 'react-native-paper';
  4. import {View} from "react-native-animatable";
  5. import type {CustomTheme} from "../../managers/ThemeManager";
  6. import Slider, {SliderProps} from "@react-native-community/slider";
  7. type Props = {
  8. theme: CustomTheme,
  9. valueSuffix: string,
  10. ...SliderProps
  11. }
  12. type State = {
  13. currentValue: number,
  14. }
  15. /**
  16. * Abstraction layer for Modalize component, using custom configuration
  17. *
  18. * @param props Props to pass to the element. Must specify an onRef prop to get an Modalize ref.
  19. * @return {*}
  20. */
  21. class CustomSlider extends React.Component<Props, State> {
  22. static defaultProps = {
  23. valueSuffix: "",
  24. }
  25. state = {
  26. currentValue: this.props.value,
  27. }
  28. onValueChange = (value: number) => {
  29. this.setState({currentValue: value});
  30. if (this.props.onValueChange != null)
  31. this.props.onValueChange(value);
  32. }
  33. render() {
  34. return (
  35. <View style={{flex: 1, flexDirection: 'row'}}>
  36. <Text style={{marginHorizontal: 10, marginTop: 'auto', marginBottom: 'auto'}}>
  37. {this.state.currentValue}min
  38. </Text>
  39. <Slider
  40. {...this.props}
  41. onValueChange={this.onValueChange}
  42. />
  43. </View>
  44. );
  45. }
  46. }
  47. export default withTheme(CustomSlider);