diff --git a/GHFollowers.xcodeproj/project.xcworkspace/xcuserdata/vasilis.xcuserdatad/UserInterfaceState.xcuserstate b/GHFollowers.xcodeproj/project.xcworkspace/xcuserdata/vasilis.xcuserdatad/UserInterfaceState.xcuserstate index 6fe1780..41f8a9c 100644 Binary files a/GHFollowers.xcodeproj/project.xcworkspace/xcuserdata/vasilis.xcuserdatad/UserInterfaceState.xcuserstate and b/GHFollowers.xcodeproj/project.xcworkspace/xcuserdata/vasilis.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/GHFollowers/Components/ViewControllers/GFUserInfoheaderVC.swift b/GHFollowers/Components/ViewControllers/GFUserInfoheaderVC.swift index c26dd3a..2eb014a 100644 --- a/GHFollowers/Components/ViewControllers/GFUserInfoheaderVC.swift +++ b/GHFollowers/Components/ViewControllers/GFUserInfoheaderVC.swift @@ -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), @@ -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) ]) } diff --git a/GHFollowers/Screens/UserInfoVC.swift b/GHFollowers/Screens/UserInfoVC.swift index 1838530..db21a40 100644 --- a/GHFollowers/Screens/UserInfoVC.swift +++ b/GHFollowers/Screens/UserInfoVC.swift @@ -11,6 +11,9 @@ 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! @@ -18,14 +21,28 @@ class UserInfoVC: UIViewController { 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} @@ -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), ]) }