Is there a way to make a transitional change of value with increments over time in React native (or any method in JS that I don't know of / can't find?
I could of course create some sort of loop with interval or setTimeout, but I was wondering if there is something like the Animated API with interpolation that could be used to just change a value when there is not actually any view that is being animated?
In my case I want to change the screen brightness of the users device smoothly, right now it goes from 0-1 instantly, which is not what I want.
I will provide code in case anyone would like to see that. This process takes place in a useEffect() that reacts when the user is opening a scannable code on their screen.
const [brightness, setBrightness] = useState(null);
...
...
useEffect(() => {
(async () => {
const currentBrightness =
await DeviceBrightness.getBrightnessLevel();
setBrightness(currentBrightness);
})();
if (isOpened) {
DeviceBrightness.setBrightnessLevel(1);
}
if (!isOpened && brightness) {
DeviceBrightness.setBrightnessLevel(brightness);
}
}, [isOpened]);