Skip to content

Commit ad41c6e

Browse files
authored
Merge pull request #61 from rafallgo/feat/UserProfileButton
Botão com a foto de perfil implementado,sem a customização porque não…
2 parents 0130680 + b02cccc commit ad41c6e

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private extension HomeView {
6363

6464
func configureSubviewsConstraints() {
6565
NSLayoutConstraint.activate([
66-
accountSummaryView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor),
66+
accountSummaryView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor, constant: 16),
6767
accountSummaryView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor, constant: 16),
6868
accountSummaryView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor, constant: -16),
6969

solutions/devsprint-caio-santos-7/FinanceApp/Screens/Home/HomeViewController.swift

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class HomeViewController: UIViewController {
1717
}()
1818

1919
override func viewDidLoad() {
20-
navigationItem.title = "Finance App 💰"
21-
navigationController?.navigationBar.prefersLargeTitles = true
20+
customNavBar()
21+
profilePictureNavBar()
2222

2323
service.fetchHomeData { homeData in
2424
guard let homeData = homeData else {
@@ -36,4 +36,23 @@ class HomeViewController: UIViewController {
3636
override func loadView() {
3737
self.view = homeView
3838
}
39+
40+
private func customNavBar() {
41+
let configNavBar = UINavigationBarAppearance()
42+
configNavBar.backgroundColor = UIColor.systemBackground
43+
navigationController?.navigationBar.standardAppearance = configNavBar
44+
navigationController?.navigationBar.scrollEdgeAppearance = configNavBar
45+
}
46+
47+
private func profilePictureNavBar() {
48+
let profilePicture = UIView(frame: CGRect(x: 0, y: 0, width: 40, height: 40))
49+
let image = UIImageView(frame: CGRect(x: 0, y: 0, width: 40, height: 40))
50+
image.image = UIImage(named: "avatar-placeholder")
51+
image.contentMode = .scaleAspectFit
52+
image.layer.cornerRadius = 22.5
53+
image.layer.masksToBounds = true
54+
profilePicture.addSubview(image)
55+
let rightBarButton = UIBarButtonItem(customView: profilePicture)
56+
navigationItem.rightBarButtonItem = rightBarButton
57+
}
3958
}

0 commit comments

Comments
 (0)