-
Notifications
You must be signed in to change notification settings - Fork 2
[Feat] #27 - DMList뼈대 UI구현 #37
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
base: develop
Are you sure you want to change the base?
Changes from 16 commits
30328f5
f25bf14
e0a5d19
29c629d
578ca0d
cafdb19
63bed21
c44d168
c272606
a726470
d81272f
1974260
198d0af
ea56562
e4fb03f
8d51333
4536358
83e42dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // | ||
| // DMCollectionViewCell.swift | ||
| // Instagram-iOS | ||
| // | ||
| // Created by Joon Baek on 2023/05/26. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| import SnapKit | ||
|
|
||
| final class DMCollectionViewCell: BaseCollectionViewCell { | ||
|
|
||
| // MARK: - Property | ||
| // MARK: - UI Property | ||
|
|
||
| let userProfileView = UserProfileView(usedView: .dm, storyStatus: .none) | ||
|
|
||
| let usernameLabel: UILabel = { | ||
| let label = UILabel() | ||
| label.text = "hanyee" | ||
| label.font = .detail4 | ||
| label.textColor = .gray2 | ||
| return label | ||
| }() | ||
|
|
||
|
|
||
| // MARK: - Layout | ||
|
|
||
| override func setLayout() { | ||
| addSubview(userProfileView) | ||
| userProfileView.snp.makeConstraints { | ||
| $0.top.equalToSuperview().offset(10) | ||
| $0.leading.equalToSuperview().offset(7) | ||
| $0.width.height.equalTo(58) | ||
| $0.centerX.equalToSuperview() | ||
| } | ||
|
|
||
| addSubview(usernameLabel) | ||
| usernameLabel.snp.makeConstraints { | ||
| $0.top.equalTo(userProfileView.snp.bottom).offset(10) | ||
| $0.centerX.equalTo(userProfileView) | ||
| } | ||
| } | ||
|
|
||
| override func setStyle() { | ||
|
|
||
| } | ||
joonBaek12 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // MARK: - Custom Method | ||
|
|
||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // | ||
| // DMTableViewCellHeader.swift | ||
| // Instagram-iOS | ||
| // | ||
| // Created by Joon Baek on 2023/05/29. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| import SnapKit | ||
|
|
||
| final class DMTableViewCellHeader: UITableViewHeaderFooterView { | ||
| // MARK: - Property | ||
|
|
||
| static let identifier = "DMTableViewCellHeader" | ||
|
|
||
| // MARK: - UI Property | ||
|
|
||
| private let sectionLabel: UILabel = { | ||
| let label = UILabel() | ||
| label.font = .bodyKorBold | ||
| label.textColor = .black1 | ||
| label.text = "메시지" | ||
| return label | ||
| }() | ||
|
|
||
| // MARK: - Life Cycle | ||
|
|
||
| override init(reuseIdentifier: String?) { | ||
| super.init(reuseIdentifier: reuseIdentifier) | ||
|
|
||
| setLayout() | ||
| } | ||
|
|
||
| required init?(coder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
| // MARK: - Layout | ||
|
|
||
| private func setLayout() { | ||
|
|
||
| addSubview(sectionLabel) | ||
| sectionLabel.snp.makeConstraints { | ||
| $0.leading.equalToSuperview().offset(16) | ||
| $0.bottom.equalToSuperview().offset(-8) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| // | ||
| // DMTableViewHeader.swift | ||
| // Instagram-iOS | ||
| // | ||
| // Created by Joon Baek on 2023/05/26. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| import SnapKit | ||
|
|
||
| final class DMTableViewHeader: UIView { | ||
|
|
||
| private lazy var storyCollectionView: UICollectionView = { | ||
| let layout = UICollectionViewFlowLayout() | ||
| layout.scrollDirection = .horizontal | ||
|
|
||
| let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) | ||
| collectionView.translatesAutoresizingMaskIntoConstraints = false | ||
| collectionView.showsVerticalScrollIndicator = false | ||
| return collectionView | ||
| }() | ||
|
|
||
| private let titleLabel: UILabel = { | ||
| let label = UILabel() | ||
| label.font = .bodyKorBold | ||
| label.textColor = .black1 | ||
| label.text = "즐겨찾기" | ||
| return label | ||
| }() | ||
|
|
||
| private let searchTextField: UITextField = { | ||
| let textField = UITextField() | ||
| textField.backgroundColor = .gray5 | ||
| textField.font = .body | ||
| //TODO: - 추후 placeholder 세팅 시 추가하겠습니다 | ||
| // textField.placeholder = "검색" | ||
| return textField | ||
| }() | ||
|
|
||
| private let sectionLabel: UILabel = { | ||
| let label = UILabel() | ||
| label.font = .bodyKorBold | ||
| label.textColor = .black1 | ||
| label.text = "메시지" | ||
| return label | ||
| }() | ||
|
|
||
| override init(frame: CGRect) { | ||
| super.init(frame: frame) | ||
|
|
||
| register() | ||
| configDelegate() | ||
| setLayout() | ||
| setSearchTextFieldUI() | ||
| } | ||
|
|
||
| required init?(coder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
| //MARK: - Setting | ||
|
|
||
| private func register() { | ||
| storyCollectionView.register(DMCollectionViewCell.self, forCellWithReuseIdentifier: DMCollectionViewCell.identifier) | ||
| } | ||
|
Comment on lines
+65
to
+67
Contributor
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. p3; |
||
|
|
||
| private func configDelegate() { | ||
| storyCollectionView.delegate = self | ||
| storyCollectionView.dataSource = self | ||
| } | ||
|
|
||
| private func setLayout() { | ||
|
|
||
| backgroundColor = .white1 | ||
|
||
|
|
||
| addSubview(searchTextField) | ||
| searchTextField.snp.makeConstraints { | ||
| $0.top.centerX.equalToSuperview().offset(8) | ||
| $0.centerX.equalToSuperview() | ||
| $0.leading.equalToSuperview().offset(16) | ||
| $0.height.equalTo(35) | ||
| } | ||
|
|
||
| addSubview(titleLabel) | ||
| titleLabel.snp.makeConstraints { | ||
| $0.top.equalTo(searchTextField.snp.bottom).offset(18) | ||
| $0.leading.equalToSuperview().offset(16) | ||
| } | ||
|
|
||
| addSubview(storyCollectionView) | ||
| storyCollectionView.snp.makeConstraints { | ||
| $0.top.equalTo(titleLabel.snp.bottom).offset(4) | ||
| $0.centerX.equalToSuperview() | ||
| $0.leading.equalToSuperview().offset(14) | ||
| $0.height.equalTo(90) | ||
| } | ||
|
|
||
| addSubview(sectionLabel) | ||
| sectionLabel.snp.makeConstraints { | ||
| $0.leading.equalToSuperview().offset(16) | ||
| $0.bottom.equalToSuperview().offset(-8) | ||
| } | ||
| } | ||
|
|
||
| private func setSearchTextFieldUI() { | ||
|
|
||
| searchTextField.layer.cornerRadius = 10 | ||
| searchTextField.backgroundColor = .gray5 | ||
| searchTextField.font = .body | ||
| // searchTextField.attributedPlaceholder = NSAttributedString(string: "검색", attributes: [NSAttributedString.Key.foregroundColor: UIColor.lightGray]) | ||
|
|
||
| } | ||
|
||
| } | ||
|
|
||
| //MARK: - UICollectionViewDelegateFlowLayout | ||
|
|
||
| extension DMTableViewHeader: UICollectionViewDelegateFlowLayout { | ||
| func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | ||
| return CGSize(width: 72, height: 90) | ||
| } | ||
|
|
||
| func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { | ||
| return 4 | ||
| } | ||
| } | ||
|
|
||
| //MARK: - UICollectionViewDataSource | ||
|
|
||
| extension DMTableViewHeader: UICollectionViewDataSource { | ||
| func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | ||
| return 9 | ||
| } | ||
|
|
||
| func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
| guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DMCollectionViewCell.identifier, for: indexPath) as? DMCollectionViewCell else { return UICollectionViewCell() } | ||
|
|
||
| return cell | ||
| } | ||
|
|
||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.