Skip to content

Conversation

@cirtuare
Copy link
Contributor

@cirtuare cirtuare commented May 19, 2025

🐿️ Pull Requests

🪵 작업 브랜치

🥔 작업 내용

2.0 알럿 UI를 작업했습니다.

🚨 참고 사항

구조를 대폭 개선하였습니다 ! 아래는 대략적인 설명이니 코드와 함께 읽어보시고 혹시라도 헷갈리는 부분이 있다면 리뷰 남겨주세요 ~

개요

기존의 AlertHandler을 삭제하고, 실제 알럿을 띄우는 메소드는 UIViewController+ 에 presentACAlert으로 정의해두었습니다.

// UIViewController+

func presentACAlert(_ customAlertType: CustomAlertType,
                        longAction: (() -> Void)? = nil,
                        leftAction: (() -> Void)? = nil,
                        rightAction: (() -> Void)? = nil,
                        from vc: UIViewController? = nil) {
    let alertVC = CustomAlertViewController(customAlertType)
    
    alertVC.do {
        $0.onLongButtonTapped = longAction
        $0.onLeftButtonTapped = leftAction
        $0.onRightButtonTapped = rightAction
        
        $0.modalPresentationStyle = .overFullScreen
        $0.modalTransitionStyle = .crossDissolve
    }

    if let vc = vc {
        vc.present(alertVC, animated: true)
    } else {
        self.present(alertVC, animated: true)
    }
}

버튼 하나만 길게 있는 알럿 : longAction ( ACAlertView.longButton에 적용 )
왼쪽 버튼, 오른쪽 버튼이 있는 알럿: leftAction ( ACAlertView.leftButton에 적용) / rightAction ( ACAlertView.rightButton에 적용)

각 알럿 타입에 해당하는 액션 클로저만 적용해주시면 되며, 액션 클로저를 따로 넣지 않을 경우 단순 알럿 dismiss가 적용됩니다 !

사용방법

  1. 필요하다면 ACAlertType에 새로 case 선언
  • title (필수)
  • description (선택)
  • 버튼 하나만 길게 있는 알럿 : longButtonTitle
  • 왼쪽 버튼, 오른쪽 버튼이 있는 알럿: leftButtonTitle, rightButtonTitle
    title을 제외한 모든 프로퍼티의 default 값은 nil이므로, 추가하는 case에 해당하는 프로퍼티만 정의해주세요 !
  • dismiss 외 액션이 필요없는 경우
self?.presentACAlert(.reviewLocationFail)`
  • dismiss 외 액션이 필요한 경우
    액션 클로저 객체를 먼저 정의한 후, presentACAlert 중 원하는 버튼 액션 프로퍼티 ( longAction / leftAction / rightAction) 프로퍼티에 정의한 객체를 할당
let action: () -> Void = { [weak self] in
    guard let self = self else { return }
    let vc = LocalVerificationViewController(viewModel: self.localVerificationVMSwitching)
    self.navigationController?.pushViewController(vc, animated: true)
}
self.presentACAlert(.changeVerifiedArea, rightAction: action)

*자주 사용되는 액션 클로저 객체들은 ACAlertActionType에 정의해두었습니다!
사용 : self.presentACAlert(.changeVerifiedArea, rightAction: ACAlertActionType.openSettings)

📸 스크린샷

기능 스크린샷
아이폰 16 Pro

💥 To be sure

  • 모든 뷰가 잘 실행되는지 다시 한 번 체크해주세요 !

🌰 Resolve issue

@cirtuare cirtuare requested a review from yurim830 May 19, 2025 22:14
@cirtuare cirtuare self-assigned this May 19, 2025
@cirtuare cirtuare added 🌀 feature 새로운 기능 개발 🍓 수민 수민 labels May 19, 2025
Copy link
Collaborator

@yurim830 yurim830 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다 :D

Comment on lines 12 to 24
// NOTE: - 알럿에 자주 사용되는 액션 클로저

static let openSettings = {
guard let settingsURL = URL(string: UIApplication.openSettingsURLString),
UIApplication.shared.canOpenURL(settingsURL) else { return }
UIApplication.shared.open(settingsURL, options: [:], completionHandler: nil)
}

static let goToTabBar = {
if let sceneDelegate = UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate {
sceneDelegate.window?.rootViewController = ACTabBarController()
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

센스짱!!

Comment on lines 15 to 23
case locationAccessDenied // 위치 권한 X
case locationAccessFail // 위치 인식 실패 - 외국, GPS 지원 공간 X

case reviewLocationFail // 리뷰 위치 인증 실패

case libraryAccessDenied // 사진 권한 X
case changeNotSaved // 프로필 변경사항 저장 X

case changeVerifiedArea // 지역인증 변경 (지역 1개)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐿️ NOTE: 추가해주시면 좋을 것 같아요!

Copy link
Contributor Author

@cirtuare cirtuare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurim830
(5/20 14:38 변경사항) CustomAlert -> ACAlert으로 모두 네이밍 변경했습니다! presentACAlert으로 사용해주시면 됩니당 ~

@cirtuare cirtuare merged commit 22e73f3 into develop May 20, 2025
@cirtuare cirtuare deleted the feature/#146 branch August 12, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌀 feature 새로운 기능 개발 🍓 수민 수민

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 2.0 알럿 UI

3 participants