Last active
June 24, 2020 22:46
-
-
Save jsorkin24/da9f3ef78873a20569891fe5d848e81a to your computer and use it in GitHub Desktop.
Slider.js File
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState } from 'react' | |
| import MultiSlider from '@ptomasroos/react-native-multi-slider' | |
| import styled from 'styled-components/native' | |
| import { Platform } from 'react-native' | |
| const SliderWrapper = styled.View` | |
| margin: 20px; | |
| width: 280px; | |
| height: 300px; | |
| justify-content: center; | |
| ` | |
| const ViewContainer = styled.View` | |
| align-self: center; | |
| justify-content: center; | |
| ` | |
| const LabelWrapper = styled.View` | |
| flex-direction: row; | |
| justify-content: space-between; | |
| padding: 20px 0; | |
| ` | |
| const LabelText = styled.Text` | |
| font-size: 20px; | |
| ` | |
| const Slider = () => { | |
| const [multiSliderValue, setMultiSliderValue] = useState([0, 100]) | |
| const multiSliderValuesChange = (values) => setMultiSliderValue(values) | |
| return ( | |
| <ViewContainer> | |
| <SliderWrapper> | |
| <LabelWrapper> | |
| <LabelText>{multiSliderValue[0]} </LabelText> | |
| <LabelText>{multiSliderValue[1]}</LabelText> | |
| </LabelWrapper> | |
| <MultiSlider | |
| markerStyle={{ | |
| ...Platform.select({ | |
| ios: { | |
| height: 30, | |
| width: 30, | |
| shadowColor: '#000000', | |
| shadowOffset: { | |
| width: 0, | |
| height: 3 | |
| }, | |
| shadowRadius: 1, | |
| shadowOpacity: 0.1 | |
| }, | |
| android: { | |
| height: 30, | |
| width: 30, | |
| borderRadius: 50, | |
| backgroundColor: '#1792E8' | |
| } | |
| }) | |
| }} | |
| pressedMarkerStyle={{ | |
| ...Platform.select({ | |
| android: { | |
| height: 30, | |
| width: 30, | |
| borderRadius: 20, | |
| backgroundColor: '#148ADC' | |
| } | |
| }) | |
| }} | |
| selectedStyle={{ | |
| backgroundColor: '#1792E8' | |
| }} | |
| trackStyle={{ | |
| backgroundColor: '#CECECE' | |
| }} | |
| touchDimensions={{ | |
| height: 40, | |
| width: 40, | |
| borderRadius: 20, | |
| slipDisplacement: 40 | |
| }} | |
| values={[multiSliderValue[0], multiSliderValue[1]]} | |
| sliderLength={280} | |
| onValuesChange={multiSliderValuesChange} | |
| min={0} | |
| max={100} | |
| allowOverlap={false} | |
| minMarkerOverlapDistance={10} | |
| /> | |
| </SliderWrapper> | |
| </ViewContainer> | |
| ) | |
| } | |
| export default Slider |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment