-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWelcomeViewController.swift
More file actions
62 lines (50 loc) · 1.94 KB
/
WelcomeViewController.swift
File metadata and controls
62 lines (50 loc) · 1.94 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
//
// WelcomeViewController.swift
// student_cookbook
//
// Created by Jade Redworth on 21/05/2017.
// Copyright © 2017 Jade Redworth. All rights reserved.
//
import UIKit
import FirebaseAuth
import FirebaseDatabase
class WelcomeViewController: UIViewController {
var ref: FIRDatabaseReference!
var currentStoryboard: UIStoryboard!
var userList = [User]()
var userID: String = ""
@IBOutlet weak var imageViewProfilePicture: UIImageView!
@IBOutlet weak var labelName: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
ref = FIRDatabase.database().reference()
currentStoryboard = self.storyboard
// Retrieves the logged in users details to display.
userList.fetchUsers(refName: "Users", queryKey: userID, queryValue: "" as AnyObject, ref: ref){
(result: [User]) in
if result.isEmpty{
print("No user")
} else {
self.userList = result
self.labelName.text = "\(self.userList[0].firstName!) \(self.userList[0].lastName!)"
self.imageViewProfilePicture.loadImageWithCacheWithUrlString(self.userList[0].profilePicURL!)
self.imageViewProfilePicture.makeImageCircle()
}
}
}
@IBAction func buttonGo(_ sender: Any) {
performSegue(withIdentifier: "GoSegue", sender: nil)
}
@IBAction func buttonNotMe(_ sender: Any) {
perform(#selector(handleLogout), with: nil, afterDelay: 0)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func handleLogout() {
try! FIRAuth.auth()!.signOut()
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "LogInViewController") as! LogInViewController
present(vc, animated: true, completion: nil)
}
}