From 60dec889ea570b3561d004959e1971e761c391cf Mon Sep 17 00:00:00 2001 From: so yeon Date: Tue, 5 Sep 2023 22:58:14 +0900 Subject: [PATCH 01/10] =?UTF-8?q?[Feat]=20Wal=20Creator=20UI=20=EB=B0=8F?= =?UTF-8?q?=20=ED=82=A4=EB=B3=B4=EB=93=9C=20=EC=95=A0=EB=8B=88=EB=A9=94?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EA=B5=AC=ED=98=84=20(#141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WAL/WAL.xcodeproj/project.pbxproj | 4 + .../Extension/NSNotification.Name+.swift | 3 + WAL/WAL/Resource/Support/SceneDelegate.swift | 15 +- .../Controller/CreateViewController.swift | 6 +- .../Controller/WalCreatorViewController.swift | 396 ++++++++++++++++++ 5 files changed, 414 insertions(+), 10 deletions(-) create mode 100644 WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift diff --git a/WAL/WAL.xcodeproj/project.pbxproj b/WAL/WAL.xcodeproj/project.pbxproj index 2f89dc5c..be18b7a7 100644 --- a/WAL/WAL.xcodeproj/project.pbxproj +++ b/WAL/WAL.xcodeproj/project.pbxproj @@ -111,6 +111,7 @@ 927D10F428211017001AEB78 /* HistoryDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 927D10F328211017001AEB78 /* HistoryDataModel.swift */; }; 927D10F6282110AA001AEB78 /* HistoryTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 927D10F5282110AA001AEB78 /* HistoryTableViewCell.swift */; }; 929756A9285A4C4600A9FFA8 /* MainContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929756A8285A4C4600A9FFA8 /* MainContentView.swift */; }; + 92AD24412AA72CAF0075B48E /* WalCreatorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92AD24402AA72CAF0075B48E /* WalCreatorViewController.swift */; }; 92B152D02954569800918A3B /* MainTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92B152CF2954569800918A3B /* MainTitleView.swift */; }; 92C1B84E28633FB500F97D75 /* mintPaw.json in Resources */ = {isa = PBXBuildFile; fileRef = 92C1B84C28633FB500F97D75 /* mintPaw.json */; }; 92C1B84F28633FB500F97D75 /* orangePaw.json in Resources */ = {isa = PBXBuildFile; fileRef = 92C1B84D28633FB500F97D75 /* orangePaw.json */; }; @@ -239,6 +240,7 @@ 927D10F328211017001AEB78 /* HistoryDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryDataModel.swift; sourceTree = ""; }; 927D10F5282110AA001AEB78 /* HistoryTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryTableViewCell.swift; sourceTree = ""; }; 929756A8285A4C4600A9FFA8 /* MainContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainContentView.swift; sourceTree = ""; }; + 92AD24402AA72CAF0075B48E /* WalCreatorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalCreatorViewController.swift; sourceTree = ""; }; 92B152CF2954569800918A3B /* MainTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainTitleView.swift; sourceTree = ""; }; 92C1B84C28633FB500F97D75 /* mintPaw.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = mintPaw.json; sourceTree = ""; }; 92C1B84D28633FB500F97D75 /* orangePaw.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = orangePaw.json; sourceTree = ""; }; @@ -725,6 +727,7 @@ 5BC2DD032868DCCE00AFCC29 /* SettingCategoryViewController.swift */, 5BD3585F289D45D60066C804 /* ZanzanbariViewController.swift */, 5BD35862289D45F30066C804 /* SubController */, + 92AD24402AA72CAF0075B48E /* WalCreatorViewController.swift */, ); path = Controller; sourceTree = ""; @@ -1148,6 +1151,7 @@ 5BB3FB792857254200A8A70D /* Constant.swift in Sources */, 5B515DA52A07FBA50013F03B /* Interceptor.swift in Sources */, 5BB17B3A2865BB3000029824 /* OnboardAPI.swift in Sources */, + 92AD24412AA72CAF0075B48E /* WalCreatorViewController.swift in Sources */, 5B7EE87E2822DCB5007BC265 /* MoyaLoggerPlugin.swift in Sources */, 5B020D3F281F31B00057F9B7 /* AlarmCollectionViewCell.swift in Sources */, 9213AD072865AB67009B6002 /* HistoryService.swift in Sources */, diff --git a/WAL/WAL/Global/Extension/NSNotification.Name+.swift b/WAL/WAL/Global/Extension/NSNotification.Name+.swift index d1681841..8847ef91 100644 --- a/WAL/WAL/Global/Extension/NSNotification.Name+.swift +++ b/WAL/WAL/Global/Extension/NSNotification.Name+.swift @@ -13,4 +13,7 @@ extension NSNotification.Name { static let renewToken = Notification.Name("renewToken") static let enterMain = NSNotification.Name("EnterMain") + + static let walTextViewTapped = NSNotification.Name("WalTextViewTapped") + static let walTextViewReturn = NSNotification.Name("WalTextViewReturn") } diff --git a/WAL/WAL/Resource/Support/SceneDelegate.swift b/WAL/WAL/Resource/Support/SceneDelegate.swift index e15b1acf..716c94d2 100644 --- a/WAL/WAL/Resource/Support/SceneDelegate.swift +++ b/WAL/WAL/Resource/Support/SceneDelegate.swift @@ -21,13 +21,14 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { guard let nickname = UserDefaultsHelper.standard.nickname else { return } guard let accesstoken = UserDefaultsHelper.standard.accesstoken else { return } - if nickname != Constant.Login.nickname && accesstoken != "" { // 닉네임O, 액세스토큰O -> 자동로그인 -> 메인 - window?.rootViewController = UINavigationController(rootViewController: MainViewController()) - } else if nickname == Constant.Login.nickname && accesstoken != "" { // 닉네임X, 액세스토큰O -> 온보딩 - window?.rootViewController = UINavigationController(rootViewController: OnboardingViewController()) - } else { // 로그인 - window?.rootViewController = LoginViewController(viewModel: LoginViewModel()) - } +// if nickname != Constant.Login.nickname && accesstoken != "" { // 닉네임O, 액세스토큰O -> 자동로그인 -> 메인 +// window?.rootViewController = UINavigationController(rootViewController: MainViewController()) +// } else if nickname == Constant.Login.nickname && accesstoken != "" { // 닉네임X, 액세스토큰O -> 온보딩 +// window?.rootViewController = UINavigationController(rootViewController: OnboardingViewController()) +// } else { // 로그인 +// window?.rootViewController = LoginViewController(viewModel: LoginViewModel()) +// } + window?.rootViewController = WalCreatorViewController() window?.makeKeyAndVisible() } diff --git a/WAL/WAL/Screen/Create/Controller/CreateViewController.swift b/WAL/WAL/Screen/Create/Controller/CreateViewController.swift index a76009ea..eb53be88 100644 --- a/WAL/WAL/Screen/Create/Controller/CreateViewController.swift +++ b/WAL/WAL/Screen/Create/Controller/CreateViewController.swift @@ -282,10 +282,10 @@ class CreateViewController: UIViewController { //MARK: - CustomMethod private func setSendButton() { - let isCotentFull = walSoundTextView.text.count > 0 && datePickerData.date != nil && datePickerData.time != nil + let isContentFull = walSoundTextView.text.count > 0 && datePickerData.date != nil && datePickerData.time != nil - sendButton.backgroundColor = isCotentFull ? .orange100 : .gray400 - sendButton.isEnabled = isCotentFull + sendButton.backgroundColor = isContentFull ? .orange100 : .gray400 + sendButton.isEnabled = isContentFull } private func scroll(_ datePickerType: DatePickerType) { diff --git a/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift b/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift new file mode 100644 index 00000000..3b6914a5 --- /dev/null +++ b/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift @@ -0,0 +1,396 @@ +// +// WalCreatorViewController.swift +// WAL +// +// Created by 소연 on 2023/09/05. +// + +import UIKit + +import RxCocoa +import RxSwift +import Then +import WALKit + +final class WalCreatorViewController: UIViewController { + + // MARK: - UI Property + + private lazy var navigationBar = WALNavigationBar(title: "왈소리 크리에이터").then { + $0.backgroundColor = .white100 + $0.leftIcon = WALIcon.btnBack.image + $0.leftBarButton.addTarget(self, action: #selector(touchupBackButton), for: .touchUpInside) + } + + /* + 상단 설명 화면 + - 왈뿡이 이미지 + - 타이틀 + - 서브타이틀 + */ + private lazy var guideBackView = UIView().then { + $0.backgroundColor = .white100 + } + + private lazy var guideImageView = UIImageView().then { + $0.backgroundColor = .mint100 + } + + private lazy var guideTitleLabel = UILabel().then { + $0.textColor = .black100 + $0.font = WALFont.title05.font + $0.text = """ + 당신의 왈소리를 + 세상에 뽐내보세요 + """ + $0.textAlignment = .center + $0.numberOfLines = 0 + } + + private lazy var guideSubtitleLabel = UILabel().then { + $0.textColor = .black100 + $0.font = WALFont.body10.font + $0.text = """ + 하지만 주의하세요, 이 왈소리는 언제, 누구에게 도착할지 + 아무도 몰라요! 그때까지 긴장을 늦추지 마세요. + """ + $0.textAlignment = .center + $0.numberOfLines = 0 + } + + /* + 하단 인풋 화면 + - 왈소리 유형 + - 왈소리 작성 + */ + private lazy var walInputBackView = UIView().then { + $0.backgroundColor = .gray600 + } + + private lazy var walTypeTitleLabel = UILabel().then { + $0.textColor = .black100 + $0.font = WALFont.body4.font + $0.text = "내가 뽐낼 왈소리는 어떤 유형인가요?" + } + + private lazy var walTypeTextField = WALTextField().then { + $0.placeholder = "드립" + } + + private lazy var walTextTitleLabel = UILabel().then { + $0.textColor = .black100 + $0.font = WALFont.body4.font + $0.text = "왈소리를 뽐내주세요" + } + + private lazy var walTextView = UITextView().then { + $0.font = WALFont.body5.font + $0.textColor = .black100 + $0.backgroundColor = .white100 + $0.textContainerInset = UIEdgeInsets(top: 14, left: 16, bottom: 16, right: 16) + $0.isScrollEnabled = false + $0.layer.borderColor = UIColor.gray400.cgColor + $0.layer.borderWidth = 1 + $0.layer.cornerRadius = 10 + $0.delegate = self + } + + private let placeholderLabel = UILabel().then { + $0.textColor = .gray300 + $0.font = WALFont.body5.font + $0.text = "내가 받을 왈소리를 작성해주세요" + } + + private let countLabel = UILabel().then { + $0.textColor = .gray200 + $0.font = WALFont.body8.font + $0.text = "0" + } + + private let maximumCountLabel = UILabel().then { + $0.textColor = .gray200 + $0.font = WALFont.body8.font + $0.text = "/50" + } + + private lazy var sendButton = WALPlainButton().then { + $0.title = "보내기" + $0.isDisabled = true + $0.addTarget(self, action: #selector(touchUpSendButton), for: .touchUpInside) + } + + // 로딩 뷰 + private let loadingView = LoadingView().then { + $0.alpha = 0 + } + + // MARK: - Property + + private lazy var walTypePickerView = UIPickerView() + private var walType: [WalCategoryType] = [.comedy, .fuss, .comfort, .yell] + + // MARK: - Initializer + + init() { + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + deinit { + + } + + override func viewDidLoad() { + super.viewDidLoad() + configUI() + setupLayout() + setPickerView() + setTextField() + setToolbar() + } + + // MARK: - Init UI + + private func configUI() { + view.backgroundColor = .gray600 + + navigationController?.navigationBar.isHidden = true + navigationController?.interactivePopGestureRecognizer?.delegate = nil + + walTextView.returnKeyType = .done + + guideTitleLabel.addLineSpacing(spacing: 0.4) + guideTitleLabel.addLetterSpacing() + guideSubtitleLabel.addLineSpacing(spacing: 0.4) + guideSubtitleLabel.addLetterSpacing() + } + + private func setupLayout() { + view.addSubviews([guideBackView, navigationBar, walInputBackView, sendButton]) + navigationBar.snp.makeConstraints { + $0.top.trailing.equalTo(view.layoutMarginsGuide) + $0.leading.equalToSuperview().inset(4) + } + guideBackView.snp.makeConstraints { + $0.top.horizontalEdges.equalToSuperview() + $0.height.equalTo(389) + } + walInputBackView.snp.makeConstraints { + $0.top.equalTo(guideBackView.snp.bottom) + $0.horizontalEdges.equalToSuperview() + $0.bottom.equalTo(sendButton.snp.top) + } + sendButton.snp.makeConstraints { + $0.horizontalEdges.equalToSuperview().inset(Layouts.horizontalMargin) + $0.bottom.equalTo(view.safeAreaLayoutGuide).inset(16) + } + + setupGuideViewLayout() + setupInputViewLayout() + + } + + /// 왈소리 크리에이터 Guide UI Layout + private func setupGuideViewLayout() { + guideBackView.addSubviews([guideImageView, + guideTitleLabel, + guideSubtitleLabel]) + guideImageView.snp.makeConstraints { + $0.top.equalToSuperview().inset(110) + $0.width.equalTo(132) + $0.height.equalTo(121) + $0.centerX.equalToSuperview() + } + + guideTitleLabel.snp.makeConstraints { + $0.top.equalTo(guideImageView.snp.bottom).offset(19) + $0.centerX.equalToSuperview() + } + + guideSubtitleLabel.snp.makeConstraints { + $0.top.equalTo(guideTitleLabel.snp.bottom).offset(11) + $0.horizontalEdges.equalToSuperview().inset(20) + } + } + + /// 왈소리 유형/컨텐츠 입력 UI Layout + private func setupInputViewLayout() { + walInputBackView.addSubviews([walTypeTitleLabel, walTypeTextField, walTextTitleLabel, walTextView]) + walTypeTitleLabel.snp.makeConstraints { + $0.top.equalToSuperview().offset(26) + $0.leading.equalToSuperview().inset(Layouts.horizontalMargin) + } + walTypeTextField.snp.makeConstraints { + $0.top.equalTo(walTypeTitleLabel.snp.bottom).offset(17) + $0.horizontalEdges.equalToSuperview().inset(Layouts.horizontalMargin) + } + walTextTitleLabel.snp.makeConstraints { + $0.top.equalTo(walTypeTextField.snp.bottom).offset(20) + $0.leading.equalToSuperview().inset(Layouts.horizontalMargin) + } + walTextView.snp.makeConstraints { + $0.top.equalTo(walTextTitleLabel.snp.bottom).offset(17) + $0.horizontalEdges.equalToSuperview().inset(Layouts.horizontalMargin) + $0.height.equalTo(99) + } + } + + // MARK: - Custom Method + + private func configLoadingView() { + let loadingView = LoadingView() + view.addSubview(loadingView) + loadingView.snp.makeConstraints { make in + make.edges.equalToSuperview() + } + loadingView.play() + } + + private func setSendButton() { + let isCotentFull = walTextView.text.count > 0 + + sendButton.backgroundColor = isCotentFull ? .orange100 : .gray400 + sendButton.isEnabled = isCotentFull + } + + private func setPickerView() { + walTypePickerView.delegate = self + walTypePickerView.dataSource = self + } + + private func setTextField() { +// typeTextField.delegate = self + + walTypeTextField.tintColor = .clear + walTypeTextField.inputView = walTypePickerView + walTypeTextField.text = WalCategoryType.comedy.kor + } + + private func setToolbar() { + let toolBar = UIToolbar() + toolBar.sizeToFit() + toolBar.translatesAutoresizingMaskIntoConstraints = false + toolBar.tintColor = .orange100 + + let button = UIBarButtonItem(title: "확인", style: .done, target: self, action: #selector(touchUpDoneButton)) + let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) + + toolBar.setItems([flexibleSpace, button], animated: true) + toolBar.isUserInteractionEnabled = true + + walTypeTextField.inputAccessoryView = toolBar + } + + private func keyboardUp() { + UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseOut, animations: { + self.walInputBackView.snp.remakeConstraints { + $0.top.equalTo(self.navigationBar.snp.bottom) + $0.horizontalEdges.equalToSuperview() + $0.bottom.equalTo(self.sendButton.snp.top) + } + self.walInputBackView.superview?.layoutIfNeeded() + }) + } + + private func keyboardDown() { + UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseOut, animations: { + self.walInputBackView.snp.remakeConstraints { + $0.top.equalTo(self.guideBackView.snp.bottom) + $0.horizontalEdges.equalToSuperview() + $0.bottom.equalTo(self.sendButton.snp.top) + } + self.walInputBackView.superview?.layoutIfNeeded() + }) + } + + // MARK: - @objc + + @objc func touchupBackButton() { + navigationController?.popViewController(animated: true) + } + + @objc func touchUpSendButton() { + print("SERVER 연결") + } + + @objc func touchUpDoneButton() { + self.view.endEditing(true) + } + +} + +// MARK: - Layouts { + +extension WalCreatorViewController { + + enum Layouts { + static let horizontalMargin = 20 + } + +} + +// MARK: - UITextView Delegate + +extension WalCreatorViewController: UITextViewDelegate { + + func textViewDidEndEditing(_ textView: UITextView) { + walTextView.layer.borderColor = UIColor.gray400.cgColor + + (walTextView.text.count == 0) ? (placeholderLabel.isHidden = false) : (placeholderLabel.isHidden = true) + + keyboardDown() + } + + func textViewDidBeginEditing(_ textView: UITextView) { + walTextView.layer.borderColor = UIColor.orange100.cgColor + placeholderLabel.isHidden = true + + keyboardUp() + } + + func textViewDidChange(_ textView: UITextView) { + countLabel.text = "\(walTextView.text.count)" + + countLabel.textColor = walTextView.text.count >= 100 ? .orange100 : .gray200 + + if walTextView.text.count > 100 { + walTextView.deleteBackward() + } + + setSendButton() + } + + func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { + if text == "\n" { + walTextView.resignFirstResponder() + return false + } + return true + } + +} + +// MARK: - UIPickerView Delegate + +extension WalCreatorViewController: UIPickerViewDelegate, UIPickerViewDataSource { + + func numberOfComponents(in pickerView: UIPickerView) -> Int { + return 1 + } + + func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { + return walType.count + } + + func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { + return walType[row].kor + } + + func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { + walTypeTextField.text = walType[row].kor + } + +} From 589a1cbfe06dbbe7cc7dc7f97718baee740c8ae3 Mon Sep 17 00:00:00 2001 From: so yeon Date: Fri, 8 Sep 2023 18:31:12 +0900 Subject: [PATCH 02/10] =?UTF-8?q?[Feat]=20=ED=82=A4=EB=B3=B4=EB=93=9C=20?= =?UTF-8?q?=EC=95=A0=EB=8B=88=EB=A9=94=EC=9D=B4=EC=85=98=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95=20(#141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 하단 입력 뷰만 올라오는 방식에서 전체 뷰가 올라오는 방식으로 수정 (하단 뷰를 기준으로 위의 View의 레이아웃을 설정) --- .../Controller/WalCreatorViewController.swift | 50 +++++++++++++++---- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift b/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift index 3b6914a5..5a317074 100644 --- a/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift +++ b/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift @@ -22,6 +22,10 @@ final class WalCreatorViewController: UIViewController { $0.leftBarButton.addTarget(self, action: #selector(touchupBackButton), for: .touchUpInside) } + private lazy var navigationBackView = UIView().then { + $0.backgroundColor = .white100 + } + /* 상단 설명 화면 - 왈뿡이 이미지 @@ -169,28 +173,38 @@ final class WalCreatorViewController: UIViewController { } private func setupLayout() { - view.addSubviews([guideBackView, navigationBar, walInputBackView, sendButton]) + view.addSubviews([guideBackView, navigationBackView, navigationBar, walInputBackView, sendButton]) + guideBackView.snp.makeConstraints { + $0.bottom.equalTo(walInputBackView.snp.top) + $0.horizontalEdges.equalToSuperview() + $0.height.equalTo(389) + } + navigationBackView.snp.makeConstraints { + $0.top.horizontalEdges.equalToSuperview() + $0.height.equalTo(91) + } navigationBar.snp.makeConstraints { $0.top.trailing.equalTo(view.layoutMarginsGuide) $0.leading.equalToSuperview().inset(4) } - guideBackView.snp.makeConstraints { - $0.top.horizontalEdges.equalToSuperview() - $0.height.equalTo(389) - } walInputBackView.snp.makeConstraints { - $0.top.equalTo(guideBackView.snp.bottom) + $0.top.equalTo(navigationBar.snp.bottom).offset(298) $0.horizontalEdges.equalToSuperview() $0.bottom.equalTo(sendButton.snp.top) } sendButton.snp.makeConstraints { $0.horizontalEdges.equalToSuperview().inset(Layouts.horizontalMargin) - $0.bottom.equalTo(view.safeAreaLayoutGuide).inset(16) } setupGuideViewLayout() setupInputViewLayout() + NSLayoutConstraint.activate([ + view.keyboardLayoutGuide.topAnchor.constraint( + equalTo: sendButton.bottomAnchor, + constant: 16 + ) + ]) } /// 왈소리 크리에이터 Guide UI Layout @@ -262,7 +276,7 @@ final class WalCreatorViewController: UIViewController { } private func setTextField() { -// typeTextField.delegate = self + walTypeTextField.delegate = self walTypeTextField.tintColor = .clear walTypeTextField.inputView = walTypePickerView @@ -285,20 +299,21 @@ final class WalCreatorViewController: UIViewController { } private func keyboardUp() { - UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseOut, animations: { + UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseOut, animations: { self.walInputBackView.snp.remakeConstraints { $0.top.equalTo(self.navigationBar.snp.bottom) $0.horizontalEdges.equalToSuperview() $0.bottom.equalTo(self.sendButton.snp.top) } + self.walInputBackView.superview?.layoutIfNeeded() }) } private func keyboardDown() { - UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseOut, animations: { + UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseOut, animations: { self.walInputBackView.snp.remakeConstraints { - $0.top.equalTo(self.guideBackView.snp.bottom) + $0.top.equalTo(self.navigationBar.snp.bottom).offset(298) $0.horizontalEdges.equalToSuperview() $0.bottom.equalTo(self.sendButton.snp.top) } @@ -318,6 +333,8 @@ final class WalCreatorViewController: UIViewController { @objc func touchUpDoneButton() { self.view.endEditing(true) + keyboardDown() + walTypeTextField.layer.borderColor = UIColor.gray400.cgColor } } @@ -332,6 +349,17 @@ extension WalCreatorViewController { } +// MARK: - UITextField Delegate + +extension WalCreatorViewController: UITextFieldDelegate { + + func textFieldDidBeginEditing(_ textField: UITextField) { + keyboardUp() + walTypeTextField.layer.borderColor = UIColor.orange100.cgColor + } + +} + // MARK: - UITextView Delegate extension WalCreatorViewController: UITextViewDelegate { From a6af401042be6839f1aada6081b4b0f52ba42e4d Mon Sep 17 00:00:00 2001 From: so yeon Date: Sun, 10 Sep 2023 22:20:40 +0900 Subject: [PATCH 03/10] =?UTF-8?q?[Chore]=20=EC=8B=9C=EC=9E=91=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20=EC=88=98=EC=A0=95=20(#141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WAL/WAL/Resource/Support/SceneDelegate.swift | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/WAL/WAL/Resource/Support/SceneDelegate.swift b/WAL/WAL/Resource/Support/SceneDelegate.swift index 716c94d2..e15b1acf 100644 --- a/WAL/WAL/Resource/Support/SceneDelegate.swift +++ b/WAL/WAL/Resource/Support/SceneDelegate.swift @@ -21,14 +21,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { guard let nickname = UserDefaultsHelper.standard.nickname else { return } guard let accesstoken = UserDefaultsHelper.standard.accesstoken else { return } -// if nickname != Constant.Login.nickname && accesstoken != "" { // 닉네임O, 액세스토큰O -> 자동로그인 -> 메인 -// window?.rootViewController = UINavigationController(rootViewController: MainViewController()) -// } else if nickname == Constant.Login.nickname && accesstoken != "" { // 닉네임X, 액세스토큰O -> 온보딩 -// window?.rootViewController = UINavigationController(rootViewController: OnboardingViewController()) -// } else { // 로그인 -// window?.rootViewController = LoginViewController(viewModel: LoginViewModel()) -// } - window?.rootViewController = WalCreatorViewController() + if nickname != Constant.Login.nickname && accesstoken != "" { // 닉네임O, 액세스토큰O -> 자동로그인 -> 메인 + window?.rootViewController = UINavigationController(rootViewController: MainViewController()) + } else if nickname == Constant.Login.nickname && accesstoken != "" { // 닉네임X, 액세스토큰O -> 온보딩 + window?.rootViewController = UINavigationController(rootViewController: OnboardingViewController()) + } else { // 로그인 + window?.rootViewController = LoginViewController(viewModel: LoginViewModel()) + } window?.makeKeyAndVisible() } From f2b0ce658b37947aecb4a08f01b0ef985a8da3c8 Mon Sep 17 00:00:00 2001 From: so yeon Date: Sun, 10 Sep 2023 22:21:19 +0900 Subject: [PATCH 04/10] =?UTF-8?q?[Chore]=20=EC=84=A4=EC=A0=95=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20->=20=EC=99=88=ED=81=AC=EB=A6=AC=EC=97=90=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=ED=99=94=EB=A9=B4=20=EC=97=B0=EA=B2=B0=20(#141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Screen/Setting/Controller/SettingViewController.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/WAL/WAL/Screen/Setting/Controller/SettingViewController.swift b/WAL/WAL/Screen/Setting/Controller/SettingViewController.swift index a5577f05..38a2517b 100644 --- a/WAL/WAL/Screen/Setting/Controller/SettingViewController.swift +++ b/WAL/WAL/Screen/Setting/Controller/SettingViewController.swift @@ -113,9 +113,8 @@ extension SettingViewController: UITableViewDelegate { transition(viewController) } case 2: - print("여기 주석 처리 해제해주세요~ SettingVC 116번 줄") -// let viewController = WalCreatorViewController() -// transition(viewController) + let viewController = WalCreatorViewController() + transition(viewController) default: if indexPath.row == 0 { let viewController = ZanzanbariViewController() From eb864a1803c48bd9618a3175d42250699246532b Mon Sep 17 00:00:00 2001 From: so yeon Date: Sun, 10 Sep 2023 22:22:12 +0900 Subject: [PATCH 05/10] =?UTF-8?q?[Feat]=20Wal=20Creator=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=EC=A0=95=EB=A6=AC=20=EB=B0=8F=20count=20UI=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20(#141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcshareddata/swiftpm/Package.resolved | 11 ++- .../Controller/WalCreatorViewController.swift | 89 ++++++++++++++----- 2 files changed, 79 insertions(+), 21 deletions(-) diff --git a/WAL/WAL.xcworkspace/xcshareddata/swiftpm/Package.resolved b/WAL/WAL.xcworkspace/xcshareddata/swiftpm/Package.resolved index 2588c915..14096014 100644 --- a/WAL/WAL.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/WAL/WAL.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -9,6 +9,15 @@ "version" : "3.3.1" } }, + { + "identity" : "lottie-ios", + "kind" : "remoteSourceControl", + "location" : "https://github.com/airbnb/lottie-ios.git", + "state" : { + "revision" : "d6feea26a370019b4d3a85f5984cb95a2734776f", + "version" : "4.2.0" + } + }, { "identity" : "snapkit", "kind" : "remoteSourceControl", @@ -24,7 +33,7 @@ "location" : "https://github.com/zanzanbari/WALKit.git", "state" : { "branch" : "develop", - "revision" : "31eaa8614c9e330f7e0c54d54e95aed1fc66e536" + "revision" : "c976c62e4986561c2eac9080cabfa3aee9dd7f97" } } ], diff --git a/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift b/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift index 5a317074..b41c54c9 100644 --- a/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift +++ b/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift @@ -37,7 +37,8 @@ final class WalCreatorViewController: UIViewController { } private lazy var guideImageView = UIImageView().then { - $0.backgroundColor = .mint100 + $0.image = WALIcon.icnCreate.image + $0.contentMode = .scaleToFill } private lazy var guideTitleLabel = UILabel().then { @@ -97,26 +98,35 @@ final class WalCreatorViewController: UIViewController { $0.layer.borderWidth = 1 $0.layer.cornerRadius = 10 $0.delegate = self + $0.tintColor = .orange100 } - private let placeholderLabel = UILabel().then { + private lazy var placeholderLabel = UILabel().then { $0.textColor = .gray300 $0.font = WALFont.body5.font $0.text = "내가 받을 왈소리를 작성해주세요" } - private let countLabel = UILabel().then { + private lazy var countLabel = UILabel().then { $0.textColor = .gray200 $0.font = WALFont.body8.font $0.text = "0" } - private let maximumCountLabel = UILabel().then { + private lazy var maximumCountLabel = UILabel().then { $0.textColor = .gray200 $0.font = WALFont.body8.font $0.text = "/50" } + private lazy var countStackView = UIStackView().then { + $0.axis = .horizontal + $0.alignment = .fill + $0.distribution = .fill + $0.spacing = 0 + $0.addArrangedSubviews([countLabel, maximumCountLabel]) + } + private lazy var sendButton = WALPlainButton().then { $0.title = "보내기" $0.isDisabled = true @@ -128,9 +138,15 @@ final class WalCreatorViewController: UIViewController { $0.alpha = 0 } + private lazy var walTypePickerView = UIPickerView().then { + $0.delegate = self + $0.dataSource = self + $0.autoresizingMask = .flexibleWidth + $0.backgroundColor = .gray500 + } + // MARK: - Property - private lazy var walTypePickerView = UIPickerView() private var walType: [WalCategoryType] = [.comedy, .fuss, .comfort, .yell] // MARK: - Initializer @@ -151,7 +167,6 @@ final class WalCreatorViewController: UIViewController { super.viewDidLoad() configUI() setupLayout() - setPickerView() setTextField() setToolbar() } @@ -173,7 +188,12 @@ final class WalCreatorViewController: UIViewController { } private func setupLayout() { - view.addSubviews([guideBackView, navigationBackView, navigationBar, walInputBackView, sendButton]) + view.addSubviews([guideBackView, + navigationBackView, + navigationBar, + walInputBackView, + sendButton]) + guideBackView.snp.makeConstraints { $0.bottom.equalTo(walInputBackView.snp.top) $0.horizontalEdges.equalToSuperview() @@ -212,10 +232,11 @@ final class WalCreatorViewController: UIViewController { guideBackView.addSubviews([guideImageView, guideTitleLabel, guideSubtitleLabel]) + guideImageView.snp.makeConstraints { $0.top.equalToSuperview().inset(110) - $0.width.equalTo(132) - $0.height.equalTo(121) + $0.width.equalTo(188) + $0.height.equalTo(122) $0.centerX.equalToSuperview() } @@ -226,13 +247,18 @@ final class WalCreatorViewController: UIViewController { guideSubtitleLabel.snp.makeConstraints { $0.top.equalTo(guideTitleLabel.snp.bottom).offset(11) - $0.horizontalEdges.equalToSuperview().inset(20) + $0.horizontalEdges.equalToSuperview().inset(Layouts.horizontalMargin) } } /// 왈소리 유형/컨텐츠 입력 UI Layout private func setupInputViewLayout() { - walInputBackView.addSubviews([walTypeTitleLabel, walTypeTextField, walTextTitleLabel, walTextView]) + walInputBackView.addSubviews([walTypeTitleLabel, + walTypeTextField, + walTextTitleLabel, + walTextView, + countStackView]) + walTypeTitleLabel.snp.makeConstraints { $0.top.equalToSuperview().offset(26) $0.leading.equalToSuperview().inset(Layouts.horizontalMargin) @@ -250,6 +276,10 @@ final class WalCreatorViewController: UIViewController { $0.horizontalEdges.equalToSuperview().inset(Layouts.horizontalMargin) $0.height.equalTo(99) } + countStackView.snp.makeConstraints { + $0.bottom.equalTo(walTextView.snp.bottom).inset(10) + $0.trailing.equalTo(walTextView.snp.trailing).inset(17) + } } // MARK: - Custom Method @@ -270,11 +300,6 @@ final class WalCreatorViewController: UIViewController { sendButton.isEnabled = isCotentFull } - private func setPickerView() { - walTypePickerView.delegate = self - walTypePickerView.dataSource = self - } - private func setTextField() { walTypeTextField.delegate = self @@ -344,6 +369,7 @@ final class WalCreatorViewController: UIViewController { extension WalCreatorViewController { enum Layouts { + /// 좌/우 static let horizontalMargin = 20 } @@ -382,9 +408,9 @@ extension WalCreatorViewController: UITextViewDelegate { func textViewDidChange(_ textView: UITextView) { countLabel.text = "\(walTextView.text.count)" - countLabel.textColor = walTextView.text.count >= 100 ? .orange100 : .gray200 + countLabel.textColor = walTextView.text.count >= 50 ? .orange100 : .gray200 - if walTextView.text.count > 100 { + if walTextView.text.count > 50 { walTextView.deleteBackward() } @@ -413,12 +439,35 @@ extension WalCreatorViewController: UIPickerViewDelegate, UIPickerViewDataSource return walType.count } - func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { - return walType[row].kor + func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView { + let label = (view as? UILabel) ?? UILabel() + + label.textAlignment = .center + + if pickerView.selectedRow(inComponent: component) == row { + label.attributedText = NSAttributedString(string: walType[row].kor, + attributes: [NSAttributedString.Key.font: WALFont.body2.font, + NSAttributedString.Key.foregroundColor: UIColor.orange100]) + } else { + label.attributedText = NSAttributedString(string: walType[row].kor, + attributes: [NSAttributedString.Key.font: WALFont.body2.font, + NSAttributedString.Key.foregroundColor: UIColor.gray100]) + } + + return label + } + + func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat { + return 44 + } + + func pickerView(_ pickerView: UIPickerView, widthForComponent component: Int) -> CGFloat { + return 200 } func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { walTypeTextField.text = walType[row].kor + pickerView.reloadAllComponents() } } From 694be07f0a82c0d2b1c06c8cd22c3cc3bb632968 Mon Sep 17 00:00:00 2001 From: so yeon Date: Sun, 5 Nov 2023 15:33:31 +0900 Subject: [PATCH 06/10] =?UTF-8?q?[Feat]=20Podfile=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=B0=8F=20TextField=20=ED=99=9C=EC=84=B1=ED=99=94=20=EC=A1=B0?= =?UTF-8?q?=EA=B1=B4=20=EC=B6=94=EA=B0=80(#141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Xcode 업데이트 이후, 툴체인 오류 해결을 위한 Podfile 버전 수정, 왈소리 카테고리 TextField 활성/비활성 조건 추가 --- WAL/Podfile.lock | 102 +++++++++--------- WAL/WAL.xcodeproj/project.pbxproj | 12 +++ .../Controller/SettingViewController.swift | 11 +- .../Controller/WalCreatorViewController.swift | 5 + .../ViewModel/WalCreatorViewModel.swift | 8 ++ 5 files changed, 86 insertions(+), 52 deletions(-) create mode 100644 WAL/WAL/Screen/Setting/ViewModel/WalCreatorViewModel.swift diff --git a/WAL/Podfile.lock b/WAL/Podfile.lock index e3c9c407..74c4be2d 100644 --- a/WAL/Podfile.lock +++ b/WAL/Podfile.lock @@ -1,22 +1,22 @@ PODS: - - Alamofire (5.6.4) - - Firebase/CoreOnly (10.9.0): - - FirebaseCore (= 10.9.0) - - Firebase/Messaging (10.9.0): + - Alamofire (5.8.1) + - Firebase/CoreOnly (10.17.0): + - FirebaseCore (= 10.17.0) + - Firebase/Messaging (10.17.0): - Firebase/CoreOnly - - FirebaseMessaging (~> 10.9.0) - - FirebaseCore (10.9.0): + - FirebaseMessaging (~> 10.17.0) + - FirebaseCore (10.17.0): - FirebaseCoreInternal (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - GoogleUtilities/Logger (~> 7.8) - - FirebaseCoreInternal (10.9.0): + - FirebaseCoreInternal (10.17.0): - "GoogleUtilities/NSData+zlib (~> 7.8)" - - FirebaseInstallations (10.9.0): + - FirebaseInstallations (10.17.0): - FirebaseCore (~> 10.0) - GoogleUtilities/Environment (~> 7.8) - GoogleUtilities/UserDefaults (~> 7.8) - PromisesObjC (~> 2.1) - - FirebaseMessaging (10.9.0): + - FirebaseMessaging (10.17.0): - FirebaseCore (~> 10.0) - FirebaseInstallations (~> 10.0) - GoogleDataTransport (~> 9.2) @@ -25,50 +25,50 @@ PODS: - GoogleUtilities/Reachability (~> 7.8) - GoogleUtilities/UserDefaults (~> 7.8) - nanopb (< 2.30910.0, >= 2.30908.0) - - GoogleDataTransport (9.2.2): + - GoogleDataTransport (9.2.5): - GoogleUtilities/Environment (~> 7.7) - nanopb (< 2.30910.0, >= 2.30908.0) - PromisesObjC (< 3.0, >= 1.2) - - GoogleUtilities/AppDelegateSwizzler (7.11.1): + - GoogleUtilities/AppDelegateSwizzler (7.11.6): - GoogleUtilities/Environment - GoogleUtilities/Logger - GoogleUtilities/Network - - GoogleUtilities/Environment (7.11.1): + - GoogleUtilities/Environment (7.11.6): - PromisesObjC (< 3.0, >= 1.2) - - GoogleUtilities/Logger (7.11.1): + - GoogleUtilities/Logger (7.11.6): - GoogleUtilities/Environment - - GoogleUtilities/Network (7.11.1): + - GoogleUtilities/Network (7.11.6): - GoogleUtilities/Logger - "GoogleUtilities/NSData+zlib" - GoogleUtilities/Reachability - - "GoogleUtilities/NSData+zlib (7.11.1)" - - GoogleUtilities/Reachability (7.11.1): + - "GoogleUtilities/NSData+zlib (7.11.6)" + - GoogleUtilities/Reachability (7.11.6): - GoogleUtilities/Logger - - GoogleUtilities/UserDefaults (7.11.1): + - GoogleUtilities/UserDefaults (7.11.6): - GoogleUtilities/Logger - - KakaoSDKAuth (2.15.0): - - KakaoSDKCommon (= 2.15.0) - - KakaoSDKCommon (2.15.0): - - KakaoSDKCommon/Common (= 2.15.0) - - KakaoSDKCommon/Network (= 2.15.0) - - KakaoSDKCommon/Common (2.15.0) - - KakaoSDKCommon/Network (2.15.0): + - KakaoSDKAuth (2.18.2): + - KakaoSDKCommon (= 2.18.2) + - KakaoSDKCommon (2.18.2): + - KakaoSDKCommon/Common (= 2.18.2) + - KakaoSDKCommon/Network (= 2.18.2) + - KakaoSDKCommon/Common (2.18.2) + - KakaoSDKCommon/Network (2.18.2): - Alamofire (~> 5.1) - - KakaoSDKCommon/Common (= 2.15.0) - - KakaoSDKUser (2.15.0): - - KakaoSDKAuth (= 2.15.0) - - Kingfisher (7.6.2) - - lottie-ios (4.2.0) + - KakaoSDKCommon/Common (= 2.18.2) + - KakaoSDKUser (2.18.2): + - KakaoSDKAuth (= 2.18.2) + - Kingfisher (7.10.0) + - lottie-ios (4.3.3) - Moya (14.0.0): - Moya/Core (= 14.0.0) - Moya/Core (14.0.0): - Alamofire (~> 5.0) - - nanopb (2.30909.0): - - nanopb/decode (= 2.30909.0) - - nanopb/encode (= 2.30909.0) - - nanopb/decode (2.30909.0) - - nanopb/encode (2.30909.0) - - PromisesObjC (2.2.0) + - nanopb (2.30909.1): + - nanopb/decode (= 2.30909.1) + - nanopb/encode (= 2.30909.1) + - nanopb/decode (2.30909.1) + - nanopb/encode (2.30909.1) + - PromisesObjC (2.3.1) - RxCocoa (6.5.0): - RxRelay (= 6.5.0) - RxSwift (= 6.5.0) @@ -113,22 +113,22 @@ SPEC REPOS: - Then SPEC CHECKSUMS: - Alamofire: 4e95d97098eacb88856099c4fc79b526a299e48c - Firebase: bd152f0f3d278c4060c5c71359db08ebcfd5a3e2 - FirebaseCore: b68d3616526ec02e4d155166bbafb8eca64af557 - FirebaseCoreInternal: d2b4acb827908e72eca47a9fd896767c3053921e - FirebaseInstallations: c58489c9caacdbf27d1da60891a87318e20218e0 - FirebaseMessaging: 6b7052cc3da7bc8e5f72bef871243e8f04a14eed - GoogleDataTransport: 8378d1fa8ac49753ea6ce70d65a7cb70ce5f66e6 - GoogleUtilities: 9aa0ad5a7bc171f8bae016300bfcfa3fb8425749 - KakaoSDKAuth: 0fe5cf1756e8a9f66f8fc77826061aafa93034f3 - KakaoSDKCommon: 89d863b7f34398e6fb93a0acb28a204908551a39 - KakaoSDKUser: a997ca5c4c18ece2ab30646ff74841bc29d4399d - Kingfisher: 6c5449c6450c5239166510ba04afe374a98afc4f - lottie-ios: 809ecf2d460ed650a6aed7aa88b2ec45fab4779c + Alamofire: 3ca42e259043ee0dc5c0cdd76c4bc568b8e42af7 + Firebase: f4ac0b02927af9253ae094d23deecf0890da7374 + FirebaseCore: 534544dd98cabcf4bf8598d88ec683b02319a528 + FirebaseCoreInternal: 2cf9202e226e3f78d2bf6d56c472686b935bfb7f + FirebaseInstallations: 9387bf15abfc69a714f54e54f74a251264fdb79b + FirebaseMessaging: 1367b28c0c83a63072af4a711328fcc2e6899902 + GoogleDataTransport: 54dee9d48d14580407f8f5fbf2f496e92437a2f2 + GoogleUtilities: 202e7a9f5128accd11160fb9c19612de1911aa19 + KakaoSDKAuth: 3daf72ec463876e0fe6d0d37c7d6b0b2729169f1 + KakaoSDKCommon: 516f68bc6b223ed502c34a362d6ecc9145e0dcc0 + KakaoSDKUser: 5b0826033381d314f550dd90fbf70d3612044ad6 + Kingfisher: a18f05d3b6d37d8650ee4a3e61d57a28fc6207f6 + lottie-ios: 25e7b2675dad5c3ddad369ac9baab03560c5bfdd Moya: 5b45dacb75adb009f97fde91c204c1e565d31916 - nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431 - PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef + nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5 + PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4 RxCocoa: 94f817b71c07517321eb4f9ad299112ca8af743b RxRelay: 1de1523e604c72b6c68feadedd1af3b1b4d0ecbd RxSwift: 5710a9e6b17f3c3d6e40d6e559b9fa1e813b2ef8 @@ -136,4 +136,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 18f68ce9c38692309069cdcaeca1009aa5c19352 -COCOAPODS: 1.12.1 +COCOAPODS: 1.14.2 diff --git a/WAL/WAL.xcodeproj/project.pbxproj b/WAL/WAL.xcodeproj/project.pbxproj index be18b7a7..f0002b84 100644 --- a/WAL/WAL.xcodeproj/project.pbxproj +++ b/WAL/WAL.xcodeproj/project.pbxproj @@ -96,6 +96,7 @@ 9213AD042865A93A009B6002 /* HistoryResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9213AD032865A93A009B6002 /* HistoryResponse.swift */; }; 9213AD072865AB67009B6002 /* HistoryService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9213AD062865AB67009B6002 /* HistoryService.swift */; }; 9213AD0A2865ADBC009B6002 /* HistoryAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9213AD092865ADBC009B6002 /* HistoryAPI.swift */; }; + 921D34DD2AF6472A00419B3E /* WalCreatorViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 921D34DC2AF6472A00419B3E /* WalCreatorViewModel.swift */; }; 924B60FD28A7D1E4002804B1 /* WalStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 924B60FC28A7D1E4002804B1 /* WalStatus.swift */; }; 925D13F929F95FB00024F0E5 /* BaseResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 925D13F829F95FB00024F0E5 /* BaseResponse.swift */; }; 925D13FB29FABF220024F0E5 /* WalCategoryType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 925D13FA29FABF220024F0E5 /* WalCategoryType.swift */; }; @@ -224,6 +225,7 @@ 9213AD032865A93A009B6002 /* HistoryResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryResponse.swift; sourceTree = ""; }; 9213AD062865AB67009B6002 /* HistoryService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryService.swift; sourceTree = ""; }; 9213AD092865ADBC009B6002 /* HistoryAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryAPI.swift; sourceTree = ""; }; + 921D34DC2AF6472A00419B3E /* WalCreatorViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalCreatorViewModel.swift; sourceTree = ""; }; 92322AAD28049C2C002E281F /* WAL.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WAL.entitlements; sourceTree = ""; }; 924B60FC28A7D1E4002804B1 /* WalStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalStatus.swift; sourceTree = ""; }; 925D13F829F95FB00024F0E5 /* BaseResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseResponse.swift; sourceTree = ""; }; @@ -695,6 +697,7 @@ 5BD17417282CDD0200C77A95 /* Model */, 5BD17414282CDCCD00C77A95 /* View */, 5BD1741A282CDD1C00C77A95 /* Controller */, + 921D34DB2AF6470B00419B3E /* ViewModel */, ); path = Setting; sourceTree = ""; @@ -795,6 +798,14 @@ path = History; sourceTree = ""; }; + 921D34DB2AF6470B00419B3E /* ViewModel */ = { + isa = PBXGroup; + children = ( + 921D34DC2AF6472A00419B3E /* WalCreatorViewModel.swift */, + ); + path = ViewModel; + sourceTree = ""; + }; 925D13F729F95F920024F0E5 /* Protocol */ = { isa = PBXGroup; children = ( @@ -1095,6 +1106,7 @@ 5BA3896727F6C28C0010EAA1 /* AuthService.swift in Sources */, 5BC2DD042868DCCE00AFCC29 /* SettingCategoryViewController.swift in Sources */, 925D13FD29FABF360024F0E5 /* AlarmTimeType.swift in Sources */, + 921D34DD2AF6472A00419B3E /* WalCreatorViewModel.swift in Sources */, 5BC2DD0D2868E75100AFCC29 /* ResignViewController.swift in Sources */, 5B44E57F28A6BCED000ABF0C /* SettingService.swift in Sources */, 927519AF29815A6B0010022A /* MainViewModel.swift in Sources */, diff --git a/WAL/WAL/Screen/Setting/Controller/SettingViewController.swift b/WAL/WAL/Screen/Setting/Controller/SettingViewController.swift index 38a2517b..f5efe291 100644 --- a/WAL/WAL/Screen/Setting/Controller/SettingViewController.swift +++ b/WAL/WAL/Screen/Setting/Controller/SettingViewController.swift @@ -39,6 +39,11 @@ final class SettingViewController: UIViewController, SendNicknameDelegate { // MARK: - Life Cycle + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + configNavigationUI() + } + override func viewDidLoad() { super.viewDidLoad() configUI() @@ -49,12 +54,16 @@ final class SettingViewController: UIViewController, SendNicknameDelegate { // MARK: - InitUI + private func configNavigationUI() { + navigationController?.navigationBar.isHidden = true + } + private func configUI() { view.backgroundColor = .white100 } private func setupLayout() { - view.addSubviews([navigationBar, tableView, backView]) + view.addSubviews([navigationBar, backView, tableView]) navigationBar.snp.makeConstraints { make in make.top.equalTo(view.safeAreaLayoutGuide) diff --git a/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift b/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift index b41c54c9..f7982726 100644 --- a/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift +++ b/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift @@ -384,6 +384,11 @@ extension WalCreatorViewController: UITextFieldDelegate { walTypeTextField.layer.borderColor = UIColor.orange100.cgColor } + func textFieldDidEndEditing(_ textField: UITextField) { + keyboardDown() + walTypeTextField.layer.borderColor = UIColor.gray400.cgColor + } + } // MARK: - UITextView Delegate diff --git a/WAL/WAL/Screen/Setting/ViewModel/WalCreatorViewModel.swift b/WAL/WAL/Screen/Setting/ViewModel/WalCreatorViewModel.swift new file mode 100644 index 00000000..e3ea271d --- /dev/null +++ b/WAL/WAL/Screen/Setting/ViewModel/WalCreatorViewModel.swift @@ -0,0 +1,8 @@ +// +// WalCreatorViewModel.swift +// WAL +// +// Created by 소연 on 2023/11/04. +// + +import Foundation From 8a09b448ffc55a3acbc4fe4b448cf423d5245c40 Mon Sep 17 00:00:00 2001 From: so yeon Date: Sun, 12 Nov 2023 01:40:49 +0900 Subject: [PATCH 07/10] =?UTF-8?q?[Fix]=20=EC=99=88=EC=86=8C=EB=A6=AC=20?= =?UTF-8?q?=ED=81=AC=EB=A6=AC=EC=97=90=EC=9D=B4=ED=84=B0=20=ED=8F=B0?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95=20(#141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Screen/Setting/Controller/WalCreatorViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift b/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift index f7982726..3dc139ec 100644 --- a/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift +++ b/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift @@ -54,7 +54,7 @@ final class WalCreatorViewController: UIViewController { private lazy var guideSubtitleLabel = UILabel().then { $0.textColor = .black100 - $0.font = WALFont.body10.font + $0.font = WALFont.body9.font $0.text = """ 하지만 주의하세요, 이 왈소리는 언제, 누구에게 도착할지 아무도 몰라요! 그때까지 긴장을 늦추지 마세요. From f64276646cf5378464b0e786067c2fe5a9bad83f Mon Sep 17 00:00:00 2001 From: so yeon Date: Sun, 12 Nov 2023 01:42:09 +0900 Subject: [PATCH 08/10] =?UTF-8?q?[Fix]=20=EC=99=88=20=ED=9E=88=EC=8A=A4?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EB=94=94=EB=8D=B0=EC=9D=B4=20=ED=8F=B0?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95=20(#141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WAL/WAL/Screen/History/View/HistoryTableViewCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WAL/WAL/Screen/History/View/HistoryTableViewCell.swift b/WAL/WAL/Screen/History/View/HistoryTableViewCell.swift index 2b1b7a01..86a8fa98 100644 --- a/WAL/WAL/Screen/History/View/HistoryTableViewCell.swift +++ b/WAL/WAL/Screen/History/View/HistoryTableViewCell.swift @@ -57,7 +57,7 @@ class HistoryTableViewCell: UITableViewCell { var dDayLabel = UILabel().then { $0.text = "D-6" - $0.font = WALFont.body8.font + $0.font = WALFont.body10.font $0.textColor = .mint100 } From e0ee23c606096aa3e333703191f6de3c61657ab7 Mon Sep 17 00:00:00 2001 From: so yeon Date: Sun, 12 Nov 2023 01:53:12 +0900 Subject: [PATCH 09/10] =?UTF-8?q?[Feat]=20WalCreator=20API=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Setting API/Service 수정 및 WalCreator Request 구조체 추가 --- WAL/WAL.xcodeproj/project.pbxproj | 4 +++ WAL/WAL/Network/API/Setting/SettingAPI.swift | 32 ++++++++++++------- .../DataModel/Setting/WalCreatorRequest.swift | 13 ++++++++ .../Service/Setting/SettingService.swift | 6 +++- 4 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 WAL/WAL/Network/DataModel/Setting/WalCreatorRequest.swift diff --git a/WAL/WAL.xcodeproj/project.pbxproj b/WAL/WAL.xcodeproj/project.pbxproj index f0002b84..cc3be149 100644 --- a/WAL/WAL.xcodeproj/project.pbxproj +++ b/WAL/WAL.xcodeproj/project.pbxproj @@ -105,6 +105,7 @@ 926480FF2A34BB91007DEC0B /* CustomIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 926480FE2A34BB91007DEC0B /* CustomIndicator.swift */; }; 926A2A132A02A85F005DDCEA /* MainSubtitle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 926A2A122A02A85F005DDCEA /* MainSubtitle.swift */; }; 926A2A152A054BF9005DDCEA /* MainSubtitleStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 926A2A142A054BF9005DDCEA /* MainSubtitleStatus.swift */; }; + 926E1BBB2AF77761003BE5AF /* WalCreatorRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 926E1BBA2AF77761003BE5AF /* WalCreatorRequest.swift */; }; 927519AF29815A6B0010022A /* MainViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 927519AE29815A6B0010022A /* MainViewModel.swift */; }; 927D10EE28210F81001AEB78 /* HistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 927D10ED28210F81001AEB78 /* HistoryViewController.swift */; }; 927D10F028210FD1001AEB78 /* HistoryReserveHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 927D10EF28210FD1001AEB78 /* HistoryReserveHeaderView.swift */; }; @@ -235,6 +236,7 @@ 926480FE2A34BB91007DEC0B /* CustomIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomIndicator.swift; sourceTree = ""; }; 926A2A122A02A85F005DDCEA /* MainSubtitle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainSubtitle.swift; sourceTree = ""; }; 926A2A142A054BF9005DDCEA /* MainSubtitleStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainSubtitleStatus.swift; sourceTree = ""; }; + 926E1BBA2AF77761003BE5AF /* WalCreatorRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalCreatorRequest.swift; sourceTree = ""; }; 927519AE29815A6B0010022A /* MainViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewModel.swift; sourceTree = ""; }; 927D10ED28210F81001AEB78 /* HistoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryViewController.swift; sourceTree = ""; }; 927D10EF28210FD1001AEB78 /* HistoryReserveHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryReserveHeaderView.swift; sourceTree = ""; }; @@ -379,6 +381,7 @@ 5B44E58528A6C846000ABF0C /* UserAlarm.swift */, 5B44E58728A6C881000ABF0C /* UserCategory.swift */, 5B44E58928A6D044000ABF0C /* UserRequest.swift */, + 926E1BBA2AF77761003BE5AF /* WalCreatorRequest.swift */, ); path = Setting; sourceTree = ""; @@ -1157,6 +1160,7 @@ 5BECCA8F286A43B800DD70A3 /* MenuButton.swift in Sources */, 925D13FF29FAC29B0024F0E5 /* UICollectionViewCell+.swift in Sources */, 5B422BA228676CF8001B6807 /* (null) in Sources */, + 926E1BBB2AF77761003BE5AF /* WalCreatorRequest.swift in Sources */, 5B44E58A28A6D044000ABF0C /* UserRequest.swift in Sources */, 5BB6616828285A5B00D54353 /* TimeButton.swift in Sources */, 5BD17419282CDD0A00C77A95 /* Setting.swift in Sources */, diff --git a/WAL/WAL/Network/API/Setting/SettingAPI.swift b/WAL/WAL/Network/API/Setting/SettingAPI.swift index 9aac9d30..fffa2308 100644 --- a/WAL/WAL/Network/API/Setting/SettingAPI.swift +++ b/WAL/WAL/Network/API/Setting/SettingAPI.swift @@ -25,8 +25,7 @@ final class SettingAPI { private(set) var alarm: UserAlarm? private(set) var category: UserCategory? - // MARK: - GET 유저 닉네임 조회하기 - + /// 닉네임 조회하기 (GET) func getUserInfo(completion: @escaping completion) { settingProvider.request(.checkNickname) { [weak self] result in guard let self else { return } @@ -47,8 +46,7 @@ final class SettingAPI { } } - // MARK: - GET 알림 시간 조회하기 - + /// 알림 시간 조회하기 (GET) func getAlarm(completion: @escaping alarmCompletion) { settingProvider.request(.checkAlarm) { [weak self] result in guard let self else { return } @@ -69,8 +67,7 @@ final class SettingAPI { } } - // MARK: - GET 카테고리 조회하기 - + /// 카테고리 조회하기 (GET) func getCategory(completion: @escaping categoryCompletion) { settingProvider.request(.checkCategory) { result in switch result { @@ -90,8 +87,7 @@ final class SettingAPI { } } - // MARK: - POST 유저 닉네임 수정하기 - + /// 유저 닉네임 수정하기 (POST) func postUserInfo(nickname: String, completion: @escaping completion) { settingProvider.request(.editNickname(nickname)) { [weak self] result in guard let self else { return } @@ -106,8 +102,7 @@ final class SettingAPI { } } - // MARK: - POST 알림 시간 수정하기 - + /// 알림 시간 수정하기 (POST) func postAlarm(data: [String], completion: @escaping defaultCompletion) { let param = UserAlarmRequest(timeTypes: data) @@ -124,8 +119,7 @@ final class SettingAPI { } } - // MARK: - POST 카테고리 수정하기 - + /// 카테고리 수정하기 (POST) func postCategory(data: [String], completion: @escaping categoryCompletion) { let param = UserCategoryRequest(categoryTypes: data) @@ -141,4 +135,18 @@ final class SettingAPI { } } } + + /// 왈소리 만들기 (POST) + func postWal(param: WalCreatorRequest, completion: @escaping defaultCompletion) { + settingProvider.request(.walCreator(param)) { result in + switch result { + case .success(let response): + completion(nil, response.statusCode) + case .failure(let error): + print("[왈소리 만들기] DEBUG: - \(error.localizedDescription)") + completion(nil, error.response?.statusCode) + } + } + } + } diff --git a/WAL/WAL/Network/DataModel/Setting/WalCreatorRequest.swift b/WAL/WAL/Network/DataModel/Setting/WalCreatorRequest.swift new file mode 100644 index 00000000..8312cc1e --- /dev/null +++ b/WAL/WAL/Network/DataModel/Setting/WalCreatorRequest.swift @@ -0,0 +1,13 @@ +// +// WalCreatorRequest.swift +// WAL +// +// Created by 소연 on 2023/11/05. +// + +import Foundation + +struct WalCreatorRequest: Codable { + let categoryType: String + let contents: String +} diff --git a/WAL/WAL/Network/Service/Setting/SettingService.swift b/WAL/WAL/Network/Service/Setting/SettingService.swift index 6b2793a1..dbb30f48 100644 --- a/WAL/WAL/Network/Service/Setting/SettingService.swift +++ b/WAL/WAL/Network/Service/Setting/SettingService.swift @@ -14,6 +14,7 @@ enum SettingService { case editNickname(String) case editAlarm(UserAlarmRequest) case editCategory(UserCategoryRequest) + case walCreator(WalCreatorRequest) } extension SettingService: BaseTargetType { @@ -26,6 +27,7 @@ extension SettingService: BaseTargetType { case .editNickname: return "/user/me/nickname/edit" case .editAlarm: return "/onboard/time/edit" case .editCategory: return "/onboard/category/edit" + case .walCreator: return "/censor/create" } } @@ -33,7 +35,7 @@ extension SettingService: BaseTargetType { switch self { case .checkNickname, .checkAlarm, .checkCategory: return .get case .editNickname: return .patch - case .editAlarm, .editCategory: return .post + case .editAlarm, .editCategory, .walCreator: return .post } } @@ -47,6 +49,8 @@ extension SettingService: BaseTargetType { return .requestJSONEncodable(param) case .editCategory(let param): return .requestJSONEncodable(param) + case .walCreator(let param): + return .requestJSONEncodable(param) } } } From 1752828fc95c28643d76341a3e4490c3235f34aa Mon Sep 17 00:00:00 2001 From: so yeon Date: Sun, 12 Nov 2023 15:13:39 +0900 Subject: [PATCH 10/10] =?UTF-8?q?[Feat]=20WalCreatorAPI=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0=20(#146)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 서버 배포 후 다시 테스트 필요 (현재 statusCode 500 내려오는 중) --- .../Controller/WalCreatorViewController.swift | 62 +++++++-- .../ViewModel/WalCreatorViewModel.swift | 120 ++++++++++++++++++ 2 files changed, 172 insertions(+), 10 deletions(-) diff --git a/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift b/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift index 3dc139ec..94259d01 100644 --- a/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift +++ b/WAL/WAL/Screen/Setting/Controller/WalCreatorViewController.swift @@ -19,7 +19,6 @@ final class WalCreatorViewController: UIViewController { private lazy var navigationBar = WALNavigationBar(title: "왈소리 크리에이터").then { $0.backgroundColor = .white100 $0.leftIcon = WALIcon.btnBack.image - $0.leftBarButton.addTarget(self, action: #selector(touchupBackButton), for: .touchUpInside) } private lazy var navigationBackView = UIView().then { @@ -130,7 +129,6 @@ final class WalCreatorViewController: UIViewController { private lazy var sendButton = WALPlainButton().then { $0.title = "보내기" $0.isDisabled = true - $0.addTarget(self, action: #selector(touchUpSendButton), for: .touchUpInside) } // 로딩 뷰 @@ -148,6 +146,10 @@ final class WalCreatorViewController: UIViewController { // MARK: - Property private var walType: [WalCategoryType] = [.comedy, .fuss, .comfort, .yell] + private var selectedWalType: WalCategoryType = .comedy + + private let viewModel = WalCreatorViewModel() + private let disposeBag = DisposeBag() // MARK: - Initializer @@ -165,10 +167,14 @@ final class WalCreatorViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + configUI() setupLayout() setTextField() setToolbar() + + rxBindOutput() + rxBindView() } // MARK: - Init UI @@ -282,6 +288,49 @@ final class WalCreatorViewController: UIViewController { } } + // MARK: - RxBind + + private func rxBindOutput() { + viewModel.output.wal + .asDriver(onErrorDriveWith: .empty()) + .drive(with: self) { owner, result in + switch result { + case .created: + owner.navigationController?.popViewController(animated: true) + default: + owner.navigationController?.popViewController(animated: true) + return + } + } + .disposed(by: disposeBag) + } + + private func rxBindView() { + navigationBar.leftBarButton + .rx + .tap + .preventDuplication() + .asDriver(onErrorDriveWith: .empty()) + .drive(with: self) { owner, _ in + owner.navigationController?.popViewController(animated: true) + } + .disposed(by: disposeBag) + + sendButton + .rx + .tap + .preventDuplication() + .asDriver(onErrorDriveWith: .empty()) + .drive(with: self) { owner, _ in + owner.viewModel.input.postWal.accept((owner.selectedWalType, owner.walTextView.text)) + } + .disposed(by: disposeBag) + } + + private func rxBindInput() { + + } + // MARK: - Custom Method private func configLoadingView() { @@ -348,14 +397,6 @@ final class WalCreatorViewController: UIViewController { // MARK: - @objc - @objc func touchupBackButton() { - navigationController?.popViewController(animated: true) - } - - @objc func touchUpSendButton() { - print("SERVER 연결") - } - @objc func touchUpDoneButton() { self.view.endEditing(true) keyboardDown() @@ -453,6 +494,7 @@ extension WalCreatorViewController: UIPickerViewDelegate, UIPickerViewDataSource label.attributedText = NSAttributedString(string: walType[row].kor, attributes: [NSAttributedString.Key.font: WALFont.body2.font, NSAttributedString.Key.foregroundColor: UIColor.orange100]) + selectedWalType = walType[row] } else { label.attributedText = NSAttributedString(string: walType[row].kor, attributes: [NSAttributedString.Key.font: WALFont.body2.font, diff --git a/WAL/WAL/Screen/Setting/ViewModel/WalCreatorViewModel.swift b/WAL/WAL/Screen/Setting/ViewModel/WalCreatorViewModel.swift index e3ea271d..bbfcabaa 100644 --- a/WAL/WAL/Screen/Setting/ViewModel/WalCreatorViewModel.swift +++ b/WAL/WAL/Screen/Setting/ViewModel/WalCreatorViewModel.swift @@ -6,3 +6,123 @@ // import Foundation + +import RxSwift +import RxCocoa + +final class WalCreatorViewModel { + + // MARK: - Essential + + private(set) var input = Input() + private(set) var output = Output() + private(set) var bothways = Bothways() + private(set) var dependency = Dependency() + // private(set) var load: Load // info, load, initialize + + // MARK: - Properties + + private let disposeBag = DisposeBag() + + // MARK: - Life Cycle + + init() { + rxBind() + } + + // init(load: Load) { + // self.load = load + // + // rxBind() + // } + + // MARK: - Helpers + + private func rxBind() { + input.postWal + .bind(with: self) { owner, args in + let (type, contents) = args + owner.postWal(type: type, contents: contents) + } + .disposed(by: disposeBag) + } + +} + +// MARK: - API Request + +extension WalCreatorViewModel { + + /// 왈소리 크리에이터 만들기 + private func postWal(type: WalCategoryType, contents: String) { + let param: WalCreatorRequest = .init(categoryType: type.rawValue, contents: contents) + SettingAPI.shared.postWal(param: param) { [weak self] response, statusCode in + guard let self else { return } + guard let statusCode = statusCode else { return } + + let networkResult = NetworkResult(rawValue: statusCode) ?? .none + switch networkResult { + case .created: + self.output.wal.accept(.created) + case .unAuthorized: + self.requestRefreshToken(requestType: param) + default: + self.output.wal.accept(networkResult) + return + } + } + } + + /// 토근 재발급 + private func requestRefreshToken(requestType: WalCreatorRequest) { + AuthAPI.shared.postReissue { [weak self] response, statusCode in + guard let _self = self else { return } + guard let _statusCode = statusCode else { return } + + let networkResult = NetworkResult(rawValue: _statusCode) ?? .none + switch networkResult { + case .okay: + print("왈소리 만들기 API 한번 더 연결") + case .unAuthorized: + print("로그인 화면으로 이동") + default: + break + } + } + } + +} + +// MARK: - ViewModel Structure + +extension WalCreatorViewModel { + + enum ErrorResult: Error { + case postWal + } + + struct Input { + let postWal = PublishRelay<(WalCategoryType, String)>() + } + + struct Output { + let wal = PublishRelay() + } + + /// View <-> ViewModel + struct Bothways { + let userInteraction = PublishRelay() + let loading = PublishRelay() + } + + /// Service + struct Dependency { + + } + + /// Initialze (생성자로 enum 을 필요로 할 경우 해당 enum은 전역으로 선언) + // struct Load { + // + // } + +}