Skip to content

Commit d5d9813

Browse files
committed
[#142] 메시지 확인 엠티뷰 UI 구현 코드로 변경
1 parent 0003e87 commit d5d9813

File tree

2 files changed

+188
-0
lines changed

2 files changed

+188
-0
lines changed

Deartoday/Deartoday.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
984099ED2881F50000025092 /* sound_player.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 984099EC2881F50000025092 /* sound_player.mp3 */; };
8989
9858B3D0288097B000860439 /* MessageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9858B3CE288097B000860439 /* MessageCollectionViewCell.swift */; };
9090
9858B3D1288097B000860439 /* MessageCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9858B3CF288097B000860439 /* MessageCollectionViewCell.xib */; };
91+
986E000128A4DCC9008EB3F2 /* CheckMessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 986E000028A4DCC9008EB3F2 /* CheckMessagesViewController.swift */; };
9192
986F5C362887FA83001109F1 /* TravelInfoCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 986F5C342887FA83001109F1 /* TravelInfoCollectionReusableView.swift */; };
9293
986F5C372887FA83001109F1 /* TravelInfoCollectionReusableView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 986F5C352887FA83001109F1 /* TravelInfoCollectionReusableView.xib */; };
9394
986F5C3C2888345E001109F1 /* PastDialogCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 986F5C3A2888345E001109F1 /* PastDialogCollectionViewCell.swift */; };
@@ -212,6 +213,7 @@
212213
984099EC2881F50000025092 /* sound_player.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = sound_player.mp3; sourceTree = "<group>"; };
213214
9858B3CE288097B000860439 /* MessageCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageCollectionViewCell.swift; sourceTree = "<group>"; };
214215
9858B3CF288097B000860439 /* MessageCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MessageCollectionViewCell.xib; sourceTree = "<group>"; };
216+
986E000028A4DCC9008EB3F2 /* CheckMessagesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckMessagesViewController.swift; sourceTree = "<group>"; };
215217
986F5C342887FA83001109F1 /* TravelInfoCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TravelInfoCollectionReusableView.swift; sourceTree = "<group>"; };
216218
986F5C352887FA83001109F1 /* TravelInfoCollectionReusableView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TravelInfoCollectionReusableView.xib; sourceTree = "<group>"; };
217219
986F5C3A2888345E001109F1 /* PastDialogCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PastDialogCollectionViewCell.swift; sourceTree = "<group>"; };
@@ -1014,6 +1016,7 @@
10141016
isa = PBXGroup;
10151017
children = (
10161018
98D912CD287DC3430088A7F9 /* CheckMessageViewController.swift */,
1019+
986E000028A4DCC9008EB3F2 /* CheckMessagesViewController.swift */,
10171020
);
10181021
path = Controller;
10191022
sourceTree = "<group>";
@@ -1240,6 +1243,7 @@
12401243
98B4B5AA287EB54600F4AD7A /* ViewController.swift in Sources */,
12411244
98245CF028869CCB007821FA /* PastImageCollectionViewCell.swift in Sources */,
12421245
98D912D2287DC3590088A7F9 /* CheckMessageDataModel.swift in Sources */,
1246+
986E000128A4DCC9008EB3F2 /* CheckMessagesViewController.swift in Sources */,
12431247
4A44EEFB28807DC00062420E /* PlayTapeOnboardingViewController.swift in Sources */,
12441248
98D912A5287D3B0D0088A7F9 /* DeartodayAlertViewController.swift in Sources */,
12451249
92DB356A28756577001E2006 /* DDSTextField.swift in Sources */,
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
//
2+
// CheckMessagesViewController.swift
3+
// Deartoday
4+
//
5+
// Created by 이경민 on 2022/08/11.
6+
//
7+
8+
import UIKit
9+
10+
import SnapKit
11+
import Then
12+
13+
final class CheckMessagesViewController: UIViewController {
14+
15+
// MARK: - Property
16+
// MARK: - UI Property
17+
18+
private let navigationView = UIView().then {
19+
$0.backgroundColor = .clear
20+
}
21+
22+
private let backButton = UIButton().then {
23+
$0.setImage(Constant.Image.icBack, for: .normal)
24+
$0.addTarget(self, action: #selector(backButtonDidTap), for: .touchUpInside)
25+
}
26+
27+
private let messageImageView = UIImageView().then {
28+
$0.image = Constant.Image.imgMemoBundle
29+
}
30+
31+
private let titleLabel = UILabel().then {
32+
$0.text = "나의 메시지"
33+
$0.font = .h1
34+
$0.textColor = .darkGray01
35+
$0.setPartialLabelColor(targetStringList: ["메시지"], color: .blue02)
36+
}
37+
38+
private let descriptionLabel = UILabel().then {
39+
$0.text = "미래의 나로부터 도착한 메시지를 확인해보세요"
40+
$0.font = .caption2
41+
$0.textColor = .gray00
42+
}
43+
44+
private let emptyView = UIView().then {
45+
$0.isHidden = false
46+
$0.backgroundColor = .clear
47+
}
48+
49+
private let emptyMessageImageView = UIImageView().then {
50+
$0.image = Constant.Image.imgMemoempty
51+
}
52+
53+
private let emptyDescriptionLabel = UILabel().then {
54+
$0.text = "아직 나에게 도착한 메시지가 없어요!\n지금 바로 시간 여행을 떠나볼까요?"
55+
$0.numberOfLines = 0
56+
$0.font = .caption2
57+
$0.textColor = .gray01
58+
$0.setTextWithLineHeight(text: $0.text, lineHeight: 22)
59+
}
60+
61+
private let timeTravelButton = DDSButton().then {
62+
$0.text = "시간 여행 떠나기"
63+
$0.hasLeftIcon = true
64+
$0.style = .present
65+
}
66+
67+
private let timeTravelView = UIView().then {
68+
$0.backgroundColor = .clear
69+
$0.isUserInteractionEnabled = true
70+
}
71+
72+
// MARK: - Life Cycle
73+
74+
override func viewDidLoad() {
75+
super.viewDidLoad()
76+
setUI()
77+
setLayout()
78+
setGesture()
79+
}
80+
81+
// MARK: - @objc
82+
83+
@objc private func backButtonDidTap() {
84+
navigationController?.popViewController(animated: true)
85+
}
86+
87+
@objc private func timeTravelButtonDidTap() {
88+
let timeTravel = TimeTravelViewController()
89+
timeTravel.modalTransitionStyle = .crossDissolve
90+
timeTravel.modalPresentationStyle = .fullScreen
91+
present(timeTravel, animated: true) {
92+
self.navigationController?.popViewController(animated: false)
93+
}
94+
}
95+
96+
// MARK: - Custom Method
97+
98+
private func setUI() {
99+
view.backgroundColor = .white
100+
}
101+
102+
private func setLayout() {
103+
setHierarchy()
104+
setConstraint()
105+
}
106+
107+
private func setHierarchy() {
108+
view.addSubviews([navigationView, emptyView])
109+
navigationView.addSubviews([backButton, messageImageView,
110+
titleLabel, descriptionLabel])
111+
emptyView.addSubviews([emptyMessageImageView, emptyDescriptionLabel, timeTravelButton])
112+
timeTravelButton.addSubview(timeTravelView)
113+
}
114+
115+
private func setConstraint() {
116+
setNavigationBarConstraint()
117+
setEmptyViewContraint()
118+
}
119+
120+
private func setGesture() {
121+
let gesture = UITapGestureRecognizer(target: self, action: #selector(timeTravelButtonDidTap))
122+
timeTravelView.addGestureRecognizer(gesture)
123+
}
124+
}
125+
126+
// MARK: - Constraints
127+
128+
extension CheckMessagesViewController {
129+
private func setNavigationBarConstraint() {
130+
navigationView.snp.makeConstraints { make in
131+
make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(0)
132+
make.height.equalTo(161)
133+
}
134+
135+
backButton.snp.makeConstraints { make in
136+
make.top.equalToSuperview().inset(14)
137+
make.leading.equalToSuperview().inset(6)
138+
make.width.height.equalTo(44)
139+
}
140+
141+
messageImageView.snp.makeConstraints { make in
142+
make.top.equalToSuperview().inset(2)
143+
make.trailing.equalToSuperview().inset(16)
144+
}
145+
146+
titleLabel.snp.makeConstraints { make in
147+
make.top.equalToSuperview().inset(72)
148+
make.leading.equalToSuperview().inset(20)
149+
}
150+
151+
descriptionLabel.snp.makeConstraints { make in
152+
make.top.equalTo(titleLabel.snp.bottom).offset(4)
153+
make.leading.equalToSuperview().inset(20)
154+
}
155+
}
156+
157+
private func setEmptyViewContraint() {
158+
emptyView.snp.makeConstraints { make in
159+
make.top.equalTo(navigationView.snp.bottom).offset(0)
160+
make.leading.trailing.bottom.equalTo(view.safeAreaLayoutGuide).inset(0)
161+
}
162+
163+
emptyMessageImageView.snp.makeConstraints { make in
164+
make.top.equalToSuperview().offset(constraintByNotch(83, 50))
165+
make.centerX.equalToSuperview()
166+
}
167+
168+
emptyDescriptionLabel.snp.makeConstraints { make in
169+
make.top.equalTo(emptyMessageImageView.snp.bottom).offset(8)
170+
make.centerX.equalToSuperview()
171+
}
172+
173+
timeTravelButton.snp.makeConstraints { make in
174+
make.top.equalTo(emptyDescriptionLabel.snp.bottom).offset(12)
175+
make.width.equalTo(190)
176+
make.height.equalTo(68)
177+
make.centerX.equalToSuperview()
178+
}
179+
180+
timeTravelView.snp.makeConstraints { make in
181+
make.top.leading.trailing.bottom.equalToSuperview()
182+
}
183+
}
184+
}

0 commit comments

Comments
 (0)