Skip to content

Commit

Permalink
UI bug fix and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
grenos committed Apr 13, 2020
1 parent e7c3358 commit cb76820
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
Binary file not shown.
4 changes: 2 additions & 2 deletions GHFollowers/Components/ViewControllers/GFDataLoadingVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class GFDataLoadingVC: UIViewController {

// center indicator on containerView
NSLayoutConstraint.activate([
activityIndicator.centerYAnchor.constraint(equalTo: view.centerYAnchor),
activityIndicator.centerXAnchor.constraint(equalTo: view.centerXAnchor)
activityIndicator.centerYAnchor.constraint(equalTo: containerView.centerYAnchor),
activityIndicator.centerXAnchor.constraint(equalTo: containerView.centerXAnchor)
])

activityIndicator.startAnimating()
Expand Down
39 changes: 28 additions & 11 deletions GHFollowers/Components/Views/GFEmptyStateView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GFEmptyStateView: UIView {

override init(frame: CGRect) {
super.init(frame: frame)
configure()
configureUI()
}

required init?(coder: NSCoder) {
Expand All @@ -29,33 +29,50 @@ class GFEmptyStateView: UIView {
}


private func configure() {

private func configureUI() {
configureMessageLabel()
configureLogoImageView()
}


private func configureMessageLabel() {
addSubview(messageLabel)
addSubview(logoImageView)

messageLabel.numberOfLines = 3
messageLabel.textColor = .secondaryLabel

logoImageView.image = Images.emptyStateLogo
logoImageView.translatesAutoresizingMaskIntoConstraints = false
//center item on screen verrtically and then push up a litle bit
let labelCenterYConstant: CGFloat = DeviceTypes.isiPhoneSE || DeviceTypes.isiPhone8Zoomed ? -80 : -150
let messageLabelCenterYConstraint = messageLabel.centerYAnchor.constraint(equalTo: self.centerYAnchor, constant: labelCenterYConstant)
messageLabelCenterYConstraint.isActive = true

NSLayoutConstraint.activate([
//center item on screen verrtically and then push up a litle bit
messageLabel.centerYAnchor.constraint(equalTo: self.centerYAnchor, constant: -150),
messageLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 40),
messageLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -40),
// hard code height since we know the text message already
messageLabel.heightAnchor.constraint(equalToConstant: 200),

])
}



private func configureLogoImageView() {
addSubview(logoImageView)
logoImageView.image = Images.emptyStateLogo
logoImageView.translatesAutoresizingMaskIntoConstraints = false

let logoBottomConstant: CGFloat = DeviceTypes.isiPhoneSE || DeviceTypes.isiPhone8Zoomed ? 80 : 40
let logoImageViewBottomConstraint = logoImageView.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: logoBottomConstant)
logoImageViewBottomConstraint.isActive = true

NSLayoutConstraint.activate([
// take the image and make it 1.3 times larger then it curretn width (scale: 1.3)
logoImageView.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 1.3),
// make height same as width (height will be 1.3 times larger)
logoImageView.heightAnchor.constraint(equalTo: self.widthAnchor, multiplier: 1.3),
// we use 200 to push the element TOWARDS the edge and not pull it like we did any other time
logoImageView.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: 170),
logoImageView.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: 170)
// same as above (push insted of pull) so not using a negative number in constant
logoImageView.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: 40)
])
}

Expand Down

0 comments on commit cb76820

Please sign in to comment.