From a20ccf0d94ffcacf60d615d68570b090aef52901 Mon Sep 17 00:00:00 2001 From: Kim Minjae Date: Wed, 6 Jul 2022 23:51:09 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT]=20HomView=20CollectionView=EA=B5=AC?= =?UTF-8?q?=EC=A1=B0=EB=A1=9C=20=EC=9E=AC=EA=B5=AC=ED=98=84=20=EC=97=B0?= =?UTF-8?q?=EC=8A=B5=20#4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HousLab_iOS.xcodeproj/project.pbxproj | 4 + .../ComingEventsCollectionViewCell.swift | 26 ++- .../Cells/RulesTodoCollectionViewCell.swift | 56 ++++- .../MinJae/HeaderCollectionReusableView.swift | 2 + .../MinJae/HomeViewController.swift | 216 +++++++++--------- .../MinJae/PopUpViewController.swift | 112 +++++++++ 6 files changed, 292 insertions(+), 124 deletions(-) create mode 100644 HousLab_iOS/HousLab_iOS/MinJae/PopUpViewController.swift diff --git a/HousLab_iOS/HousLab_iOS.xcodeproj/project.pbxproj b/HousLab_iOS/HousLab_iOS.xcodeproj/project.pbxproj index cafd846..612027b 100644 --- a/HousLab_iOS/HousLab_iOS.xcodeproj/project.pbxproj +++ b/HousLab_iOS/HousLab_iOS.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ B59C945D2874962D005865CA /* RulesTodoCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59C945C2874962D005865CA /* RulesTodoCollectionViewCell.swift */; }; B59C945F28749DFC005865CA /* HeaderCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59C945E28749DFC005865CA /* HeaderCollectionReusableView.swift */; }; B59C94612874C7AF005865CA /* ComingEventsCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59C94602874C7AF005865CA /* ComingEventsCollectionViewCell.swift */; }; + B59C9465287586AA005865CA /* PopUpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59C9464287586AA005865CA /* PopUpViewController.swift */; }; B5B5C11D2872E3DB00FC5134 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = B5B5C11C2872E3DB00FC5134 /* SnapKit */; }; B5B5C1202872E43E00FC5134 /* Then in Frameworks */ = {isa = PBXBuildFile; productRef = B5B5C11F2872E43E00FC5134 /* Then */; }; B5B5C1222872E63C00FC5134 /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5B5C1212872E63C00FC5134 /* HomeViewController.swift */; }; @@ -54,6 +55,7 @@ B59C945C2874962D005865CA /* RulesTodoCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RulesTodoCollectionViewCell.swift; sourceTree = ""; }; B59C945E28749DFC005865CA /* HeaderCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderCollectionReusableView.swift; sourceTree = ""; }; B59C94602874C7AF005865CA /* ComingEventsCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComingEventsCollectionViewCell.swift; sourceTree = ""; }; + B59C9464287586AA005865CA /* PopUpViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopUpViewController.swift; sourceTree = ""; }; B5B5C1212872E63C00FC5134 /* HomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewController.swift; sourceTree = ""; }; B5B5C1242872E7A000FC5134 /* UIFont+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIFont+Extension.swift"; sourceTree = ""; }; B5B5C1262872E7BC00FC5134 /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; @@ -203,6 +205,7 @@ B5B5C1212872E63C00FC5134 /* HomeViewController.swift */, B59C94542874274F005865CA /* RulesTodosView.swift */, B59C945E28749DFC005865CA /* HeaderCollectionReusableView.swift */, + B59C9464287586AA005865CA /* PopUpViewController.swift */, ); path = MinJae; sourceTree = ""; @@ -337,6 +340,7 @@ B85302AA28728F6300F06234 /* ViewController.swift in Sources */, B85302C72872A20600F06234 /* JiHyeonViewController.swift in Sources */, B5B5C12F2872E85200FC5134 /* UIButton+Extension.swift in Sources */, + B59C9465287586AA005865CA /* PopUpViewController.swift in Sources */, B5B5C1352872E89F00FC5134 /* NSObject+Extension.swift in Sources */, B59C94612874C7AF005865CA /* ComingEventsCollectionViewCell.swift in Sources */, B85302C12872A1EC00F06234 /* HoseViewController.swift in Sources */, diff --git a/HousLab_iOS/HousLab_iOS/MinJae/Cells/Events/ComingEventsCollectionViewCell.swift b/HousLab_iOS/HousLab_iOS/MinJae/Cells/Events/ComingEventsCollectionViewCell.swift index 197ad25..dd9da0e 100644 --- a/HousLab_iOS/HousLab_iOS/MinJae/Cells/Events/ComingEventsCollectionViewCell.swift +++ b/HousLab_iOS/HousLab_iOS/MinJae/Cells/Events/ComingEventsCollectionViewCell.swift @@ -7,6 +7,11 @@ import UIKit +protocol ComingEventsCollectionViewCellDelegate: AnyObject { + func showPopup(_ row: Int) +} + + class ComingEventsCollectionViewCell: UICollectionViewCell { private enum Size { @@ -15,6 +20,8 @@ class ComingEventsCollectionViewCell: UICollectionViewCell { static let eventCellSize = CGSize(width: 88, height: 88) } + weak var delegate: ComingEventsCollectionViewCellDelegate? + private let subtitleLabel = UILabel().then { $0.text = "Coming up-" $0.font = .systemFont(ofSize: 20, weight: .semibold) @@ -44,13 +51,14 @@ class ComingEventsCollectionViewCell: UICollectionViewCell { subtitleLabel.snp.makeConstraints { make in make.top.equalToSuperview().offset(5) - make.leading.equalToSuperview().offset(24) + make.leading.equalToSuperview().inset(24) } incomingEventsCollectionView.snp.makeConstraints { make in make.top.equalTo(subtitleLabel.snp.bottom).offset(12) - make.leading.trailing.equalToSuperview() - make.bottom.equalToSuperview().inset(24) + make.leading.equalToSuperview().inset(24) + make.bottom.equalToSuperview() + make.trailing.equalToSuperview() } } @@ -66,14 +74,14 @@ class ComingEventsCollectionViewCell: UICollectionViewCell { extension ComingEventsCollectionViewCell: UICollectionViewDelegate { + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + delegate?.showPopup(indexPath.row) + } + } extension ComingEventsCollectionViewCell: UICollectionViewDataSource { - -// func numberOfSections(in collectionView: UICollectionView) -> Int { -// return 1 -// } - + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return EventDataModel.sampleData.count + 1 } @@ -112,7 +120,7 @@ extension ComingEventsCollectionViewCell: UICollectionViewDelegateFlowLayout { } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { - return UIEdgeInsets(top: 5, left: 0, bottom: 0, right: 0) + return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { diff --git a/HousLab_iOS/HousLab_iOS/MinJae/Cells/RulesTodoCollectionViewCell.swift b/HousLab_iOS/HousLab_iOS/MinJae/Cells/RulesTodoCollectionViewCell.swift index 2274fca..2302cba 100644 --- a/HousLab_iOS/HousLab_iOS/MinJae/Cells/RulesTodoCollectionViewCell.swift +++ b/HousLab_iOS/HousLab_iOS/MinJae/Cells/RulesTodoCollectionViewCell.swift @@ -27,11 +27,13 @@ class RulesTodoCollectionViewCell: UICollectionViewCell { private lazy var ruleLabelStackView = UIStackView(arrangedSubviews: [ruleLabel1, ruleLabel2, ruleLabel3, ruleLabel4, ruleLabel5]).then { $0.axis = .vertical - $0.alignment = .center + $0.alignment = .leading $0.distribution = .fillEqually $0.spacing = 8 } + private let ruleBackground = UIView() + private lazy var ruleStackView = UIStackView(arrangedSubviews: [ruleTitleLabel, ruleLabelStackView]).then { $0.axis = .vertical $0.spacing = 12 @@ -53,9 +55,11 @@ class RulesTodoCollectionViewCell: UICollectionViewCell { private let todoLabel5 = RulesTodosView() + private let todoBackground = UIView() + private lazy var todoLabelStackView = UIStackView(arrangedSubviews: [todoLabel1, todoLabel2, todoLabel3, todoLabel4, todoLabel5]).then { $0.axis = .vertical - $0.alignment = .center + $0.alignment = .leading $0.distribution = .fillEqually $0.spacing = 8 } @@ -76,6 +80,7 @@ class RulesTodoCollectionViewCell: UICollectionViewCell { override init(frame: CGRect) { super.init(frame: frame) render() + configUI() } required init?(coder: NSCoder) { @@ -83,10 +88,51 @@ class RulesTodoCollectionViewCell: UICollectionViewCell { } private func render() { - addSubview(totalStackView) - totalStackView.snp.makeConstraints { make in - make.top.bottom.leading.trailing.equalToSuperview() + addSubViews([ruleTitleLabel,ruleBackground, todoTitleLabel, todoBackground]) + ruleBackground.addSubview(ruleLabelStackView) + todoBackground.addSubview(todoLabelStackView) + + ruleTitleLabel.snp.makeConstraints { make in + make.top.equalToSuperview() + make.leading.equalToSuperview().offset(24) + } + + ruleBackground.snp.makeConstraints { make in + make.top.equalTo(ruleTitleLabel.snp.bottom).offset(12) + make.leading.equalTo(ruleTitleLabel.snp.leading) + make.bottom.equalToSuperview() + make.width.equalTo(156) + } + + ruleLabelStackView.snp.makeConstraints { make in + make.center.equalToSuperview() + } + + todoTitleLabel.snp.makeConstraints { make in + make.centerY.equalTo(ruleTitleLabel) + make.leading.equalTo(ruleBackground.snp.trailing).offset(15) } + + todoBackground.snp.makeConstraints { make in + make.top.equalTo(todoTitleLabel.snp.bottom).offset(12) + make.leading.equalTo(todoTitleLabel.snp.leading) + make.bottom.equalToSuperview() + make.trailing.equalToSuperview().inset(24) + make.width.equalTo(156) + } + + todoLabelStackView.snp.makeConstraints { make in + make.center.equalToSuperview() + } + + } + + private func configUI() { + ruleBackground.backgroundColor = UIColor(hex: "EFF5FF") + todoBackground.backgroundColor = UIColor(hex: "EFF5FF") + + ruleBackground.layer.cornerRadius = 16 + todoBackground.layer.cornerRadius = 16 } func setRulesData(_ data: [RulesDataModel]) { diff --git a/HousLab_iOS/HousLab_iOS/MinJae/HeaderCollectionReusableView.swift b/HousLab_iOS/HousLab_iOS/MinJae/HeaderCollectionReusableView.swift index bdf6f2a..f7fc8fc 100644 --- a/HousLab_iOS/HousLab_iOS/MinJae/HeaderCollectionReusableView.swift +++ b/HousLab_iOS/HousLab_iOS/MinJae/HeaderCollectionReusableView.swift @@ -9,6 +9,8 @@ import UIKit class HeaderCollectionReusableView: UICollectionReusableView { + static let identifier = "HeaderCollectionReusableView" + let subtitleLabel = UILabel().then { $0.text = "Coming up-" $0.font = .systemFont(ofSize: 20, weight: .semibold) diff --git a/HousLab_iOS/HousLab_iOS/MinJae/HomeViewController.swift b/HousLab_iOS/HousLab_iOS/MinJae/HomeViewController.swift index 9e51138..decd6b5 100644 --- a/HousLab_iOS/HousLab_iOS/MinJae/HomeViewController.swift +++ b/HousLab_iOS/HousLab_iOS/MinJae/HomeViewController.swift @@ -31,6 +31,7 @@ class HomeViewController: UIViewController { private let homeCollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewLayout()).then { let layout = UICollectionViewFlowLayout() layout.scrollDirection = .vertical + $0.collectionViewLayout = layout $0.showsVerticalScrollIndicator = false } @@ -59,8 +60,8 @@ class HomeViewController: UIViewController { // homeCollectionView.register(HeaderCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: HeaderCollectionReusableView.className) homeCollectionView.register(cell: ComingEventsCollectionViewCell.self) -// homeCollectionView.register(cell: RulesTodoCollectionViewCell.self) -// homeCollectionView.register(cell: ProfileCollectionViewCell.self) + homeCollectionView.register(cell: RulesTodoCollectionViewCell.self) + homeCollectionView.register(cell: ProfileCollectionViewCell.self) homeCollectionView.delegate = self homeCollectionView.dataSource = self @@ -76,9 +77,8 @@ class HomeViewController: UIViewController { } homeCollectionView.snp.makeConstraints { - $0.top.equalTo(titleLabel.snp.bottom).offset(24) - $0.leading.equalToSuperview().offset(24) - $0.trailing.equalToSuperview() + $0.top.equalTo(titleLabel.snp.bottom).offset(24).multipliedBy(0.9) + $0.leading.trailing.equalToSuperview() $0.bottom.equalToSuperview() } } @@ -88,83 +88,73 @@ class HomeViewController: UIViewController { //MARK: Delegate & Datasource extension HomeViewController: UICollectionViewDelegate { -// func numberOfSections(in collectionView: UICollectionView) -> Int { -// return 1 -// } + func numberOfSections(in collectionView: UICollectionView) -> Int { + return 3 + } // func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { -// return CGSize(width: view.frame.size.width, height: HeaderCollectionReusableView().subtitleLabel.intrinsicContentSize.height) +// return CGSize(width: view.frame.size.width, height: 24) // } } extension HomeViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - - return 1 - -// switch section { -// case 0..<2: -// return 1 -// case 2: -// return ProfileDataModel.sampleData.count + 1 -// default: -// return 0 -// } + + switch section { + case 0..<2: + return 1 + case 2: + return ProfileDataModel.sampleData.count + 1 + default: + return 0 + } } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let cell = homeCollectionView.dequeueReusableCell(withReuseIdentifier: ComingEventsCollectionViewCell.className, for: indexPath) as? ComingEventsCollectionViewCell else { return UICollectionViewCell() } - - return cell - -// switch indexPath.section { -// case 0: -// guard let cell = homeCollectionView.dequeueReusableCell(withReuseIdentifier: ComingEventsCollectionViewCell.className, for: indexPath) as? ComingEventsCollectionViewCell else { return UICollectionViewCell() } -// -// return cell -// case 1: -// guard let cell = homeCollectionView.dequeueReusableCell(withReuseIdentifier: RulesTodoCollectionViewCell.className, for: indexPath) as? RulesTodoCollectionViewCell, -// let rules = rules, -// let todos = todos -// else { return UICollectionViewCell() } -// -// cell.setRulesData(rules) -// cell.setTodosData(todos) -// -// return cell -// case 2: -// guard let cell = profileCollectionView.dequeueReusableCell(withReuseIdentifier: ProfileCollectionViewCell.className, for: indexPath) as? ProfileCollectionViewCell else { return UICollectionViewCell() } -// -// if indexPath.row == ProfileDataModel.sampleData.count { -// cell.profileStack.isHidden = true -// cell.codeViewStack.isHidden = false -// -// return cell -// } -// -// cell.setProfileData(ProfileDataModel.sampleData[indexPath.row]) -// -// return cell -// default: -// return UICollectionViewCell() -// } + switch indexPath.section { + case 0: + guard let cell = homeCollectionView.dequeueReusableCell(withReuseIdentifier: ComingEventsCollectionViewCell.className, for: indexPath) as? ComingEventsCollectionViewCell else { return UICollectionViewCell() } + + cell.delegate = self + + return cell + case 1: + guard let cell = homeCollectionView.dequeueReusableCell(withReuseIdentifier: RulesTodoCollectionViewCell.className, for: indexPath) as? RulesTodoCollectionViewCell, + let rules = rules, + let todos = todos + else { return UICollectionViewCell() } + + cell.setRulesData(rules) + cell.setTodosData(todos) + + return cell + case 2: + guard let cell = homeCollectionView.dequeueReusableCell(withReuseIdentifier: ProfileCollectionViewCell.className, for: indexPath) as? ProfileCollectionViewCell else { return UICollectionViewCell() } + + if indexPath.row == ProfileDataModel.sampleData.count { + cell.profileStack.isHidden = true + cell.codeViewStack.isHidden = false + + return cell + } + + cell.setProfileData(ProfileDataModel.sampleData[indexPath.row]) + + return cell + default: + return UICollectionViewCell() + } } // func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { // if kind == UICollectionView.elementKindSectionHeader { -// guard let header = homeCollectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: HeaderCollectionReusableView.className, for: indexPath) as? HeaderCollectionReusableView else { return UICollectionReusableView() } +// guard let header = homeCollectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "HeaderCollectionReusableView", for: indexPath) as? HeaderCollectionReusableView else { return UICollectionReusableView() } // -// switch indexPath.section { -// case 0: -// header.setSubTitleLabel(data: "Coming up-") -// case 1: -// return UICollectionReusableView() -// case 2: +// if indexPath.section == 2 { // header.setSubTitleLabel(data: "Homie Profile-") -// default: -// return UICollectionReusableView() +// return header // } // } // @@ -175,66 +165,72 @@ extension HomeViewController: UICollectionViewDataSource { extension HomeViewController: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - return CGSize(width: Size.screenWidth, height: 110) -// switch indexPath.section { -// // 이거 동적으로 collection 높이 -// case 0: -// return CGSize(width: Size.screenWidth, height: 110) -// case 1: -// return CGSize(width: Size.screenWidth, height: 208) -// case 2: -// return Size.profileCellSize -// default: -// return CGSize() -// } + switch indexPath.section { + // 이거 동적으로 collection 높이 + case 0: + return CGSize(width: Size.screenWidth, height: 153) + case 1: + return CGSize(width: Size.screenWidth, height: 180) + case 2: + return Size.profileCellSize + default: + return CGSize() + } } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { - return UIEdgeInsets(top: 5, left: 0, bottom: 0, right: 0) -// switch section { -// case 0: -// return UIEdgeInsets(top: 5, left: 0, bottom: 0, right: 0) -// case 1: -// return UIEdgeInsets(top: 3, left: 0, bottom: 0, right: 24) -// case 2: -// return UIEdgeInsets(top: 3, left: 0, bottom: 0, right: 24) -// default: -// return UIEdgeInsets() -// } + switch section { + case 0: + return UIEdgeInsets(top: 5, left: 0, bottom: 0, right: 0) + case 1: + return UIEdgeInsets(top: 3, left: 24, bottom: 0, right: 24) + case 2: + return UIEdgeInsets(top: 3, left: 24, bottom: 0, right: 24) + default: + return UIEdgeInsets() + } } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { - return 0 -// switch section { -// case 0: -// return 0 -// case 1: -// return 0 -// case 2: -// return 15 -// default: -// return 0 -// } + switch section { + case 0: + return 0 + case 1: + return 0 + case 2: + return 15 + default: + return 0 + } } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { - return 15 - -// switch section { -// case 0: -// return 0 -// case 1: -// return 0 -// case 2: -// return 15 -// default: -// return 0 -// } + switch section { + case 0: + return 0 + case 1: + return 0 + case 2: + return 15 + default: + return 0 + } } } + + +extension HomeViewController: ComingEventsCollectionViewCellDelegate { + + func showPopup(_ row: Int) { + let popUp = PopUpViewController() + popUp.modalTransitionStyle = .crossDissolve + popUp.modalPresentationStyle = .overFullScreen + present(popUp, animated: true) + } +} diff --git a/HousLab_iOS/HousLab_iOS/MinJae/PopUpViewController.swift b/HousLab_iOS/HousLab_iOS/MinJae/PopUpViewController.swift new file mode 100644 index 0000000..82fa27b --- /dev/null +++ b/HousLab_iOS/HousLab_iOS/MinJae/PopUpViewController.swift @@ -0,0 +1,112 @@ +// +// PopUpViewController.swift +// HousLab_iOS +// +// Created by 김민재 on 2022/07/06. +// + +import UIKit +import SnapKit +import Then + +class PopUpViewController: UIViewController { + + private let popUpView = UIView().then { + $0.backgroundColor = .white + $0.layer.cornerRadius = 20 + } + + private let titleLabel = UILabel().then { + $0.text = "이벤트" + $0.font = .systemFont(ofSize: 20, weight: .semibold) + $0.tintColor = .black + } + + private let eventImageView = UIImageView().then { + $0.layer.cornerRadius = 30 + $0.clipsToBounds = true + $0.backgroundColor = UIColor(hex: "FFD66D") + } + + private let eventTextField = UITextField().then { + $0.backgroundColor = UIColor(hex: "FFD66D") + } + + private let cancelButton = UIButton().then { + // 여기해야됨 + var config = UIButton.Configuration.plain() + config.title = "취소" + config.baseForegroundColor = .red + config.baseBackgroundColor = .white + $0.configuration = config + + $0.addTarget(PopUpViewController.self, action: #selector(cancelButtonDidTapped), for: .touchUpInside) + + $0.layer.borderColor = UIColor.red.cgColor + $0.layer.borderWidth = 1 + } + + private let saveButton = UIButton().then { + $0.setTitle("저장", for: .normal) + $0.backgroundColor = UIColor(hex: "FFD66D") + } + + private lazy var buttonStackView = UIStackView(arrangedSubviews: [cancelButton, saveButton]).then { + $0.axis = .horizontal + $0.distribution = .fillEqually + $0.spacing = 15 + } + + override func viewDidLoad() { + super.viewDidLoad() + render() + configUI() + } + + override func touchesBegan(_ touches: Set, with event: UIEvent?) { + super.touchesBegan(touches, with: event) + + if let touch = touches.first, touch.view == self.view { + dismiss(animated: true) + } + } + + @objc + private func cancelButtonDidTapped() { + self.dismiss(animated: true) + } + + private func configUI() { + view.backgroundColor = .black.withAlphaComponent(0.4) + + } + + private func render() { + self.view.addSubview(popUpView) + popUpView.addSubViews([titleLabel, eventImageView, buttonStackView]) + + popUpView.snp.makeConstraints { make in + make.center.equalToSuperview() + make.width.equalTo(UIScreen.main.bounds.width * (272/375)) + make.height.equalTo(UIScreen.main.bounds.height * (439/812)) + } + + titleLabel.snp.makeConstraints { make in + make.top.equalToSuperview().offset(36) + make.leading.equalToSuperview().offset(24) + } + + eventImageView.snp.makeConstraints { make in + make.top.equalTo(titleLabel.snp.bottom).offset(10) + make.leading.equalToSuperview().offset(20) + make.width.height.equalTo(60) + } + + buttonStackView.snp.makeConstraints { make in + make.leading.trailing.equalToSuperview().inset(24) + make.bottom.equalToSuperview().inset(20) + } + + } + +}