121 lines
4.3 KiB
TypeScript
121 lines
4.3 KiB
TypeScript
// Metro module 9813 (f9814).
|
|
import { useCallback, useEffect, useRef, useState, useContext } from "react";
|
|
import * as _ReanimatedRexport from "../../reanimated/ReanimatedRexport";
|
|
import ReanimatedRexport, { useSharedValue, useAnimatedStyle } from "../../reanimated/ReanimatedRexport";
|
|
import { AccessibilityPreferencesContext } from "../../../_bundle/Module3908";
|
|
import { withSpring } from "../../../design/animation/reanimated/spring/spring";
|
|
import { getDesiredAnimationConfigs, EXPECTED_ORB_LOTTIE_ANIMATION_DURATION_MS } from "../shared/AnimationUtils";
|
|
import { Text } from "../../../design/components/Text/native/Text";
|
|
const __initData = {
|
|
code: "function BalanceCounterTsx1(){const{runOnJS,setIsAnimating}=this.__closure;runOnJS(setIsAnimating)(false);}"
|
|
};
|
|
const __initData2 = {
|
|
code: "function BalanceCounterTsx2(){const{isAnimating,animatedValue,runOnJS,setDisplayValue,setMaxDigits}=this.__closure;if(isAnimating){const roundedValue=Math.round(animatedValue.get());runOnJS(setDisplayValue)(roundedValue);runOnJS(setMaxDigits)(roundedValue.toString().length);}return{};}"
|
|
};
|
|
export const BalanceCounter = (props) => {
|
|
let ref, sharedValue, ref2, enabled, setState, setState2, state, setState3, callback;
|
|
const { value, onValueChange, onValueReached, style } = props;
|
|
ref = void 0;
|
|
sharedValue = void 0;
|
|
ref2 = void 0;
|
|
enabled = void 0;
|
|
setState = void 0;
|
|
setState2 = void 0;
|
|
state = void 0;
|
|
setState3 = void 0;
|
|
callback = void 0;
|
|
const clearAnimationTimeout2 = function clearAnimationTimeout() {
|
|
if (ref2.current != null) {
|
|
clearTimeout(ref2.current);
|
|
ref2.current = null;
|
|
}
|
|
setState3(false);
|
|
};
|
|
ref = useRef(null);
|
|
sharedValue = useSharedValue(0);
|
|
ref2 = useRef(null);
|
|
enabled = useContext(AccessibilityPreferencesContext).reducedMotion.enabled;
|
|
let state2;
|
|
[state2, setState] = useState(0);
|
|
let state3;
|
|
[state3, setState2] = useState(1);
|
|
[state, setState3] = useState(false);
|
|
callback = useCallback((a0, a1, a2) => {
|
|
setState3(true);
|
|
const set = a0.set;
|
|
const r8 = {
|
|
duration: a2,
|
|
damping: 15,
|
|
stiffness: 150,
|
|
mass: 1
|
|
};
|
|
const l = function l() {
|
|
_ReanimatedRexport.runOnJS(setState3)(false);
|
|
};
|
|
l.__closure = {
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
setIsAnimating: setState3
|
|
};
|
|
l.__workletHash = 16153226572520;
|
|
l.__initData = __initData;
|
|
set.call(a0, withSpring(a1, r8, "respect-motion-settings", l));
|
|
}, []);
|
|
useEffect(() => {
|
|
L5: {
|
|
if (value !== null) {
|
|
if (ref.current !== null && !enabled) {
|
|
if (value !== ref.current) {
|
|
const r9 = value - ref.current;
|
|
onValueChange(r9);
|
|
ref.current = value;
|
|
const desiredAnimationConfigs = getDesiredAnimationConfigs(r9, EXPECTED_ORB_LOTTIE_ANIMATION_DURATION_MS);
|
|
const { duration, delay } = desiredAnimationConfigs;
|
|
if (ref2.current != null) {
|
|
clearTimeout(ref2.current);
|
|
ref2.current = null;
|
|
}
|
|
setState3(false);
|
|
ref2.current = setTimeout(() => {
|
|
callback(sharedValue, value, duration);
|
|
ref2.current = null;
|
|
}, delay);
|
|
return clearAnimationTimeout2;
|
|
}
|
|
setState(value);
|
|
break L5;
|
|
}
|
|
setState(value);
|
|
sharedValue.set(value);
|
|
ref.current = value;
|
|
return void 0;
|
|
}
|
|
}
|
|
}, [value, onValueChange, onValueReached, sharedValue, callback, enabled]);
|
|
const F = function F() {
|
|
if (state) {
|
|
const r11 = Math.round(sharedValue.get());
|
|
_ReanimatedRexport.runOnJS(setState)(r11);
|
|
_ReanimatedRexport.runOnJS(setState2)(r11.toString().length);
|
|
}
|
|
return {};
|
|
};
|
|
F.__closure = {
|
|
isAnimating: state,
|
|
animatedValue: sharedValue,
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
setDisplayValue: setState,
|
|
setMaxDigits: setState2
|
|
};
|
|
F.__workletHash = 4408542396979;
|
|
F.__initData = __initData2;
|
|
const animatedStyle = useAnimatedStyle(F);
|
|
return value !== null ? <ReanimatedRexport.View style={[animatedStyle, {
|
|
minWidth: 7 * state3
|
|
}]}>
|
|
<Text variant="text-sm/semibold" style={style} maxFontSizeMultiplier={2}>
|
|
{state2.toFixed(0)}
|
|
</Text>
|
|
</ReanimatedRexport.View> : null;
|
|
};
|
|
export default BalanceCounter;
|