-
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.
- Loading branch information
Showing
10 changed files
with
408 additions
and
99 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
26 changes: 26 additions & 0 deletions
26
POME/Domain/UseCase/Record/SelectSecondEmotionUseCase.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// SelectSecondEmotionUseCase.swift | ||
// POME | ||
// | ||
// Created by gomin on 2023/06/05. | ||
// | ||
|
||
import Foundation | ||
import RxSwift | ||
|
||
protocol PostSecondEmotionUseCaseInterface { | ||
func execute(recordId: Int, requestValue: RecordSecondEmotionRequestModel) -> Observable<BaseResponseStatus> | ||
} | ||
|
||
final class PostSecondEmotionUseCase: PostSecondEmotionUseCaseInterface { | ||
|
||
private let recordRepository: RecordRepositoryInterface | ||
|
||
init(recordRepository: RecordRepositoryInterface = RecordRepository()) { | ||
self.recordRepository = recordRepository | ||
} | ||
|
||
func execute(recordId: Int, requestValue: RecordSecondEmotionRequestModel) -> Observable<BaseResponseStatus>{ | ||
return recordRepository.postSecondEmotion(id: recordId, requestValue: requestValue) | ||
} | ||
} |
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
94 changes: 94 additions & 0 deletions
94
POME/Presentation/ViewControllers/SecondEmotion/PostSecondEmotionViewController.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 |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// | ||
// SecondEmotionViewController.swift | ||
// POME | ||
// | ||
// Created by gomin on 2022/11/26. | ||
// | ||
|
||
import Foundation | ||
import RxSwift | ||
import RxCocoa | ||
|
||
|
||
final class PostSecondEmotionViewController: BaseViewController{ | ||
|
||
private let recordId: Int | ||
|
||
init(recordId: Int){ | ||
self.recordId = recordId | ||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
private typealias emotionViewType = SelectEmotionView.EmotionElementView | ||
|
||
private let mainView = SelectEmotionView(type: .Second) | ||
private let viewModel = PostSecondEmotionViewModel() | ||
|
||
|
||
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 = PostSecondEmotionViewModel.Input(record: recordId, | ||
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] status in | ||
if status == .success { | ||
RecordObserver.shared.registerSecondEmotion.onNext(Void()) | ||
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) | ||
} | ||
} | ||
} | ||
} |
91 changes: 0 additions & 91 deletions
91
POME/Presentation/ViewControllers/SecondEmotion/SecondEmotionViewController.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.