From efd64abeb9b036678f8fe10504e0b625532e04df Mon Sep 17 00:00:00 2001 From: "whey.party" Date: Tue, 2 Dec 2025 02:05:59 +0100 Subject: [PATCH] Revert "attempt 3 of slider android crash fix" This reverts commit d6da5ec34a0a01074a2de727706e90e13dce0f7f. --- package.json | 1 - src/components/forms/Slider.tsx | 90 ++++++++++++++------------------- yarn.lock | 5 -- 3 files changed, 38 insertions(+), 58 deletions(-) diff --git a/package.json b/package.json index b3cc6e0e9..90befd7c7 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,6 @@ "@miblanchard/react-native-slider": "^2.6.0", "@mozzius/expo-dynamic-app-icon": "^1.8.0", "@react-native-async-storage/async-storage": "2.2.0", - "@react-native-community/slider": "^5.1.1", "@react-navigation/bottom-tabs": "^7.3.13", "@react-navigation/drawer": "^7.3.12", "@react-navigation/native": "^7.1.9", diff --git a/src/components/forms/Slider.tsx b/src/components/forms/Slider.tsx index 7296b720d..237ef83b3 100644 --- a/src/components/forms/Slider.tsx +++ b/src/components/forms/Slider.tsx @@ -1,7 +1,5 @@ -import {useCallback, useEffect, useMemo, useState} from 'react' import {type ViewStyle} from 'react-native' -import RNSlider from '@react-native-community/slider' -import {throttle} from 'lodash' +import {Slider as RNSlider} from '@miblanchard/react-native-slider' import {useTheme} from '#/alf' @@ -11,7 +9,10 @@ interface SliderProps { minimumValue?: number maximumValue?: number step?: number - sliderStyle?: ViewStyle + trackStyle?: ViewStyle + minimumTrackStyle?: ViewStyle + thumbStyle?: ViewStyle + thumbTouchSize?: {width: number; height: number} } export function Slider({ @@ -20,62 +21,47 @@ export function Slider({ minimumValue = 0, maximumValue = 1, step = 1, - sliderStyle, + trackStyle, + minimumTrackStyle, + thumbStyle, + thumbTouchSize = {width: 40, height: 40}, }: SliderProps) { const t = useTheme() - const [localValue, setLocalValue] = useState(value) - - useEffect(() => { - setLocalValue(value) - }, [value]) - - const throttledOnValueChange = useMemo( - () => - throttle( - (val: number) => { - onValueChange(val) - }, - 50, - {leading: true, trailing: true}, - ), - [onValueChange], - ) - - const handleValueChange = useCallback( - (val: number) => { - setLocalValue(val) - throttledOnValueChange(val) - }, - [throttledOnValueChange], - ) - - const handleSlidingComplete = useCallback( - (val: number) => { - throttledOnValueChange.cancel() - onValueChange(val) - }, - [throttledOnValueChange, onValueChange], - ) - return ( onValueChange(values[0])} minimumValue={minimumValue} maximumValue={maximumValue} step={step} - minimumTrackTintColor={t.palette.primary_500} - maximumTrackTintColor={t.atoms.bg_contrast_50.backgroundColor} - thumbTintColor={t.atoms.bg_contrast_500.backgroundColor} - thumbImage={undefined} - style={[ - { - height: 40, - }, - sliderStyle, - ]} + trackStyle={{ + height: 4, + borderRadius: 2, + backgroundColor: t.atoms.bg_contrast_50.backgroundColor, + ...trackStyle, + }} + minimumTrackStyle={{ + height: 4, + borderRadius: 2, + backgroundColor: t.palette.primary_500, + ...minimumTrackStyle, + }} + thumbStyle={{ + width: 24, + height: 24, + borderRadius: 12, + borderWidth: 1, + borderColor: t.atoms.border_contrast_low.borderColor, + backgroundColor: t.atoms.bg.backgroundColor, + shadowColor: '#000', + shadowOffset: {width: 0, height: 2}, + shadowOpacity: 0.15, + shadowRadius: 4, + elevation: 3, + ...thumbStyle, + }} + thumbTouchSize={thumbTouchSize} /> ) } diff --git a/yarn.lock b/yarn.lock index d6f1602e9..7e1954909 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6185,11 +6185,6 @@ dependencies: merge-options "^3.0.4" -"@react-native-community/slider@^5.1.1": - version "5.1.1" - resolved "https://registry.yarnpkg.com/@react-native-community/slider/-/slider-5.1.1.tgz#321c37da565b264fd8f96a4edcb55d3fe78f26aa" - integrity sha512-W98If/LnTaziU3/0h5+G1LvJaRhMc6iLQBte6UWa4WBIHDMaDPglNBIFKcCXc9Dxp83W+f+5Wv22Olq9M2HJYA== - "@react-native/assets-registry@0.81.5": version "0.81.5" resolved "https://registry.yarnpkg.com/@react-native/assets-registry/-/assets-registry-0.81.5.tgz#d22c924fa6f6d4a463c5af34ce91f38756c0fa7d" -- 2.47.3