Skip to content

Commit

Permalink
PROGRESS UserInfoVC cleanup and setup
Browse files Browse the repository at this point in the history
  • Loading branch information
grenos committed Apr 2, 2020
1 parent f4b66bd commit a007ac0
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 17 deletions.
Binary file not shown.
10 changes: 5 additions & 5 deletions GHFollowers/Components/ViewControllers/GFUserInfoheaderVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ class GFUserInfoheaderVC: UIViewController {

NSLayoutConstraint.activate([
avatarImageView.topAnchor.constraint(equalTo: view.topAnchor, constant: padding),
avatarImageView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: padding),
avatarImageView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
avatarImageView.widthAnchor.constraint(equalToConstant: 90),
avatarImageView.heightAnchor.constraint(equalToConstant: 90),

usernameLabel.topAnchor.constraint(equalTo: avatarImageView.topAnchor),
usernameLabel.leadingAnchor.constraint(equalTo: avatarImageView.trailingAnchor, constant: textImagePadding),
usernameLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -padding),
usernameLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor),
usernameLabel.heightAnchor.constraint(equalToConstant: 38),

nameLabel.centerYAnchor.constraint(equalTo: avatarImageView.centerYAnchor, constant: 8),
nameLabel.leadingAnchor.constraint(equalTo: avatarImageView.trailingAnchor, constant: textImagePadding),
nameLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -padding),
nameLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor),
nameLabel.heightAnchor.constraint(equalToConstant: 20),

locationImageView.bottomAnchor.constraint(equalTo: avatarImageView.bottomAnchor),
Expand All @@ -96,12 +96,12 @@ class GFUserInfoheaderVC: UIViewController {

locationLabel.centerYAnchor.constraint(equalTo: locationImageView.centerYAnchor),
locationLabel.leadingAnchor.constraint(equalTo: locationImageView.trailingAnchor, constant: 5),
locationLabel.trailingAnchor.constraint(equalToSystemSpacingAfter: view.trailingAnchor, multiplier: -padding),
locationLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor),
locationLabel.heightAnchor.constraint(equalToConstant: 20),

bioLabel.topAnchor.constraint(equalTo: avatarImageView.bottomAnchor, constant: textImagePadding),
bioLabel.leadingAnchor.constraint(equalTo: avatarImageView.leadingAnchor),
bioLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -padding),
bioLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor),
bioLabel.heightAnchor.constraint(equalToConstant: 60)
])
}
Expand Down
56 changes: 44 additions & 12 deletions GHFollowers/Screens/UserInfoVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,38 @@ import UIKit
class UserInfoVC: UIViewController {

let headerView = UIView()
let itemViewOne = UIView()
let itemViewTwo = UIView()
var itemViews: [UIView] = []

// username gets passed here from FollowerListVC from function -- extension FollowerListVC: UICollectionViewDelegate --
var username: String!

override func viewDidLoad() {
super.viewDidLoad()

configureVC()
layoutUI()
getUserInfo()
}


func configureVC() {
view.backgroundColor = .systemBackground
// create done button for navigation
let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(dismissVC))
// add button to navigation bar
navigationItem.rightBarButtonItem = doneButton

layoutUI()

}

@objc func dismissVC() {
dismiss(animated: true)
}



// MARK: Network call
func getUserInfo() {
NetworkManager.shared.getUserInfo(for: username) { [weak self] result in
guard let self = self else {return}

Expand All @@ -42,21 +59,36 @@ class UserInfoVC: UIViewController {
}
}

@objc func dismissVC() {
dismiss(animated: true)
}



// MARK: UI layout
func layoutUI() {
view.addSubview(headerView)
headerView.translatesAutoresizingMaskIntoConstraints = false
itemViews = [headerView, itemViewOne, itemViewTwo]
let padding: CGFloat = 20

for itemView in itemViews {
view.addSubview(itemView)
itemView.translatesAutoresizingMaskIntoConstraints = false

//add left-right padding
NSLayoutConstraint.activate([
itemView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: padding),
itemView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -padding)
])
}

itemViewOne.backgroundColor = .systemPink
itemViewTwo.backgroundColor = .systemBlue

NSLayoutConstraint.activate([
headerView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
headerView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
headerView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
headerView.heightAnchor.constraint(equalToConstant: 180)
headerView.heightAnchor.constraint(equalToConstant: 180),

itemViewOne.topAnchor.constraint(equalTo: headerView.bottomAnchor, constant: padding),
itemViewOne.heightAnchor.constraint(equalToConstant: 140),

itemViewTwo.topAnchor.constraint(equalTo: itemViewOne.bottomAnchor, constant: padding),
itemViewTwo.heightAnchor.constraint(equalToConstant: 140),
])
}

Expand Down

0 comments on commit a007ac0

Please sign in to comment.