fixed issues with stackview stretching + updated biolabel
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
7b65685d1a
commit
aae4f5b67c
@ -16,8 +16,8 @@ public class EmployeeDetailViewController: UIViewController {
|
||||
private let employeeTypeLabel = UILabel()
|
||||
private let phoneLabel = UILabel()
|
||||
private let bioLabel = UILabel()
|
||||
|
||||
private let stackView = UIStackView()
|
||||
private let scrollView = UIScrollView()
|
||||
|
||||
/// Used for grabbing the photo
|
||||
private var largerPhotoSubscriber: AnyCancellable?
|
||||
@ -29,18 +29,22 @@ public class EmployeeDetailViewController: UIViewController {
|
||||
|
||||
view.backgroundColor = .white
|
||||
|
||||
// default image
|
||||
// Configure Photo
|
||||
photoImageView.image = UIImage(systemName: "person.crop.circle")
|
||||
photoImageView.contentMode = .scaleAspectFit
|
||||
photoImageView.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
// Configure stackView
|
||||
// Configure StackView
|
||||
stackView.axis = .vertical
|
||||
stackView.spacing = 5
|
||||
stackView.alignment = .top
|
||||
stackView.spacing = 10
|
||||
stackView.alignment = .leading
|
||||
stackView.distribution = .fill
|
||||
stackView.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
// Configure Labels
|
||||
bioLabel.numberOfLines = 0
|
||||
|
||||
// Add labels to stackView
|
||||
// Add views to stackView
|
||||
stackView.addArrangedSubview(photoImageView)
|
||||
stackView.addArrangedSubview(nameLabel)
|
||||
stackView.addArrangedSubview(teamLabel)
|
||||
@ -53,10 +57,10 @@ public class EmployeeDetailViewController: UIViewController {
|
||||
photoImageView.heightAnchor.constraint(equalToConstant: 200).isActive = true
|
||||
photoImageView.widthAnchor.constraint(equalToConstant: 200).isActive = true
|
||||
stackView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
|
||||
stackView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true
|
||||
stackView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, constant: 10).isActive = true
|
||||
stackView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor, constant: -10).isActive = true
|
||||
|
||||
stackView.bottomAnchor.constraint(lessThanOrEqualTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true
|
||||
stackView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 10).isActive = true
|
||||
stackView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -10).isActive = true
|
||||
|
||||
// Bind the image to the photoImageView
|
||||
largerPhotoSubscriber = viewModel?.$largePhoto
|
||||
.compactMap { $0 }
|
||||
@ -82,18 +86,19 @@ public class EmployeeDetailViewController: UIViewController {
|
||||
let phoneTap = UITapGestureRecognizer(target: self, action: #selector(didTapPhoneView(_:)))
|
||||
phoneLabel.isUserInteractionEnabled = true
|
||||
phoneLabel.addGestureRecognizer(phoneTap)
|
||||
|
||||
}
|
||||
|
||||
@objc func didTapPhoneView(_ sender: UITapGestureRecognizer) {
|
||||
guard let phoneNumber = viewModel?.phoneNumber?.filter({ $0.isNumber }) else {
|
||||
print("phone not there")
|
||||
print("phoneNumber not there")
|
||||
return
|
||||
}
|
||||
let numberUrl = URL(string: "tel://\(phoneNumber)")!
|
||||
if UIApplication.shared.canOpenURL(numberUrl) {
|
||||
UIApplication.shared.open(numberUrl)
|
||||
}
|
||||
print("print", phoneNumber)
|
||||
print("call:", phoneNumber)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user