-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInviteFriendsViewController.swift
More file actions
50 lines (39 loc) · 1.23 KB
/
InviteFriendsViewController.swift
File metadata and controls
50 lines (39 loc) · 1.23 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
//
// 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 inviteButton: UIButton!
var emailDelegate: CustomTextFieldDelegate?
@IBAction func invite(_ sender: AnyObject) {
guard let e = email.text, isValidEmail(e) else {
emailDelegate?.textFieldDidEndEditing(email)
return
}
OGCloud.sharedInstance.inviteNewUser(e)
.then{ response -> Void in
log.debug("invitation sent")
HUD.flash(.success, delay: 1.0)
}
.catch{ error -> Void in
log.debug(error)
}
}
override func viewDidLoad() {
super.viewDidLoad()
emailDelegate = CustomTextFieldDelegate(email, isValid: isValidEmail)
}
func isValidEmail(_ string: String?) -> Bool {
if let str = string {
return str.isValidEmail()
}
return false
}
}