-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Feat/#24] CapsuleButton Component #27
base: main
Are you sure you want to change the base?
Conversation
|
||
// MARK: - Initializer | ||
init(type: CapsuleButtonType, title: String, icon: UIImage?, action: (() -> Void)? = nil) { | ||
self.defaultTitle = title |
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.
CapsuleType์ด ๋ ๊ฐ๋ฐ์ ์๋ ๊ฑฐ ๊ฐ์๋ฐ, ์ฌ๊ธฐ์ title์ ๋ฐ๋ก ๋ฐ์ง ๋ง๊ณ ๊ฐ case๋ง๋ค ๋ฒํผ ํ์ดํ์ ์ถ๊ฐํ๋๊ฑด ์ด๋ต๊ฐ์?
super.init(frame: .zero) | ||
setupUI() | ||
configure(title: title, icon: icon) | ||
addTarget(self, action: #selector(buttonTapped), 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.
rx ํ์์ผ๋ก ๋๋ ค์ฃผ์ธ์
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 updateButton(isExpanded: Bool) { | ||
let title = isExpanded ? "" : defaultTitle | ||
let icon = isExpanded ? UIImage(systemName: "xmark") : UIImage(systemName: "plus") |
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.
์์ด์ฝ์ ์์ ic_ ๋ถ์ฌ์ฃผ์ผ
private func updateWidth(isExpanded: Bool) { | ||
|
||
} |
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.
์ด๊ฑด ๋ญ๊ฐ์?
UIView.animate(withDuration: 0.3) { | ||
self.superview?.layoutIfNeeded() | ||
} |
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.
๊ณ ์ ๋ง์ผ์ จ์ต๋๋ค! ๋ช๊ฐ์ง ์์ ์ฌํญ์ด ๋ณด์ด๋๋ฐ ์ด๋ฏธ ๋ค๋ฅธ๋ถ๋ค์ด ์ ๋จ๊ฒจ์ฃผ์ ์ ์ถ๊ฐ ๋ฉํธ๋ง ์์ฑํ์ต๋๋ค. ์ฐธ๊ณ ๋ถํ๋๋ฆฝ๋๋ค
super.init(frame: .zero) | ||
setupUI() | ||
configure(title: title, icon: icon) | ||
addTarget(self, action: #selector(buttonTapped), 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.
ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ใ ๋๋ ค์ฃผ์ธ์
enum CapsuleButtonType { | ||
case expand(isExpanded: Bool) | ||
case normal | ||
} |
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.
Nested Type์ธ ๊ฒฝ์ฐ
CapsuleButton.CapsuleButtonType ์ผ๋ก ์ ๊ทผ๋๋
์์ ํ์
๊ณผ ๊ฒน์น๋ ๋ค์ด๋ฐ์ ์ง์ํ์๋ฉด ์ข์ต๋๋ค!
private func setupUI() { | ||
self.do { | ||
$0.backgroundColor = .appBlack | ||
$0.layer.cornerRadius = 25 | ||
} | ||
|
||
self.snp.makeConstraints { | ||
$0.height.equalTo(50) | ||
self.widthConstraint = $0.width.equalTo(100).constraint | ||
} | ||
} |
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.
ํ ์ฝ๋ ์ปจ๋ฒค์ ๋ง์ถฐ์ฃผ์ญ์ผ!
let newState = !isExpanded | ||
capsuleButtonType = .expand(isExpanded: newState) | ||
updateButton(isExpanded: newState) | ||
action?() |
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.
์ด๊ฑด ์ด๋ค ์๋๋ก ์์ฑํ์ ๊ฑธ๊น์?
๐ฅ Issue
close #
๐ฅ ๋ณ๊ฒฝ๋ ๋ด์ฉ
expand๋ ๋๋น๊ฐ ํ ๊ธ๋๋ฉด์ ๋ฐ๋๋ ๋ ์, normal์ ํ๋ฒํ ์บก์ ๋ฒํผ
UIImage(systemName: "plus") ์ด ๋ถ๋ถ๋ defaultTitle๊ณผ ๊ฐ์ด ์ด๊ธฐํ ๋ ๋ฐ์ ์์ด์ฝ์ผ๋ก ํ ๊ธ๋๊ฒ ๋ฐ๊ฟ์ค์ผํ๋๋ฐ ์ผ๋จ ๋ ์์ ํ๊ฒ ์..
๋จธ๋ฆฌ๊ฐ ์ ์๋์๊ฐ์ ๋ง์ ํผ๋๋ฐฑ ๋ถํ......ใ ใ
๋ค ํ๊ฑฐ ์๋๊ณ ๋ผ ๋ ์ถ๊ฐํ๊ฒ ์ผ ใ ใ
๐ฅ PR Point
์ด๋ฐ์์ผ๋ก ์ฌ์ฉ
๐ฅ ScreenShot
๐ฅ Reference