-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProfileSummary.swift
134 lines (107 loc) · 4.53 KB
/
ProfileSummary.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//
// ProfileSummary.swift
// My Diabetic Manager
//
// Created by Anna Belardo on 02/02/17.
// Copyright © 2017 Vincenzo De Rosa. All rights reserved.
//
import UIKit
class ProfileSummary: UIViewController {
@IBOutlet var LoggedName: UILabel!
@IBOutlet var LoggedSurname: UILabel!
@IBOutlet var LoggedICHO: UILabel!
@IBOutlet var OminoImage: UIImageView!
@IBOutlet var LoggedAverage: UILabel!
//DA VEDERE se fisso o se deve funzionare il log in
var Name:String = "Anna"
var Surname = "Belardo"
var ICHO = "12"
var Email = "[email protected]"
var Birthdate = "02/09/1994"
var Password = "password"
//ENZO FAI COSE A QUESTA VARIABILE
var Average = "8"
override func viewDidLoad() {
//Label per Nome Profilo
LoggedName.layer.borderWidth = 0.5
LoggedName.layer.cornerRadius = 7
LoggedName.layer.borderColor = UIColor.lightGray.cgColor
LoggedName.layer.backgroundColor = hexStringToUIColor(hex: "EBEBF1").cgColor
LoggedName.text = Name
//Label per Cognome Profilo
LoggedSurname.layer.borderWidth = 0.5
LoggedSurname.layer.cornerRadius = 7
LoggedSurname.layer.borderColor = UIColor.lightGray.cgColor
LoggedSurname.layer.backgroundColor = hexStringToUIColor(hex: "EBEBF1").cgColor
LoggedSurname.text = Surname
//Label per ICHO Profilo
LoggedICHO.layer.borderWidth = 0.5
LoggedICHO.layer.cornerRadius = 7
LoggedICHO.layer.borderColor = UIColor.lightGray.cgColor
LoggedICHO.layer.backgroundColor = hexStringToUIColor(hex: "EBEBF1").cgColor
LoggedICHO.text = ICHO
//immagine rotonda
OminoImage.layer.borderWidth = 1
OminoImage.layer.masksToBounds = false
OminoImage.layer.cornerRadius = OminoImage.frame.size.height/2
OminoImage.layer.cornerRadius = OminoImage.frame.size.width/2
OminoImage.clipsToBounds = true
OminoImage.image = UIImage(named: "Simba")
OminoImage.layer.borderColor = hexStringToUIColor(hex: "034f84").cgColor
//Label per valori glicemici
LoggedAverage.layer.borderWidth = 0.5
LoggedAverage.layer.cornerRadius = 7
LoggedAverage.layer.borderColor = UIColor.lightGray.cgColor
LoggedAverage.layer.backgroundColor = hexStringToUIColor(hex: "EBEBF1").cgColor
LoggedAverage.text = Average
//gesture per swap DAAGGIUNGERE
super.viewDidLoad()
// Do any additional setup after loading the view.
}
func hexStringToUIColor (hex:String) -> UIColor {
var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
if (cString.hasPrefix("#")) {
cString.remove(at: cString.startIndex)
}
if ((cString.characters.count) != 6) {
return UIColor.gray
}
var rgbValue:UInt32 = 0
Scanner(string: cString).scanHexInt32(&rgbValue)
return UIColor(
red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
alpha: CGFloat(1.0)
)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "modifyProfile"{
let destinationController = segue.destination as! modifyProfile
destinationController.newName = Name
destinationController.newSurname = Surname
destinationController.newICHO = ICHO
destinationController.newEmail = Email
destinationController.newPassword = Password
destinationController.newImage = "ominopc"
destinationController.newBirthdate = Birthdate
}
}
override func viewDidAppear(_ animated: Bool)
{
let isUserLoggedIn = UserDefaults.standard.bool(forKey: "isUserLoggedIn");
if(!isUserLoggedIn)
{
self.performSegue(withIdentifier: "loginView", sender: self);
}
}
@IBAction func logoutButtonTapped(_ sender: AnyObject) {
UserDefaults.standard.set(false,forKey:"isUserLoggedIn");
UserDefaults.standard.synchronize();
self.performSegue(withIdentifier: "loginView", sender: self);
}
}