diff --git a/FREEWAY/FREEWAY/Presentation/BaseView/BaseViewModel.swift b/FREEWAY/FREEWAY/Presentation/BaseView/BaseViewModel.swift index 14cee2a..ef700d3 100644 --- a/FREEWAY/FREEWAY/Presentation/BaseView/BaseViewModel.swift +++ b/FREEWAY/FREEWAY/Presentation/BaseView/BaseViewModel.swift @@ -20,7 +20,7 @@ class BaseViewModel { // 입력된 데이터를 저장하는 BehaviorSubject let inputText = BehaviorSubject(value: "") - let inputVoice = PassthroughSubject() + let inputVoicePublisher = PassthroughSubject() //TODO: MapsViewController의 ViewModel에 들어갈 부분 let searchPublisher = PassthroughSubject() let inputTextPublisher = PassthroughSubject() diff --git a/FREEWAY/FREEWAY/Presentation/HomeView/HomeViewController.swift b/FREEWAY/FREEWAY/Presentation/HomeView/HomeViewController.swift index 44b980e..d0dc513 100644 --- a/FREEWAY/FREEWAY/Presentation/HomeView/HomeViewController.swift +++ b/FREEWAY/FREEWAY/Presentation/HomeView/HomeViewController.swift @@ -94,7 +94,7 @@ final class HomeViewController: UIViewController { } private func bind() { - viewModel.inputVoice.withRetained(self) + viewModel.inputVoicePublisher.withRetained(self) .sink { `self`, resultText in self.voiceSearchLottieView.resultTextLabel.text = resultText }.store(in: &cancelBag) diff --git a/FREEWAY/FREEWAY/Presentation/SearchView/SearchViewController.swift b/FREEWAY/FREEWAY/Presentation/SearchView/SearchViewController.swift index ec17111..e1b4b44 100644 --- a/FREEWAY/FREEWAY/Presentation/SearchView/SearchViewController.swift +++ b/FREEWAY/FREEWAY/Presentation/SearchView/SearchViewController.swift @@ -78,7 +78,7 @@ final class SearchViewController: UIViewController { @objc func backButtonPressed(_ sender: UIButton) { self.navigationController?.popViewController(animated: true) } - + //TODO: Combine으로 상태 수정 @objc func voiceButtonPressed(_ sender: UIButton) { searchListViewModule.view.isHidden = true setupLottieLayout() @@ -91,12 +91,13 @@ final class SearchViewController: UIViewController { self.voiceRecognitionManager.stopRecognition() self.searchTextFieldView.voiceImage = "mic.fill" self.voiceSearchLottieView.removeFromSuperview() + //TODO: 옵셔널 타입 제거 강남으로 이동하지 못하도록 설정 self.navigateToMapsViewControllerIfNeeded(self.viewModel.getStationName() ?? "강남") } } private func bind() { - viewModel.inputVoice.withRetained(self) + viewModel.inputVoicePublisher.withRetained(self) .sink { `self`, resultText in self.voiceSearchLottieView.resultTextLabel.text = resultText }.store(in: &cancelBag) @@ -199,7 +200,15 @@ extension SearchViewController: UITextFieldDelegate { viewModel.inputTextPublisher.send(textField.text ?? "") } } - + + func textFieldShouldReturn(_ textField: UITextField) -> Bool { + if let searchText = textField.text { + navigateToMapsViewControllerIfNeeded(searchText) + } + return true + } + //MARK: UITextFieldDelegate와는 관련 없지만 사용되는 로직 + //TODO: 추후 AlertManager로 들어갈 부분 private func showInvalidStationNameAlert() { let alert = UIAlertController(title: "역 이름을 다시 한 번 확인해주세요!", message: "", preferredStyle: .alert) @@ -219,14 +228,6 @@ extension SearchViewController: UITextFieldDelegate { showInvalidStationNameAlert() } } - - func textFieldShouldReturn(_ textField: UITextField) -> Bool { - if let searchText = textField.text { - navigateToMapsViewControllerIfNeeded(searchText) - } - return true - } - } extension SearchViewController: UITableViewDelegate { diff --git a/FREEWAY/FREEWAY/Services/VoiceRecognitionManager.swift b/FREEWAY/FREEWAY/Services/VoiceRecognitionManager.swift index 8d31923..9ac5b53 100644 --- a/FREEWAY/FREEWAY/Services/VoiceRecognitionManager.swift +++ b/FREEWAY/FREEWAY/Services/VoiceRecognitionManager.swift @@ -57,7 +57,7 @@ class VoiceRecognitionManager: NSObject, SFSpeechRecognizerDelegate { guard let self = self else { return } if let result = result { self.resultText = result.bestTranscription.formattedString - self.viewModel?.inputVoice.send(self.resultText ?? "") + self.viewModel?.inputVoicePublisher.send(self.resultText ?? "") self.viewModel?.updateText(self.resultText) self.delegate?.didRecognizeVoice(text: self.resultText ?? "") }