From 2cceffa66384bb1ac79602654bc6e769a37df53b Mon Sep 17 00:00:00 2001 From: so yeon Date: Fri, 15 Jul 2022 20:08:08 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[#45]=20=EB=B3=B4=EB=82=B4=EA=B8=B0=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20enable=20=EB=B6=84=EA=B8=B0=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/DialogViewController+.swift | 1 - .../Controller/DialogViewController.swift | 86 +++++++++++++++---- .../Screen/Dialog/Model/DialogDataModel.swift | 10 +-- .../Dialog/View/DialogMessageView.swift | 2 +- 4 files changed, 73 insertions(+), 26 deletions(-) diff --git a/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController+.swift b/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController+.swift index a4a773d7..26b71df7 100644 --- a/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController+.swift +++ b/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController+.swift @@ -78,7 +78,6 @@ extension DialogViewController { } // 나타나는 애니메이션 - internal func showView(_ component: UIView, delay: Double = 0.8, duration: Double = 0.3){ UIView.animate(withDuration: duration, delay: delay, options: .curveEaseOut) { component.alpha = 1 diff --git a/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController.swift b/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController.swift index 53be8f70..b8b2b9bc 100644 --- a/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController.swift +++ b/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController.swift @@ -57,8 +57,16 @@ final class DialogViewController: UIViewController { } } + private var canSendMessage: Bool = false { + didSet { + sendButton.isUserInteractionEnabled = canSendMessage ? true : false + } + } + + private var isTextViewEditing: Bool = false + private var questions: [String] = DialogDataModel.questions - private var answers: [String] = ["", "", "", "", "", "", ""] + private var answers = [String]() private var count: Int = 0 @@ -145,6 +153,7 @@ final class DialogViewController: UIViewController { private lazy var sendButton = UIButton().then { $0.setTitle("보내기", for: .normal) + $0.setTitleColor(.gray01, for: .disabled) $0.setTitleColor(.blue02, for: .normal) $0.setTitleColor(.blue02, for: .highlighted) $0.isHidden = true @@ -180,9 +189,9 @@ final class DialogViewController: UIViewController { hidePastView(self.pastMessageView) { } hideButton(self.nextButton) { self.pastMessageView.dialogText = """ - 고마워! - 아하, 너는 이때로 가장 돌아가고 싶었구나. - """ + 고마워! + 아하, 너는 이때로 가장 돌아가고 싶었구나. + """ self.setDialogMessageViewHeight() @@ -197,7 +206,48 @@ final class DialogViewController: UIViewController { } @objc func sendButtonDidTap() { - print("보내기 버튼 누르기") + presentMessageView.dialogText = answerTextView.text + setDialogMessageViewHeight() + + answerTextView.text = "" + sendButton.isEnabled = false + + count += 1 + switch count { + case 0, 1, 2, 3, 4, 5: + hidePastView(pastMessageView) { + self.showPresentView(self.presentMessageView) { + self.sendButton.isEnabled = false + self.hidePresentView(self.presentMessageView) { + self.pastMessageView.dialogText = self.questions[self.count] + self.setDialogMessageViewHeight() + + self.showPastView(self.pastMessageView) { + self.sendButton.isEnabled = true + } + } + } + } + case 6: + hidePastView(pastMessageView) { + self.showPresentView(self.presentMessageView) { + self.hidePresentView(self.presentMessageView) { + self.guideText = "마지막으로,\n과거의 당신에게 꼭 해주고 싶은 말을 남기세요." + self.guideLabel.snp.updateConstraints { + $0.top.equalTo(self.view.safeAreaLayoutGuide).inset(300) + } + + self.showNarrationLabel(self.guideLabel) { + self.presentMessageView.dialogText = self.answerTextView.text + self.setDialogMessageViewHeight() + self.sendButton.isEnabled = true + } + } + } + } + default: + print("어쩔") + } } // MARK: - Custom Method @@ -290,7 +340,9 @@ final class DialogViewController: UIViewController { presentMessageView.snp.makeConstraints { $0.top.equalTo(view.safeAreaLayoutGuide).inset(228) + $0.width.equalTo(343) $0.height.equalTo(110) + $0.centerX.equalToSuperview() } photoImageView.snp.makeConstraints { @@ -334,7 +386,7 @@ final class DialogViewController: UIViewController { } private func setDialogAnimation() { - pastMessageView.dialogText = DialogDataModel.questions[0] + pastMessageView.dialogText = questions[count] setDialogMessageViewHeight() showPastView(self.pastMessageView) { @@ -350,11 +402,13 @@ final class DialogViewController: UIViewController { } private func setDialogMessageViewHeight() { - let height = pastMessageView.dialogLabel.intrinsicContentSize.height + 30 - - pastMessageView.snp.updateConstraints { - $0.top.equalTo(self.view.safeAreaLayoutGuide).inset(290) - $0.height.equalTo(height) + [pastMessageView, presentMessageView].forEach { + let height = $0.dialogLabel.intrinsicContentSize.height + 30 + + $0.snp.updateConstraints { + $0.top.equalTo(self.view.safeAreaLayoutGuide).inset(290) + $0.height.equalTo(height) + } } } } @@ -367,6 +421,8 @@ extension DialogViewController: UITextViewDelegate { } func textViewDidChange(_ textView: UITextView) { + + let size = CGSize(width: answerTextView.frame.width, height: .infinity) let estimatedSize = textView.sizeThatFits(size) @@ -388,12 +444,4 @@ extension DialogViewController: UITextViewDelegate { } } } - - func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { - if text == "\n" { - textView.resignFirstResponder() - return false - } - return true - } } diff --git a/Deartoday/Deartoday/Screen/Dialog/Model/DialogDataModel.swift b/Deartoday/Deartoday/Screen/Dialog/Model/DialogDataModel.swift index 74f2f03b..957626bf 100644 --- a/Deartoday/Deartoday/Screen/Dialog/Model/DialogDataModel.swift +++ b/Deartoday/Deartoday/Screen/Dialog/Model/DialogDataModel.swift @@ -8,10 +8,10 @@ import Foundation struct DialogDataModel { - static let questions: [String] = ["이때가 어떤 순간이었는지 설명해줄 수 있을까?", - "그럼, 이때 어떤 감정과 생각이 들었어? ", - "너가 이 순간으로 돌아오고 싶다고 생각한 이유가 알고 싶어.", - "이 순간을 생각했을 때 혹시 과거랑 지금 달라진 점이 있을까?", - "그렇다면, 이때의 경험이 가지는 의미를 새롭게 생각해볼 수 있지 않을까?", + static let questions: [String] = ["이 순간에 대해 설명해 줄 수 있어?", + "그럼, 그 당시에 너는 어떤 감정과 생각이 들었던 것 같아?", + "너가 왜 돌아가고 싶은 순간으로 이때를 골랐는지 알고 싶어.", + "과거의 이 순간을 떠올리면 지금은 어떤 감정과 생각이 들어?", + "그렇다면, 너는 이때의 경험으로부터 어떤 점들을 가져가고 싶어?", "너의 2022년은 어때?"] } diff --git a/Deartoday/Deartoday/Screen/Dialog/View/DialogMessageView.swift b/Deartoday/Deartoday/Screen/Dialog/View/DialogMessageView.swift index 06a2ff95..6c3e92ef 100644 --- a/Deartoday/Deartoday/Screen/Dialog/View/DialogMessageView.swift +++ b/Deartoday/Deartoday/Screen/Dialog/View/DialogMessageView.swift @@ -82,7 +82,7 @@ final class DialogMessageView: UIView { } dialogLabel.snp.makeConstraints { - $0.bottom.equalToSuperview().inset(13) + $0.top.equalToSuperview().inset(15) $0.leading.trailing.equalToSuperview().inset(35) } } From 81472b8a5c3f81322cf4f9a7c4182bd1f6657e15 Mon Sep 17 00:00:00 2001 From: so yeon Date: Sat, 16 Jul 2022 02:25:45 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[#45]=20=EB=A7=88=EC=A7=80=EB=A7=89=20?= =?UTF-8?q?=EB=A7=90=20=EC=95=A0=EB=8B=88=EB=A9=94=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/DialogViewController.swift | 59 ++++++++++++++++--- .../Screen/Dialog/Model/DialogDataModel.swift | 3 + 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController.swift b/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController.swift index b8b2b9bc..4000709d 100644 --- a/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController.swift +++ b/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController.swift @@ -66,6 +66,7 @@ final class DialogViewController: UIViewController { private var isTextViewEditing: Bool = false private var questions: [String] = DialogDataModel.questions + private var lastMessage: [String] = DialogDataModel.lastMessage private var answers = [String]() private var count: Int = 0 @@ -185,7 +186,7 @@ final class DialogViewController: UIViewController { self.showButton(self.nextButton) { } } } - } else { + } else if sender.text == "응, 좋아!"{ hidePastView(self.pastMessageView) { } hideButton(self.nextButton) { self.pastMessageView.dialogText = """ @@ -202,6 +203,8 @@ final class DialogViewController: UIViewController { } } } + } else { + print("다음 화면으로 이동") } } @@ -246,15 +249,58 @@ final class DialogViewController: UIViewController { } } default: - print("어쩔") + hideNarrationLabel(guideLabel) { + self.showPresentView(self.presentMessageView) { + self.hidePastView(self.photoImageView) { + UIView.animate(withDuration: 0.5, delay: 0.7, options: .curveEaseOut) { + self.presentMessageView.transform = CGAffineTransform(translationX: 0, y: -154) + self.presentMessageView.alpha = 0 + } completion: { _ in + [self.answerTextView, self.underLineView, self.sendButton].forEach { + $0.isHidden = true + } + self.answerTextView.resignFirstResponder() + + self.pastMessageView.dialogText = "소중한 말 남겨줘서 정말 고마워." + self.setDialogMessageViewHeight() + + self.pastMessageView.snp.updateConstraints { + $0.top.equalTo(self.view.safeAreaLayoutGuide).inset(228) + } + + self.showPastView(self.pastMessageView) { + self.hidePastView(self.pastMessageView) { + self.pastMessageView.dialogText = self.lastMessage[0] + self.setDialogMessageViewHeight(topConstant: 228) + + self.showPastView(self.pastMessageView) { + self.hidePastView(self.pastMessageView) { + self.pastMessageView.dialogText = self.lastMessage[1] + self.setDialogMessageViewHeight(topConstant: 228) + + self.showPastView(self.pastMessageView) { + self.nextButton.text = "다시 오늘을 살아가기" + self.nextButton.snp.updateConstraints { + $0.bottom.equalTo(self.view.safeAreaLayoutGuide).inset(2) + $0.centerX.equalToSuperview() + $0.width.equalTo(363) + } + self.showButton(self.nextButton) { } + } + } + } + } + } + } + } + } + } } } // MARK: - Custom Method private func setUI() { - view.backgroundColor = .gray - setDateLabel() DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { @@ -401,12 +447,12 @@ final class DialogViewController: UIViewController { answerTextView.delegate = self } - private func setDialogMessageViewHeight() { + private func setDialogMessageViewHeight(topConstant: Double = 290) { [pastMessageView, presentMessageView].forEach { let height = $0.dialogLabel.intrinsicContentSize.height + 30 $0.snp.updateConstraints { - $0.top.equalTo(self.view.safeAreaLayoutGuide).inset(290) + $0.top.equalTo(self.view.safeAreaLayoutGuide).inset(topConstant) $0.height.equalTo(height) } } @@ -422,7 +468,6 @@ extension DialogViewController: UITextViewDelegate { func textViewDidChange(_ textView: UITextView) { - let size = CGSize(width: answerTextView.frame.width, height: .infinity) let estimatedSize = textView.sizeThatFits(size) diff --git a/Deartoday/Deartoday/Screen/Dialog/Model/DialogDataModel.swift b/Deartoday/Deartoday/Screen/Dialog/Model/DialogDataModel.swift index 957626bf..8c1a40b0 100644 --- a/Deartoday/Deartoday/Screen/Dialog/Model/DialogDataModel.swift +++ b/Deartoday/Deartoday/Screen/Dialog/Model/DialogDataModel.swift @@ -14,4 +14,7 @@ struct DialogDataModel { "과거의 이 순간을 떠올리면 지금은 어떤 감정과 생각이 들어?", "그렇다면, 너는 이때의 경험으로부터 어떤 점들을 가져가고 싶어?", "너의 2022년은 어때?"] + + static let lastMessage: [String] = ["우리는 어쩌면 10년 후에 “그때가 좋았지” 하면서\n시간을 되돌리고 싶어할 수도 있어.", + "그럼, 지금부터 다시 시작하자.\n너는 지금, 10년 후의 미래에서 되돌아온 거야.\n그러니 행복한 이 순간에 최선을 다해 살 수 있기를 :)"] } From 84ee2773741c1fd8be9eb3f928a54fd1142a1881 Mon Sep 17 00:00:00 2001 From: so yeon Date: Sat, 16 Jul 2022 16:03:57 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[#45]=20=EC=95=A0=EB=8B=88=EB=A9=94?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EC=8B=9C=EA=B0=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/DialogViewController.swift | 89 ++++++++++--------- .../Dialog/View/DialogMessageView.swift | 5 +- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController.swift b/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController.swift index 4000709d..4f0b0fdd 100644 --- a/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController.swift +++ b/Deartoday/Deartoday/Screen/Dialog/Controller/DialogViewController.swift @@ -22,12 +22,14 @@ final class DialogViewController: UIViewController { 반갑게 손을 흔들며 당신을 맞이하네요. 한 번 인사를 건네보세요! """ + guideLabel.addLineSpacing(spacing: 27) + guideLabel.textAlignment = .center pastMessageView.dialogText = """ - 안녕! 나는 \(year)년도의 너야. - 만나서 정말 반가워! - 너에게 몇 가지 궁금한 게 있는데 - 괜찮다면 너와 잠깐 얘기하고 싶어. - """ + 안녕! 나는 \(year)년도의 너야. + 만나서 정말 반가워! + 너에게 몇 가지 궁금한 게 있는데 + 괜찮다면 너와 잠깐 얘기하고 싶어. + """ } } @@ -204,7 +206,7 @@ final class DialogViewController: UIViewController { } } } else { - print("다음 화면으로 이동") + view.window?.rootViewController?.dismiss(animated: true) } } @@ -251,42 +253,41 @@ final class DialogViewController: UIViewController { default: hideNarrationLabel(guideLabel) { self.showPresentView(self.presentMessageView) { - self.hidePastView(self.photoImageView) { - UIView.animate(withDuration: 0.5, delay: 0.7, options: .curveEaseOut) { - self.presentMessageView.transform = CGAffineTransform(translationX: 0, y: -154) - self.presentMessageView.alpha = 0 - } completion: { _ in - [self.answerTextView, self.underLineView, self.sendButton].forEach { - $0.isHidden = true - } - self.answerTextView.resignFirstResponder() - - self.pastMessageView.dialogText = "소중한 말 남겨줘서 정말 고마워." - self.setDialogMessageViewHeight() - - self.pastMessageView.snp.updateConstraints { - $0.top.equalTo(self.view.safeAreaLayoutGuide).inset(228) - } - - self.showPastView(self.pastMessageView) { - self.hidePastView(self.pastMessageView) { - self.pastMessageView.dialogText = self.lastMessage[0] - self.setDialogMessageViewHeight(topConstant: 228) - - self.showPastView(self.pastMessageView) { - self.hidePastView(self.pastMessageView) { - self.pastMessageView.dialogText = self.lastMessage[1] - self.setDialogMessageViewHeight(topConstant: 228) - - self.showPastView(self.pastMessageView) { - self.nextButton.text = "다시 오늘을 살아가기" - self.nextButton.snp.updateConstraints { - $0.bottom.equalTo(self.view.safeAreaLayoutGuide).inset(2) - $0.centerX.equalToSuperview() - $0.width.equalTo(363) - } - self.showButton(self.nextButton) { } + self.hidePastView(self.photoImageView, delay: 1.0 , duration: 1.0) { } + UIView.animate(withDuration: 1.0, delay: 0.7, options: .curveEaseOut) { + self.presentMessageView.transform = CGAffineTransform(translationX: 0, y: -154) + self.presentMessageView.alpha = 0 + } completion: { _ in + [self.answerTextView, self.underLineView, self.sendButton].forEach { + $0.isHidden = true + } + self.answerTextView.resignFirstResponder() + + self.pastMessageView.dialogText = "소중한 말 남겨줘서 정말 고마워." + self.setDialogMessageViewHeight() + + self.pastMessageView.snp.updateConstraints { + $0.top.equalTo(self.view.safeAreaLayoutGuide).inset(228) + } + + self.showPastView(self.pastMessageView) { + self.hidePastView(self.pastMessageView, delay: 1.2, duration: 1.0) { + self.pastMessageView.dialogText = self.lastMessage[0] + self.setDialogMessageViewHeight(topConstant: 228) + + self.showPastView(self.pastMessageView) { + self.hidePastView(self.pastMessageView) { + self.pastMessageView.dialogText = self.lastMessage[1] + self.setDialogMessageViewHeight(topConstant: 228) + + self.showPastView(self.pastMessageView) { + self.nextButton.text = "다시 오늘을 살아가기" + self.nextButton.snp.updateConstraints { + $0.bottom.equalTo(self.view.safeAreaLayoutGuide).inset(2) + $0.centerX.equalToSuperview() + $0.width.equalTo(363) } + self.showButton(self.nextButton) { } } } } @@ -354,7 +355,7 @@ final class DialogViewController: UIViewController { $0.leading.equalToSuperview().inset(165) } - [yearLabel , monthLabel, dayLabel].forEach { + [yearLabel, monthLabel, dayLabel].forEach { $0.snp.makeConstraints { $0.centerX.centerY.equalToSuperview() } @@ -380,14 +381,14 @@ final class DialogViewController: UIViewController { pastMessageView.snp.makeConstraints { $0.top.equalTo(view.safeAreaLayoutGuide).inset(228) $0.width.equalTo(343) - $0.height.equalTo(110) + $0.height.equalTo(115) $0.centerX.equalToSuperview() } presentMessageView.snp.makeConstraints { $0.top.equalTo(view.safeAreaLayoutGuide).inset(228) $0.width.equalTo(343) - $0.height.equalTo(110) + $0.height.equalTo(115) $0.centerX.equalToSuperview() } diff --git a/Deartoday/Deartoday/Screen/Dialog/View/DialogMessageView.swift b/Deartoday/Deartoday/Screen/Dialog/View/DialogMessageView.swift index 6c3e92ef..882690f6 100644 --- a/Deartoday/Deartoday/Screen/Dialog/View/DialogMessageView.swift +++ b/Deartoday/Deartoday/Screen/Dialog/View/DialogMessageView.swift @@ -74,15 +74,14 @@ final class DialogMessageView: UIView { } private func setLayout() { - addSubview(backgroundImageView) - backgroundImageView.addSubview(dialogLabel) + addSubviews([backgroundImageView, dialogLabel]) backgroundImageView.snp.makeConstraints { $0.top.leading.trailing.bottom.equalToSuperview() } dialogLabel.snp.makeConstraints { - $0.top.equalToSuperview().inset(15) + $0.top.equalToSuperview().inset(10) $0.leading.trailing.equalToSuperview().inset(35) } }