-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 컬렉션 뷰안에 컬렉션 뷰
- Loading branch information
Showing
7 changed files
with
444 additions
and
229 deletions.
There are no files selected for viewing
This file contains 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
122 changes: 122 additions & 0 deletions
122
HousLab_iOS/HousLab_iOS/MinJae/Cells/Events/ComingEventsCollectionViewCell.swift
This file contains 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,122 @@ | ||
// | ||
// ComingEventsCollectionViewCell.swift | ||
// HousLab_iOS | ||
// | ||
// Created by 김민재 on 2022/07/06. | ||
// | ||
|
||
import UIKit | ||
|
||
class ComingEventsCollectionViewCell: UICollectionViewCell { | ||
|
||
private enum Size { | ||
static let screenWidth = UIScreen.main.bounds.width | ||
static let addEventCellSize = CGSize(width: 72, height: 88) | ||
static let eventCellSize = CGSize(width: 88, height: 88) | ||
} | ||
|
||
private let subtitleLabel = UILabel().then { | ||
$0.text = "Coming up-" | ||
$0.font = .systemFont(ofSize: 20, weight: .semibold) | ||
$0.textAlignment = .left | ||
} | ||
|
||
private var incomingEventsCollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewLayout()).then { | ||
let layout = UICollectionViewFlowLayout() | ||
layout.scrollDirection = .horizontal | ||
$0.collectionViewLayout = layout | ||
$0.showsHorizontalScrollIndicator = false | ||
} | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
render() | ||
setEventCollectionView() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func render() { | ||
addSubview(incomingEventsCollectionView) | ||
addSubview(subtitleLabel) | ||
|
||
subtitleLabel.snp.makeConstraints { make in | ||
make.top.equalToSuperview().offset(5) | ||
make.leading.equalToSuperview().offset(24) | ||
} | ||
|
||
incomingEventsCollectionView.snp.makeConstraints { make in | ||
make.top.equalTo(subtitleLabel.snp.bottom).offset(12) | ||
make.leading.trailing.equalToSuperview() | ||
make.bottom.equalToSuperview().inset(24) | ||
} | ||
} | ||
|
||
private func setEventCollectionView() { | ||
incomingEventsCollectionView.register(cell: EventsCollectionViewCell.self) | ||
|
||
incomingEventsCollectionView.delegate = self | ||
incomingEventsCollectionView.dataSource = self | ||
} | ||
|
||
} | ||
|
||
|
||
extension ComingEventsCollectionViewCell: UICollectionViewDelegate { | ||
|
||
} | ||
|
||
extension ComingEventsCollectionViewCell: UICollectionViewDataSource { | ||
|
||
// func numberOfSections(in collectionView: UICollectionView) -> Int { | ||
// return 1 | ||
// } | ||
|
||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | ||
return EventDataModel.sampleData.count + 1 | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
guard let cell = incomingEventsCollectionView.dequeueReusableCell(withReuseIdentifier: EventsCollectionViewCell.className, for: indexPath) as? EventsCollectionViewCell else { return UICollectionViewCell() } | ||
|
||
if indexPath.row == 0 { | ||
cell.d_dayLabel.isHidden = true | ||
cell.addIcon.isHidden = false | ||
cell.backgroudImageView.image = nil | ||
cell.backgroundColor = UIColor(hex: "FFF8E6") | ||
return cell | ||
} else { | ||
cell.d_dayLabel.isHidden = false | ||
cell.addIcon.isHidden = true | ||
cell.backgroudImageView.image = UIImage(systemName: "clock") | ||
cell.backgroundColor = UIColor(hex: "FFDE8A") | ||
} | ||
|
||
cell.setEventCellData(EventDataModel.sampleData[indexPath.row - 1]) | ||
return cell | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
extension ComingEventsCollectionViewCell: UICollectionViewDelegateFlowLayout { | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | ||
if indexPath.row == 0 { | ||
return Size.addEventCellSize | ||
} | ||
return Size.eventCellSize | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { | ||
return UIEdgeInsets(top: 5, left: 0, bottom: 0, right: 0) | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { | ||
return 8 | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
121 changes: 121 additions & 0 deletions
121
HousLab_iOS/HousLab_iOS/MinJae/Cells/RulesTodoCollectionViewCell.swift
This file contains 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,121 @@ | ||
// | ||
// RulesTodoCollectionViewCell.swift | ||
// HousLab_iOS | ||
// | ||
// Created by 김민재 on 2022/07/06. | ||
// | ||
|
||
import UIKit | ||
|
||
class RulesTodoCollectionViewCell: UICollectionViewCell { | ||
|
||
private let ruleTitleLabel = UILabel().then { | ||
$0.text = "Rules" | ||
$0.font = .systemFont(ofSize: 20, weight: .semibold) | ||
$0.textAlignment = .left | ||
} | ||
|
||
private let ruleLabel1 = RulesTodosView() | ||
|
||
private let ruleLabel2 = RulesTodosView() | ||
|
||
private let ruleLabel3 = RulesTodosView() | ||
|
||
private let ruleLabel4 = RulesTodosView() | ||
|
||
private let ruleLabel5 = RulesTodosView() | ||
|
||
private lazy var ruleLabelStackView = UIStackView(arrangedSubviews: [ruleLabel1, ruleLabel2, ruleLabel3, ruleLabel4, ruleLabel5]).then { | ||
$0.axis = .vertical | ||
$0.alignment = .center | ||
$0.distribution = .fillEqually | ||
$0.spacing = 8 | ||
} | ||
|
||
private lazy var ruleStackView = UIStackView(arrangedSubviews: [ruleTitleLabel, ruleLabelStackView]).then { | ||
$0.axis = .vertical | ||
$0.spacing = 12 | ||
} | ||
|
||
private let todoTitleLabel = UILabel().then { | ||
$0.text = "To-Do" | ||
$0.font = .systemFont(ofSize: 20, weight: .semibold) | ||
$0.textAlignment = .left | ||
} | ||
|
||
private let todoLabel1 = RulesTodosView() | ||
|
||
private let todoLabel2 = RulesTodosView() | ||
|
||
private let todoLabel3 = RulesTodosView() | ||
|
||
private let todoLabel4 = RulesTodosView() | ||
|
||
private let todoLabel5 = RulesTodosView() | ||
|
||
private lazy var todoLabelStackView = UIStackView(arrangedSubviews: [todoLabel1, todoLabel2, todoLabel3, todoLabel4, todoLabel5]).then { | ||
$0.axis = .vertical | ||
$0.alignment = .center | ||
$0.distribution = .fillEqually | ||
$0.spacing = 8 | ||
} | ||
|
||
private lazy var todoStackView = UIStackView(arrangedSubviews: [todoTitleLabel, todoLabelStackView]).then { | ||
$0.axis = .vertical | ||
$0.spacing = 12 | ||
} | ||
|
||
private lazy var totalStackView = UIStackView(arrangedSubviews: [ruleStackView, todoStackView]).then { | ||
$0.axis = .horizontal | ||
$0.distribution = .fillEqually | ||
$0.spacing = 15 | ||
} | ||
|
||
|
||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
render() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func render() { | ||
addSubview(totalStackView) | ||
totalStackView.snp.makeConstraints { make in | ||
make.top.bottom.leading.trailing.equalToSuperview() | ||
} | ||
} | ||
|
||
func setRulesData(_ data: [RulesDataModel]) { | ||
|
||
let labelList = [ruleLabel1, ruleLabel2, ruleLabel3, ruleLabel4, ruleLabel5] | ||
|
||
var index = 0 | ||
labelList.forEach { | ||
$0.checkButton.isHidden = true | ||
$0.setRulesLabelData(rule: data[index].ruleString) | ||
|
||
index += 1 | ||
} | ||
|
||
} | ||
|
||
func setTodosData(_ data: [TodoDataModel]) { | ||
|
||
let labelList = [todoLabel1, todoLabel2, todoLabel3, todoLabel4, todoLabel5] | ||
|
||
var index = 0 | ||
labelList.forEach { | ||
$0.circleImageView.isHidden = true | ||
$0.setRulesLabelData(rule: data[index].todoString) | ||
|
||
index += 1 | ||
} | ||
|
||
} | ||
|
||
|
||
} |
38 changes: 38 additions & 0 deletions
38
HousLab_iOS/HousLab_iOS/MinJae/HeaderCollectionReusableView.swift
This file contains 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,38 @@ | ||
// | ||
// CollectionReusableView.swift | ||
// HousLab_iOS | ||
// | ||
// Created by 김민재 on 2022/07/06. | ||
// | ||
|
||
import UIKit | ||
|
||
class HeaderCollectionReusableView: UICollectionReusableView { | ||
|
||
let subtitleLabel = UILabel().then { | ||
$0.text = "Coming up-" | ||
$0.font = .systemFont(ofSize: 20, weight: .semibold) | ||
$0.textAlignment = .left | ||
} | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
render() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func render() { | ||
addSubview(subtitleLabel) | ||
subtitleLabel.snp.makeConstraints { make in | ||
make.top.leading.trailing.bottom.equalToSuperview() | ||
} | ||
} | ||
|
||
func setSubTitleLabel(data: String) { | ||
subtitleLabel.text = data | ||
} | ||
|
||
} |
Oops, something went wrong.