diff --git a/Deartoday/Deartoday.xcodeproj/project.pbxproj b/Deartoday/Deartoday.xcodeproj/project.pbxproj index c6cc485..6e625fa 100644 --- a/Deartoday/Deartoday.xcodeproj/project.pbxproj +++ b/Deartoday/Deartoday.xcodeproj/project.pbxproj @@ -88,6 +88,7 @@ 984099ED2881F50000025092 /* sound_player.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 984099EC2881F50000025092 /* sound_player.mp3 */; }; 9858B3D0288097B000860439 /* MessageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9858B3CE288097B000860439 /* MessageCollectionViewCell.swift */; }; 9858B3D1288097B000860439 /* MessageCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9858B3CF288097B000860439 /* MessageCollectionViewCell.xib */; }; + 986E000128A4DCC9008EB3F2 /* CheckMessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 986E000028A4DCC9008EB3F2 /* CheckMessagesViewController.swift */; }; 986F5C362887FA83001109F1 /* TravelInfoCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 986F5C342887FA83001109F1 /* TravelInfoCollectionReusableView.swift */; }; 986F5C372887FA83001109F1 /* TravelInfoCollectionReusableView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 986F5C352887FA83001109F1 /* TravelInfoCollectionReusableView.xib */; }; 986F5C3C2888345E001109F1 /* PastDialogCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 986F5C3A2888345E001109F1 /* PastDialogCollectionViewCell.swift */; }; @@ -212,6 +213,7 @@ 984099EC2881F50000025092 /* sound_player.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = sound_player.mp3; sourceTree = ""; }; 9858B3CE288097B000860439 /* MessageCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageCollectionViewCell.swift; sourceTree = ""; }; 9858B3CF288097B000860439 /* MessageCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MessageCollectionViewCell.xib; sourceTree = ""; }; + 986E000028A4DCC9008EB3F2 /* CheckMessagesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckMessagesViewController.swift; sourceTree = ""; }; 986F5C342887FA83001109F1 /* TravelInfoCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TravelInfoCollectionReusableView.swift; sourceTree = ""; }; 986F5C352887FA83001109F1 /* TravelInfoCollectionReusableView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TravelInfoCollectionReusableView.xib; sourceTree = ""; }; 986F5C3A2888345E001109F1 /* PastDialogCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PastDialogCollectionViewCell.swift; sourceTree = ""; }; @@ -1014,6 +1016,7 @@ isa = PBXGroup; children = ( 98D912CD287DC3430088A7F9 /* CheckMessageViewController.swift */, + 986E000028A4DCC9008EB3F2 /* CheckMessagesViewController.swift */, ); path = Controller; sourceTree = ""; @@ -1240,6 +1243,7 @@ 98B4B5AA287EB54600F4AD7A /* ViewController.swift in Sources */, 98245CF028869CCB007821FA /* PastImageCollectionViewCell.swift in Sources */, 98D912D2287DC3590088A7F9 /* CheckMessageDataModel.swift in Sources */, + 986E000128A4DCC9008EB3F2 /* CheckMessagesViewController.swift in Sources */, 4A44EEFB28807DC00062420E /* PlayTapeOnboardingViewController.swift in Sources */, 98D912A5287D3B0D0088A7F9 /* DeartodayAlertViewController.swift in Sources */, 92DB356A28756577001E2006 /* DDSTextField.swift in Sources */, diff --git a/Deartoday/Deartoday/Screen/CheckMessage/Controller/CheckMessagesViewController.swift b/Deartoday/Deartoday/Screen/CheckMessage/Controller/CheckMessagesViewController.swift new file mode 100644 index 0000000..8bea825 --- /dev/null +++ b/Deartoday/Deartoday/Screen/CheckMessage/Controller/CheckMessagesViewController.swift @@ -0,0 +1,184 @@ +// +// CheckMessagesViewController.swift +// Deartoday +// +// Created by 이경민 on 2022/08/11. +// + +import UIKit + +import SnapKit +import Then + +final class CheckMessagesViewController: UIViewController { + + // MARK: - Property + // MARK: - UI Property + + private let navigationView = UIView().then { + $0.backgroundColor = .clear + } + + private let backButton = UIButton().then { + $0.setImage(Constant.Image.icBack, for: .normal) + $0.addTarget(self, action: #selector(backButtonDidTap), for: .touchUpInside) + } + + private let messageImageView = UIImageView().then { + $0.image = Constant.Image.imgMemoBundle + } + + private let titleLabel = UILabel().then { + $0.text = "나의 메시지" + $0.font = .h1 + $0.textColor = .darkGray01 + $0.setPartialLabelColor(targetStringList: ["메시지"], color: .blue02) + } + + private let descriptionLabel = UILabel().then { + $0.text = "미래의 나로부터 도착한 메시지를 확인해보세요" + $0.font = .caption2 + $0.textColor = .gray00 + } + + private let emptyView = UIView().then { + $0.isHidden = false + $0.backgroundColor = .clear + } + + private let emptyMessageImageView = UIImageView().then { + $0.image = Constant.Image.imgMemoempty + } + + private let emptyDescriptionLabel = UILabel().then { + $0.text = "아직 나에게 도착한 메시지가 없어요!\n지금 바로 시간 여행을 떠나볼까요?" + $0.numberOfLines = 0 + $0.font = .caption2 + $0.textColor = .gray01 + $0.setTextWithLineHeight(text: $0.text, lineHeight: 22) + } + + private let timeTravelButton = DDSButton().then { + $0.text = "시간 여행 떠나기" + $0.hasLeftIcon = true + $0.style = .present + } + + private let timeTravelView = UIView().then { + $0.backgroundColor = .clear + $0.isUserInteractionEnabled = true + } + + // MARK: - Life Cycle + + override func viewDidLoad() { + super.viewDidLoad() + setUI() + setLayout() + setGesture() + } + + // MARK: - @objc + + @objc private func backButtonDidTap() { + navigationController?.popViewController(animated: true) + } + + @objc private func timeTravelButtonDidTap() { + let timeTravel = TimeTravelViewController() + timeTravel.modalTransitionStyle = .crossDissolve + timeTravel.modalPresentationStyle = .fullScreen + present(timeTravel, animated: true) { + self.navigationController?.popViewController(animated: false) + } + } + + // MARK: - Custom Method + + private func setUI() { + view.backgroundColor = .white + } + + private func setLayout() { + setHierarchy() + setConstraint() + } + + private func setHierarchy() { + view.addSubviews([navigationView, emptyView]) + navigationView.addSubviews([backButton, messageImageView, + titleLabel, descriptionLabel]) + emptyView.addSubviews([emptyMessageImageView, emptyDescriptionLabel, timeTravelButton]) + timeTravelButton.addSubview(timeTravelView) + } + + private func setConstraint() { + setNavigationBarConstraint() + setEmptyViewContraint() + } + + private func setGesture() { + let gesture = UITapGestureRecognizer(target: self, action: #selector(timeTravelButtonDidTap)) + timeTravelView.addGestureRecognizer(gesture) + } +} + +// MARK: - Constraints + +extension CheckMessagesViewController { + private func setNavigationBarConstraint() { + navigationView.snp.makeConstraints { make in + make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(0) + make.height.equalTo(161) + } + + backButton.snp.makeConstraints { make in + make.top.equalToSuperview().inset(14) + make.leading.equalToSuperview().inset(6) + make.width.height.equalTo(44) + } + + messageImageView.snp.makeConstraints { make in + make.top.equalToSuperview().inset(2) + make.trailing.equalToSuperview().inset(16) + } + + titleLabel.snp.makeConstraints { make in + make.top.equalToSuperview().inset(72) + make.leading.equalToSuperview().inset(20) + } + + descriptionLabel.snp.makeConstraints { make in + make.top.equalTo(titleLabel.snp.bottom).offset(4) + make.leading.equalToSuperview().inset(20) + } + } + + private func setEmptyViewContraint() { + emptyView.snp.makeConstraints { make in + make.top.equalTo(navigationView.snp.bottom).offset(0) + make.leading.trailing.bottom.equalTo(view.safeAreaLayoutGuide).inset(0) + } + + emptyMessageImageView.snp.makeConstraints { make in + make.top.equalToSuperview().offset(constraintByNotch(83, 50)) + make.centerX.equalToSuperview() + } + + emptyDescriptionLabel.snp.makeConstraints { make in + make.top.equalTo(emptyMessageImageView.snp.bottom).offset(8) + make.centerX.equalToSuperview() + } + + timeTravelButton.snp.makeConstraints { make in + make.top.equalTo(emptyDescriptionLabel.snp.bottom).offset(12) + make.width.equalTo(190) + make.height.equalTo(68) + make.centerX.equalToSuperview() + } + + timeTravelView.snp.makeConstraints { make in + make.top.leading.trailing.bottom.equalToSuperview() + } + } +}