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.tsx 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2019 - 2020 Arnaud Vergnet.
  3. *
  4. * This file is part of Campus INSAT.
  5. *
  6. * Campus INSAT is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Campus INSAT is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Campus INSAT. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. import * as React from 'react';
  20. import {Text} from 'react-native-paper';
  21. import {View} from 'react-native-animatable';
  22. import Slider, {SliderProps} from '@react-native-community/slider';
  23. import {useState} from 'react';
  24. type PropsType = {
  25. valueSuffix?: string;
  26. } & SliderProps;
  27. /**
  28. * Abstraction layer for Modalize component, using custom configuration
  29. *
  30. * @param props Props to pass to the element. Must specify an onRef prop to get an Modalize ref.
  31. * @return {*}
  32. */
  33. function CustomSlider(props: PropsType) {
  34. const [currentValue, setCurrentValue] = useState(props.value);
  35. const onValueChange = (value: number) => {
  36. setCurrentValue(value);
  37. if (props.onValueChange) {
  38. props.onValueChange(value);
  39. }
  40. };
  41. return (
  42. <View style={{flex: 1, flexDirection: 'row'}}>
  43. <Text
  44. style={{
  45. marginHorizontal: 10,
  46. marginTop: 'auto',
  47. marginBottom: 'auto',
  48. }}>
  49. {currentValue}min
  50. </Text>
  51. <Slider {...props} ref={undefined} onValueChange={onValueChange} />
  52. </View>
  53. );
  54. }
  55. export default CustomSlider;