Skip to content

Commit

Permalink
feat(example): putting graphics instead of buttons only wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mateoguzmana committed Aug 13, 2022
1 parent 127655e commit f1f39ff
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
32 changes: 31 additions & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import React, { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { Pressable, StyleSheet, View } from 'react-native';
import {
Balloons,
Fireworks,
FiestaThemes,
Stars,
Hearts,
Balloon,
Star,
} from 'react-native-fiesta';
import Content from './components/Content';
import Button from './components/Button';
import { Canvas } from '@shopify/react-native-skia';

function App() {
const [lightMode, setLightMode] = useState(false);
Expand Down Expand Up @@ -44,6 +47,30 @@ function App() {
<Button title="Hearts" onPress={() => setComponentToRender(<Hearts />)} />

{componentToRender}

<Pressable
onPress={() => {
setComponentToRender(
<Balloons
theme={lightMode ? FiestaThemes.dark : FiestaThemes.default}
/>
);
}}
style={styles.canvas}
>
<Canvas style={styles.canvas}>
<Balloon x={20} y={50} color={'blue'} depth={0.4} />
</Canvas>
</Pressable>

<Pressable
onPress={() => setComponentToRender(<Stars />)}
style={styles.canvas}
>
<Canvas style={styles.canvas}>
<Star x={20} y={50} />
</Canvas>
</Pressable>
</View>
);
}
Expand All @@ -60,6 +87,9 @@ const styles = StyleSheet.create({
lightMode: {
backgroundColor: 'white',
},
canvas: {
flex: 1,
},
});

export default App;
7 changes: 4 additions & 3 deletions src/components/Star.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { screenHeight } from '../constants/dimensions';
interface StarProps {
x: number;
y: number;
autoplay?: boolean;
}

function Star({ x, y }: StarProps) {
function Star({ x, y, autoplay = true }: StarProps) {
const opacity = useValue(1);

const changeOpacity = useCallback(
Expand All @@ -20,8 +21,8 @@ function Star({ x, y }: StarProps) {
);

useEffect(() => {
changeOpacity();
}, [changeOpacity]);
autoplay && changeOpacity();
}, [changeOpacity, autoplay]);

return (
<Group transform={[{ translateY: y }]}>
Expand Down

0 comments on commit f1f39ff

Please sign in to comment.