diff --git a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift index 42069943..82659e39 100644 --- a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift +++ b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift @@ -7,6 +7,7 @@ import UIKit import Combine +import CombineCocoa @frozen enum SheetType { @@ -25,14 +26,11 @@ final class CustomBottomSheetVC: UIViewController { private var BottomsheetType: SheetType! var backgroundTapAction: (() -> Void)? + var completeButtonTapAction: ((String) -> Void)? - var completeButtonTapped: Driver { - completeButton.publisher(for: .touchUpInside) - .map { _ in } - .asDriver() - } // 바텀 시트 높이 let bottomHeight: CGFloat = 206 + private var cancelBag = CancelBag() // MARK: - UI Components @@ -91,6 +89,7 @@ final class CustomBottomSheetVC: UIViewController { self.setDelegate() self.setTapGesture() self.setAddTarget() + self.setBinding() if BottomsheetType == .TextField { showBottomSheet() setupGestureRecognizer() @@ -244,6 +243,14 @@ extension CustomBottomSheetVC { } } + private func setBinding() { + self.completeButton.tapPublisher.sink { [weak self] _ in + guard let self = self else { return } + guard let text = self.bottomSheetTextField.text else { return } + self.completeButtonTapAction?(text) + }.store(in: cancelBag) + } + private func showBottomSheet() { let safeAreaHeight: CGFloat = view.safeAreaLayoutGuide.layoutFrame.height diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/RequestDto/CourseDrawingRequestDto.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/RequestDto/CourseDrawingRequestDto.swift index 75000491..c339f79c 100644 --- a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/RequestDto/CourseDrawingRequestDto.swift +++ b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/RequestDto/CourseDrawingRequestDto.swift @@ -18,6 +18,7 @@ struct CourseDrawingRequestDto: Codable { struct CourseDrawingRequestData: Codable { let path: [RNLocationModel] +// let title: String let distance: Float let departureAddress, departureName: String } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift index d387214f..48aff37b 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift @@ -21,6 +21,7 @@ final class CourseDrawingVC: UIViewController { var pathImage: UIImage? var distance: Float = 0.0 + private var courseName = String() private var cancelBag = CancelBag() @@ -228,12 +229,6 @@ extension CourseDrawingVC { self.present(alertVC, animated: false) } - - /// 수정 필요 - 바텀시트에서 완료 버튼을 누른 경우 - /// 아래의 코드를 호출해주어야함 - /// guard let self = self else { return } - /// guard handleVisitor() else { return } - /// self.mapView.capturePathImage() } // MARK: - @objc Function @@ -245,6 +240,7 @@ extension CourseDrawingVC { if SelectedInfo.shared.type == .map { startMarkStackView.isHidden = true guard let model = self.departureLocationModel else { return } + SelectedInfo.shared.type = .other mapView.makeStartMarker(at: model.toNMGLatLng(), withCameraMove: true) } @@ -255,11 +251,17 @@ extension CourseDrawingVC { mapView.undo() } - /// 수정 필요 - 다음으로 버튼 눌린 경우 호출될 함수 @objc private func completeButtonDidTap() { -// let bottomSheetVC = CourseNameBottomSheetVC() -// bottomSheetVC.modalPresentationStyle = .overFullScreen -// self.present(bottomSheetVC, animated: false) + let bottomSheetVC = CustomBottomSheetVC(type: .TextField) + bottomSheetVC.modalPresentationStyle = .overFullScreen + bottomSheetVC.completeButtonTapAction = { [weak self] text in + guard let self = self else { return } + guard handleVisitor() else { return } + self.courseName = text + self.mapView.capturePathImage() + self.dismiss(animated: true) + } + self.present(bottomSheetVC, animated: false) } } @@ -430,6 +432,7 @@ extension CourseDrawingVC { guard let departureLocationModel = self.departureLocationModel else { return nil } let path = mapView.getMarkersLatLng().map { $0.toRNLocationModel() } let courseDrawingRequestData = CourseDrawingRequestData(path: path, +// title : self.courseName, distance: self.distance, departureAddress: departureLocationModel.departureAddress, departureName: departureLocationModel.departureName) @@ -441,8 +444,8 @@ extension CourseDrawingVC { private func uploadCourseDrawing() { guard let requestDto = makecourseDrawingRequestDto() else { return } - LoadingIndicator.showLoading() + courseProvider.request(.uploadCourseDrawing(param: requestDto)) {[weak self] response in guard let self = self else { return } LoadingIndicator.hideLoading() diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/DepartureSearchVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/DepartureSearchVC.swift index 1365441f..5313442a 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/DepartureSearchVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/DepartureSearchVC.swift @@ -218,8 +218,8 @@ extension DepartureSearchVC: UITableViewDelegate, UITableViewDataSource { let courseDrawingVC = CourseDrawingVC() let departureLocationModel = addressList[indexPath.item].toDepartureLocationModel() - courseDrawingVC.setData(model: departureLocationModel) SelectedInfo.shared.type = .other + courseDrawingVC.setData(model: departureLocationModel) courseDrawingVC.hidesBottomBarWhenPushed = true self.navigationController?.pushViewController(courseDrawingVC, animated: true)