/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format * @flow */ 'use strict'; const React = require('react'); const {Slider, Text, StyleSheet, View} = require('react-native'); function SliderExample(props: React.ElementConfig) { const [value, setValue] = React.useState(0); return ( {value.toFixed(3)} setValue(newValue)} /> ); } function SlidingCompleteExample(props: React.ElementConfig) { const [slideCompletionValue, setSlideCompletionValue] = React.useState(0); const [slideCompletionCount, setSlideCompletionCount] = React.useState(0); return ( { setSlideCompletionValue(value); setSlideCompletionCount(count => count + 1); }} /> Completions: {slideCompletionCount} Value: {slideCompletionValue} ); } const styles = StyleSheet.create({ text: { fontSize: 14, textAlign: 'center', fontWeight: '500', margin: 10, }, }); exports.title = ''; exports.displayName = 'SliderExample'; exports.description = 'Slider input for numeric values'; exports.examples = [ { title: 'Default settings', render(): React.Element { return ; }, }, { title: 'Initial value: 0.5', render(): React.Element { return ; }, }, { title: 'minimumValue: -1, maximumValue: 2', render(): React.Element { return ; }, }, { title: 'step: 0.25', render(): React.Element { return ; }, }, { title: 'onSlidingComplete', render(): React.Element { return ; }, }, { title: 'Custom min/max track tint color', render(): React.Element { return ( ); }, }, { title: 'Custom thumb tint color', render(): React.Element { return ; }, }, { title: 'Custom thumb image', platform: 'ios', render(): React.Element { return ( ); }, }, { title: 'Custom track image', platform: 'ios', render(): React.Element { return ; }, }, { title: 'Custom min/max track image', platform: 'ios', render(): React.Element { return ( ); }, }, ];