-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInviteFriendsViewController.swift
More file actions
71 lines (52 loc) · 1.84 KB
/
Copy pathInviteFriendsViewController.swift
File metadata and controls
71 lines (52 loc) · 1.84 KB
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
//
// InviteFriendsViewController.swift
// Absinthe-iOS
//
// Created by Alyssa Torres on 10/25/16.
// Copyright © 2016 AppDelegates. All rights reserved.
//
import UIKit
import PromiseKit
import PKHUD
class InviteFriendsViewController: AccountBaseViewController {
@IBOutlet weak var email: UITextField!
@IBOutlet weak var emailGoodCheck: UIImageView!
@IBOutlet weak var inviteButton: UIButton!
@IBAction func invite(_ sender: AnyObject) {
guard let e = self.email.text
else {
showAlert("Oops!", message: "The email you put in is not valid.")
return
}
if e.isValidEmail() {
Asahi.sharedInstance.inviteNewUser(e)
.then{ response -> Void in
HUD.flash(.success, delay: 1.0) }
}
else {
showAlert("Oops!", message: "The email you put in is not valid.")
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.emailGoodCheck.alpha = 0
self.inviteButton.alpha = 0
NotificationCenter.default.addObserver(self, selector: #selector(checkEmail), name: NSNotification.Name.UITextFieldTextDidChange, object: nil)
}
func checkEmail() {
if let email = self.email.text {
if email.isValidEmail() {
fadeIn(self.emailGoodCheck)
fadeIn(self.inviteButton)
}
if !email.isValidEmail() {
fadeOut(self.emailGoodCheck)
fadeOut(self.inviteButton)
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}