-
Notifications
You must be signed in to change notification settings - Fork 0
/
PopUpViewController
100 lines (82 loc) · 3.34 KB
/
PopUpViewController
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//
// PopUpViewController.swift
// Radius
//
// Created by Kassandra Capretta on 1/18/20.
// Copyright © 2020 Kassandra Capretta. All rights reserved.
//
import UIKit
import Firebase
import MessageUI
import ProgressHUD
//var currentlyViewedUserId: String?
//
//var usersDict: [String: LocalUser] = [:]
//var users: [LocalUser] = []
//
//var userDetails: [[UserDetail: String]] = []
// Post
//var postData = [UISwitch]()
//let firebaseServer = FirebaseFunctions.shared
class PopUpViewController: UIViewController, MFMailComposeViewControllerDelegate {
@IBOutlet weak var sendTapped: UIButton!
@IBOutlet weak var cancelTapped: UIButton!
@IBOutlet weak var myView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
Utilities.styleHollowButton(sendTapped)
Utilities.styleHollowButton(cancelTapped)
// Animate View
func showAnimate()
{
self.myView.transform = CGAffineTransform(scaleX: 1.3, y: 1.3)
self.myView.alpha = 0.0;
UIView.animate(withDuration: 0.25, animations: {
self.myView.alpha = 1.0
self.myView.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
});
}
func removeAnimate()
{
UIView.animate(withDuration: 0.25, animations: {
self.myView.transform = CGAffineTransform(scaleX: 1.3, y: 1.3)
self.myView.alpha = 0.0;
}, completion:{(finished : Bool) in if (finished)
{
self.myView.removeFromSuperview()
}
});
}
// Shadow on View
self.myView.layer.shadowColor = UIColor.gray.cgColor
self.myView.layer.shadowOpacity = 0.5
self.myView.layer.shadowOffset = CGSize(width: 2, height: 2)
self.myView.layer.shadowRadius = 6
self.myView.layer.masksToBounds = false
}
@IBAction func sendReport(_ sender: Any) {
let mailComposeViewController = configureMailController()
if MFMailComposeViewController.canSendMail() {
self.present(mailComposeViewController, animated:true, completion: nil) }
else {
showMailError()
}
}
func configureMailController() -> MFMailComposeViewController {
let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self
mailComposerVC.setToRecipients(["[email protected]"])
mailComposerVC.setSubject("Reporting user")
mailComposerVC.setMessageBody("Please include as much detail as possible:", isHTML: false)
return mailComposerVC
}
func showMailError() {
let sendMailErrorAlert = showAlert(withTitle: "Could not send message", message: "Please try again")
let dismiss = UIAlertAction(title: "Okay", style: .default, handler: nil)
// sendMailErrorAlert.addAction(dismiss)
// self.present(sendMailErrorAlert, animated: true, completion: nil)
}
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true, completion: nil)
}
}