Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Redesign] 내비게이션바 #104

Open
wants to merge 4 commits into
base: Redesign/99-TabBar
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions HRHN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

/* Begin PBXBuildFile section */
500CA076299740260012779B /* CustomHeightTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 500CA075299740260012779B /* CustomHeightTabBar.swift */; };
500CA071299697320012779B /* CustomNavBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 500CA070299697320012779B /* CustomNavBar.swift */; };
505B95352959926A005F00C8 /* ReviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505B95342959926A005F00C8 /* ReviewViewController.swift */; };
505B953829599976005F00C8 /* UIViewController+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505B953729599976005F00C8 /* UIViewController+.swift */; };
505B953B29599A24005F00C8 /* ReviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505B953A29599A24005F00C8 /* ReviewView.swift */; };
507089B0295ABC2B00DD8D85 /* Color+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507089AF295ABC2B00DD8D85 /* Color+.swift */; };
507089B2295ADE1A00DD8D85 /* View+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507089B1295ADE1A00DD8D85 /* View+.swift */; };
507089B4295AE9D600DD8D85 /* ReviewViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507089B3295AE9D600DD8D85 /* ReviewViewModel.swift */; };
507305F229965AAB00A20CA1 /* TabIcons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507305F129965AAB00A20CA1 /* TabIcons.swift */; };
507305F42996652500A20CA1 /* UINavigationBar+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507305F32996652500A20CA1 /* UINavigationBar+.swift */; };
5080B2ED29601A2A005115AA /* DateComponents+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5080B2EC29601A2A005115AA /* DateComponents+.swift */; };
5080B2EE29601A3D005115AA /* DateComponents+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5080B2EC29601A2A005115AA /* DateComponents+.swift */; };
5080B2EF29601A41005115AA /* Date+.swift in Sources */ = {isa = PBXBuildFile; fileRef = A79121682954FB600044E652 /* Date+.swift */; };
Expand Down Expand Up @@ -130,13 +132,15 @@

/* Begin PBXFileReference section */
500CA075299740260012779B /* CustomHeightTabBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomHeightTabBar.swift; sourceTree = "<group>"; };
500CA070299697320012779B /* CustomNavBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomNavBar.swift; sourceTree = "<group>"; };
505B95342959926A005F00C8 /* ReviewViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewViewController.swift; sourceTree = "<group>"; };
505B953729599976005F00C8 /* UIViewController+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+.swift"; sourceTree = "<group>"; };
505B953A29599A24005F00C8 /* ReviewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewView.swift; sourceTree = "<group>"; };
507089AF295ABC2B00DD8D85 /* Color+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+.swift"; sourceTree = "<group>"; };
507089B1295ADE1A00DD8D85 /* View+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+.swift"; sourceTree = "<group>"; };
507089B3295AE9D600DD8D85 /* ReviewViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewViewModel.swift; sourceTree = "<group>"; };
507305F129965AAB00A20CA1 /* TabIcons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabIcons.swift; sourceTree = "<group>"; };
507305F32996652500A20CA1 /* UINavigationBar+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationBar+.swift"; sourceTree = "<group>"; };
5080B2EC29601A2A005115AA /* DateComponents+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateComponents+.swift"; sourceTree = "<group>"; };
50A5000B295D8B8300710B5D /* HRHN.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = HRHN.entitlements; sourceTree = "<group>"; };
50A5000C295D8BAD00710B5D /* LockscreenWidgetExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = LockscreenWidgetExtension.entitlements; sourceTree = "<group>"; };
Expand Down Expand Up @@ -248,6 +252,14 @@
path = TabBar;
sourceTree = "<group>";
};
500CA06F299697110012779B /* Protocol */ = {
isa = PBXGroup;
children = (
500CA070299697320012779B /* CustomNavBar.swift */,
);
path = Protocol;
sourceTree = "<group>";
};
505B9539295999EA005F00C8 /* SupportingViews */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -395,6 +407,7 @@
50C1BE39295C7539009A57BA /* UITextView+.swift */,
50A50016295D951600710B5D /* URL+.swift */,
A74C75192975325B0046B1B1 /* String+.swift */,
507305F32996652500A20CA1 /* UINavigationBar+.swift */,
);
path = Extension;
sourceTree = "<group>";
Expand Down Expand Up @@ -488,6 +501,7 @@
A7912187295775D50044E652 /* Helper */,
507305EF29965A8100A20CA1 /* Design */,
A791210F294B1A3A0044E652 /* Extension */,
500CA06F299697110012779B /* Protocol */,
);
path = Utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -792,6 +806,7 @@
A7ED3F07295E053600342CC8 /* OBFirstViewController.swift in Sources */,
A74C751A2975325B0046B1B1 /* String+.swift in Sources */,
A79121632954C2D60044E652 /* ChallengeMO+CoreDataProperties.swift in Sources */,
500CA071299697320012779B /* CustomNavBar.swift in Sources */,
A79121292950D2000044E652 /* RecordViewController.swift in Sources */,
A7ED3EFA295C6E6E00342CC8 /* SettingViewModel.swift in Sources */,
A7912115294B1AAB0044E652 /* Challenge.swift in Sources */,
Expand All @@ -802,6 +817,7 @@
507089B0295ABC2B00DD8D85 /* Color+.swift in Sources */,
A791214B295227230044E652 /* DeviceManager.swift in Sources */,
A7ED3F0B295E192E00342CC8 /* OBThirdViewController.swift in Sources */,
507305F42996652500A20CA1 /* UINavigationBar+.swift in Sources */,
A79120D2294A0A5F0044E652 /* AppDelegate.swift in Sources */,
50BD58A029587240009F9556 /* FullWidthButton.swift in Sources */,
50BD589E29580C3E009F9556 /* UIFullWidthButton.swift in Sources */,
Expand Down
3 changes: 3 additions & 0 deletions HRHN/Sources/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().delegate = self
debugPrint("Documents Directory:", FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last ?? "Not Found!")

