Skip to content

Instantly share code, notes, and snippets.

@hurali97
Created February 13, 2024 07:26
Show Gist options
  • Save hurali97/5fa7b77afcc58555b5ca20bf6402bd8d to your computer and use it in GitHub Desktop.
Save hurali97/5fa7b77afcc58555b5ca20bf6402bd8d to your computer and use it in GitHub Desktop.
App file for Callstack Blog
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