-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 소식 탭 화면 구현 #140
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] 소식 탭 화면 구현 #140
Conversation
- 객체(레이블 등) 초기화 시, 자간, 행간을 설정하고 추후 text로 실제 바인딩
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.
고생하셨습니다 ~~! 몇가지 코멘트만 확인 부탁드려요 ^_^
| setupConstraint() | ||
| } | ||
|
|
||
| @available(*, unavailable) |
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 DataSource = UICollectionViewDiffableDataSource<Section, Item> | ||
| typealias Snapshot = NSDiffableDataSourceSnapshot<Section, Item> | ||
| typealias CellRegistration = UICollectionView.CellRegistration | ||
| typealias SupplementaryRegistration = UICollectionView.SupplementaryRegistration |
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 gameDateFormatter = DateFormatter().then { | ||
| // $0.dateFormat = "MM.dd (E)" | ||
| // $0.locale = Locale(identifier: "ko_KR") | ||
| // } |
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.
추후 로직을 위해 남겨두었습니다.
제가 Todo 주석을 깜빡했습니다.
| ) | ||
| let item = NSCollectionLayoutItem(layoutSize: itemSize) |
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.
다른 프로퍼티들도 개행한다면 여기도 개행해도 좋을 것 같은 ... 느낌이네요 반영은 안하셔도 괜춘합니다
| var gameTypeSection: NSCollectionLayoutSection { | ||
| let itemSize = NSCollectionLayoutSize( | ||
| widthDimension: .fractionalWidth(1), | ||
| heightDimension: .fractionalHeight(1) | ||
| ) | ||
| let item = NSCollectionLayoutItem(layoutSize: itemSize) | ||
|
|
||
| let groupSize = NSCollectionLayoutSize( | ||
| widthDimension: .fractionalWidth(1), | ||
| heightDimension: .estimated(40) | ||
| ) | ||
| let group = NSCollectionLayoutGroup.horizontal( | ||
| layoutSize: groupSize, | ||
| subitems: [item] | ||
| ) | ||
|
|
||
| let section = NSCollectionLayoutSection(group: group) | ||
| section.contentInsets = .init(top: 24, leading: 16, bottom: 20, trailing: 16) | ||
|
|
||
| return section | ||
| } | ||
|
|
||
| var gameScheduleSection: NSCollectionLayoutSection { | ||
| let itemSize = NSCollectionLayoutSize( | ||
| widthDimension: .fractionalWidth(1), | ||
| heightDimension: .fractionalHeight(1) |
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.
itemSize처럼 중복되는 프로퍼티는 합쳐서 사용해도 좋을 것 같아용
|
|
||
| private let labelStackView: UIStackView = .init(axis: .vertical).then { | ||
| $0.alignment = .leading | ||
| $0.distribution = .fillProportionally |
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.
오 이런 것도 있군요 !!
| override init(frame: CGRect) { | ||
| super.init(frame: frame) | ||
| } | ||
|
|
||
| @available(*, unavailable) | ||
| required init?(coder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } |
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.
제가 setup~ 메서드를 호출하는 것을 깜빡했네요.
알려주셔서 감사합니다!
| func elapsedString(from date: Date?) -> String { | ||
| guard let date else { | ||
| return "지금" | ||
| } | ||
|
|
||
| let now = Date() | ||
| let calendar = Calendar.current | ||
|
|
||
| let components = calendar.dateComponents( | ||
| [.minute, .hour, .day, .weekOfMonth, .month, .year], | ||
| from: date, | ||
| to: now | ||
| ) | ||
|
|
||
| if let years = components.year, years > 0 { | ||
| return "\(years)년 전" | ||
| } else if let months = components.month, months > 0 { | ||
| return "\(months)달 전" | ||
| } else if let weeks = components.weekOfMonth, weeks > 0 { | ||
| return "\(weeks)주 전" | ||
| } else if let days = components.day, days > 0 { | ||
| return "\(days)일 전" | ||
| } else if let hours = components.hour, hours > 0 { | ||
| return "\(hours)시간 전" | ||
| } else if let minutes = components.minute, minutes > 0 { | ||
| return "\(minutes)분 전" | ||
| } else { | ||
| return "지금" | ||
| } | ||
| } |
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.
이거 홈 화면에서도 사용하는데 따로 분리해도 괜찮을 것 같습니닷
그리고 switch문으로 처리해도 좋을 것 같네요 ~~!
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.
기존 플젝의 코드를 그대로 차용하다 보니 이렇게 작성되었네요.
저도 Date의 익스텐션으로 빼도 좋을 것 같습니다.
| // MARK: - backgroundColor Initializer | ||
|
|
||
| convenience init(backgroundColor: UIColor) { | ||
| self.init() | ||
|
|
||
| self.backgroundColor = backgroundColor | ||
| } |
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.
캬 감사합니다 ~~! 더 간편해졌네요
- Date 객체로붙터 얼마나 지났는지 string을 반환하는 계산 속성 구현
👻 PULL REQUEST
📄 작업 내용
💻 주요 코드 설명
뷰컨트롤러 하나로 또는 분리해서,,,
AnnouncementDetailViewController.swift
🔗 연결된 이슈