Skip to content

Commit

Permalink
[FEAT][#7] 출석코드 입력 화면 navigationBar 설정
Browse files Browse the repository at this point in the history
- navigationBar appearance 설정
- backButton, titleView 설정
- swipeback 동작하도록 UINavigationController+Extension 추가
  • Loading branch information
tngusmiso committed Feb 11, 2023
1 parent cca6f56 commit 45bab8a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Extensions/UINavigationController+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// UINavigationController+Extension.swift
// momoIOS
//
// Created by 임수현 on 2023/02/11.
//

import UIKit

extension UINavigationController: ObservableObject, UIGestureRecognizerDelegate {
override open func viewDidLoad() {
super.viewDidLoad()

// backButton을 임의로 변경하면 swipe back 동작이 되지 않기 떄문에 gestureRecognizer를 설정하여 동작하도록 함.
interactivePopGestureRecognizer?.delegate = self
}

public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
return viewControllers.count > 1
}
}
4 changes: 4 additions & 0 deletions momoIOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
3ABBF7362996B6C9004D4D0B /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ABBF7352996B6C9004D4D0B /* String+Extension.swift */; };
3ABBF73A2996B8C9004D4D0B /* Collection+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ABBF7392996B8C9004D4D0B /* Collection+Extension.swift */; };
3ABBF73C2996D48C004D4D0B /* Optional+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ABBF73B2996D48C004D4D0B /* Optional+Extension.swift */; };
3ABBF73E2997370D004D4D0B /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ABBF73D2997370D004D4D0B /* UINavigationController+Extension.swift */; };
3ADF66102993F48A00577028 /* AttendanceDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ADF660F2993F48A00577028 /* AttendanceDetailViewController.swift */; };
BF0408632987B3AA00F1129B /* LoginController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF0408622987B3AA00F1129B /* LoginController.swift */; };
BF04086B2987E34800F1129B /* AuthCommonConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF04086A2987E34800F1129B /* AuthCommonConstants.swift */; };
Expand Down Expand Up @@ -51,6 +52,7 @@
3ABBF7352996B6C9004D4D0B /* String+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extension.swift"; sourceTree = "<group>"; };
3ABBF7392996B8C9004D4D0B /* Collection+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Collection+Extension.swift"; sourceTree = "<group>"; };
3ABBF73B2996D48C004D4D0B /* Optional+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Optional+Extension.swift"; sourceTree = "<group>"; };
3ABBF73D2997370D004D4D0B /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = "<group>"; };
3ADF660F2993F48A00577028 /* AttendanceDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttendanceDetailViewController.swift; sourceTree = "<group>"; };
BF0408622987B3AA00F1129B /* LoginController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginController.swift; sourceTree = "<group>"; };
BF04086A2987E34800F1129B /* AuthCommonConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthCommonConstants.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -183,6 +185,7 @@
3ABBF7352996B6C9004D4D0B /* String+Extension.swift */,
3ABBF7392996B8C9004D4D0B /* Collection+Extension.swift */,
3ABBF73B2996D48C004D4D0B /* Optional+Extension.swift */,
3ABBF73D2997370D004D4D0B /* UINavigationController+Extension.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -345,6 +348,7 @@
3ADF66102993F48A00577028 /* AttendanceDetailViewController.swift in Sources */,
E8207934298A22D000B36FC9 /* MainSessionInfoCell.swift in Sources */,
E8207932298A163400B36FC9 /* UIView+Extension.swift in Sources */,
3ABBF73E2997370D004D4D0B /* UINavigationController+Extension.swift in Sources */,
BFB8431F298CFF9200BA11EC /* UIStackView+Extension.swift in Sources */,
E820792D298A137700B36FC9 /* MainSessionTimeCell.swift in Sources */,
E820792B298A119900B36FC9 /* MainSessionDetailCell.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,21 @@ class AttendanceDetailViewController: UIViewController {
}

private func setupNavigation() {
let navigationBar = self.navigationController?.navigationBar
let appearance = navigationBar?.standardAppearance ?? UINavigationBarAppearance()
appearance.shadowColor = .rgba(24, 24, 24, 0.16)
appearance.backgroundColor = .white.withAlphaComponent(0.96)
navigationBar?.standardAppearance = appearance

let backButtonImage = UIImage(systemName: "arrow.left")
let backBarButton = UIBarButtonItem(image: backButtonImage, style: .plain, target: self, action: #selector(popViewController))
self.navigationItem.leftBarButtonItem = backBarButton

let titleLabel = UILabel()
titleLabel.text = "서울특별시 강남구 역삼로"
titleLabel.textColor = .black
titleLabel.font = .systemFont(ofSize: 14)
self.navigationItem.titleView = titleLabel
}

private func setupViews() {
Expand Down Expand Up @@ -150,7 +164,7 @@ class AttendanceDetailViewController: UIViewController {

// MARK: - Actions
@objc private func didTapAttendanceButton() {
self.navigationController?.popViewController(animated: true)
self.popViewController()
}

private func configureAttendButtonEnabled() {
Expand All @@ -169,6 +183,10 @@ class AttendanceDetailViewController: UIViewController {
self.attendButton.configurate(bgColor: .rgba(200, 200, 200, 1), cornerRadius: 7, padding: 10)
}
}

@objc private func popViewController(animated: Bool = true) {
self.navigationController?.popViewController(animated: true)
}
}

// MARK: - UITextFieldDelegate
Expand Down

0 comments on commit 45bab8a

Please sign in to comment.