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 @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
0AEBD608F3973389E8E1C6D6 /* Pods_Runnect_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 015778D02D5CDE0838284CD7 /* Pods_Runnect_iOS.framework */; };
A3305A97296EF58C000B1A10 /* GoalRewardInfoDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3305A96296EF58C000B1A10 /* GoalRewardInfoDto.swift */; };
A3BC2F2B2962C3D500198261 /* GoalRewardInfoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F2A2962C3D500198261 /* GoalRewardInfoVC.swift */; };
A3BC2F2D2962C3F200198261 /* ActivityRecordInfoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F2C2962C3F200198261 /* ActivityRecordInfoVC.swift */; };
A3BC2F2F2962C40A00198261 /* UploadedCourseInfoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F2E2962C40A00198261 /* UploadedCourseInfoVC.swift */; };
Expand Down Expand Up @@ -145,6 +146,7 @@
/* Begin PBXFileReference section */
015778D02D5CDE0838284CD7 /* Pods_Runnect_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runnect_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3C3033C911343B5C57EB68E7 /* Pods-Runnect-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runnect-iOS.debug.xcconfig"; path = "Target Support Files/Pods-Runnect-iOS/Pods-Runnect-iOS.debug.xcconfig"; sourceTree = "<group>"; };
A3305A96296EF58C000B1A10 /* GoalRewardInfoDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoalRewardInfoDto.swift; sourceTree = "<group>"; };
A3BC2F2A2962C3D500198261 /* GoalRewardInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoalRewardInfoVC.swift; sourceTree = "<group>"; };
A3BC2F2C2962C3F200198261 /* ActivityRecordInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityRecordInfoVC.swift; sourceTree = "<group>"; };
A3BC2F2E2962C40A00198261 /* UploadedCourseInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadedCourseInfoVC.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -416,6 +418,7 @@
CE10063D29680C8100FD31FB /* .gitkeep */,
A3F67AE1296D33AC001598A2 /* MyPageDto.swift */,
A3F67AE9296E4936001598A2 /* ActivityRecordInfoDto.swift */,
A3305A96296EF58C000B1A10 /* GoalRewardInfoDto.swift */,
);
path = MyPageDto;
sourceTree = "<group>";
Expand Down Expand Up @@ -1305,6 +1308,7 @@
CEC2A68729629B9B00160BF7 /* SignInVC.swift in Sources */,
CE665602295D918000C64E12 /* JsonCoder.swift in Sources */,
CE4545CD295D7AF4003201E1 /* TaBarController.swift in Sources */,
A3305A97296EF58C000B1A10 /* GoalRewardInfoDto.swift in Sources */,
CE6655F4295D898400C64E12 /* UIViewController+.swift in Sources */,
CE320F36296C8EAB009F89A7 /* CourseDrawingRouter.swift in Sources */,
CE14677829658C7200DCEA1B /* Stopwatch.swift in Sources */,
Expand Down
6 changes: 3 additions & 3 deletions Runnect-iOS/Runnect-iOS/Global/Literal/ImageLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ enum ImageLiterals {
static var imgStampC1: UIImage { .load(named: "img_stamp_c1") }
static var imgStampC2: UIImage { .load(named: "img_stamp_c2") }
static var imgStampC3: UIImage { .load(named: "img_stamp_c3") }
static var imgStampP1: UIImage { .load(named: "img_stamp_p1") }
static var imgStampP2: UIImage { .load(named: "img_stamp_p2") }
static var imgStampP3: UIImage { .load(named: "img_stamp_p3") }
static var imgStampU1: UIImage { .load(named: "img_stamp_u1") }
static var imgStampU2: UIImage { .load(named: "img_stamp_u2") }
static var imgStampU3: UIImage { .load(named: "img_stamp_u3") }
static var imgStampR1: UIImage { .load(named: "img_stamp_r1") }
static var imgStampR2: UIImage { .load(named: "img_stamp_r2") }
static var imgStampR3: UIImage { .load(named: "img_stamp_r3") }
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"images" : [
{
"filename" : "Component 89.png",
"filename" : "mypage_img_stamp6.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Component 89@2x.png",
"filename" : "mypage_img_stamp6@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Component 89@3x.png",
"filename" : "mypage_img_stamp6@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// GoalRewardInfoDto.swift
// Runnect-iOS
//
// Created by 몽이 누나 on 2023/01/11.
//

import Foundation

// MARK: - GoalRewardInfoDto

struct GoalRewardInfoDto: Codable {
let stamps: [GoalRewardStamp]
}

// MARK: - GoalRewardStamp

struct GoalRewardStamp: Codable {
let id: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum MyPageRouter {
case getMyPageInfo
case getUploadedCourseInfo
case getActivityRecordInfo
case getGoalRewardInfo
}

extension MyPageRouter: TargetType {
Expand All @@ -32,40 +33,28 @@ extension MyPageRouter: TargetType {
return "/public-course/user"
case .getActivityRecordInfo:
return "/record/user"
case .getGoalRewardInfo:
return "/stamp/user"
}
}

var method: Moya.Method {
switch self {
case .getMyPageInfo:
return .get
case .getUploadedCourseInfo:
return .get
case .getActivityRecordInfo:
case .getMyPageInfo, .getUploadedCourseInfo, .getActivityRecordInfo, .getGoalRewardInfo:
return .get
}
}

var task: Moya.Task {
switch self {
case .getMyPageInfo:
return .requestPlain
case .getUploadedCourseInfo:
return .requestPlain
case .getActivityRecordInfo:
case .getMyPageInfo, .getUploadedCourseInfo, .getActivityRecordInfo, .getGoalRewardInfo:
return .requestPlain
}
}

var headers: [String: String]? {
switch self {
case .getMyPageInfo:
return ["Content-Type": "application/json",
"machineId": "1"]
case .getUploadedCourseInfo:
return ["Content-Type": "application/json",
"machineId": "1"]
case .getActivityRecordInfo:
case .getMyPageInfo, .getUploadedCourseInfo, .getActivityRecordInfo, .getGoalRewardInfo:
return ["Content-Type": "application/json",
"machineId": "1"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
//

import UIKit

import SnapKit
import Then
import Kingfisher

// MARK: - GoalRewardInfoCVC

Expand All @@ -33,10 +35,24 @@ final class GoalRewardInfoCVC: UICollectionViewCell {
}
}

// MARK: - Methods

extension GoalRewardInfoCVC {
func setData(model: GoalRewardInfoModel, item: Bool) {
if item == true {
stampImageView.image = model.stampImg

} else {
stampImageView.image = ImageLiterals.imgLock
}
stampStandardLabel.text = model.stampStandard
}
}

extension GoalRewardInfoCVC {

// MARK: - Layout Helpers

private func setLayout() {
contentView.addSubviews(stampImageView, stampStandardLabel)

Expand All @@ -50,11 +66,4 @@ extension GoalRewardInfoCVC {
make.centerX.equalToSuperview()
}
}

// MARK: - General Helpers

func dataBind(model: GoalRewardInfoModel) {
stampImageView.image = model.stampImg
stampStandardLabel.text = model.stampStandard
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,29 @@ struct GoalRewardInfoModel {
let stampImg: UIImage
let stampStandard: String
}

extension GoalRewardInfoModel {
static var stampNameList: [GoalRewardInfoModel] {
return [
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampC1, stampStandard: "그린 코스 1개"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampC2, stampStandard: "그린 코스 5개"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampC3, stampStandard: "그린 코스 10개"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS1, stampStandard: "스크랩 1회"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS2, stampStandard: "스크랩 5회"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS3, stampStandard: "스크랩 10회"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampU1, stampStandard: "업로드 1회"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampU2, stampStandard: "업로드 5회"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampU3, stampStandard: "업로드 10회"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR1, stampStandard: "달리기 1회"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR2, stampStandard: "달리기 5회"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR2, stampStandard: "달리기 10회")
]
}

static var stampNameImageDictionary: [String: UIImage] { ["c1": ImageLiterals.imgStampC1, "c2": ImageLiterals.imgStampC2, "c3": ImageLiterals.imgStampC3,
"s1": ImageLiterals.imgStampS1, "s2": ImageLiterals.imgStampS2, "s3": ImageLiterals.imgStampS3,
"u1": ImageLiterals.imgStampU1, "u2": ImageLiterals.imgStampU2, "u3": ImageLiterals.imgStampU3,
"r1": ImageLiterals.imgStampR1, "r2": ImageLiterals.imgStampR2, "r3": ImageLiterals.imgStampR3]

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,26 @@
//

import UIKit

import SnapKit
import Then
import Moya

final class GoalRewardInfoVC: UIViewController {

// MARK: - Properties
private var goalRewardProvider = MoyaProvider<MyPageRouter>(
plugins: [NetworkLoggerPlugin(verbose: true)]
)

var stampNameList: [GoalRewardInfoModel] = GoalRewardInfoModel.stampNameList

var stampList: [GoalRewardInfoModel] = [
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampC1, stampStandard: "그리기 스타터"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampC2, stampStandard: "그리기 중수"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampC3, stampStandard: "그리기 마스터"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS1, stampStandard: "스크랩 베이비"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS2, stampStandard: "스크랩 어린이"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS3, stampStandard: "스크랩 어른이"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampP1, stampStandard: "새싹 업로더"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampP2, stampStandard: "중수 업로더"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampP3, stampStandard: "인플루언서"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR1, stampStandard: "달리기 유망주"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR2, stampStandard: "아마추어 선수"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR2, stampStandard: "마라톤 선수")
]
private var goalRewardList = [GoalRewardStamp]()
let stampNameDictionary: [String: Int] = ["c1": 0, "c2": 1, "c3": 2,
"s1": 3, "s2": 4, "s3": 5,
"u1": 6, "u2": 7, "u3": 8,
"r1": 9, "r2": 10, "r3": 11]
var isStampExistList = Array(repeating: false, count: 12)

// MARK: - Constants

Expand Down Expand Up @@ -57,8 +56,6 @@ final class GoalRewardInfoVC: UIViewController {
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.isScrollEnabled = true
collectionView.showsVerticalScrollIndicator = false
collectionView.delegate = self
collectionView.dataSource = self

return collectionView
}()
Expand All @@ -70,7 +67,32 @@ final class GoalRewardInfoVC: UIViewController {
setNavigationBar()
setUI()
setLayout()
setDelegate()
register()
getGoalRewardInfo()
}
}

// MARK: - Methods

extension GoalRewardInfoVC {
private func setDelegate() {
stampCollectionView.delegate = self
stampCollectionView.dataSource = self
}

private func register() {
stampCollectionView.register(GoalRewardInfoCVC.self,
forCellWithReuseIdentifier: GoalRewardInfoCVC.className)
}

func setIsStampExistList(list: [GoalRewardStamp]) {
for stamp in list {
guard let index = stampNameDictionary[stamp.id] else { return }
self.isStampExistList[index] = true
}

stampCollectionView.reloadData()
}
}

Expand Down Expand Up @@ -121,13 +143,6 @@ extension GoalRewardInfoVC {
make.bottom.equalToSuperview()
}
}

// MARK: - General Helpers

private func register() {
stampCollectionView.register(GoalRewardInfoCVC.self,
forCellWithReuseIdentifier: GoalRewardInfoCVC.className)
}
}

// MARK: - UICollectionViewDelegateFlowLayout
Expand All @@ -153,12 +168,44 @@ extension GoalRewardInfoVC: UICollectionViewDelegateFlowLayout {

extension GoalRewardInfoVC: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return stampList.count
return stampNameList.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let stampCell = collectionView.dequeueReusableCell(withReuseIdentifier: GoalRewardInfoCVC.className, for: indexPath) as? GoalRewardInfoCVC else { return UICollectionViewCell()}
stampCell.dataBind(model: stampList[indexPath.item])
stampCell.setData(model: stampNameList[indexPath.item], item: isStampExistList[indexPath.item])
return stampCell
}
}

// MARK: - Network

extension GoalRewardInfoVC {
func getGoalRewardInfo() {
LoadingIndicator.showLoading()
goalRewardProvider.request(.getGoalRewardInfo) { [weak self] response in
LoadingIndicator.hideLoading()
guard let self = self else { return }
switch response {
case .success(let result):
let status = result.statusCode
if 200..<300 ~= status {
do {
let responseDto = try result.map(BaseResponse<GoalRewardInfoDto>.self)
guard let data = responseDto.data else { return }
self.setIsStampExistList(list: data.stamps)
} catch {
print(error.localizedDescription)
}
}
if status >= 400 {
print("400 error")
self.showNetworkFailureToast()
}
case .failure(let error):
print(error.localizedDescription)
self.showNetworkFailureToast()
}
}
}
}
Loading