Update Sync
This commit is contained in:
commit
4777571334
30 files changed
+9627
No files matched your search
@@ -0,0 +1,51 @@
|
||||
import React from 'react';
|
||||
import { View, Text, Button, StyleSheet } from 'react-native';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
|
||||
const MainScreen = () => {
|
||||
const navigation = useNavigation();
|
||||
|
||||
const navigateToSendEmail = () => {
|
||||
navigation.navigate('SendEmail');
|
||||
}
|
||||
|
||||
const navigateToSendSMS = () => {
|
||||
navigation.navigate('SendSMS');
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>SEND MY INFO</Text>
|
||||
<Text style={styles.title}>l_mclean215318</Text>
|
||||
<View style={styles.buttonContainer}>
|
||||
<Button title="EMAIL MY INFO" color="green" onPress={navigateToSendEmail} />
|
||||
</View>
|
||||
<View style={styles.buttonContainer}>
|
||||
<Button title="SMS MY INFO" color="blue" onPress={navigateToSendSMS} />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
marginTop: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
},
|
||||
title: {
|
||||
fontSize: 30,
|
||||
fontWeight: 'bold',
|
||||
marginBottom: 20,
|
||||
alignItems: 'center',
|
||||
},
|
||||
buttonContainer: {
|
||||
borderRadius: 10,
|
||||
marginTop: 10,
|
||||
padding: 10,
|
||||
width: 200,
|
||||
alignItems: 'center',
|
||||
},
|
||||
});
|
||||
|
||||
export default MainScreen;
|
||||
@@ -0,0 +1,60 @@
|
||||
import React from 'react';
|
||||
import { View, Text, StyleSheet, Button, Alert } from 'react-native';
|
||||
import * as MailComposer from 'expo-mail-composer';
|
||||
|
||||
const SendEmail = () => {
|
||||
const [message, setMessage] = React.useState('Levi McLean\n123 Main St\nLondon, ON\n(555) 555-5555\naidanmclean111@gmail.com');
|
||||
|
||||
const sendMessageWithEmail = async () => {
|
||||
try {
|
||||
const isAvailable = await MailComposer.isAvailableAsync();
|
||||
if (!isAvailable) {
|
||||
Alert.alert('Email is not available on this device');
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await MailComposer.composeAsync({
|
||||
recipients: ['aidanmclean111@gmail.com'],
|
||||
subject: 'Lab 4 - Customized Email',
|
||||
body: message,
|
||||
});
|
||||
|
||||
if (result.status === 'sent') {
|
||||
Alert.alert('Email sent successfully');
|
||||
} else {
|
||||
Alert.alert('Failed to send email');
|
||||
}
|
||||
} catch (error) {
|
||||
Alert.alert('Error sending email', error.message);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={styles.form}>
|
||||
<Text style={styles.label}>You are going to send the following info:</Text>
|
||||
<Text style={styles.messageInfo}>{message}</Text>
|
||||
|
||||
<Button title="Send via Email" onPress={sendMessageWithEmail} />
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
form: {
|
||||
padding: 30,
|
||||
marginTop: 60,
|
||||
},
|
||||
label: {
|
||||
fontSize: 18,
|
||||
marginBottom: 30,
|
||||
textAlign: 'center',
|
||||
},
|
||||
messageInfo: {
|
||||
fontSize: 16,
|
||||
marginBottom: 15,
|
||||
textAlign: 'center',
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
});
|
||||
|
||||
export default SendEmail;
|
||||
@@ -0,0 +1,64 @@
|
||||
import React, { useState } from 'react';
|
||||
import { View, Text, StyleSheet, Button } from 'react-native';
|
||||
import * as SMS from 'expo-sms';
|
||||
|
||||
const SendSMS = () => {
|
||||
const [message, setMessage] = useState('Levi McLean\n123 Main St\nLondon, ON\n(555) 555-5555\naidanmclean111@gmail.com');
|
||||
|
||||
const sendMessageWithSMS = async () => {
|
||||
const isAvailable = await SMS.isAvailableAsync();
|
||||
if (isAvailable) {
|
||||
const recipients = ['+15195351398']; // Replace with the recipient's phone number
|
||||
const options = {
|
||||
recipients: recipients,
|
||||
message: message,
|
||||
};
|
||||
await SMS.sendSMSAsync(options.recipients, options.message)
|
||||
.then((result) => {
|
||||
if (result.result === 'sent') {
|
||||
Alert.alert('SMS sent successfully');
|
||||
} else {
|
||||
Alert.alert('Failed to send SMS');
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
Alert.alert('Error sending SMS');
|
||||
});
|
||||
} else {
|
||||
Alert.alert('SMS is not available on this device');
|
||||
};
|
||||
};
|
||||
|
||||
const onChangeHandler = (value) => {
|
||||
setMessage(value);
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={styles.form}>
|
||||
<Text style={styles.label}>You are going to send the following info:</Text>
|
||||
<Text style={styles.messageInfo}>{message}</Text>
|
||||
|
||||
<Button title="Send via SMS" onPress={sendMessageWithSMS} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
form: {
|
||||
padding: 30,
|
||||
marginTop: 60,
|
||||
},
|
||||
label: {
|
||||
fontSize: 18,
|
||||
marginBottom: 30,
|
||||
textAlign: 'center',
|
||||
},
|
||||
messageInfo: {
|
||||
fontSize: 16,
|
||||
marginBottom: 15,
|
||||
textAlign: 'center',
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
});
|
||||
|
||||
export default SendSMS;
|
||||
Reference in new issue
Block a user