Skip to content

Commit 1774eb3

Browse files
committed
refactor: remove glow animation and adjust minimum slider value in example app
1 parent 38c86a3 commit 1774eb3

1 file changed

Lines changed: 4 additions & 47 deletions

File tree

example/App.tsx

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Modern flashlight controller with smooth animations
44
*/
55

6-
import React, { useEffect, useRef, useState } from 'react';
6+
import React, { useRef, useState } from 'react';
77
import {
88
Animated,
99
Dimensions,
@@ -25,7 +25,6 @@ const { width } = Dimensions.get('window');
2525
function App() {
2626
const [isOn, setIsOn] = useState(false);
2727
const [currentLevel, setCurrentLevel] = useState(0);
28-
const glowAnim = useRef(new Animated.Value(0)).current;
2928
const scaleAnim = useRef(new Animated.Value(1)).current;
3029

3130
const { toggle, setLevel, getMaxLevel } = useTorch({
@@ -36,29 +35,12 @@ function App() {
3635
console.log('Torch error:', error.code);
3736
},
3837
onLevelChanged: level => {
39-
setCurrentLevel(level || 0);
38+
setCurrentLevel(level ?? 1);
4039
},
4140
});
4241

4342
const maxLevel = getMaxLevel() || 10;
4443

45-
useEffect(() => {
46-
Animated.loop(
47-
Animated.sequence([
48-
Animated.timing(glowAnim, {
49-
toValue: 1,
50-
duration: 2000,
51-
useNativeDriver: true,
52-
}),
53-
Animated.timing(glowAnim, {
54-
toValue: 0,
55-
duration: 2000,
56-
useNativeDriver: true,
57-
}),
58-
]),
59-
).start();
60-
}, [glowAnim]);
61-
6244
const handleToggle = () => {
6345
Animated.sequence([
6446
Animated.timing(scaleAnim, {
@@ -75,19 +57,13 @@ function App() {
7557
toggle();
7658
};
7759

78-
const glowOpacity = glowAnim.interpolate({
79-
inputRange: [0, 1],
80-
outputRange: [0.3, 0.7],
81-
});
82-
8360
return (
8461
<SafeAreaProvider>
8562
<StatusBar barStyle="light-content" />
8663
<AppContent
8764
isOn={isOn}
8865
currentLevel={currentLevel}
8966
maxLevel={maxLevel}
90-
glowOpacity={glowOpacity}
9167
scaleAnim={scaleAnim}
9268
onToggle={handleToggle}
9369
onLevelChange={setLevel}
@@ -100,7 +76,6 @@ interface AppContentProps {
10076
isOn: boolean;
10177
currentLevel: number;
10278
maxLevel: number;
103-
glowOpacity: Animated.AnimatedInterpolation<number>;
10479
scaleAnim: Animated.Value;
10580
onToggle: () => void;
10681
onLevelChange: (level: number) => void;
@@ -110,7 +85,6 @@ function AppContent({
11085
isOn,
11186
currentLevel,
11287
maxLevel,
113-
glowOpacity,
11488
scaleAnim,
11589
onToggle,
11690
onLevelChange,
@@ -159,24 +133,7 @@ function AppContent({
159133
</View>
160134

161135
<View style={styles.torchContainer}>
162-
{isOn && (
163-
<Animated.View
164-
style={[
165-
styles.glow,
166-
{
167-
opacity: glowOpacity,
168-
transform: [
169-
{
170-
scale: glowOpacity.interpolate({
171-
inputRange: [0, 1],
172-
outputRange: [1, 1.2],
173-
}),
174-
},
175-
],
176-
},
177-
]}
178-
/>
179-
)}
136+
{isOn && <View style={styles.glow} />}
180137

181138
<Pressable onPress={onToggle}>
182139
<Animated.View style={torchButtonStyle}>
@@ -221,7 +178,7 @@ function AppContent({
221178
<Text style={styles.sliderLabel}>MIN</Text>
222179
<Slider
223180
value={currentLevel}
224-
minimumValue={0}
181+
minimumValue={1}
225182
maximumValue={maxLevel}
226183
step={1}
227184
onValueChange={value => {

0 commit comments

Comments
 (0)