### Install React Native Awesome Slider with Yarn Source: https://github.com/alantoa/react-native-awesome-slider/blob/main/docs/src/pages/docs/get-started.mdx Installs the React Native Awesome Slider library using Yarn. The specific version to install depends on the version of react-native-gesture-handler being used. Ensure you have Reanimated v2 and react-native-gesture-handler properly installed first. ```bash yarn add react-native-awesome-slider ``` ```bash yarn add react-native-awesome-slider@1 ``` -------------------------------- ### Basic Usage of React Native Awesome Slider Source: https://github.com/alantoa/react-native-awesome-slider/blob/main/docs/src/pages/docs/get-started.mdx Demonstrates the basic integration of the Slider component from react-native-awesome-slider. It utilizes shared values from 'react-native-reanimated' for progress, minimum, and maximum values, and requires basic styling. ```jsx import { useSharedValue } from 'react-native-reanimated'; import { Slider } from 'react-native-awesome-slider'; export const Example = () => { const progress = useSharedValue(30); const min = useSharedValue(0); const max = useSharedValue(100); return ( ); }; ``` -------------------------------- ### Discrete Slider with Steps and Custom Marks Source: https://github.com/alantoa/react-native-awesome-slider/blob/main/docs/src/pages/docs/examples.mdx Shows how to configure the Slider for discrete value selection using 'step', 'steps', and 'snapToStep' props. This example also demonstrates custom rendering of slider marks using the 'renderMark' prop, allowing for visual indicators at specific intervals. ```jsx function DiscreteSlider() { const progress = useSharedValue(0); const min = useSharedValue(0); const max = useSharedValue(100); return ( ( {index * 10} )} /> ); } ``` -------------------------------- ### Slider with Haptic Feedback Integration Source: https://github.com/alantoa/react-native-awesome-slider/blob/main/docs/src/pages/docs/examples.mdx Explains how to integrate haptic feedback with the slider using the 'onHapticFeedback' and 'hapticMode' props. This example shows triggering a 'selection' haptic feedback event when the slider value changes, enhancing user experience, especially in discrete modes. ```jsx function HapticSlider() { return ( { HapticFeedback.trigger('selection'); }} hapticMode="STEP" step={20} steps={5} /> ); } ``` -------------------------------- ### Basic Slider Example with React Native Reanimated Source: https://github.com/alantoa/react-native-awesome-slider/blob/main/docs/src/pages/docs/examples.mdx Demonstrates the fundamental usage of the Slider component from 'react-native-awesome-slider'. It utilizes 'react-native-reanimated' for shared values to control the slider's progress and range. This example sets up a simple slider with minimum and maximum values. ```jsx import { useSharedValue } from 'react-native-reanimated'; import { Slider } from 'react-native-awesome-slider'; function BasicSlider() { const progress = useSharedValue(50); const min = useSharedValue(0); const max = useSharedValue(100); return ( ); } ``` -------------------------------- ### Step-based Slider with Snap-to-Step Functionality Source: https://context7.com/alantoa/react-native-awesome-slider/llms.txt This example shows how to implement a step-based slider where the selection snaps to predefined steps. The `steps` prop defines the number of steps, and `forceSnapToStep` ensures the slider adheres to these steps. `stepTimingOptions` can be used to control the animation duration when snapping. Custom `markStyle` can also be applied. ```tsx import { useSharedValue } from 'react-native-reanimated'; import { Slider } from 'react-native-awesome-slider'; import { View, StyleSheet } from 'react-native'; export function StepSlider() { const progress = useSharedValue(50); const min = useSharedValue(0); const max = useSharedValue(100); return ( { console.log(`Step value: ${value}`); }} /> ); } const styles = StyleSheet.create({ container: { padding: 20 }, mark: { backgroundColor: '#ffffff', height: 4, }, }); ``` -------------------------------- ### Advanced Snap Threshold Configuration for Slider in React Native Source: https://context7.com/alantoa/react-native-awesome-slider/llms.txt This example demonstrates how to configure advanced snapping behavior for the slider. The `snapThreshold` and `snapThresholdMode` props allow for magnetic snapping to steps within a specified distance, enhancing user control. `stepTimingOptions` can be used to animate the snapping motion. ```tsx import { useSharedValue } from 'react-native-reanimated'; import { Slider } from 'react-native-awesome-slider'; export function SnapThresholdSlider() { const progress = useSharedValue(0); const min = useSharedValue(0); const max = useSharedValue(100); return ( { console.log(`Snapped value: ${value}`); }} /> ); } ``` -------------------------------- ### Custom Bubble Rendering for Slider Source: https://github.com/alantoa/react-native-awesome-slider/blob/main/docs/src/pages/docs/examples.mdx Demonstrates advanced customization of the slider's bubble (tooltip) using the 'renderBubble' prop. This allows for completely custom UI elements to display the slider's value. Props like 'bubbleTranslateY' and 'bubbleWidth' offer further control over the bubble's appearance and positioning. ```jsx function CustomBubbleSlider() { return ( ( {Math.round(value)}% )} bubbleTranslateY={-30} bubbleWidth={40} /> ); } ``` -------------------------------- ### Custom Theming for React Native Slider Source: https://github.com/alantoa/react-native-awesome-slider/blob/main/docs/src/pages/docs/examples.mdx Illustrates how to apply custom themes to the Slider component using the 'theme' prop. This allows developers to override default colors for the minimum track, maximum track, and cache track, enabling full control over the slider's visual appearance to match application design. ```jsx function ThemedSlider() { return ( ); }; ``` -------------------------------- ### Customize React Native Awesome Slider Theme Source: https://github.com/alantoa/react-native-awesome-slider/blob/main/docs/src/pages/docs/get-started.mdx Shows how to customize the appearance of the Slider component using the 'theme' prop. Various color properties can be modified to change the look of the track, bubble, and heartbeat. ```jsx ``` -------------------------------- ### Basic Slider Usage in React Native Source: https://github.com/alantoa/react-native-awesome-slider/blob/main/README.md Demonstrates the fundamental implementation of the Slider component in a React Native application. It utilizes `useSharedValue` from `react-native-reanimated` to manage the slider's progress, minimum, and maximum values. Ensure Reanimated v2 and react-native-gesture-handler are installed. ```jsx import { useSharedValue } from 'react-native-reanimated'; import { Slider } from 'react-native-awesome-slider'; export const Example = () => { const progress = useSharedValue(30); const min = useSharedValue(0); const max = useSharedValue(100); return ; }; ``` -------------------------------- ### Custom Thumb and Track Rendering for Slider in React Native Source: https://context7.com/alantoa/react-native-awesome-slider/llms.txt This example shows how to fully customize the appearance of the slider's thumb and track using custom React Native components. The `renderThumb` prop allows for a custom JSX element to be rendered as the thumb, and `containerStyle` can be used to style the overall slider container. ```tsx import { useSharedValue } from 'react-native-reanimated'; import { Slider } from 'react-native-awesome-slider'; import { View } from 'react-native'; export function CustomSlider() { const progress = useSharedValue(50); const min = useSharedValue(0); const max = useSharedValue(100); return ( ( )} containerStyle={{ borderRadius: 8, }} /> ); } ``` -------------------------------- ### Video Player Slider with Progress and Cache Source: https://github.com/alantoa/react-native-awesome-slider/blob/main/docs/src/pages/docs/examples.mdx Illustrates how to use the Slider component for a video player interface. It showcases the 'cache' prop for displaying buffered progress and the 'bubble' prop for custom time formatting. The 'disableTrackFollow' prop is used to prevent the slider track from moving with the thumb, typical for video players. ```jsx function VideoPlayerSlider() { // Initialize values for video progress const progress = useSharedValue(0); const cache = useSharedValue(0); const duration = useSharedValue(300); return ( formatTime(value)} // Disable track follow for video player disableTrackFollow // Custom styles containerStyle={styles.videoSlider} /> ); } ``` -------------------------------- ### Scrubbing State Detection for Video Player Slider in React Native Source: https://context7.com/alantoa/react-native-awesome-slider/llms.txt This example demonstrates how to track the scrubbing state of the slider, which is useful for video player controls. The `isScrubbing` prop, managed by `useSharedValue`, allows the application to know when the user is actively dragging the slider. The `useEffect` hook includes logic for auto-playing content when not scrubbing. ```tsx import { useSharedValue } from 'react-native-reanimated'; import { Slider } from 'react-native-awesome-slider'; import { useEffect } from 'react'; export function VideoPlayerSlider() { const progress = useSharedValue(0); const isScrubbing = useSharedValue(false); const min = useSharedValue(0); const max = useSharedValue(100); useEffect(() => { // Auto-play when not scrubbing const interval = setInterval(() => { if (!isScrubbing.value && progress.value < max.value) { progress.value += 1; } }, 1000); return () => clearInterval(interval); }, []); return ( { console.log('User started scrubbing'); }} onSlidingComplete={(value) => { console.log(`Seeked to: ${value}`); }} /> ); } ``` -------------------------------- ### Haptic Feedback Slider with React Native Reanimated and Expo Haptics Source: https://context7.com/alantoa/react-native-awesome-slider/llms.txt This example demonstrates a slider that provides haptic feedback on interaction. It utilizes `react-native-reanimated` for state management and `expo-haptics` for generating haptic feedback. The `onHapticFeedback` prop is used to trigger the haptic effect when the slider's value changes to a new step. ```tsx import { useSharedValue } from 'react-native-reanimated'; import { Slider, HapticModeEnum } from 'react-native-awesome-slider'; import * as Haptics from 'expo-haptics'; export function HapticSlider() { const progress = useSharedValue(5); const min = useSharedValue(0); const max = useSharedValue(10); const handleHaptic = () => { Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); }; return ( { console.log(`Haptic step: ${value}`); }} /> ); } ``` -------------------------------- ### Slider with Custom Bubble Formatter for Time Display Source: https://context7.com/alantoa/react-native-awesome-slider/llms.txt This example demonstrates how to customize the bubble tooltip's displayed value using the `bubble` prop. A custom function `formatTime` is provided to format the slider's value (in seconds) into a human-readable time string (MM:SS). The `bubbleMaxWidth` and `bubbleTextStyle` props allow further customization of the tooltip's appearance. ```tsx import { useSharedValue } from 'react-native-reanimated'; import { Slider } from 'react-native-awesome-slider'; export function TimeSlider() { const progress = useSharedValue(0); const min = useSharedValue(0); const max = useSharedValue(3600); // 1 hour in seconds const formatTime = (seconds: number) => { const mins = Math.floor(seconds / 60); const secs = Math.floor(seconds % 60); return `${mins}:${secs.toString().padStart(2, '0')}`; }; return ( { console.log(`Time: ${formatTime(value)}`); }} /> ); } ``` -------------------------------- ### Pan Direction Enum Definition (TypeScript) Source: https://github.com/alantoa/react-native-awesome-slider/blob/main/docs/src/pages/docs/api-reference.mdx Defines an enumeration for tracking the direction of a pan gesture within the slider. This enum helps in interpreting user interactions like left, right, start, and end movements. ```typescript enum PanDirectionEnum { START = 0, // Pan gesture started LEFT = 1, // Panning left RIGHT = 2, // Panning right END = 3, // Pan gesture ended } ``` -------------------------------- ### RTL Support and Direction Detection for Slider in React Native Source: https://context7.com/alantoa/react-native-awesome-slider/llms.txt This example showcases the slider's support for Right-to-Left (RTL) layouts and the ability to detect the pan direction during interaction. The `isRTL` prop enables RTL mode, and `panDirectionValue` tracks whether the user is swiping left or right. This is useful for internationalization and precise gesture control. ```tsx import { useSharedValue } from 'react-native-reanimated'; import { Slider, PanDirectionEnum } from 'react-native-awesome-slider'; export function RTLSlider() { const progress = useSharedValue(30); const panDirection = useSharedValue(PanDirectionEnum.START); const min = useSharedValue(0); const max = useSharedValue(100); return ( { const direction = panDirection.value === PanDirectionEnum.LEFT ? 'left' : panDirection.value === PanDirectionEnum.RIGHT ? 'right' : 'idle'; console.log(`Value: ${value}, Direction: ${direction}`); }} /> ); } ``` -------------------------------- ### Slider with Cache Indicator for Media Playback Source: https://context7.com/alantoa/react-native-awesome-slider/llms.txt This snippet implements a slider with a cache indicator, suitable for media players. It uses an additional `cache` shared value to represent the buffered progress. The `cacheTrackTintColor` prop customizes the appearance of the cache bar. The example includes a `useEffect` hook to simulate cache loading over time. ```tsx import { useSharedValue } from 'react-native-reanimated'; import { Slider } from 'react-native-awesome-slider'; import { useEffect } from 'react'; export function MediaSlider() { const progress = useSharedValue(0); const cache = useSharedValue(0); const min = useSharedValue(0); const max = useSharedValue(100); // Simulate cache loading useEffect(() => { const interval = setInterval(() => { if (cache.value < max.value) { cache.value = Math.min(cache.value + 5, max.value); } }, 500); return () => clearInterval(interval); }, []); return ( ); } ``` -------------------------------- ### Configure Slider Gestures to Prevent Scroll Conflicts Source: https://context7.com/alantoa/react-native-awesome-slider/llms.txt This example illustrates how to configure the slider's gesture handling to prevent conflicts with parent scroll views. Props like `activeOffsetX`, `failOffsetY`, and `panHitSlop` are used to fine-tune the gesture recognition. This ensures that vertical scrolling is prioritized when needed, while horizontal sliding on the slider still functions correctly. It requires `react-native-reanimated` and `react-native-awesome-slider`. ```tsx import { useSharedValue } from 'react-native-reanimated'; import { Slider } from 'react-native-awesome-slider'; import { ScrollView } from 'react-native'; export function ScrollableSlider() { const progress = useSharedValue(30); const min = useSharedValue(0); const max = useSharedValue(100); return ( { console.log(`Scroll-safe value: ${value}`); }} /> ); } ``` -------------------------------- ### Disable Slider and Track Press Interaction Source: https://context7.com/alantoa/react-native-awesome-slider/llms.txt This example demonstrates how to disable the slider's interaction entirely using the `disable` prop and how to prevent users from interacting with the track by setting `disableTrackPress` to true. It uses `react-native-reanimated` for shared values and `react-native-awesome-slider` for the slider component. The state management for disabling is handled by React's `useState` hook. ```tsx import { useSharedValue } from 'react-native-reanimated'; import { Slider } from 'react-native-awesome-slider'; import { useState } from 'react'; import { Button, View } from 'react-native'; export function ControlledSlider() { const progress = useSharedValue(50); const min = useSharedValue(0); const max = useSharedValue(100); const [disabled, setDisabled] = useState(false); return (