Skip to content

Commit

Permalink
[Chore] Runnect#84 - MyPage 유저 프로필 이미지 데이터 바인딩
Browse files Browse the repository at this point in the history
  • Loading branch information
dlwogus0128 committed Jan 12, 2023
1 parent e8433bc commit 681351a
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 27 deletions.
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
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 @@ -18,22 +18,13 @@ final class GoalRewardInfoVC: UIViewController {
plugins: [NetworkLoggerPlugin(verbose: true)]
)

var stampNameList: [GoalRewardInfoModel] = [
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.imgStampP1, stampStandard: "업로드 1회"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampP2, stampStandard: "업로드 5회"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampP3, stampStandard: "업로드 10회"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR1, stampStandard: "달리기 1회"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR2, stampStandard: "달리기 5회"),
GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR2, stampStandard: "달리기 10회")
]
var stampNameList: [GoalRewardInfoModel] = GoalRewardInfoModel.stampNameList

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 @@ -96,18 +87,11 @@ extension GoalRewardInfoVC {
}

func setIsStampExistList(list: [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]

for stamp in list {
guard let index = stampNameDictionary[stamp.id] else { return }
self.isStampExistList[index] = true
}

print(isStampExistList)

stampCollectionView.reloadData()
}
}
Expand Down
11 changes: 8 additions & 3 deletions Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ final class MyPageVC: UIViewController {
private var myPageProvider = MoyaProvider<MyPageRouter>(
plugins: [NetworkLoggerPlugin(verbose: true)]
)

let stampNameImageDictionary: [String: UIImage] = GoalRewardInfoModel.stampNameImageDictionary

// MARK: - UI Components

Expand All @@ -28,9 +30,7 @@ final class MyPageVC: UIViewController {
private let secondDivideView = UIView()
private let thirdDivideView = UIView()

private let myProfileImage = UIImageView().then {
$0.image = ImageLiterals.imgStampR2
}
private let myProfileImage = UIImageView()

private let myProfileNameLabel = UILabel().then {
$0.textColor = .m1
Expand Down Expand Up @@ -159,6 +159,7 @@ extension MyPageVC {
self.myRunningProgressBar.setProgress(Float(model.user.levelPercent)/100, animated: false)
setMyRunningProgressPercentLabel(label: myRunnigProgressPercentLabel, model: model)
setMyRunningLevelLavel(label: myRunningLevelLavel, model: model)
setMyProfileImage(model: model)
}

private func setMyRunningProgressPercentLabel(label: UILabel, model: MyPageDto) {
Expand All @@ -173,6 +174,10 @@ extension MyPageVC {
label.attributedText = attributedString
}

private func setMyProfileImage(model: MyPageDto) {
guard let profileImage = stampNameImageDictionary[model.user.latestStamp] else { return }
myProfileImage.image = profileImage
}
}

// MARK: - @objc Function
Expand Down

0 comments on commit 681351a

Please sign in to comment.