From b33fef6cfb865f88b184542802e6f58e3c5462cb Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Tue, 10 Jan 2023 23:42:33 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[Feat]=20#74=20-=20RunningModel=EC=97=90=20?= =?UTF-8?q?=EC=B6=9C=EB=B0=9C=EC=A7=80=20=EC=A3=BC=EC=86=8C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Model/CourseDrawingModel/DepartureLocationModel.swift | 8 ++++++++ .../Network/Model/RunningModel/RunningModel.swift | 2 ++ .../Presentation/CourseDrawing/VC/CourseDrawingVC.swift | 4 +++- .../Presentation/Running/VC/RunningRecordVC.swift | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Runnect-iOS/Runnect-iOS/Network/Model/CourseDrawingModel/DepartureLocationModel.swift b/Runnect-iOS/Runnect-iOS/Network/Model/CourseDrawingModel/DepartureLocationModel.swift index 80bc5173..57c58d4b 100644 --- a/Runnect-iOS/Runnect-iOS/Network/Model/CourseDrawingModel/DepartureLocationModel.swift +++ b/Runnect-iOS/Runnect-iOS/Network/Model/CourseDrawingModel/DepartureLocationModel.swift @@ -12,4 +12,12 @@ struct DepartureLocationModel { let departureAddress: String let latitude: String let longitude: String + + var region: String { + departureAddress.split(separator: " ").map {String($0)}[0] + } + + var city: String { + departureAddress.split(separator: " ").map {String($0)}[1] + } } diff --git a/Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/RunningModel.swift b/Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/RunningModel.swift index a61b152d..a9653750 100644 --- a/Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/RunningModel.swift +++ b/Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/RunningModel.swift @@ -16,6 +16,8 @@ struct RunningModel { var distance: String? var pathImage: UIImage? var totalTime: Int? + var region: String? + var city: String? /// HH:MM:SS 형식으로 반환 func getFormattedTotalTime() -> String? { diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift index af708be9..d6d59b29 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDrawing/VC/CourseDrawingVC.swift @@ -173,7 +173,9 @@ extension CourseDrawingVC { let runningModel = RunningModel(courseId: courseId, locations: self.mapView.getMarkersLatLng(), distance: self.distanceLabel.text, - pathImage: self.pathImage) + pathImage: self.pathImage, + region: self.departureLocationModel?.region, + city: self.departureLocationModel?.city) countDownVC.setData(runningModel: runningModel) self.navigationController?.pushViewController(countDownVC, animated: true) alertVC.dismiss(animated: true) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningRecordVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningRecordVC.swift index bfc2c88c..6f352882 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningRecordVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningRecordVC.swift @@ -134,6 +134,9 @@ extension RunningRecordVC { self.totalTimeStatsView.setStats(stats: runningModel.getFormattedTotalTime() ?? "00:00:00") self.averagePaceStatsView.setStats(stats: runningModel.getFormattedAveragePage() ?? "0'00''") self.courseImageView.image = runningModel.pathImage + + guard let region = runningModel.region, let city = runningModel.city else { return } + self.departureInfoView.setDescriptionText(description: "\(region) \(city)") } } From 4216078a8d2258bb9c7a4a20e7c43c814018a1f5 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Tue, 10 Jan 2023 23:56:50 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[Feat]=20#74=20-=20=EC=BD=94=EC=8A=A4=20?= =?UTF-8?q?=EB=94=94=ED=85=8C=EC=9D=BC=EC=9D=84=20=EB=B0=9B=EA=B8=B0=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20Dto=EB=B0=8F=20=EB=9D=BC=EC=9A=B0=ED=84=B0?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runnect-iOS.xcodeproj/project.pbxproj | 11 ++++------- .../ResponseDto/CourseDetailResponseDto.swift | 17 +++++++++++++++++ Runnect-iOS/Runnect-iOS/Network/Router/.gitkeep | 0 .../Router/RunningRouter/RunningRouter.swift | 9 ++++++++- 4 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 Runnect-iOS/Runnect-iOS/Network/Dto/RunningDto/ResponseDto/CourseDetailResponseDto.swift delete mode 100644 Runnect-iOS/Runnect-iOS/Network/Router/.gitkeep diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index 776fde5a..b48334f7 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -127,6 +127,7 @@ CEEC6B492961C5E200D00E1E /* SplashVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEEC6B482961C5E200D00E1E /* SplashVC.swift */; }; CEEC6B4B2961D89700D00E1E /* CustomNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEEC6B4A2961D89700D00E1E /* CustomNavigationBar.swift */; }; CEF3CD98296D63B9002723A1 /* CourseStorageRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEF3CD97296D63B9002723A1 /* CourseStorageRouter.swift */; }; + CEF3CD9A296DB305002723A1 /* CourseDetailResponseDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEF3CD99296DB305002723A1 /* CourseDetailResponseDto.swift */; }; DA20D847296697A600F1581F /* MyCourseSelectVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D846296697A600F1581F /* MyCourseSelectVC.swift */; }; DA20D849296697B400F1581F /* CourseUploadVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D848296697B400F1581F /* CourseUploadVC.swift */; }; DA20D84E2966A9B300F1581F /* CourseSearchVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D84D2966A9B300F1581F /* CourseSearchVC.swift */; }; @@ -158,13 +159,8 @@ CE0C23782966D6AF00B45063 /* ViewPager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewPager.swift; sourceTree = ""; }; CE0D9FD229648DA300CEB5CD /* CustomAlertVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlertVC.swift; sourceTree = ""; }; CE10063929680C5700FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; - CE10063B29680C6800FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; - CE10063C29680C7000FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10063D29680C8100FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10063E29680C8800FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; - CE10063F29680C9800FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; - CE10064129680CA700FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; - CE10064229680CAD00FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10064329680CB400FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10064429680CBC00FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE10064D29680D2500FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; @@ -215,7 +211,6 @@ CE591E9D296D5140000FCBB3 /* RunningRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunningRouter.swift; sourceTree = ""; }; CE591EA0296D5EB5000FCBB3 /* PrivateCourseResponseDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivateCourseResponseDto.swift; sourceTree = ""; }; CE6655BE295D82E200C64E12 /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; - CE6655C0295D82F000C64E12 /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE6655C1295D82F700C64E12 /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE6655C5295D83B700C64E12 /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; CE6655C7295D849F00C64E12 /* StringLiterals.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringLiterals.swift; sourceTree = ""; }; @@ -283,6 +278,7 @@ CEEC6B482961C5E200D00E1E /* SplashVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashVC.swift; sourceTree = ""; }; CEEC6B4A2961D89700D00E1E /* CustomNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomNavigationBar.swift; sourceTree = ""; }; CEF3CD97296D63B9002723A1 /* CourseStorageRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseStorageRouter.swift; sourceTree = ""; }; + CEF3CD99296DB305002723A1 /* CourseDetailResponseDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDetailResponseDto.swift; sourceTree = ""; }; DA20D846296697A600F1581F /* MyCourseSelectVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyCourseSelectVC.swift; sourceTree = ""; }; DA20D848296697B400F1581F /* CourseUploadVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseUploadVC.swift; sourceTree = ""; }; DA20D84D2966A9B300F1581F /* CourseSearchVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseSearchVC.swift; sourceTree = ""; }; @@ -816,6 +812,7 @@ isa = PBXGroup; children = ( CE591E9B296D4F69000FCBB3 /* RunningRecordResonseDto.swift */, + CEF3CD99296DB305002723A1 /* CourseDetailResponseDto.swift */, ); path = ResponseDto; sourceTree = ""; @@ -903,7 +900,6 @@ CE40BB292968083B0030ABCA /* MyPageRouter */, CE40BB2A296808440030ABCA /* CourseDetailRouter */, CE40BB2B296808500030ABCA /* RunningRouter */, - CE6655C0295D82F000C64E12 /* .gitkeep */, ); path = Router; sourceTree = ""; @@ -1362,6 +1358,7 @@ CEC2A6902962B06C00160BF7 /* convertLocationObject.swift in Sources */, CEC2A6852961F92C00160BF7 /* CustomButton.swift in Sources */, CE6B63D3296725E6003F900F /* CourseListCVC.swift in Sources */, + CEF3CD9A296DB305002723A1 /* CourseDetailResponseDto.swift in Sources */, CE29D584296416D800F47542 /* caculateStatusBarHeight.swift in Sources */, CE66560C295D928300C64E12 /* setRootViewController.swift in Sources */, CE6655D9295D871B00C64E12 /* URL+.swift in Sources */, diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/RunningDto/ResponseDto/CourseDetailResponseDto.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/RunningDto/ResponseDto/CourseDetailResponseDto.swift new file mode 100644 index 00000000..14768606 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Network/Dto/RunningDto/ResponseDto/CourseDetailResponseDto.swift @@ -0,0 +1,17 @@ +// +// CourseDetailResponseDto.swift +// Runnect-iOS +// +// Created by sejin on 2023/01/10. +// + +import Foundation + +typealias Course = PrivateCourse +typealias CourseDeparture = PrivateCourseDeparture + +// MARK: - CourseDetailResponseDto + +struct CourseDetailResponseDto: Codable { + let course: [Course] +} diff --git a/Runnect-iOS/Runnect-iOS/Network/Router/.gitkeep b/Runnect-iOS/Runnect-iOS/Network/Router/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Runnect-iOS/Runnect-iOS/Network/Router/RunningRouter/RunningRouter.swift b/Runnect-iOS/Runnect-iOS/Network/Router/RunningRouter/RunningRouter.swift index a43e73b0..b8dbe68a 100644 --- a/Runnect-iOS/Runnect-iOS/Network/Router/RunningRouter/RunningRouter.swift +++ b/Runnect-iOS/Runnect-iOS/Network/Router/RunningRouter/RunningRouter.swift @@ -11,6 +11,7 @@ import Moya enum RunningRouter { case recordRunning(param: RunningRecordRequestDto) + case getCourseDetail(courseId: Int) } extension RunningRouter: TargetType { @@ -26,6 +27,8 @@ extension RunningRouter: TargetType { switch self { case .recordRunning: return "/record" + case .getCourseDetail(let courseId): + return "/course/detail/\(courseId)" } } @@ -33,6 +36,8 @@ extension RunningRouter: TargetType { switch self { case .recordRunning: return .post + case .getCourseDetail: + return .get } } @@ -44,12 +49,14 @@ extension RunningRouter: TargetType { } catch { fatalError(error.localizedDescription) } + case .getCourseDetail: + return .requestPlain } } var headers: [String: String]? { switch self { - case .recordRunning: + case .recordRunning, .getCourseDetail: return Config.headerWithDeviceId } } From b574b96724cb6b7e372de427e3e1e30be4d504f5 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Wed, 11 Jan 2023 00:45:39 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[Feat]=20#74=20-=20=EC=BD=94=EC=8A=A4=20?= =?UTF-8?q?=EB=94=94=ED=85=8C=EC=9D=BC=20API=20=EC=97=B0=EA=B2=B0=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PrivateCourseResponseDto.swift | 2 +- .../ResponseDto/CourseDetailResponseDto.swift | 2 +- .../Model/RunningModel/RunningModel.swift | 1 + .../CourseStorage/VC/CourseStorageVC.swift | 1 + .../Presentation/Running/VC/CountDownVC.swift | 1 + .../Running/VC/RunningRecordVC.swift | 3 + .../Running/VC/RunningWaitingVC.swift | 80 +++++++++++++++++-- 7 files changed, 82 insertions(+), 8 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseStorageDto/ResponseDto/PrivateCourseResponseDto.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseStorageDto/ResponseDto/PrivateCourseResponseDto.swift index e4a31dd0..da9621fd 100644 --- a/Runnect-iOS/Runnect-iOS/Network/Dto/CourseStorageDto/ResponseDto/PrivateCourseResponseDto.swift +++ b/Runnect-iOS/Runnect-iOS/Network/Dto/CourseStorageDto/ResponseDto/PrivateCourseResponseDto.swift @@ -18,7 +18,7 @@ struct PrivateCourseResponseDto: Codable { struct PrivateCourse: Codable { let id: Int let image, createdAt: String - let distance: Float? + let distance: String? let path: [[Double]]? let departure: PrivateCourseDeparture } diff --git a/Runnect-iOS/Runnect-iOS/Network/Dto/RunningDto/ResponseDto/CourseDetailResponseDto.swift b/Runnect-iOS/Runnect-iOS/Network/Dto/RunningDto/ResponseDto/CourseDetailResponseDto.swift index 14768606..10fab8fb 100644 --- a/Runnect-iOS/Runnect-iOS/Network/Dto/RunningDto/ResponseDto/CourseDetailResponseDto.swift +++ b/Runnect-iOS/Runnect-iOS/Network/Dto/RunningDto/ResponseDto/CourseDetailResponseDto.swift @@ -13,5 +13,5 @@ typealias CourseDeparture = PrivateCourseDeparture // MARK: - CourseDetailResponseDto struct CourseDetailResponseDto: Codable { - let course: [Course] + let course: Course } diff --git a/Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/RunningModel.swift b/Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/RunningModel.swift index a9653750..b9aa6ce0 100644 --- a/Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/RunningModel.swift +++ b/Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/RunningModel.swift @@ -15,6 +15,7 @@ struct RunningModel { var locations: [NMGLatLng] var distance: String? var pathImage: UIImage? + var imageUrl: String? var totalTime: Int? var region: String? var city: String? diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseStorage/VC/CourseStorageVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseStorage/VC/CourseStorageVC.swift index be78bf7d..58516be4 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseStorage/VC/CourseStorageVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseStorage/VC/CourseStorageVC.swift @@ -70,6 +70,7 @@ extension CourseStorageVC { privateCourseListView.cellDidTapped.sink { [weak self] index in guard let self = self else { return } let runningWaitingVC = RunningWaitingVC() + runningWaitingVC.setData(courseId: self.privateCourseList[index].id, publicCourseId: nil) runningWaitingVC.hidesBottomBarWhenPushed = true self.navigationController?.pushViewController(runningWaitingVC, animated: true) }.store(in: cancelBag) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/CountDownVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/CountDownVC.swift index e79d7e0b..287c0ae1 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/CountDownVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/CountDownVC.swift @@ -80,6 +80,7 @@ extension CountDownVC { extension CountDownVC { private func setUI() { view.backgroundColor = .m1 + self.navigationController?.isNavigationBarHidden = true } private func setLayout() { diff --git a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningRecordVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningRecordVC.swift index 6f352882..b50d0936 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningRecordVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningRecordVC.swift @@ -137,6 +137,9 @@ extension RunningRecordVC { guard let region = runningModel.region, let city = runningModel.city else { return } self.departureInfoView.setDescriptionText(description: "\(region) \(city)") + + guard let imageUrl = runningModel.imageUrl else { return } + self.courseImageView.setImage(with: imageUrl) } } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningWaitingVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningWaitingVC.swift index 221f7a90..7e03c09b 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningWaitingVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/Running/VC/RunningWaitingVC.swift @@ -7,8 +7,21 @@ import UIKit +import NMapsMap +import Moya + final class RunningWaitingVC: UIViewController { + // MARK: - Properties + + private var courseId: Int? + private var publicCourseId: Int? + private var courseModel: Course? + + private let runningProvider = MoyaProvider( + plugins: [NetworkLoggerPlugin(verbose: true)] + ) + // MARK: - UI Components private lazy var naviBar = CustomNavigationBar(self, type: .titleWithLeftButton) @@ -59,6 +72,26 @@ final class RunningWaitingVC: UIViewController { // MARK: - Methods extension RunningWaitingVC { + func setData(courseId: Int, publicCourseId: Int?) { + self.courseId = courseId + self.publicCourseId = publicCourseId + + getCourseDetail(courseId: courseId) + } + + private func setCourseData(courseModel: Course) { + self.courseModel = courseModel + + guard let path = courseModel.path, let distance = courseModel.distance else { return } + let locations = path.map { NMGLatLng(lat: $0[0], lng: $0[1]) } + self.makePath(locations: locations) + self.distanceLabel.text = String(distance) + } + + func makePath(locations: [NMGLatLng]) { + self.mapView.makeMarkersWithStartMarker(at: locations, moveCameraToStartMarker: true) + } + private func setAddTarget() { self.startButton.addTarget(self, action: #selector(startButtonDidTap), for: .touchUpInside) } @@ -68,15 +101,17 @@ extension RunningWaitingVC { extension RunningWaitingVC { @objc private func startButtonDidTap() { - if self.distanceLabel.text == "0.0" { - return - } + guard let courseModel = self.courseModel, self.distanceLabel.text != "0.0" else { return } let countDownVC = CountDownVC() - - let runningModel = RunningModel(locations: self.mapView.getMarkersLatLng(), + let runningModel = RunningModel(courseId: self.courseId, + publicCourseId: self.publicCourseId, + locations: self.mapView.getMarkersLatLng(), distance: self.distanceLabel.text, - pathImage: UIImage()) + imageUrl: courseModel.image, + region: courseModel.departure.region, + city: courseModel.departure.city) + countDownVC.setData(runningModel: runningModel) self.navigationController?.pushViewController(countDownVC, animated: true) } @@ -139,3 +174,36 @@ extension RunningWaitingVC { } } } + +// MARK: - Network + +extension RunningWaitingVC { + private func getCourseDetail(courseId: Int) { + LoadingIndicator.showLoading() + + runningProvider.request(.getCourseDetail(courseId: courseId)) { [weak self] response in + guard let self = self else { return } + LoadingIndicator.hideLoading() + switch response { + case .success(let result): + let status = result.statusCode + if 200..<300 ~= status { + do { + let responseDto = try result.map(BaseResponse.self) + guard let data = responseDto.data else { return } + self.setCourseData(courseModel: data.course) + } catch { + print(error.localizedDescription) + } + } + if status >= 400 { + print("400 error") + self.showNetworkFailureToast() + } + case .failure(let error): + print(error.localizedDescription) + self.showNetworkFailureToast() + } + } + } +}