Skip to content

Commit fb7d691

Browse files
feat(example): add shadow/elevation demo
1 parent 400accc commit fb7d691

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

example/src/demos/ShadowDemo.tsx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { useState } from 'react';
2+
import { Text, StyleSheet, Platform } from 'react-native';
3+
import { EaseView } from 'react-native-ease';
4+
5+
import { Section } from '../components/Section';
6+
import { Button } from '../components/Button';
7+
8+
export function ShadowDemo() {
9+
const [active, setActive] = useState(false);
10+
return (
11+
<Section title="Shadow / Elevation">
12+
<EaseView
13+
animate={
14+
active
15+
? {
16+
shadowOpacity: 0.4,
17+
shadowRadius: 16,
18+
shadowOffsetX: 0,
19+
shadowOffsetY: 8,
20+
elevation: 12,
21+
}
22+
: {
23+
shadowOpacity: 0,
24+
shadowRadius: 0,
25+
shadowOffsetX: 0,
26+
shadowOffsetY: 0,
27+
elevation: 0,
28+
}
29+
}
30+
transition={{
31+
shadow: { type: 'spring', damping: 15, stiffness: 120 },
32+
}}
33+
style={styles.box}
34+
>
35+
<Text style={styles.text}>
36+
{active
37+
? Platform.OS === 'android'
38+
? 'Elevated'
39+
: 'Shadow'
40+
: 'Flat'}
41+
</Text>
42+
</EaseView>
43+
<Button
44+
label={active ? 'Remove' : 'Add Shadow'}
45+
onPress={() => setActive((v) => !v)}
46+
/>
47+
</Section>
48+
);
49+
}
50+
51+
const styles = StyleSheet.create({
52+
box: {
53+
width: 100,
54+
height: 100,
55+
borderRadius: 16,
56+
backgroundColor: '#fff',
57+
shadowColor: '#000',
58+
alignItems: 'center',
59+
justifyContent: 'center',
60+
},
61+
text: {
62+
color: '#333',
63+
fontSize: 13,
64+
fontWeight: '700',
65+
},
66+
});

example/src/demos/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { StyleReRenderDemo } from './StyleReRenderDemo';
2323
import { StyledCardDemo } from './StyledCardDemo';
2424
import { TransformOriginDemo } from './TransformOriginDemo';
2525
import { PerPropertyDemo } from './PerPropertyDemo';
26+
import { ShadowDemo } from './ShadowDemo';
2627
import { SpinDemo } from './SpinDemo';
2728
import { UniwindDemo } from './uniwind/UniwindDemo';
2829

@@ -72,6 +73,11 @@ export const demos: Record<string, DemoEntry> = {
7273
title: 'Background Color',
7374
section: 'Style',
7475
},
76+
'shadow': {
77+
component: ShadowDemo,
78+
title: 'Shadow',
79+
section: 'Style',
80+
},
7581
'style-rerender': {
7682
component: StyleReRenderDemo,
7783
title: 'Style Re-Render',

0 commit comments

Comments
 (0)