UINavigationBar.setCustomNavBar()

return true
}

Expand Down
22 changes: 8 additions & 14 deletions HRHN/Sources/UI/EditChallenge/EditChallengeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,6 @@ final class EditChallengeViewController: UIViewController {
return $0
}(UILabel())

private lazy var deleteChallengeBarButton: UIBarButtonItem = {
$0.tintColor = .systemRed
return $0
}(UIBarButtonItem(
title: I18N.deleteButtonTitle,
style: .plain,
target: self,
action: #selector(deleteChallengeBarButtonDidTap)
))

private lazy var deleteChallengeAlert: UIAlertController = { [weak self] in
let deleteAction = UIAlertAction(title: I18N.deleteAlertConfirm, style: .destructive) { _ in
self?.viewModel.deleteChallenge()
Expand Down Expand Up @@ -217,11 +207,11 @@ final class EditChallengeViewController: UIViewController {

// MARK: UI Functions

extension EditChallengeViewController {
extension EditChallengeViewController: CustomNavBar {

private func setUI() {
view.backgroundColor = .background
navigationController?.navigationBar.topItem?.title = ""
setNavigationBarBackButton()

switch viewModel.mode {
case .add:
Expand All @@ -231,7 +221,11 @@ extension EditChallengeViewController {
)
challengeTextView.delegate = self
case .modify:
navigationItem.rightBarButtonItem = deleteChallengeBarButton
setNavigationBarRightLabelButton(
title: "삭제",
color: .systemRed,
action: #selector(rightBarButtonDidTap)
)
}

textViewDidChange(challengeTextView)
Expand Down Expand Up @@ -344,7 +338,7 @@ extension EditChallengeViewController {
}

@objc
private func deleteChallengeBarButtonDidTap() {
private func rightBarButtonDidTap() {
self.present(deleteChallengeAlert, animated: true)
}

Expand Down
9 changes: 6 additions & 3 deletions HRHN/Sources/UI/Record/RecordViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ extension RecordViewController {
$0.edges.equalToSuperview()
}
}

}

extension RecordViewController: CustomNavBar {
private func setNavigationBar() {
let rightBarButton: UIBarButtonItem = UIBarButtonItem(image: UIImage(systemName: "gearshape"), style: .plain, target: self, action: #selector(settingsDidTap))
navigationItem.rightBarButtonItem = rightBarButton
setNavigationBarAppLogo()
setNavigationBarBackButton()
setNavigationBarRightIconButton(systemName: "gearshape.fill", action: #selector(settingsDidTap))
}
}

Expand Down
6 changes: 4 additions & 2 deletions HRHN/Sources/UI/Review/ReviewViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ extension ReviewViewController {
$0.bottom.equalTo(view.safeAreaLayoutGuide).inset(120)
}
}

}

extension ReviewViewController: CustomNavBar {
private func setNavigationBar() {
navigationController?.navigationBar.topItem?.title = ""
setNavigationBarBackButton()
}
}

Expand Down
7 changes: 4 additions & 3 deletions HRHN/Sources/UI/Setting/SettingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ extension SettingViewController {
$0.bottom.equalTo(view.safeAreaLayoutGuide)
}
}

}

extension SettingViewController: CustomNavBar {
private func setNavigationBar() {
navigationController?.navigationBar.topItem?.title = ""
setNavigationBarBackButton()
}
}


// MARK: - UITableViewDataSource

extension SettingViewController: UITableViewDataSource {
Expand Down
9 changes: 6 additions & 3 deletions HRHN/Sources/UI/Today/TodayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,12 @@ extension TodayViewController {
$0.height.equalTo(40)
}
}

}

extension TodayViewController: CustomNavBar {
private func setNavigationBar() {
let rightBarButton: UIBarButtonItem = UIBarButtonItem(image: UIImage(systemName: "gearshape"), style: .plain, target: self, action: #selector(settingsDidTap))
navigationItem.rightBarButtonItem = rightBarButton
setNavigationBarAppLogo()
setNavigationBarBackButton()
setNavigationBarRightIconButton(systemName: "gearshape.fill", action: #selector(settingsDidTap))
}
}
21 changes: 21 additions & 0 deletions HRHN/Sources/Utils/Extension/UINavigationBar+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// UINavigationBar+.swift
// HRHN
//
// Created by 민채호 on 2023/02/10.
//

import UIKit

extension UINavigationBar {
static func setCustomNavBar() {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = UIColor(red: 244/255, green: 244/255, blue: 244/255, alpha: 0.3)
appearance.backgroundEffect = UIBlurEffect(style: .light)
appearance.shadowColor = .clear
appearance.shadowImage = UIImage()
Self.appearance().standardAppearance = appearance
Self.appearance().scrollEdgeAppearance = appearance
}
}
62 changes: 62 additions & 0 deletions HRHN/Sources/Utils/Protocol/CustomNavBar.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// CustomNavBar.swift
// HRHN
//
// Created by 민채호 on 2023/02/11.
//

import UIKit

protocol CustomNavBar {

func setNavigationBarAppLogo()
func setNavigationBarBackButton()
func setNavigationBarRightIconButton(systemName: String, action: Selector)
func setNavigationBarRightLabelButton(title: String, color: UIColor, action: Selector)
}

extension CustomNavBar where Self: UIViewController {

func setNavigationBarAppLogo() {
let leftBarTitle: UILabel = {
$0.text = "1D1C"
$0.font = UIFont.systemFont(ofSize: 20, weight: .semibold)
$0.textColor = UIColor(red: 60/255, green: 60/255, blue: 67/255, alpha: 0.4)
return $0
}(UILabel())
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: leftBarTitle)
}

func setNavigationBarBackButton() {
let backButton: UIBarButtonItem = UIBarButtonItem(
title: "",
style: .plain,
target: self,
action: nil
)
backButton.tintColor = UIColor(red: 60/255, green: 60/255, blue: 67/255, alpha: 0.4)
navigationItem.backBarButtonItem = backButton
}

func setNavigationBarRightIconButton(systemName: String, action: Selector) {
let rightBarButton: UIBarButtonItem = UIBarButtonItem(
image: UIImage(systemName: systemName),
style: .plain,
target: self,
action: action
)
rightBarButton.tintColor = UIColor(red: 60/255, green: 60/255, blue: 67/255, alpha: 0.4)
navigationItem.rightBarButtonItem = rightBarButton
}

func setNavigationBarRightLabelButton(title: String, color: UIColor, action: Selector) {
let rightBarButton = UIBarButtonItem(
title: I18N.deleteButtonTitle,
style: .plain,
target: self,
action: action
)
rightBarButton.tintColor = color
navigationItem.rightBarButtonItem = rightBarButton
}
}