Skip to content

Commit

Permalink
fix : 문장 추출 후 저장버튼 탭시 다음 사진으로 자동 스와이프 #7
Browse files Browse the repository at this point in the history
- 마지막 사진에서 문장 추출 후 저장버튼 탭시, 다음 버튼 활성화
  • Loading branch information
wongbingg committed Aug 22, 2023
1 parent 5deacd1 commit 06c1c3f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ protocol EditSentencePresentable: Presentable {
}

protocol EditSentenceListener: AnyObject {
// TODO: Declare methods the interactor can invoke to communicate with other RIBs.
func dismissEditSentence(with text: String)
func swipeToNextPhoto()
}

final class EditSentenceInteractor: PresentableInteractor<EditSentencePresentable>,
Expand Down Expand Up @@ -50,5 +50,6 @@ final class EditSentenceInteractor: PresentableInteractor<EditSentencePresentabl

func saveButtonTapped(with text: String) {
listener?.dismissEditSentence(with: text)
listener?.swipeToNextPhoto()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ protocol SelectSentenceRouting: ViewableRouting {
protocol SelectSentencePresentable: Presentable {
var listener: SelectSentencePresentableListener? { get set }
// TODO: Declare methods the interactor can invoke the presenter to present data.
func showSwipeAnimation()
}

protocol SelectSentenceListener: AnyObject {
Expand Down Expand Up @@ -59,6 +60,16 @@ final class SelectSentenceInteractor: PresentableInteractor<SelectSentencePresen
router?.attachEditSentence(with: text)
}

func backButtonTapped() {
listener?.popSelectSentence()
}

func nextButtonTapped() {
listener?.pushToOrganizingSentence()
}

// MARK: - SelectSentenceInteractable

func dismissEditSentence(with text: String) {
guard var list = try? organizingSentenceRepository.sentenceFile.value() else {
Console.error("\(#function) value 를 가져올 수 없습니다.")
Expand All @@ -69,11 +80,9 @@ final class SelectSentenceInteractor: PresentableInteractor<SelectSentencePresen
router?.detachEditSentence()
}

func backButtonTapped() {
listener?.popSelectSentence()
func swipeToNextPhoto() {
// TODO: 다음 사진으로 자동 스와이프 처리
presenter.showSwipeAnimation()
}

func nextButtonTapped() {
listener?.pushToOrganizingSentence()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ final class SelectSentenceViewController: UIViewController,
.disposed(by: disposeBag)

// TODO: 각 사진에서 문장추출이 모두 완료되었을 때 nextButton 활성화
// nextButton.isEnabled = false
nextButton.isEnabled = false
}

private func bind() {
Expand Down Expand Up @@ -229,6 +229,21 @@ final class SelectSentenceViewController: UIViewController,
dismiss(animated: true)
}
}

// MARK: - SelectSentencePresentable

func showSwipeAnimation() {

let contentOffset = selectedPhotoCollectionView.contentOffset.x
let contentOffsetOnLastPage = DeviceSize.width * CGFloat(selectedImages.count-1)
guard contentOffset != contentOffsetOnLastPage else {
nextButton.isEnabled = true
return
}
UIView.animate(withDuration: 0.5, delay: 0) {
self.selectedPhotoCollectionView.contentOffset.x += DeviceSize.width
}
}
}

extension SelectSentenceViewController: SelectedPhotoCellListener {
Expand Down

0 comments on commit 06c1c3f

Please sign in to comment.