This repository has been archived by the owner on Apr 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ProfileViewController.swift
94 lines (71 loc) · 2.37 KB
/
ProfileViewController.swift
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
//
// ProfileViewController.swift
//
// Created by TestProject on 28/07/2017.
// Copyright © 2017 TestProject. All rights reserved.
//
import UIKit
class ProfileViewController: UIViewController, UITextFieldDelegate {
var fullName = "";
@IBOutlet weak var greetings: UILabel!
@IBOutlet weak var country: UITextField!
@IBOutlet weak var address: UITextField!
@IBOutlet weak var email: UITextField!
@IBOutlet weak var phone: UITextField!
@IBOutlet weak var validationCountry: UILabel!
@IBOutlet weak var validationAddress: UILabel!
@IBOutlet weak var validationEmail: UILabel!
@IBOutlet weak var validationPhone: UILabel!
@IBOutlet weak var saved: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
self.country.delegate = self
self.address.delegate = self
self.email.delegate = self
self.phone.delegate = self
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
greetings.text = "Hello " + fullName
saved.isHidden = true
}
@IBAction func performLogout(_ sender: Any) {
performSegue(withIdentifier: "unwindSegueToLogin", sender: self)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
self.view.endEditing(true)
return false
}
@IBAction func performSave(_ sender: Any) {
var hasErrors = false;
if (country.text == "") {
validationCountry.isHidden = false;
hasErrors = true;
} else {
validationCountry.isHidden = true;
}
if (address.text == "") {
validationAddress.isHidden = false;
hasErrors = true;
} else {
validationAddress.isHidden = true;
}
if (email.text == "") {
validationEmail.isHidden = false;
hasErrors = true;
} else {
validationEmail.isHidden = true;
}
if (phone.text == "") {
validationPhone.isHidden = false;
hasErrors = true;
} else {
validationPhone.isHidden = true;
}
if (!hasErrors) {
saved.isHidden = false;
} else {
saved.isHidden = true;
}
}
}