-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTeamMember.swift
94 lines (76 loc) · 3.01 KB
/
TeamMember.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
//
// ViewController.swift
// meetTheTeam
//
// Created by Taylor Simpson on 5/10/17.
// Copyright © 2017 Taylor Simpson. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
// MARK: - Variables to be set from TeamTableViewController
var fullName: String?
var staffTitle: String?
var avatar: String?
var bio: String?
var firstName: String?
// MARK: - IBOutlets to change view heights and to make mods to views
@IBOutlet weak var bioView: UIView!
@IBOutlet weak var bioViewHeightContraint: NSLayoutConstraint!
@IBOutlet weak var bioTextView: UITextView!
@IBOutlet weak var bioLabel: UILabel!
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
var bioViewHeight: CGFloat! {
/*
Here we're using a property observer to execute code whenever
this value is updated
*/
didSet {
print("stackViewHeight updated to \(bioViewHeight)")
UIView.animate(withDuration: 0.5, delay: 0.0, options: [.curveEaseIn], animations: {
self.bioViewHeightContraint.constant = self.bioViewHeight
self.view.layoutIfNeeded()
}) { _ in
self.bioTextView.scrollRangeToVisible(NSRange(location: 0, length: 0))
print("animation complete")
}
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(false)
bioViewHeight = bioViewHeightContraint.constant
bioViewHeight = UIScreen.main.bounds.height / 2
}
override func viewDidLoad() {
super.viewDidLoad()
configureTapGesture()
bioView.layer.addBorder(edge: .top, color: UIColor(red:0.15, green:0.54, blue:0.90, alpha:1.0), thickness: 10)
self.title = firstName
bioLabel.text = fullName
titleLabel.text = staffTitle
bioTextView.text = bio
let url = URL(string: avatar!)
//Shows an indicator when the images are being downloaded
imageView.kf.indicatorType = .activity
imageView.kf.setImage(with: url)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
//Configures The Tap Gesture and calls toggelHeight
func configureTapGesture() {
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(toggleHeight(sender:)))
tapGestureRecognizer.numberOfTapsRequired = 1
bioView.addGestureRecognizer(tapGestureRecognizer)
}
//changes bioView height when tap gesture is fired
func toggleHeight(sender: UITapGestureRecognizer) {
if bioViewHeightContraint.constant == UIScreen.main.bounds.height / 2 {
// true
bioViewHeight = UIScreen.main.bounds.height - 80 // gives space for status bar and navigation bar
} else {
// false
bioViewHeight = UIScreen.main.bounds.height / 2
}
}
}