Love calculator project
app.js this project only contains app.js and images in assets
import React, {useState} from 'react';
import {
View,
Text,
StyleSheet,
TextInput,
Button,
ActivityIndicator,
ImageBackground,
Image,
Alert,
Modal,
} from 'react-native';
const App = () => {
const [itext1, setitext1] = useState('');
const [modal, setModal] = useState(false);
const [itext2, setitext2] = useState('');
const [loading, setloading] = useState(false);
if (loading) {
return (
<ImageBackground
source={require('./assets/heart.jpg')}
style={{flex: 1, height: '100%', width: '100%'}}>
<View
style={{
alignItems: 'center',
justifyContent: 'center',
marginTop: 100,
}}>
<Text>Calculating Love...</Text>
<ActivityIndicator size={200} color="#d924e3" />
</View>
</ImageBackground>
);
}
const calculateLove = () => {
setloading(true);
setTimeout(() => {
setloading(false);
setModal(true);
// Alert.alert(
// Math.floor(Math.random() * 100) + '% ' + ' ' + 'Love Matched',
// );
}, 3000);
};
function calculateL() {
return Math.floor(Math.random() * 100);
}
return (
<ImageBackground source={require('./assets/bgimage.jpg')} style={{flex: 1}}>
<View
style={{
alignItems: 'center',
justifyContent: 'center',
paddingTop: 150,
}}>
<Text style={styles.text}> Boy</Text>
<TextInput
placeholder="Type Name"
value={itext1}
maxLength={15}
style={styles.txtinput2}
onChangeText={Text => {
setitext1(Text);
}}
/>
<Text style={styles.text}> Girl</Text>
<TextInput
placeholder="Type Name"
value={itext2}
maxLength={15}
style={styles.txtinput1}
onChangeText={Text => {
setitext2(Text);
}}
/>
<Modal visible={modal} onRequestClose={() => setModal(!modal)}>
<View>
<Text>{Math.floor(Math.random() * 100)}%</Text>
</View>
</Modal>
</View>
<View style={styles.buttonview}>
<Button
title="Calculate Love"
style={{}}
onPress={() => calculateLove()}
/>
</View>
</ImageBackground>
);
};
export default App;
const styles = StyleSheet.create({
text: {
fontSize: 30,
justifyContent: 'center',
// backgroundColor: 'transparent',
fontWeight: '700',
borderRadius: 35,
marginTop: 15,
},
buttonview: {
height: 100,
width: 200,
marginLeft: 80,
marginTop: 20,
},
txtinput1: {
borderWidth: 1,
borderTopLeftRadius: 20,
borderBottomRightRadius: 20,
fontSize: 20,
width: 300,
backgroundColor: 'skyblue',
textAlign: 'center',
color: 'white',
fontWeight: 'bold',
},
txtinput2: {
borderWidth: 1,
borderTopRightRadius: 20,
borderBottomLeftRadius: 20,
fontSize: 20,
width: 300,
backgroundColor: 'skyblue',
textAlign: 'center',
color: 'white',
fontWeight: 'bold',
},
});
*****************************************************************pkg.json
"dependencies": {
"@react-navigation/drawer": "^6.1.4",
"@react-navigation/native": "^6.0.2",
"react": "17.0.1",
"react-native": "0.64.2",
"react-native-responsive-screen": "^1.4.2",
"react-native-safe-area-context": "^3.3.0",
"react-native-screens": "^3.5.0"
},
Comments
Post a Comment