Skip to content

Conversation

@ena-isme
Copy link
Member

⭐️Issue

close #184

🌟Motivation

AlertButton 을 구현하였습니다

🌟Key Changes

아래 처럼 사용하시면 됩니당

All Icon❌ contentLabel ❌ cancelButton ❌
Simulator Screenshot - iPhone 15 Pro - 2024-07-15 at 05 05 34 Simulator Screenshot - iPhone 15 Pro - 2024-07-15 at 05 19 30 Simulator Screenshot - iPhone 15 Pro - 2024-07-15 at 05 06 20 Simulator Screenshot - iPhone 15 Pro - 2024-07-15 at 05 07 40

주요 코드는 아래와 같습니당
present 함수를 부르고 actionButton 을 탭하시게 되면 Observable 형태가 return 되게 됩니다.
저걸 구독하시면 될 것 같아용


// In UIViewController+
func presentToAlertViewController(iconImage: UIImage?,
                                      titleText: String?,
                                      contentText: String?,
                                      cancelTitle: String?,
                                      actionTitle: String?,
                                      actionBackgroundColor: CGColor?) -> Observable<Void> {
        let alertViewController = WSSAlertViewController(iconImage: iconImage,
                                                         titleText: titleText,
                                                         contentText: contentText,
                                                         cancelTitle: cancelTitle,
                                                         actionTitle: actionTitle,
                                                         actionBackgroundColor: actionBackgroundColor)
        alertViewController.modalPresentationStyle = .overFullScreen
        alertViewController.modalTransitionStyle = .crossDissolve
        
        self.present(alertViewController, animated: true)
        
        return alertViewController.actionButtonTap
    }
// In WSSAlertViewController
private let actionButtonTapSubject = PublishSubject<Void>()
    var actionButtonTap: Observable<Void> {
        return actionButtonTapSubject.asObservable()
    }

사용하시는 방법은 아래와 같습니당
필요하신 건 내용 넣어주시고, 안 넣어주실 건 nill 넣어주시면 됩니다!


        presentToAlertViewController(iconImage: .icAlertWarningCircle,
                                     titleText: "신고가 접수되었어요!",
                                     contentText: "해당 글이 커뮤니티 가이드를\n위반했는지 검토할게요",
                                     cancelTitle: nil,
                                     actionTitle: "로그아웃",
                                     actionBackgroundColor: UIColor.wssPrimary100.cgColor)
        .subscribe({ _ in 
            print("버튼이 눌렸군요!")
        })
        .disposed(by: disposeBag)

cancelButton(배경이 하얀 버튼) 을 눌렀을 때는 dismiss 만 하게 되고,
actionButton(베경이 색깔있는 버튼) 을 눌렀을 때는 return 값을 받을 수 있게 됩니다.
=> subscribe 하셔서 viewModel 에서 편하신대로 작업하시면 됩니둥


혹시 몰라 AlertVC 내에 print 문도 찍어두었어요!

  • actionButton 눌렀을 때
스크린샷 2024-07-15 오전 5 25 53
  • cancelButton 눌렀을 때
스크린샷 2024-07-15 오전 5 25 31

@ena-isme ena-isme requested review from Guryss, Naknakk and hyowon612 and removed request for Guryss and hyowon612 July 14, 2024 20:30
@ena-isme ena-isme self-assigned this Jul 14, 2024
Copy link
Member

@Guryss Guryss left a comment

Choose a reason for hiding this comment

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

최고오오옹 수고 많았습니당 ♡
리뷰 하나만 확인해주세요 🙌

Comment on lines 147 to 167
cancelButton.do {
$0.setTitle(cancelTitle, for: .normal)
$0.setTitleColor(.wssGray300, for: .normal)
$0.titleLabel?.font = .Label1
$0.layer.backgroundColor = UIColor.wssGray50.cgColor
$0.layer.cornerRadius = 8
}
} else {
cancelButton.removeFromSuperview()
actionButton.snp.makeConstraints {
$0.height.width.equalToSuperview()
}
}

if let actionTitle {
actionButton.do {
$0.setTitle(actionTitle, for: .normal)
$0.setTitleColor(.wssWhite, for: .normal)
$0.titleLabel?.font = .Label1
$0.layer.backgroundColor = actionBackgroundColor
$0.layer.cornerRadius = 8
Copy link
Member

Choose a reason for hiding this comment

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

W1;
완벽한 디자인 구현을 위해 UIButton에 title 말고, 버튼 위에 UILabel을 올려주는 건 어떤지 제안해봅니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

넵 좋은 것 같아요, 그런데 혹시 더 완벽한 디자인이라고 생각하신 이유가 있을까요?

Copy link
Member

Choose a reason for hiding this comment

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

앗 왜냐하면 지금 버튼의 title에는 kerning이랑 lineSpacing이 안잡혀있어서용! 오직 폰트만 잡혀있어서..
그래서 UILabel을 올려주면 완벽해진다고 생각했습니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

앗,, 굳 ,,,

Copy link
Collaborator

@hyowon612 hyowon612 left a comment

Choose a reason for hiding this comment

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

짱이에요 😘

Comment on lines 27 to 32
private var alertIconImage: UIImage?
private var alertTitle: String?
private var alertContent: String?
private var cancelTitle: String?
private var actionTitle: String?
private var actionBackgroundColor: CGColor?
Copy link
Collaborator

Choose a reason for hiding this comment

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

W1
얘네는 Properties로 옮겨주세용

Copy link
Member

@Guryss Guryss left a comment

Choose a reason for hiding this comment

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

코리 하나만 반영하고 머지해주세요오 수고 많았오 쿠로미로미

}

actionButtonTitleLabel.do {
$0.isUserInteractionEnabled = true
Copy link
Member

Choose a reason for hiding this comment

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

W1;

Suggested change
$0.isUserInteractionEnabled = true
$0.isUserInteractionEnabled = false

로 해줘야 버튼 액션 활성화! 요거만 빠루게 수정 부탁드려용

Copy link
Member Author

Choose a reason for hiding this comment

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

나 왜저랬대

}

cancelButtonTitleLabel.do {
$0.isUserInteractionEnabled = true
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$0.isUserInteractionEnabled = true
$0.isUserInteractionEnabled = false

W1; 여기두용

@ena-isme ena-isme merged commit 89e6060 into main Jul 18, 2024
@ena-isme ena-isme deleted the Design/#184 branch July 18, 2024 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Design] 공용 컴포넌트 AlertButton 구현

4 participants