Skip to content
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
4 changes: 4 additions & 0 deletions Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
712F661D2A7B7BAB00D9539B /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 712F661C2A7B7BAB00D9539B /* Config.swift */; };
7136BF8A2AF921A900679364 /* CustomBottomSheetVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7136BF892AF921A900679364 /* CustomBottomSheetVC.swift */; };
713A98F02B29DD9900189B3C /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 713A98EF2B29DD9900189B3C /* GoogleService-Info.plist */; };
715D36E82B2CC64000CAA9D6 /* MyUploadedCourseResponseDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 715D36E72B2CC64000CAA9D6 /* MyUploadedCourseResponseDto.swift */; };
717916DA2B13613B009CEF97 /* MarathonListResponseDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 717916D92B13613B009CEF97 /* MarathonListResponseDto.swift */; };
71BAD06A2B24CECC0061E31D /* UserProfileDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71BAD0692B24CECC0061E31D /* UserProfileDto.swift */; };
71BAD06C2B24D1F70061E31D /* UserProfileVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71BAD06B2B24D1F70061E31D /* UserProfileVC.swift */; };
Expand Down Expand Up @@ -190,6 +191,7 @@
712F661C2A7B7BAB00D9539B /* Config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
7136BF892AF921A900679364 /* CustomBottomSheetVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomBottomSheetVC.swift; sourceTree = "<group>"; };
713A98EF2B29DD9900189B3C /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
715D36E72B2CC64000CAA9D6 /* MyUploadedCourseResponseDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyUploadedCourseResponseDto.swift; sourceTree = "<group>"; };
717916D92B13613B009CEF97 /* MarathonListResponseDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarathonListResponseDto.swift; sourceTree = "<group>"; };
71BAD0692B24CECC0061E31D /* UserProfileDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserProfileDto.swift; sourceTree = "<group>"; };
71BAD06B2B24D1F70061E31D /* UserProfileVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserProfileVC.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -523,6 +525,7 @@
A3305A96296EF58C000B1A10 /* GoalRewardInfoDto.swift */,
CEFA9A2E29FC263700F2D0CF /* UserDeleteResponseDto.swift */,
71BAD0692B24CECC0061E31D /* UserProfileDto.swift */,
715D36E72B2CC64000CAA9D6 /* MyUploadedCourseResponseDto.swift */,
);
path = MyPageDto;
sourceTree = "<group>";
Expand Down Expand Up @@ -1392,6 +1395,7 @@
buildActionMask = 2147483647;
files = (
CE40BB20296805F70030ABCA /* NetworkResult.swift in Sources */,
715D36E82B2CC64000CAA9D6 /* MyUploadedCourseResponseDto.swift in Sources */,
CE55BC11296D4EA600E8CD69 /* RunningRecordRequestDto.swift in Sources */,
CE665604295D91B100C64E12 /* makeAlert.swift in Sources */,
A3BC2F2F2962C40A00198261 /* UploadedCourseInfoVC.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
import Foundation

struct PrivateCourseNotUploadedResponseDto: Codable {
let privateCourses: [Course]
let courses: [Course]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// MyUploadedCourseResponseDto.swift
// Runnect-iOS
//
// Created by 이명진 on 12/16/23.
//

import Foundation

// MARK: - MyUploadedCourseResponseDto
struct MyUploadedCourseResponseDto: Codable {
let user: MyPage
let publicCourses: [PublicCourse]
}

// MARK: - MyPage
struct MyPage: Codable {
let id: Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -601,11 +601,11 @@ extension CourseDetailVC {
print("리절트", result)
let status = result.statusCode
if 200..<300 ~= status {
print("삭제 성공")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
delegate?.didRemoveCourse(publicCourseId: courseId)
print("코스 \(courseId) 번 삭제 성공")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
self.navigationController?.popViewController(animated: true)
}
delegate?.didRemoveCourse(publicCourseId: courseId)
}
if status >= 400 {
print("400 error")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ protocol ScrapStateDelegate: AnyObject {
// 코스 상세 에서 스크랩 누르면 코스발견에 해당 부분 스크랩 누르는 이벤트 전달
}

protocol UploadSuccessDelegate: AnyObject {
// 코스 업로드시, 코스 발견 피드 새로 고침
func didUploadSuccess()
}

final class CourseDiscoveryVC: UIViewController {

// MARK: - Properties
Expand Down Expand Up @@ -118,8 +123,8 @@ extension CourseDiscoveryVC {

private func setAddTarget() {
self.searchButton.addTarget(self, action: #selector(pushToSearchVC), for: .touchUpInside)
self.uploadButton.addTarget(self, action: #selector(pushToDiscoveryVC), for: .touchUpInside)
self.miniUploadButton.addTarget(self, action: #selector(pushToDiscoveryVC), for: .touchUpInside)
self.uploadButton.addTarget(self, action: #selector(pushToCourseSelectVC), for: .touchUpInside)
self.miniUploadButton.addTarget(self, action: #selector(pushToCourseSelectVC), for: .touchUpInside)
}

private func setCombineEvent() {
Expand All @@ -137,6 +142,13 @@ extension CourseDiscoveryVC {
print("\(indexPath) 부분 스크랩 교체 되었음")
}
}

func refresh() {
print("✅ refresh ✅")
pageNo = 1
self.courseList = []
self.getCourseData(pageNo: pageNo)
}
}

// MARK: - @objc Function
Expand All @@ -147,13 +159,14 @@ extension CourseDiscoveryVC {
self.navigationController?.pushViewController(nextVC, animated: true)
}

@objc private func pushToDiscoveryVC() {
@objc private func pushToCourseSelectVC() {
guard UserManager.shared.userType != .visitor else {
self.showToastOnWindow(text: "러넥트에 가입하면 코스를 업로드할 수 있어요.")
return
}

let nextVC = MyCourseSelectVC()
nextVC.delegate = self
self.navigationController?.pushViewController(nextVC, animated: true)
}
}
Expand Down Expand Up @@ -275,6 +288,7 @@ extension CourseDiscoveryVC: UICollectionViewDelegate, UICollectionViewDataSourc
}
}

// 최신순, 스크랩순 막 연달아 누르면 앱 터짐..
private func courseListCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CourseListCVC.className, for: indexPath) as? CourseListCVC else { return UICollectionViewCell() }
cell.setCellType(type: .all)
Expand Down Expand Up @@ -436,11 +450,26 @@ extension CourseDiscoveryVC: ScrapStateDelegate {
}

func didRemoveCourse(publicCourseId: Int) {
if let index = courseList.firstIndex(where: { $0.id == publicCourseId }) {
self.courseList.remove(at: index)
self.mapCollectionView.reloadData()
print("didRemoveCourse= 삭제되었음\n")
}
// if let index = courseList.firstIndex(where: { $0.id == publicCourseId }) {
// courseList.remove(at: index)
// self.mapCollectionView.reloadData()
// }
// ⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️
// 원래 해당하는 데이터(index) 만 가지고, 그 데이터 삭제 후 courseList를 받아야하는데, 삭제가 이미되어버려서 if let index 부분이 안들어옴
// 왜??? 이미 데이터는 삭제가 되어서 $0.id 랑 publicCourseId 가 같은게 매치가 될 수 없어!!!
// 네트워크 성공하기 전에 didRemoveCourse(publicCourseId:) 를 호출 해야 해당 부분 확인하고 지운다음, 서버측에서 지워야 1페이지부터 시작 안하고 지울 수 있음
// ⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️
self.refresh()
}
}

// MARK: - didUploadCourse

extension CourseDiscoveryVC: UploadSuccessDelegate {
func didUploadSuccess() {
print("여기서 didUploadSuccess 함수 호출\n MyCourseSelectVC -> CourseDiscoveryVC 이벤트 전달")
self.refresh()
print("코스 발견 피드 새로고침 완료 되었음")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class CourseUploadVC: UIViewController {
private var courseModel: Course?
private let courseTitleMaxLength = 20

weak var delegate: UploadStateDelegate?

// MARK: - UI Components

private lazy var navibar = CustomNavigationBar(self, type: .titleWithLeftButton).setTitle("코스 업로드")
Expand Down Expand Up @@ -332,7 +334,11 @@ extension CourseUploadVC {
case .success(let result):
let status = result.statusCode
if 200..<300 ~= status {
self.navigationController?.popToRootViewController(animated: true)
delegate?.didUploadCourse()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.navigationController?.popToRootViewController(animated: true)
}
// uploadCourse 업로드 성공하면, 코스발견 CVC 맨 위에 데이터 추가
}
if status >= 400 {
print("400 error")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import UIKit
import Then
import Moya

protocol UploadStateDelegate: AnyObject {
func didUploadCourse()
}

class MyCourseSelectVC: UIViewController {

// MARK: - Properties
Expand All @@ -26,6 +30,8 @@ class MyCourseSelectVC: UIViewController {
}
}

weak var delegate: UploadSuccessDelegate?

// MARK: - UI Components

private lazy var navibar = CustomNavigationBar(self, type: .titleWithLeftButton).setTitle("불러오기")
Expand Down Expand Up @@ -116,11 +122,19 @@ extension MyCourseSelectVC {
@objc private func pushToUploadVC() {
guard let selectedIndex = self.selectedIndex else { return }
let courseUploadVC = CourseUploadVC()
courseUploadVC.delegate = self // 이 부분이 중요합니다.
courseUploadVC.setData(courseModel: courseList[selectedIndex])
self.navigationController?.pushViewController(courseUploadVC, animated: true)
}
}

extension MyCourseSelectVC: UploadStateDelegate {
func didUploadCourse() {
print("여기 한번 거치고\n CourseUploadVC -> MyCourseSelectVC 이벤트 전달\n")
delegate?.didUploadSuccess()
}
}

// MARK: - UI & Layout

extension MyCourseSelectVC {
Expand Down Expand Up @@ -269,7 +283,7 @@ extension MyCourseSelectVC {
do {
let responseDto = try result.map(BaseResponse<PrivateCourseNotUploadedResponseDto>.self)
guard let data = responseDto.data else { return }
self.setData(courseList: data.privateCourses)
self.setData(courseList: data.courses)
} catch {
print(error.localizedDescription)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ extension UploadedCourseInfoVC {
let status = result.statusCode
if 200..<300 ~= status {
do {
let responseDto = try result.map(BaseResponse<PickedMapListResponseDto>.self)
let responseDto = try result.map(BaseResponse<MyUploadedCourseResponseDto>.self)
guard let data = responseDto.data else { return }
self.setData(courseList: data.publicCourses)
UploadedCourseInfoCollectionView.reloadData()
Expand Down