-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 소식 탭 큐레이션 UI 구현하기 #290
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
9 commits
Select commit
Hold shift + click to select a range
7524d2a
[Add] #289 - 버튼 이미지 추가
JinUng41 1fc222c
[Feat] #289 - 큐레이션 UI 구현
JinUng41 a3140c5
[Refactor] #289 - MVVM 구조로 변경
JinUng41 0249357
[Feat] #289 - 더 불러올 때 하단 로딩 인디케이터 동작 추가
JinUng41 369f84f
[Style] #289 - 오토레이아웃 수정
JinUng41 b0039ab
[Chore] #289 - 제목이 길어졌을 때를 대비한 텍스트 수정
JinUng41 b8b6bc0
Merge branch 'develop' of https://github.com/Team-Wable/WABLE-iOS int…
JinUng41 1e5aba3
[Chore] #289 - 투두 주석 남기기
JinUng41 ed3979f
[Chore] #289 - 리뷰 반영
JinUng41 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
39 changes: 39 additions & 0 deletions
39
Wable-iOS/Presentation/Overview/Curation/Model/CurationItem.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,39 @@ | ||
| // | ||
| // CurationItem.swift | ||
| // Wable-iOS | ||
| // | ||
| // Created by 김진웅 on 10/16/25. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct CurationItem: Hashable, Identifiable { | ||
| let id: UUID = UUID() | ||
| let time: String | ||
| let title: String | ||
| let source: String | ||
| let thumbnailURL: URL? | ||
| } | ||
|
|
||
| extension CurationItem { | ||
| static let mocks: [CurationItem] = [ | ||
| CurationItem( | ||
| time: "1시간 전", | ||
| title: "Ad ea excepteur nostrud sint commodo duis labore nostrud veniam cillum eu irure quis veniam dolor et", | ||
| source: "Esse minim proident aliquip deserunt id magna sunt aliquip elit fugiat officia sunt consequat elit l", | ||
| thumbnailURL: URL(string: "https://fastly.picsum.photos/id/176/343/220.jpg?hmac=h_eZSSP2OjzuGIVmDs1OZ_dYT3BzPbCC_QAnMZp5Sn8") | ||
| ), | ||
| CurationItem( | ||
| time: "2시간 전", | ||
| title: "Excepteur nulla sint commodo ea labore nostrud veniam commodo eu irure reprehenderit veniam dolor eu", | ||
| source: "LMagna tempor aliquip elit id officia sunt aliquip elit fugiat officia sunt consequat eiusmod laborum", | ||
| thumbnailURL: URL(string: "https://fastly.picsum.photos/id/176/343/220.jpg?hmac=h_eZSSP2OjzuGIVmDs1OZ_dYT3BzPbCC_QAnMZp5Sn8") | ||
| ), | ||
| CurationItem( | ||
| time: "3시간 전", | ||
| title: "Ea labore nulla voluptate commodo eu labore reprehenderit veniam commodo eu irure reprehenderit veni", | ||
| source: "Labore sed voluptate dolore ex non reprehenderit cillum dolore ipsum non velit aute est ipsum qui ut", | ||
| thumbnailURL: URL(string: "https://fastly.picsum.photos/id/176/343/220.jpg?hmac=h_eZSSP2OjzuGIVmDs1OZ_dYT3BzPbCC_QAnMZp5Sn8") | ||
| ) | ||
| ] | ||
| } |
234 changes: 234 additions & 0 deletions
234
Wable-iOS/Presentation/Overview/Curation/View/Cell/CurationCell.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,234 @@ | ||
| // | ||
| // CurationCell.swift | ||
| // Wable-iOS | ||
| // | ||
| // Created by 김진웅 on 10/16/25. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| import Kingfisher | ||
| import SnapKit | ||
| import Then | ||
|
|
||
| final class CurationCell: UICollectionViewCell { | ||
|
|
||
| // MARK: - UIComponents | ||
|
|
||
| private let profileImageView = UIImageView(image: .logoSymbolSmall).then { | ||
| $0.contentMode = .scaleAspectFill | ||
| $0.clipsToBounds = true | ||
| $0.layer.cornerRadius = 20 | ||
| } | ||
|
|
||
| private let authorLabel = UILabel().then { | ||
| $0.attributedText = "와블 큐레이터".pretendardString(with: .body3) | ||
| $0.textColor = .wableBlack | ||
| } | ||
|
|
||
| private let timeLabel = UILabel().then { | ||
| $0.attributedText = "".pretendardString(with: .caption4) | ||
| $0.textColor = .gray500 | ||
| } | ||
|
|
||
| private let cardButton = UIButton().then { | ||
| $0.layer.cornerRadius = 12 | ||
| $0.clipsToBounds = true | ||
| $0.layer.borderWidth = 1 | ||
| $0.layer.borderColor = UIColor.gray200.cgColor | ||
| $0.backgroundColor = .gray100 | ||
| } | ||
|
|
||
| private let thumbnailImageView = UIImageView().then { | ||
| $0.contentMode = .scaleAspectFill | ||
| $0.clipsToBounds = true | ||
| $0.backgroundColor = .gray200 | ||
| } | ||
|
|
||
| private let descriptionView = UIView(backgroundColor: UIColor("F7F7F7")).then { | ||
| $0.isUserInteractionEnabled = false | ||
| } | ||
|
|
||
| private let titleLabel = UILabel().then { | ||
| $0.attributedText = "".pretendardString(with: .body3) | ||
| $0.textColor = .wableBlack | ||
| $0.numberOfLines = 1 | ||
| $0.lineBreakMode = .byTruncatingTail | ||
| } | ||
|
|
||
| private let sourceLabel = UILabel().then { | ||
| $0.attributedText = "".pretendardString(with: .body4) | ||
| $0.textColor = .gray600 | ||
| $0.numberOfLines = 1 | ||
| $0.lineBreakMode = .byTruncatingTail | ||
| } | ||
|
|
||
| private let openIconImageView = UIImageView(image: .btnCuration).then { | ||
| $0.contentMode = .scaleAspectFit | ||
| $0.isUserInteractionEnabled = false | ||
| } | ||
|
|
||
| private let pressedOverlay = UIView().then { | ||
| $0.backgroundColor = UIColor.black.withAlphaComponent(0.08) | ||
| $0.alpha = 0 | ||
| $0.isUserInteractionEnabled = false | ||
| } | ||
|
|
||
| // MARK: - Properties | ||
|
|
||
| private var onTapCard: (() -> Void)? | ||
|
|
||
| // MARK: - Initializer | ||
|
|
||
| override init(frame: CGRect) { | ||
| super.init(frame: frame) | ||
|
|
||
| setupView() | ||
| setupConstraint() | ||
| setupActions() | ||
| } | ||
|
|
||
| @available(*, unavailable) | ||
| required init?(coder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
| override func prepareForReuse() { | ||
| super.prepareForReuse() | ||
|
|
||
| thumbnailImageView.kf.cancelDownloadTask() | ||
| thumbnailImageView.image = nil | ||
| onTapCard = nil | ||
| pressedOverlay.alpha = 0 | ||
| } | ||
|
|
||
| func configure( | ||
| time: String, | ||
| thumbnailURL: URL?, | ||
| title: String, | ||
| source: String, | ||
| onTap: @escaping () -> Void | ||
| ) { | ||
| timeLabel.text = "· \(time)" | ||
| titleLabel.text = title | ||
| sourceLabel.text = source | ||
| onTapCard = onTap | ||
|
|
||
| thumbnailImageView.kf.setImage(with: thumbnailURL) { [weak self] result in | ||
| switch result { | ||
| case .success: | ||
| self?.thumbnailImageView.isHidden = false | ||
| case .failure: | ||
| self?.thumbnailImageView.isHidden = false | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Setup Method | ||
|
|
||
| private extension CurationCell { | ||
| func setupView() { | ||
| contentView.addSubviews( | ||
| profileImageView, | ||
| authorLabel, | ||
| timeLabel, | ||
| cardButton | ||
| ) | ||
|
|
||
| cardButton.addSubviews( | ||
| thumbnailImageView, | ||
| descriptionView, | ||
| pressedOverlay | ||
| ) | ||
|
|
||
| descriptionView.addSubviews( | ||
| titleLabel, | ||
| sourceLabel, | ||
| openIconImageView | ||
| ) | ||
| } | ||
|
|
||
| func setupConstraint() { | ||
| profileImageView.snp.makeConstraints { make in | ||
| make.top.equalToSuperview() | ||
| make.adjustedWidthEqualTo(28) | ||
| make.leading.equalToSuperview().offset(16) | ||
| make.height.equalTo(profileImageView.snp.width) | ||
| } | ||
|
|
||
| authorLabel.snp.makeConstraints { make in | ||
| make.centerY.equalTo(profileImageView) | ||
| make.leading.equalTo(profileImageView.snp.trailing).offset(8) | ||
| } | ||
|
|
||
| timeLabel.snp.makeConstraints { make in | ||
| make.centerY.equalTo(profileImageView) | ||
| make.leading.equalTo(authorLabel.snp.trailing).offset(8) | ||
| } | ||
|
|
||
| cardButton.snp.makeConstraints { make in | ||
| make.top.equalTo(profileImageView.snp.bottom).offset(8) | ||
| make.horizontalEdges.equalToSuperview().inset(16) | ||
| make.bottom.equalToSuperview() | ||
| } | ||
|
|
||
| thumbnailImageView.snp.makeConstraints { make in | ||
| make.edges.equalToSuperview() | ||
| } | ||
|
|
||
| titleLabel.snp.makeConstraints { make in | ||
| make.top.equalToSuperview().offset(12) | ||
| make.leading.equalToSuperview().offset(16) | ||
| make.trailing.equalTo(openIconImageView.snp.leading).offset(-16) | ||
| } | ||
|
|
||
| sourceLabel.snp.makeConstraints { make in | ||
| make.top.equalTo(titleLabel.snp.bottom).offset(4) | ||
| make.leading.equalTo(titleLabel) | ||
| make.bottom.equalToSuperview().offset(-12) | ||
| make.trailing.equalTo(openIconImageView.snp.leading).offset(-16) | ||
| } | ||
|
|
||
| openIconImageView.snp.makeConstraints { make in | ||
| make.centerY.equalToSuperview() | ||
| make.trailing.equalToSuperview().inset(16) | ||
| make.adjustedWidthEqualTo(32) | ||
| make.adjustedHeightEqualTo(32) | ||
| } | ||
|
|
||
| descriptionView.snp.makeConstraints { make in | ||
| make.horizontalEdges.equalToSuperview() | ||
| make.bottom.equalToSuperview() | ||
| } | ||
|
|
||
| pressedOverlay.snp.makeConstraints { make in | ||
| make.edges.equalToSuperview() | ||
| } | ||
| } | ||
|
|
||
| func setupActions() { | ||
| cardButton.addTarget(self, action: #selector(cardTapped), for: .touchUpInside) | ||
| cardButton.addTarget(self, action: #selector(cardTouchDown), for: [.touchDown]) | ||
| cardButton.addTarget(self, action: #selector(cardTouchUpCancel), for: [.touchDragExit, .touchCancel, .touchUpOutside]) | ||
| } | ||
|
|
||
| @objc func cardTapped() { | ||
| animatePressed(false) | ||
| onTapCard?() | ||
| } | ||
|
|
||
| @objc func cardTouchDown() { | ||
| animatePressed(true) | ||
| } | ||
|
|
||
| @objc func cardTouchUpCancel() { | ||
| animatePressed(false) | ||
| } | ||
|
|
||
| func animatePressed(_ pressed: Bool) { | ||
| UIView.animate(withDuration: 0.12, delay: 0, options: [.curveEaseOut, .allowUserInteraction]) { | ||
| self.pressedOverlay.alpha = pressed ? 1 : 0 | ||
| } | ||
| } | ||
| } | ||
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.
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.
The color value 'F7F7F7' is a magic value. Consider defining it as a named color in the asset catalog or as a constant to improve maintainability.