Created
February 13, 2024 07:26
-
-
Save hurali97/5fa7b77afcc58555b5ca20bf6402bd8d to your computer and use it in GitHub Desktop.
App file for Callstack Blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useState} from 'react'; | |
import { | |
SafeAreaView, | |
StatusBar, | |
StyleSheet, | |
Text, | |
TouchableOpacity, | |
useColorScheme, | |
useWindowDimensions, | |
View, | |
} from 'react-native'; | |
import {Colors} from 'react-native/Libraries/NewAppScreen'; | |
import SingingSVG from './src/assets/images/Singing.svg'; | |
function App(): React.JSX.Element { | |
const isDarkMode = useColorScheme() === 'dark'; | |
const dimensions = useWindowDimensions(); | |
const [isVisible, setIsVisible] = useState(false); | |
const backgroundStyle = { | |
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter, | |
flex: 1, | |
}; | |
return ( | |
<SafeAreaView style={backgroundStyle}> | |
<StatusBar | |
barStyle={isDarkMode ? 'light-content' : 'dark-content'} | |
backgroundColor={backgroundStyle.backgroundColor} | |
/> | |
<View style={styles.container}> | |
{!isVisible ? ( | |
<TouchableOpacity onPress={() => setIsVisible(true)}> | |
<Text style={styles.text}>Show SVG</Text> | |
</TouchableOpacity> | |
) : ( | |
<SingingSVG width={dimensions.width} height={dimensions.height / 2} /> | |
)} | |
</View> | |
</SafeAreaView> | |
); | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
justifyContent: 'center', | |
alignItems: 'center', | |
}, | |
text: { | |
color: '#000', | |
}, | |
}); | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment