-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 내리기, 좋아요, 댓글 UIButton 및 게시물, 댓글 CollectionViewCell 컴포넌트 작성 #121
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1c6739d
[Feat] #118 - GhostButton 작성
youz2me 4721fa2
[FIx] #118 - 버튼 상태 변화 맞춰서 isUserInteractionEnabled 상태 수정하도록 구현
youz2me f72453b
[Feat] #118 - 좋아요 버튼, 댓글 버튼 작성
youz2me 938c28f
[Feat] #118 - ContentCollectionViewCell 구현
youz2me f24815e
[Feat] #118 - CommentColletionViewCell 구현
youz2me c83de20
Merge remote-tracking branch 'refs/remotes/origin/develop'
youz2me 74cff76
[Fix] #118 - 파일 레퍼런스 해제되는 문제 해결
youz2me 278ee3c
[Docs] #118 - 각 클래스별 주석 추가
youz2me e62f3d9
[Docs] #118 - Opacity 구조체 주석 추가
youz2me 3366728
[Fix] #118 - 리뷰 반영
youz2me 1253de5
Merge remote-tracking branch 'refs/remotes/origin/develop'
youz2me 239616b
[Fix] #118 - 충돌 해결
youz2me 907ad11
[Fix] #118 - Recommended Setting에 따라 .pbxproj 변경
youz2me 86bc629
[Fix] #118 - 리뷰 반영
youz2me File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
Wable-iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // | ||
| // AuthorType.swift | ||
| // Wable-iOS | ||
| // | ||
| // Created by YOUJIM on 3/18/25. | ||
| // | ||
|
|
||
|
|
||
| import Foundation | ||
|
|
||
| /// 작성자 타입을 정의하는 열거형. | ||
| /// | ||
| /// - `mine`: 내가 작성한 게시물 | ||
| /// - `others`: 다른 사용자가 작성한 게시물 | ||
| enum AuthorType { | ||
| case mine | ||
| case others | ||
| } |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // | ||
| // UIColor+.swift | ||
| // Wable-iOS | ||
| // | ||
| // Created by YOUJIM on 3/10/25. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| extension UIColor { | ||
|
|
||
| // MARK: - HEX 초기화 | ||
|
|
||
| /// HEX 코드 문자열로부터 `UIColor` 인스턴스를 생성하는 편의 이니셜라이저. | ||
| /// | ||
| /// - Parameters: | ||
| /// - hex: 색상을 나타내는 HEX 문자열(예: "#FFFFFF" 또는 "FFFFFF") | ||
| /// - alpha: 색상의 알파값(투명도). 기본값은 1.0(불투명) | ||
| /// | ||
| /// 사용 예시: | ||
| /// ```swift | ||
| /// let backgroundColor = UIColor("#F5F5F5") | ||
| /// let textColor = UIColor("333333", alpha: 0.8) | ||
| /// ``` | ||
| convenience init(_ hex: String, alpha: CGFloat = 1.0) { | ||
| var hexFormatted = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased() | ||
|
|
||
| if hexFormatted.hasPrefix("#") { | ||
| hexFormatted = String(hexFormatted.dropFirst()) | ||
| } | ||
|
|
||
| assert(hexFormatted.count == 6, "유효하지 않은 HEX 코드입니다.") | ||
|
Comment on lines
+31
to
+32
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| var rgbValue: UInt64 = 0 | ||
| Scanner(string: hexFormatted).scanHexInt64(&rgbValue) | ||
|
|
||
| self.init( | ||
| red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0, | ||
| green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0, | ||
| blue: CGFloat(rgbValue & 0x0000FF) / 255.0, | ||
| alpha: alpha | ||
| ) | ||
| } | ||
| } | ||
94 changes: 94 additions & 0 deletions
94
Wable-iOS/Presentation/WableComponent/Youjin/Button/CommentButton.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| // | ||
| // CommentButton.swift | ||
| // Wable-iOS | ||
| // | ||
| // Created by YOUJIM on 3/11/25. | ||
| // | ||
|
|
||
|
|
||
| import UIKit | ||
|
|
||
| /// 댓글 버튼을 구현한 커스텀 UIButton 클래스. | ||
| /// 게시글에서는 댓글 수를 표시하고, 댓글에서는 '답글쓰기' 텍스트를 표시합니다. | ||
| /// | ||
| /// 사용 예시: | ||
| /// ```swift | ||
| /// let commentButton = CommentButton() | ||
| /// // 게시글용 댓글 버튼 구성 | ||
| /// commentButton.configureButton(commentCount: 12, type: .content) | ||
| /// // 또는 답글 버튼 구성 | ||
| /// commentButton.configureButton(commentCount: 0, type: .comment) | ||
| /// ``` | ||
| final class CommentButton: UIButton { | ||
|
|
||
| // MARK: Property | ||
|
|
||
| /// 버튼이 속한 게시물 타입 (게시글/댓글) | ||
| private let type: PostType | ||
|
|
||
| // MARK: - LifeCycle | ||
|
|
||
| init(type: PostType) { | ||
| self.type = type | ||
|
|
||
| super.init(frame: .zero) | ||
|
|
||
| setupConstraint() | ||
| } | ||
|
|
||
| required init?(coder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Private Extension | ||
|
|
||
| private extension CommentButton { | ||
|
|
||
| // MARK: - Setup | ||
|
|
||
| func setupConstraint() { | ||
| snp.makeConstraints { | ||
| $0.adjustedWidthEqualTo(45) | ||
| $0.adjustedHeightEqualTo(24) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Configure Extension | ||
|
|
||
| extension CommentButton { | ||
| /// 댓글 버튼 구성 메서드 | ||
| /// - Parameters: | ||
| /// - commentCount: 댓글 수 (게시글 타입일 때만 사용) | ||
| /// - type: 버튼이 속한 게시물 타입 (.content 또는 .comment) | ||
| func configureButton(commentCount: Int = 0) { | ||
| var configuration = UIButton.Configuration.plain() | ||
| var image = UIImage() | ||
|
|
||
| switch type { | ||
| case .content: | ||
| image = .icRipple | ||
|
|
||
| configuration.attributedTitle = String(commentCount).pretendardString(with: .caption1) | ||
| configuration.baseForegroundColor = .wableBlack | ||
| case .comment: | ||
| image = .icRippleReply | ||
|
|
||
| configuration.attributedTitle = "답글쓰기".pretendardString(with: .caption3) | ||
| configuration.baseForegroundColor = .gray600 | ||
|
|
||
| snp.makeConstraints { | ||
| $0.adjustedWidthEqualTo(66) | ||
| $0.adjustedHeightEqualTo(20) | ||
| } | ||
|
|
||
| configuration.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0) | ||
| } | ||
|
|
||
| configuration.image = image.withConfiguration(UIImage.SymbolConfiguration(pointSize: 24)) | ||
| configuration.imagePadding = 4 | ||
|
|
||
| self.configuration = configuration | ||
| } | ||
| } |
103 changes: 103 additions & 0 deletions
103
Wable-iOS/Presentation/WableComponent/Youjin/Button/GhostButton.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| // | ||
| // GhostButton.swift | ||
| // Wable-iOS | ||
| // | ||
| // Created by YOUJIM on 3/10/25. | ||
| // | ||
|
|
||
|
|
||
| import UIKit | ||
|
|
||
| /// 내리기 버튼의 크기 타입을 정의하는 열거형. | ||
| /// | ||
| /// - `large`: 텍스트를 포함한 큰 버튼 (71x32) | ||
| /// - `small`: 아이콘만 있는 작은 버튼 (32x32) | ||
| enum GhostButtonType { | ||
| case large | ||
| case small | ||
| } | ||
|
|
||
| /// 내리기 버튼의 상태를 정의하는 열거형. | ||
| /// | ||
| /// - `normal`: 정상 상태 (클릭 가능) | ||
| /// - `disabled`: 비활성화 상태 (클릭 불가) | ||
| enum GhostButtonStatus { | ||
| case normal | ||
| case disabled | ||
| } | ||
|
|
||
| /// 게시물의 투명도를 낮추는 기능을 하는 내리기 버튼 클래스. | ||
| /// 두 가지 크기(large/small)와 두 가지 상태(normal/disabled)를 지원합니다. | ||
| /// | ||
| /// 사용 예시: | ||
| /// ```swift | ||
| /// let ghostButton = GhostButton() | ||
| /// // 큰 버튼 구성 | ||
| /// ghostButton.configureButton(type: .large, status: .normal) | ||
| /// // 또는 작은 버튼 구성 | ||
| /// ghostButton.configureButton(type: .small, status: .disabled) | ||
| /// ``` | ||
| final class GhostButton: UIButton { } | ||
|
|
||
| // MARK: - Private Extension | ||
|
|
||
| private extension GhostButton { | ||
|
|
||
| // MARK: - Setup | ||
|
|
||
| /// - Parameter type: 버튼 크기 타입 | ||
| func setupConstraint(type: GhostButtonType) { | ||
| switch type { | ||
| case .large: | ||
| snp.makeConstraints { | ||
| $0.adjustedWidthEqualTo(71) | ||
| $0.adjustedHeightEqualTo(32) | ||
| } | ||
| case .small: | ||
| snp.makeConstraints { | ||
| $0.adjustedWidthEqualTo(32) | ||
| $0.adjustedHeightEqualTo(32) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Configure Extension | ||
|
|
||
| extension GhostButton { | ||
| /// 내리기 버튼 구성 메서드 | ||
| /// - Parameters: | ||
| /// - type: 버튼 크기 타입 (.large 또는 .small) | ||
| /// - status: 버튼 상태 (.normal 또는 .disabled) | ||
| func configureButton(type: GhostButtonType, status: GhostButtonStatus) { | ||
| var configuration = UIButton.Configuration.filled() | ||
| self.roundCorners([.all], radius: 16) | ||
| self.clipsToBounds = true | ||
|
|
||
| switch type { | ||
| case .large: | ||
| configuration.attributedTitle = "내리기".pretendardString(with: .caption3) | ||
| configuration.imagePadding = 4 | ||
| configuration.imagePlacement = .leading | ||
| configuration.contentInsets = NSDirectionalEdgeInsets(top: 6, leading: 10, bottom: 6, trailing: 10) | ||
| case .small: | ||
| configuration.contentInsets = NSDirectionalEdgeInsets(top: 8, leading: 8, bottom: 8, trailing: 8) | ||
| } | ||
|
|
||
| switch status { | ||
| case .normal: | ||
| configuration.attributedTitle?.foregroundColor = UIColor("556480") | ||
| configuration.image = .icGhostDefault.withTintColor(UIColor("556480")) | ||
| configuration.baseBackgroundColor = UIColor("DDE4F1") | ||
| self.isUserInteractionEnabled = true | ||
| case .disabled: | ||
| configuration.attributedTitle?.foregroundColor = UIColor("AEAEAE") | ||
| configuration.image = .icGhostDefault.withTintColor(.gray500) | ||
| configuration.baseBackgroundColor = UIColor("F7F7F7") | ||
| self.isUserInteractionEnabled = false | ||
| } | ||
|
|
||
| self.configuration = configuration | ||
| setupConstraint(type: type) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
좋은 문서 작성이네요! 👍