Skip to content

Commit

Permalink
Merge pull request #302 from boostcampwm2023/iOS/task/RecordingFlag
Browse files Browse the repository at this point in the history
[iOS] HomeViewController `isRecording` 관련 안정성 향상
  • Loading branch information
SwiftyJunnos authored Dec 11, 2023
2 parents c459de0 + d887407 commit 595366e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public final class HomeViewController: HomeBottomSheetViewController {
self?.hideBottomSheet()
} else {
self?.showBottomSheet()
self?.contentViewController.journeyShouldStopped(isCancelling: false)
}
self?.updateButtonMode(isRecording: isRecording)
}
Expand Down Expand Up @@ -227,7 +228,7 @@ extension HomeViewController: RecordJourneyButtonViewDelegate {
guard self.viewModel.state.isRecording.value == true else { return }

self.viewModel.trigger(.backButtonDidTap)
self.contentViewController.journeyShouldStopped()
self.contentViewController.journeyShouldStopped(isCancelling: true)
}

public func spotButtonDidTap(_ button: MSRectButton) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension MapViewController {
extension MapViewController {

public func journeyShouldStarted(_ startedJourney: RecordingJourney) {
guard let viewModel = self.viewModel as? NavigateMapViewModel else {
guard self.viewModel is NavigateMapViewModel else {
MSLogger.make(category: .home).error("여정이 시작되어야 하지만 이미 Map에서 RecordJourneyViewModel을 사용하고 있습니다.")
return
}
Expand All @@ -41,12 +41,15 @@ extension MapViewController {
self.swapViewModel(to: recordJourneyViewModel)
}

public func journeyShouldStopped() {
public func journeyShouldStopped(isCancelling: Bool) {
guard let viewModel = self.viewModel as? RecordJourneyViewModel else {
MSLogger.make(category: .home).error("여정이 종료되어야 하지만 이미 Map에서 NavigateMapViewModel을 사용하고 있습니다.")
return
}
viewModel.trigger(.recordingDidCancelled)

if isCancelling {
viewModel.trigger(.recordingDidCancelled)
}

let journeyRepository = JourneyRepositoryImplementation()
let navigateMapViewModel = NavigateMapViewModel(repository: journeyRepository)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,16 @@ public final class MapViewController: UIViewController {

if let navigateMapViewModel = viewModel as? NavigateMapViewModel {
self.bind(navigateMapViewModel)
#if DEBUG
MSLogger.make(category: .home).debug("Map에 NavigateMapViewModel을 바인딩 했습니다.")
#endif
}

if let recordJourneyViewModel = viewModel as? RecordJourneyViewModel {
self.bind(recordJourneyViewModel)
#if DEBUG
MSLogger.make(category: .home).debug("Map에 RecordJourneyViewModel을 바인딩 했습니다.")
#endif
}
}

Expand Down

0 comments on commit 595366e

Please sign in to comment.