Skip to content

Commit 9d3b8c5

Browse files
feat(example): cycle border demo through none, red, green
1 parent be6f2d8 commit 9d3b8c5

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

example/src/demos/BorderDemo.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,34 @@ import { EaseView } from 'react-native-ease';
55
import { Section } from '../components/Section';
66
import { Button } from '../components/Button';
77

8+
const states = [
9+
{ borderWidth: 0, borderColor: '#4a90d9', label: 'None' },
10+
{ borderWidth: 4, borderColor: '#e74c3c', label: 'Red' },
11+
{ borderWidth: 4, borderColor: '#4ade80', label: 'Green' },
12+
] as const;
13+
14+
const nextLabel = ['Add Red', 'Go Green', 'Remove'] as const;
15+
816
export function BorderDemo() {
9-
const [active, setActive] = useState(false);
17+
const [index, setIndex] = useState(0);
18+
const state = states[index]!;
1019
return (
1120
<Section title="Border">
1221
<EaseView
1322
animate={{
14-
borderWidth: active ? 4 : 0,
15-
borderColor: active ? '#e74c3c' : '#4a90d9',
23+
borderWidth: state.borderWidth,
24+
borderColor: state.borderColor,
1625
}}
1726
transition={{
1827
border: { type: 'spring', damping: 15, stiffness: 120 },
1928
}}
2029
style={styles.box}
2130
>
22-
<Text style={styles.text}>{active ? 'Red' : 'None'}</Text>
31+
<Text style={styles.text}>{state.label}</Text>
2332
</EaseView>
2433
<Button
25-
label={active ? 'Remove' : 'Add Border'}
26-
onPress={() => setActive((v) => !v)}
34+
label={nextLabel[index]!}
35+
onPress={() => setIndex((i) => (i + 1) % states.length)}
2736
/>
2837
</Section>
2938
);

0 commit comments

Comments
 (0)