From 795b87279e1758ba43e4cb4429ab3128ef7b9a6f Mon Sep 17 00:00:00 2001 From: HST Date: Thu, 13 Oct 2022 14:45:33 -0300 Subject: [PATCH 1/2] =?UTF-8?q?Bot=C3=A3o=20com=20a=20foto=20de=20perfil?= =?UTF-8?q?=20implementado,sem=20a=20customiza=C3=A7=C3=A3o=20porque=20n?= =?UTF-8?q?=C3=A3o=20recebe=20nenhuma=20imagem=20de=20profile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Screens/Home/HomeViewController.swift | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeViewController.swift b/solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeViewController.swift index 802ee82..5eef4ad 100644 --- a/solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeViewController.swift +++ b/solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeViewController.swift @@ -17,8 +17,28 @@ class HomeViewController: UIViewController { }() override func viewDidLoad() { - navigationItem.title = "Finance App 💰" - navigationController?.navigationBar.prefersLargeTitles = true + + func customNavBar(){ + let configNavBar = UINavigationBarAppearance() + configNavBar.backgroundColor = UIColor.systemBackground + navigationController?.navigationBar.standardAppearance = configNavBar + navigationController?.navigationBar.scrollEdgeAppearance = configNavBar + } + + func profilePictureNavBar(){ + let profilePicture = UIView(frame: CGRect(x: 0, y: 0, width: 40, height: 40)) + let image = UIImageView(frame: CGRect(x: 0, y: 0, width: 40, height: 40)) + image.image = UIImage(named: "avatar-placeholder") + image.contentMode = .scaleAspectFit + image.layer.cornerRadius = 22.5 + image.layer.masksToBounds = true + profilePicture.addSubview(image) + let rightBarButton = UIBarButtonItem(customView: profilePicture) + navigationItem.rightBarButtonItem = rightBarButton + } + + customNavBar() + profilePictureNavBar() service.fetchHomeData { homeData in guard let homeData = homeData else { From b02ccccd83cdd5ea350d96764cb59ba5f07f9b6c Mon Sep 17 00:00:00 2001 From: Caio Santos Date: Thu, 13 Oct 2022 19:11:25 -0300 Subject: [PATCH 2/2] PR adjustments --- .../FinanceApp/Screens/Home/HomeView.swift | 2 +- .../Screens/Home/HomeViewController.swift | 39 +++++++++---------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeView.swift b/solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeView.swift index 9adf083..e559f30 100644 --- a/solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeView.swift +++ b/solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeView.swift @@ -63,7 +63,7 @@ private extension HomeView { func configureSubviewsConstraints() { NSLayoutConstraint.activate([ - accountSummaryView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor), + accountSummaryView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor, constant: 16), accountSummaryView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor, constant: 16), accountSummaryView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor, constant: -16), diff --git a/solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeViewController.swift b/solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeViewController.swift index 5eef4ad..a829327 100644 --- a/solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeViewController.swift +++ b/solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeViewController.swift @@ -17,26 +17,6 @@ class HomeViewController: UIViewController { }() override func viewDidLoad() { - - func customNavBar(){ - let configNavBar = UINavigationBarAppearance() - configNavBar.backgroundColor = UIColor.systemBackground - navigationController?.navigationBar.standardAppearance = configNavBar - navigationController?.navigationBar.scrollEdgeAppearance = configNavBar - } - - func profilePictureNavBar(){ - let profilePicture = UIView(frame: CGRect(x: 0, y: 0, width: 40, height: 40)) - let image = UIImageView(frame: CGRect(x: 0, y: 0, width: 40, height: 40)) - image.image = UIImage(named: "avatar-placeholder") - image.contentMode = .scaleAspectFit - image.layer.cornerRadius = 22.5 - image.layer.masksToBounds = true - profilePicture.addSubview(image) - let rightBarButton = UIBarButtonItem(customView: profilePicture) - navigationItem.rightBarButtonItem = rightBarButton - } - customNavBar() profilePictureNavBar() @@ -56,4 +36,23 @@ class HomeViewController: UIViewController { override func loadView() { self.view = homeView } + + private func customNavBar() { + let configNavBar = UINavigationBarAppearance() + configNavBar.backgroundColor = UIColor.systemBackground + navigationController?.navigationBar.standardAppearance = configNavBar + navigationController?.navigationBar.scrollEdgeAppearance = configNavBar + } + + private func profilePictureNavBar() { + let profilePicture = UIView(frame: CGRect(x: 0, y: 0, width: 40, height: 40)) + let image = UIImageView(frame: CGRect(x: 0, y: 0, width: 40, height: 40)) + image.image = UIImage(named: "avatar-placeholder") + image.contentMode = .scaleAspectFit + image.layer.cornerRadius = 22.5 + image.layer.masksToBounds = true + profilePicture.addSubview(image) + let rightBarButton = UIBarButtonItem(customView: profilePicture) + navigationItem.rightBarButtonItem = rightBarButton + } }