|
| 1 | +import React, { Component } from "react"; |
| 2 | +import { |
| 3 | + Text, |
| 4 | + View, |
| 5 | + TextInput, |
| 6 | + TouchableOpacity, |
| 7 | + AsyncStorage |
| 8 | +} from "react-native"; |
| 9 | +import { Notifications } from "expo"; |
| 10 | + |
| 11 | +export default class Report extends Component { |
| 12 | + static navigationOptions = { |
| 13 | + header: null |
| 14 | + }; |
| 15 | + |
| 16 | + scheduleNotification = async () => { |
| 17 | + await Notifications.scheduleLocalNotificationAsync( |
| 18 | + { |
| 19 | + title: "Your Monthly Stats are available", |
| 20 | + body: "You have set a new record", |
| 21 | + android: { |
| 22 | + sound: "default", |
| 23 | + priority: "max", |
| 24 | + channelId: "local" |
| 25 | + }, |
| 26 | + ios: { |
| 27 | + sound: "default" |
| 28 | + }, |
| 29 | + data: { |
| 30 | + goToPage: "Stats", |
| 31 | + secret: "Just Kidding! Better Luck Next Time" |
| 32 | + } |
| 33 | + }, |
| 34 | + { |
| 35 | + time: new Date().getTime() + 5000 |
| 36 | + } |
| 37 | + ); |
| 38 | + }; |
| 39 | + |
| 40 | + handleSubmitReport = async () => { |
| 41 | + let notificationStatus = await AsyncStorage.getItem("notificationStatus"); |
| 42 | + if (notificationStatus) { |
| 43 | + Notifications.presentLocalNotificationAsync({ |
| 44 | + title: "Sending Report", |
| 45 | + body: "Connecting to Pokemon Secure Servers", |
| 46 | + android: { |
| 47 | + sound: "default", |
| 48 | + priority: "max", |
| 49 | + channelId: "local" |
| 50 | + }, |
| 51 | + ios: { |
| 52 | + sound: "default" |
| 53 | + } |
| 54 | + }); |
| 55 | + this.scheduleNotification(); |
| 56 | + } |
| 57 | + }; |
| 58 | + |
| 59 | + render() { |
| 60 | + return ( |
| 61 | + <View style={{ backgroundColor: "#000", flex: 1 }}> |
| 62 | + <View style={{ alignItems: "center", backgroundColor: "forestgreen" }}> |
| 63 | + <Text style={{ color: "#fff", fontSize: 36 }}> |
| 64 | + {" "} |
| 65 | + 📜 Create Report📜{" "} |
| 66 | + </Text> |
| 67 | + </View> |
| 68 | + <View style={{ padding: 10 }}> |
| 69 | + <Text style={{ color: "#fff", fontSize: 28 }}>Criminal Name</Text> |
| 70 | + <TextInput |
| 71 | + style={{ backgroundColor: "#fff", height: 60, fontSize: 36 }} |
| 72 | + placeholder={"Enter Criminal Name"} |
| 73 | + /> |
| 74 | + <Text style={{ color: "#fff", fontSize: 28 }}>Crime Committed</Text> |
| 75 | + <TextInput |
| 76 | + style={{ backgroundColor: "#fff", height: 60, fontSize: 36 }} |
| 77 | + placeholder={"Enter Name of Crime"} |
| 78 | + /> |
| 79 | + <Text style={{ color: "#fff", fontSize: 28 }}>Crime Location</Text> |
| 80 | + <TextInput |
| 81 | + style={{ backgroundColor: "#fff", height: 60, fontSize: 36 }} |
| 82 | + placeholder={"Enter Crime Location"} |
| 83 | + /> |
| 84 | + </View> |
| 85 | + <View style={{ flex: 1, justifyContent: "flex-end", padding: 10 }}> |
| 86 | + <TouchableOpacity |
| 87 | + style={{ |
| 88 | + backgroundColor: "maroon", |
| 89 | + alignItems: "center", |
| 90 | + justifyContent: "center" |
| 91 | + }} |
| 92 | + onPress={this.handleSubmitReport} |
| 93 | + > |
| 94 | + <Text style={{ color: "#fff", fontSize: 36 }}>Submit Report</Text> |
| 95 | + </TouchableOpacity> |
| 96 | + </View> |
| 97 | + </View> |
| 98 | + ); |
| 99 | + } |
| 100 | +} |
0 commit comments