Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] #208 코스업로드 api 연결 #210

Merged
merged 5 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import UIKit
import Combine
import CombineCocoa

@frozen
enum SheetType {
Expand All @@ -25,14 +26,11 @@ final class CustomBottomSheetVC: UIViewController {
private var BottomsheetType: SheetType!

var backgroundTapAction: (() -> Void)?
var completeButtonTapAction: ((String) -> Void)?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굿굿 감사합니다


var completeButtonTapped: Driver<Void> {
completeButton.publisher(for: .touchUpInside)
.map { _ in }
.asDriver()
}
Comment on lines -29 to -33
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

버튼에 publisher를 연결하는 과정을 combineCocoa를 사용하는 것으로 수정했습니다

// 바텀 시트 높이
let bottomHeight: CGFloat = 206
private var cancelBag = CancelBag()

// MARK: - UI Components

Expand Down Expand Up @@ -91,6 +89,7 @@ final class CustomBottomSheetVC: UIViewController {
self.setDelegate()
self.setTapGesture()
self.setAddTarget()
self.setBinding()
if BottomsheetType == .TextField {
showBottomSheet()
setupGestureRecognizer()
Expand Down Expand Up @@ -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)
Comment on lines +247 to +251
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

완성하기 버튼이 눌린 경우는 textfield의 내용을 클로저에 전달해주었습니다

}

private func showBottomSheet() {

let safeAreaHeight: CGFloat = view.safeAreaLayoutGuide.layoutFrame.height
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct CourseDrawingRequestDto: Codable {

struct CourseDrawingRequestData: Codable {
let path: [RNLocationModel]
// let title: String
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

서버 배포되면 title 관련 주석 삭제하도록 하겠습니당

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let distance: Float
let departureAddress, departureName: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ final class CourseDrawingVC: UIViewController {

var pathImage: UIImage?
var distance: Float = 0.0
private var courseName = String()

private var cancelBag = CancelBag()

Expand Down Expand Up @@ -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
Expand All @@ -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)
}

Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

순서의 중요성


courseDrawingVC.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(courseDrawingVC, animated: true)
Expand Down