-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] #331 첫번째, 두번째 감정 남길 때 공통 코드 정리 및 상속
- Loading branch information
Showing
9 changed files
with
153 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
180 changes: 90 additions & 90 deletions
180
POME/Presentation/ViewControllers/Record/Register/RecordFirstEmotionViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,93 @@ | ||
//// | ||
//// RegisterFirstEmotionViewController.swift | ||
//// POME | ||
//// | ||
//// Created by 박소윤 on 2023/03/30. | ||
//// | ||
// | ||
// RegisterFirstEmotionViewController.swift | ||
// POME | ||
//import Foundation | ||
//import RxSwift | ||
//import RxCocoa | ||
// | ||
// Created by 박소윤 on 2023/03/30. | ||
//final class RecordFirstEmotionViewController: BaseViewController{ | ||
// | ||
// private let record: RecordDTO | ||
// | ||
// init(record: RecordDTO){ | ||
// self.record = record | ||
// super.init(nibName: nil, bundle: nil) | ||
// } | ||
// | ||
// private typealias emotionViewType = SelectEmotionView.EmotionElementView | ||
// | ||
// private let mainView = SelectEmotionView(type: .First) | ||
// private let viewModel = RecordFirstEmotionViewModel() | ||
// | ||
// | ||
// required init?(coder: NSCoder) { | ||
// fatalError("init(coder:) has not been implemented") | ||
// } | ||
// | ||
// override func style(){ | ||
// super.style() | ||
// setEtcButton(title: "닫기") | ||
// } | ||
// | ||
// override func layout(){ | ||
// super.layout() | ||
// view.addSubview(mainView) | ||
// mainView.snp.makeConstraints{ | ||
// $0.top.equalTo(navigationView.snp.bottom) | ||
// $0.leading.trailing.bottom.equalToSuperview() | ||
// } | ||
// } | ||
// | ||
// override func bind(){ | ||
// | ||
// let input = RecordFirstEmotionViewModel.Input(record: record, | ||
// happyEmotionSelect: mainView.happyEmotionView.rx.tapGesture().asObservable(), | ||
// whatEmotionSelect: mainView.whatEmotionView.rx.tapGesture().asObservable(), | ||
// sadEmotionSelect: mainView.sadEmotionView.rx.tapGesture().asObservable(), | ||
// ctaButtonTap: mainView.completeButton.rx.tap) | ||
// | ||
// let output = viewModel.transform(input: input) | ||
// | ||
// output.deselectEmotion | ||
// .drive(onNext: { [weak self] emotionTag in | ||
// if let emotion = EmotionTag(tagValue: emotionTag), let emotionView = self?.mainView.emotionStackView.viewWithTag(emotion.tagBinding) as? emotionViewType{ | ||
// emotionView.changeDeselectState() | ||
// } | ||
// }).disposed(by: disposeBag) | ||
// | ||
// output.selectEmotion | ||
// .drive(onNext: { [weak self] emotionTag in | ||
// if let emotion = EmotionTag(tagValue: emotionTag), let emotionView = self?.mainView.emotionStackView.viewWithTag(emotion.tagBinding) as? emotionViewType{ | ||
// emotionView.changeSelectState() | ||
// } | ||
// }).disposed(by: disposeBag) | ||
// | ||
|
||
import Foundation | ||
import RxSwift | ||
import RxCocoa | ||
|
||
final class RecordFirstEmotionViewController: BaseViewController{ | ||
|
||
private let record: RecordDTO | ||
|
||
init(record: RecordDTO){ | ||
self.record = record | ||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
private typealias emotionViewType = SelectEmotionView.EmotionElementView | ||
|
||
private let mainView = SelectEmotionView(type: .First) | ||
private let viewModel = RecordFirstEmotionViewModel() | ||
|
||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func style(){ | ||
super.style() | ||
setEtcButton(title: "닫기") | ||
} | ||
|
||
override func layout(){ | ||
super.layout() | ||
view.addSubview(mainView) | ||
mainView.snp.makeConstraints{ | ||
$0.top.equalTo(navigationView.snp.bottom) | ||
$0.leading.trailing.bottom.equalToSuperview() | ||
} | ||
} | ||
|
||
override func bind(){ | ||
|
||
let input = RecordFirstEmotionViewModel.Input(record: record, | ||
happyEmotionSelect: mainView.happyEmotionView.rx.tapGesture().asObservable(), | ||
whatEmotionSelect: mainView.whatEmotionView.rx.tapGesture().asObservable(), | ||
sadEmotionSelect: mainView.sadEmotionView.rx.tapGesture().asObservable(), | ||
ctaButtonTap: mainView.completeButton.rx.tap) | ||
|
||
let output = viewModel.transform(input: input) | ||
|
||
output.deselectEmotion | ||
.drive(onNext: { [weak self] emotionTag in | ||
if let emotion = EmotionTag(tagValue: emotionTag), let emotionView = self?.mainView.emotionStackView.viewWithTag(emotion.tagBinding) as? emotionViewType{ | ||
emotionView.changeDeselectState() | ||
} | ||
}).disposed(by: disposeBag) | ||
|
||
output.selectEmotion | ||
.drive(onNext: { [weak self] emotionTag in | ||
if let emotion = EmotionTag(tagValue: emotionTag), let emotionView = self?.mainView.emotionStackView.viewWithTag(emotion.tagBinding) as? emotionViewType{ | ||
emotionView.changeSelectState() | ||
} | ||
}).disposed(by: disposeBag) | ||
|
||
output.ctaButtonActivate | ||
.drive(mainView.completeButton.rx.isActivate) | ||
.disposed(by: disposeBag) | ||
|
||
output.registerStatusCode | ||
.drive(onNext: { [weak self] statusCode in | ||
if(statusCode == 200){ | ||
self?.navigationController?.pushViewController(RegisterSuccessViewController(type: .consume), animated: true) | ||
} | ||
}).disposed(by: disposeBag) | ||
|
||
etcButton.rx.tap | ||
.bind{ [weak self] in | ||
self?.closeButtonDidClicked() | ||
}.disposed(by: disposeBag) | ||
} | ||
|
||
private func closeButtonDidClicked(){ | ||
ImageAlert.quitRecord.generateAndShow(in: self).do{ | ||
$0.completion = { [weak self] in | ||
self?.navigationController?.popToRootViewController(animated: true) | ||
} | ||
} | ||
} | ||
} | ||
// output.ctaButtonActivate | ||
// .drive(mainView.completeButton.rx.isActivate) | ||
// .disposed(by: disposeBag) | ||
// | ||
// output.registerStatusCode | ||
// .drive(onNext: { [weak self] statusCode in | ||
// if(statusCode == 200){ | ||
// self?.navigationController?.pushViewController(RegisterSuccessViewController(type: .consume), animated: true) | ||
// } | ||
// }).disposed(by: disposeBag) | ||
// | ||
// etcButton.rx.tap | ||
// .bind{ [weak self] in | ||
// self?.closeButtonDidClicked() | ||
// }.disposed(by: disposeBag) | ||
// } | ||
// | ||
// private func closeButtonDidClicked(){ | ||
// ImageAlert.quitRecord.generateAndShow(in: self).do{ | ||
// $0.completion = { [weak self] in | ||
// self?.navigationController?.popToRootViewController(animated: true) | ||
// } | ||
// } | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.