-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 와블 컴포넌트(액션 시트, 404, 로딩뷰, 사진 상세, CTA버튼) 구현 #122
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
Conversation
- CTA Button 4가지 스타일을 정의 - 스타일에 따른 버튼 생성이 가능
- 구현에 필요한 이미지 추가
youz2me
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다! 언제 봐도 코드가 정말 깔끔하네요 😮
궁금띠예인 부분을 리뷰에 적어놓았어요. 답변해주시면 감사하겠습니다!
|
|
||
| private let loadingDuration: TimeInterval = 1.6 | ||
|
|
||
| // MARK: - Initializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init()도 LifeCycle에 포함되는데 따로 분리하신 이유가 궁금해요 !!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
물론 이니셜라이저도 라이프 사이클에 포함되나, 의존성 주입이나 객체 구성 방식을 결정하며 이니셜라이저는 외부에서 명시적으로 호출됩니다.
그렇기 때문에 라이프 사이클의 다른 메서드와는 특징이 다르다고 생각하는데요.
그러한 이유로 저는 별도의 마크 주석으로 작성하고 있습니다.
| private func startAnimationAndDismiss() { | ||
| loadingAnimationView.play() | ||
|
|
||
| DispatchQueue.main.asyncAfter(deadline: .now() + loadingDuration) { | ||
| self.loadingAnimationView.pause() | ||
| self.dismiss(animated: true) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 ... 다른 뷰컨에서도 쓸 수 있을 것 같은데 익스텐션으로 분리해보는 것도 좋을 것 같아요!
| private let dismissButton = UIButton().then { | ||
| var configuration = UIButton.Configuration.plain() | ||
| configuration.image = .btnRemovePhoto | ||
| $0.configuration = configuration | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lazy var로 선언 안하신 이유가 궁금해요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재의 화면에서는 반드시 필요한 버튼이며, 뷰컨트롤러 인스턴스에 의존하지 않기 때문에 lazy var보다는 let으로 선언하였습니다.
| let dismissAction = UIAction { [weak self] _ in | ||
| self?.dismiss(animated: true) | ||
| } | ||
|
|
||
| dismissButton.addAction(dismissAction, for: .touchUpInside) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 ... addAction을 생각 못했네요. 굿굿 !!!
| private extension PhotoDetailViewController { | ||
| var optimalImageViewHeight: CGFloat { | ||
| let aspectRatio = image.size.height / image.size.width | ||
| let screenWidth = UIScreen.main.bounds.width | ||
| let height = screenWidth * aspectRatio | ||
|
|
||
| let maxHeight: CGFloat = 812.adjustedHeight | ||
|
|
||
| return min(height, maxHeight) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| typealias CompletionHandler = (_ completion: @escaping (Bool) -> Void) -> Void | ||
|
|
||
| // MARK: - WableActionSheetConfiguration | ||
|
|
||
| struct WableActionSheetConfiguration { | ||
| let title: String | ||
| let message: String? | ||
| let confirmButtonTitle: String | ||
| let cancelButtonTitle: String? | ||
| let confirmAction: CompletionHandler? | ||
| let cancelAction: CompletionHandler? | ||
|
|
||
| init( | ||
| title: String, | ||
| message: String? = nil, | ||
| confirmButtonTitle: String, | ||
| cancelButtonTitle: String? = nil, | ||
| confirmAction: CompletionHandler? = nil, | ||
| cancelAction: CompletionHandler? = nil | ||
| ) { | ||
| self.title = title | ||
| self.message = message | ||
| self.confirmButtonTitle = confirmButtonTitle | ||
| self.cancelButtonTitle = cancelButtonTitle | ||
| self.confirmAction = confirmAction | ||
| self.cancelAction = cancelAction | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
복잡해지기 쉬운 코드인데 이렇게 하니까 코드가 엄청 깔끔해졌네요 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
하지만 더 좋은 코드로 찾아뵙겠습니다!
[Feat] 와블 컴포넌트(액션 시트, 404, 로딩뷰, 사진 상세, CTA버튼) 구현
👻 PULL REQUEST
📄 작업 내용
💻 주요 코드 설명
WableButton (CTA)
UIButton.Configuration.filled()를 사용하였습니다.primary,pale,gray,black)init(style:)을 이용하여 WableButton을 생성할 수 있습니다.WableButton.swift
🔗 연결된 이슈