From 83f9d876dc9ac392fc59ac5fc7aaa44c229c2af5 Mon Sep 17 00:00:00 2001 From: dlwogus0128 <79050615+dlwogus0128@users.noreply.github.com> Date: Mon, 2 Jan 2023 18:09:30 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[Feat]=20#15=20-=20NavigationBar=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPage/VC/InfoVC/GoalRewardInfoVC.swift | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift index 6922d4dc..87d3e9a1 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift @@ -6,17 +6,38 @@ // import UIKit +import SnapKit +import Then final class GoalRewardInfoVC: UIViewController { + + // MARK: - UI Components + + private lazy var navibar = CustomNavigationBar(self, type: .titleWithLeftButton).setTitle("목표 보상") override func viewDidLoad() { super.viewDidLoad() + setNavigationBar() setUI() // Do any additional setup after loading the view. } } +// MARK: - Methods +// MARK: - @objc Function + +// MARK: - UI & Layout + extension GoalRewardInfoVC { + private func setNavigationBar() { + view.addSubview(navibar) + + navibar.snp.makeConstraints { make in + make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide) + make.height.equalTo(48) + } + } + private func setUI() { view.backgroundColor = .w1 } From b0697c8bf5e5c3c5b0ee5a9216a9d9d6ef6be6af Mon Sep 17 00:00:00 2001 From: dlwogus0128 <79050615+dlwogus0128@users.noreply.github.com> Date: Mon, 2 Jan 2023 18:31:50 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[Feat]=20#15=20-=20stamp=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=EC=99=80=20=ED=85=8D=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=9D=BC=EB=B2=A8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPage/VC/InfoVC/GoalRewardInfoVC.swift | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift index 87d3e9a1..a8a87dd4 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift @@ -14,11 +14,24 @@ final class GoalRewardInfoVC: UIViewController { // MARK: - UI Components private lazy var navibar = CustomNavigationBar(self, type: .titleWithLeftButton).setTitle("목표 보상") - + private let stampTopView = UIView() + private let stampBottomView = UIView() + + private let stampImage = UIImageView().then { + $0.image = ImageLiterals.imgStamp + } + + private let stampExcourageLabel = UILabel().then { + $0.text = "다양한 코스를 달리며 러닝 스탬프를 모아봐요" + $0.textColor = .g2 + $0.font = .b4 + } + override func viewDidLoad() { super.viewDidLoad() setNavigationBar() setUI() + setLayout() // Do any additional setup after loading the view. } } @@ -40,5 +53,36 @@ extension GoalRewardInfoVC { private func setUI() { view.backgroundColor = .w1 + stampBottomView.backgroundColor = .m3 + } + + private func setLayout() { + view.addSubviews(stampTopView, stampBottomView) + + stampTopView.snp.makeConstraints { make in + make.top.equalTo(navibar.snp.bottom) + make.leading.trailing.equalTo(view.safeAreaLayoutGuide) + make.height.equalTo(235) + } + + stampTopView.addSubviews(stampImage, stampExcourageLabel) + + stampImage.snp.makeConstraints { make in + make.top.equalToSuperview() + make.centerX.equalToSuperview() + make.width.equalTo(181) + make.height.equalTo(167) + } + + stampExcourageLabel.snp.makeConstraints { make in + make.top.equalTo(stampImage.snp.bottom).offset(16) + make.centerX.equalToSuperview() + } + + stampBottomView.snp.makeConstraints { make in + make.top.equalTo(stampTopView.snp.bottom) + make.leading.trailing.equalTo(view.safeAreaLayoutGuide) + make.height.equalTo(view.safeAreaLayoutGuide).inset(80) + } } } From 9e214344503da6efe8c36c009475f1d16fca8538 Mon Sep 17 00:00:00 2001 From: dlwogus0128 <79050615+dlwogus0128@users.noreply.github.com> Date: Mon, 2 Jan 2023 20:56:15 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[Feat]=20#15=20-=20stampList=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runnect-iOS.xcodeproj/project.pbxproj | 12 ++++++++ .../GoalRewardInfoModel.swift | 13 ++++++++ .../MyPage/VC/InfoVC/GoalRewardInfoVC.swift | 30 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoModel.swift diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index 818d63f0..38d57d81 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 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 */; }; + A3BC2F322962E0DB00198261 /* GoalRewardInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F312962E0DB00198261 /* GoalRewardInfoModel.swift */; }; CE17F02D2961BBA100E1DED0 /* ColorLiterals.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE17F02C2961BBA100E1DED0 /* ColorLiterals.swift */; }; CE17F0332961BEF800E1DED0 /* Pretendard-Medium.otf in Resources */ = {isa = PBXBuildFile; fileRef = CE17F02F2961BEF800E1DED0 /* Pretendard-Medium.otf */; }; CE17F0342961BEF800E1DED0 /* Pretendard-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = CE17F0302961BEF800E1DED0 /* Pretendard-Bold.otf */; }; @@ -81,6 +82,7 @@ A3BC2F2A2962C3D500198261 /* GoalRewardInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoalRewardInfoVC.swift; sourceTree = ""; }; A3BC2F2C2962C3F200198261 /* ActivityRecordInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityRecordInfoVC.swift; sourceTree = ""; }; A3BC2F2E2962C40A00198261 /* UploadedCourseInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadedCourseInfoVC.swift; sourceTree = ""; }; + A3BC2F312962E0DB00198261 /* GoalRewardInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoalRewardInfoModel.swift; sourceTree = ""; }; CE17F02C2961BBA100E1DED0 /* ColorLiterals.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorLiterals.swift; sourceTree = ""; }; CE17F02F2961BEF800E1DED0 /* Pretendard-Medium.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-Medium.otf"; sourceTree = ""; }; CE17F0302961BEF800E1DED0 /* Pretendard-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-Bold.otf"; sourceTree = ""; }; @@ -191,6 +193,7 @@ A3BC2F292962C39F00198261 /* InfoVC */ = { isa = PBXGroup; children = ( + A3BC2F302962E08400198261 /* GoalRewardInfoCollectionView */, A3BC2F2A2962C3D500198261 /* GoalRewardInfoVC.swift */, A3BC2F2C2962C3F200198261 /* ActivityRecordInfoVC.swift */, A3BC2F2E2962C40A00198261 /* UploadedCourseInfoVC.swift */, @@ -198,6 +201,14 @@ path = InfoVC; sourceTree = ""; }; + A3BC2F302962E08400198261 /* GoalRewardInfoCollectionView */ = { + isa = PBXGroup; + children = ( + A3BC2F312962E0DB00198261 /* GoalRewardInfoModel.swift */, + ); + path = GoalRewardInfoCollectionView; + sourceTree = ""; + }; CE17F02E2961BEAE00E1DED0 /* Fonts */ = { isa = PBXGroup; children = ( @@ -804,6 +815,7 @@ CE665612295D92E400C64E12 /* UserDefaultWrapper.swift in Sources */, CE665610295D92C200C64E12 /* setTextLineHeight.swift in Sources */, CE6655E2295D87EB00C64E12 /* UIImage+.swift in Sources */, + A3BC2F322962E0DB00198261 /* GoalRewardInfoModel.swift in Sources */, CE5875A4296015D2005D967E /* Encodable+.swift in Sources */, CEEC6B4B2961D89700D00E1E /* CustomNavigationBar.swift in Sources */, CE17F02D2961BBA100E1DED0 /* ColorLiterals.swift in Sources */, diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoModel.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoModel.swift new file mode 100644 index 00000000..fdf6def1 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoModel.swift @@ -0,0 +1,13 @@ +// +// GoalRewardInfoModel.swift +// Runnect-iOS +// +// Created by 몽이 누나 on 2023/01/02. +// + +import Foundation + +struct GoalRewardInfoModel { + let stampImg: String + let stampStandard: String +} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift index a8a87dd4..395e9a23 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift @@ -27,6 +27,36 @@ final class GoalRewardInfoVC: UIViewController { $0.font = .b4 } + private let stampCollectionView: UICollectionView = { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .vertical + + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) + collectionView.translatesAutoresizingMaskIntoConstraints = false + collectionView.isScrollEnabled = true + collectionView.showsVerticalScrollIndicator = false + + return collectionView + }() + + // MARK: - Variables + + var stampList: [GoalRewardInfoModel] = [ + GoalRewardInfoModel(stampImg: ImageLiterals.imgStampC1.className, stampStandard: "그리기 스타터"), + GoalRewardInfoModel(stampImg: ImageLiterals.imgStampC2.className, stampStandard: "그리기 중수"), + GoalRewardInfoModel(stampImg: ImageLiterals.imgStampC3.className, stampStandard: "그리기 마스터"), + GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS1.className, stampStandard: "스크랩 베이비"), + GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS2.className, stampStandard: "스크랩 어린이"), + GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS3.className, stampStandard: "스크랩 어른이"), + GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS3.className, stampStandard: "스크랩 어른이"), + GoalRewardInfoModel(stampImg: ImageLiterals.imgStampP1.className, stampStandard: "새싹 업로더"), + GoalRewardInfoModel(stampImg: ImageLiterals.imgStampP2.className, stampStandard: "중수 업로더"), + GoalRewardInfoModel(stampImg: ImageLiterals.imgStampP3.className, stampStandard: "인플루언서"), + GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR1.className, stampStandard: "달리기 유망주"), + GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR2.className, stampStandard: "아마추어 선수"), + GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR2.className, stampStandard: "마라톤 선수") + ] + override func viewDidLoad() { super.viewDidLoad() setNavigationBar() From a0ba27d8cec20ccbbf50e16d2882e3faa001c955 Mon Sep 17 00:00:00 2001 From: dlwogus0128 <79050615+dlwogus0128@users.noreply.github.com> Date: Mon, 2 Jan 2023 23:36:40 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[Feat]=20#15=20-=20stampCollectionView=20?= =?UTF-8?q?=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 | 4 + .../GoalRewardInfoCVC.swift | 72 ++++++++++++ .../GoalRewardInfoModel.swift | 4 +- .../MyPage/VC/InfoVC/GoalRewardInfoVC.swift | 104 +++++++++++++++--- 4 files changed, 167 insertions(+), 17 deletions(-) create mode 100644 Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoCVC.swift diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index 38d57d81..87f29244 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ A3BC2F2D2962C3F200198261 /* ActivityRecordInfoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F2C2962C3F200198261 /* ActivityRecordInfoVC.swift */; }; A3BC2F2F2962C40A00198261 /* UploadedCourseInfoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F2E2962C40A00198261 /* UploadedCourseInfoVC.swift */; }; A3BC2F322962E0DB00198261 /* GoalRewardInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F312962E0DB00198261 /* GoalRewardInfoModel.swift */; }; + A3BC2F34296303A600198261 /* GoalRewardInfoCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F33296303A600198261 /* GoalRewardInfoCVC.swift */; }; CE17F02D2961BBA100E1DED0 /* ColorLiterals.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE17F02C2961BBA100E1DED0 /* ColorLiterals.swift */; }; CE17F0332961BEF800E1DED0 /* Pretendard-Medium.otf in Resources */ = {isa = PBXBuildFile; fileRef = CE17F02F2961BEF800E1DED0 /* Pretendard-Medium.otf */; }; CE17F0342961BEF800E1DED0 /* Pretendard-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = CE17F0302961BEF800E1DED0 /* Pretendard-Bold.otf */; }; @@ -83,6 +84,7 @@ A3BC2F2C2962C3F200198261 /* ActivityRecordInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityRecordInfoVC.swift; sourceTree = ""; }; A3BC2F2E2962C40A00198261 /* UploadedCourseInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadedCourseInfoVC.swift; sourceTree = ""; }; A3BC2F312962E0DB00198261 /* GoalRewardInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoalRewardInfoModel.swift; sourceTree = ""; }; + A3BC2F33296303A600198261 /* GoalRewardInfoCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoalRewardInfoCVC.swift; sourceTree = ""; }; CE17F02C2961BBA100E1DED0 /* ColorLiterals.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorLiterals.swift; sourceTree = ""; }; CE17F02F2961BEF800E1DED0 /* Pretendard-Medium.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-Medium.otf"; sourceTree = ""; }; CE17F0302961BEF800E1DED0 /* Pretendard-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-Bold.otf"; sourceTree = ""; }; @@ -205,6 +207,7 @@ isa = PBXGroup; children = ( A3BC2F312962E0DB00198261 /* GoalRewardInfoModel.swift */, + A3BC2F33296303A600198261 /* GoalRewardInfoCVC.swift */, ); path = GoalRewardInfoCollectionView; sourceTree = ""; @@ -821,6 +824,7 @@ CE17F02D2961BBA100E1DED0 /* ColorLiterals.swift in Sources */, CE6655D2295D862A00C64E12 /* Publisher+Driver.swift in Sources */, CE6655E6295D887F00C64E12 /* UIStackView+.swift in Sources */, + A3BC2F34296303A600198261 /* GoalRewardInfoCVC.swift in Sources */, CE6655CA295D84DD00C64E12 /* UserDefaultKeyList.swift in Sources */, CE6655F2295D894D00C64E12 /* UIView+.swift in Sources */, CE665600295D915D00C64E12 /* getClassName.swift in Sources */, diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoCVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoCVC.swift new file mode 100644 index 00000000..85474d68 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoCVC.swift @@ -0,0 +1,72 @@ +// +// GoalRewardInfoCVC.swift +// Runnect-iOS +// +// Created by 몽이 누나 on 2023/01/02. +// + +import UIKit +import SnapKit +import Then + +// MARK: - GoalRewardInfoCVC + +class GoalRewardInfoCVC: UICollectionViewCell { + + // MARK: - Identifier + + static let identifier = "GoalRewardInfoCVC" + + // MARK: - UI Components + + private let containerView = UIView() + private let stampImageView = UIImageView() + private let stampStandardLabel = UILabel().then { + $0.textColor = .g1 + $0.font = .b7 + } + + // MARK: - Life Cycles + + override init(frame: CGRect) { + super.init(frame: frame) + setLayout() + } + + required init(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} + +extension GoalRewardInfoCVC { + + // MARK: - Layout Helpers + + private func setLayout() { + contentView.addSubviews(stampImageView, stampStandardLabel) + + contentView.snp.makeConstraints { make in + make.top.equalToSuperview() + make.centerX.equalToSuperview() + make.leading.equalToSuperview() + make.height.equalTo(112) + } + + stampImageView.snp.makeConstraints { make in + make.top.leading.trailing.equalToSuperview() + make.width.equalTo(90) + } + + stampStandardLabel.snp.makeConstraints { make in + make.top.equalTo(stampImageView.snp.bottom).offset(8) + make.centerX.equalToSuperview() + } + } + + // MARK: - General Helpers + + func dataBind(model: GoalRewardInfoModel) { + stampImageView.image = model.stampImg + stampStandardLabel.text = model.stampStandard + } +} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoModel.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoModel.swift index fdf6def1..61202843 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoModel.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoModel.swift @@ -5,9 +5,9 @@ // Created by 몽이 누나 on 2023/01/02. // -import Foundation +import UIKit struct GoalRewardInfoModel { - let stampImg: String + let stampImg: UIImage let stampStandard: String } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift index 395e9a23..41e772f4 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift @@ -27,7 +27,7 @@ final class GoalRewardInfoVC: UIViewController { $0.font = .b4 } - private let stampCollectionView: UICollectionView = { + private lazy var stampCollectionView: UICollectionView = { let layout = UICollectionViewFlowLayout() layout.scrollDirection = .vertical @@ -35,6 +35,8 @@ final class GoalRewardInfoVC: UIViewController { collectionView.translatesAutoresizingMaskIntoConstraints = false collectionView.isScrollEnabled = true collectionView.showsVerticalScrollIndicator = false + collectionView.delegate = self + collectionView.dataSource = self return collectionView }() @@ -42,36 +44,49 @@ final class GoalRewardInfoVC: UIViewController { // MARK: - Variables var stampList: [GoalRewardInfoModel] = [ - GoalRewardInfoModel(stampImg: ImageLiterals.imgStampC1.className, stampStandard: "그리기 스타터"), - GoalRewardInfoModel(stampImg: ImageLiterals.imgStampC2.className, stampStandard: "그리기 중수"), - GoalRewardInfoModel(stampImg: ImageLiterals.imgStampC3.className, stampStandard: "그리기 마스터"), - GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS1.className, stampStandard: "스크랩 베이비"), - GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS2.className, stampStandard: "스크랩 어린이"), - GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS3.className, stampStandard: "스크랩 어른이"), - GoalRewardInfoModel(stampImg: ImageLiterals.imgStampS3.className, stampStandard: "스크랩 어른이"), - GoalRewardInfoModel(stampImg: ImageLiterals.imgStampP1.className, stampStandard: "새싹 업로더"), - GoalRewardInfoModel(stampImg: ImageLiterals.imgStampP2.className, stampStandard: "중수 업로더"), - GoalRewardInfoModel(stampImg: ImageLiterals.imgStampP3.className, stampStandard: "인플루언서"), - GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR1.className, stampStandard: "달리기 유망주"), - GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR2.className, stampStandard: "아마추어 선수"), - GoalRewardInfoModel(stampImg: ImageLiterals.imgStampR2.className, stampStandard: "마라톤 선수") + 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: "마라톤 선수") ] + // MARK: - Constants + + final let stampInset: UIEdgeInsets = UIEdgeInsets(top: 32, left: 34, bottom: 10, right: 34) + final let stampLineSpacing: CGFloat = 20 + final let stampItemSpacing: CGFloat = 26 + final let stampCellHeight: CGFloat = 112 + + // MARK: - View Life Cycle + override func viewDidLoad() { super.viewDidLoad() setNavigationBar() setUI() setLayout() - // Do any additional setup after loading the view. + register() } + } // MARK: - Methods + // MARK: - @objc Function // MARK: - UI & Layout extension GoalRewardInfoVC { + + // MARK: - Layout Helpers + private func setNavigationBar() { view.addSubview(navibar) @@ -84,6 +99,7 @@ extension GoalRewardInfoVC { private func setUI() { view.backgroundColor = .w1 stampBottomView.backgroundColor = .m3 + stampCollectionView.backgroundColor = .m3 } private func setLayout() { @@ -114,5 +130,63 @@ extension GoalRewardInfoVC { make.leading.trailing.equalTo(view.safeAreaLayoutGuide) make.height.equalTo(view.safeAreaLayoutGuide).inset(80) } + + stampBottomView.addSubview(stampCollectionView) + + stampCollectionView.snp.makeConstraints { make in + make.top.leading.trailing.equalToSuperview() + make.height.equalTo(calculateCellHeight()) + } + } + + // MARK: - General Helpers + + private func register() { + stampCollectionView.register(GoalRewardInfoCVC.self, + forCellWithReuseIdentifier: GoalRewardInfoCVC.identifier) + } + + func calculateCellHeight() -> CGFloat { + let count = CGFloat(stampList.count) + let heightCount = count / 3 + count.truncatingRemainder(dividingBy: 3) + return heightCount * stampCellHeight + (heightCount - 1) * stampLineSpacing + stampInset.top + stampInset.bottom + } + +} + +// MARK: - UICollectionViewDelegateFlowLayout + +extension GoalRewardInfoVC: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + let screenWidth = UIScreen.main.bounds.width + let tripleCellWidth = screenWidth - stampInset.left - stampInset.right - stampItemSpacing * 2 + return CGSize(width: tripleCellWidth / 3, height: 112) + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { + return stampLineSpacing + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { + return stampLineSpacing + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { + return stampInset + } +} + +// MARK: - UICollectionViewDataSource + +extension GoalRewardInfoVC: UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return stampList.count + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let stampCell = collectionView.dequeueReusableCell(withReuseIdentifier: GoalRewardInfoCVC.identifier, for: indexPath) as? GoalRewardInfoCVC else { return UICollectionViewCell()} + stampCell.dataBind(model: stampList[indexPath.item]) + return stampCell } + } From a32508cfea16b62eb83d3dddb48db644f146e561 Mon Sep 17 00:00:00 2001 From: dlwogus0128 <79050615+dlwogus0128@users.noreply.github.com> Date: Tue, 3 Jan 2023 11:20:37 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[Fix]=20#15=20-=20=EC=BD=94=EB=A9=98?= =?UTF-8?q?=ED=8A=B8=20=EB=B0=9B=EC=9D=80=20=EB=B6=80=EB=B6=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GoalRewardInfoCVC.swift | 6 +- .../MyPage/VC/InfoVC/GoalRewardInfoVC.swift | 82 +++++++------------ .../Presentation/MyPage/VC/MyPageVC.swift | 2 +- 3 files changed, 31 insertions(+), 59 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoCVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoCVC.swift index 85474d68..6fbe6d0e 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoCVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoCollectionView/GoalRewardInfoCVC.swift @@ -11,11 +11,7 @@ import Then // MARK: - GoalRewardInfoCVC -class GoalRewardInfoCVC: UICollectionViewCell { - - // MARK: - Identifier - - static let identifier = "GoalRewardInfoCVC" +final class GoalRewardInfoCVC: UICollectionViewCell { // MARK: - UI Components diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift index 41e772f4..77cc6cea 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/GoalRewardInfoVC.swift @@ -11,11 +11,34 @@ import Then final class GoalRewardInfoVC: UIViewController { + // MARK: - Variables + + 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: "마라톤 선수") + ] + + // MARK: - Constants + + final let stampInset: UIEdgeInsets = UIEdgeInsets(top: 32, left: 34, bottom: 10, right: 34) + final let stampLineSpacing: CGFloat = 20 + final let stampItemSpacing: CGFloat = 26 + final let stampCellHeight: CGFloat = 112 + // MARK: - UI Components private lazy var navibar = CustomNavigationBar(self, type: .titleWithLeftButton).setTitle("목표 보상") private let stampTopView = UIView() - private let stampBottomView = UIView() private let stampImage = UIImageView().then { $0.image = ImageLiterals.imgStamp @@ -41,30 +64,6 @@ final class GoalRewardInfoVC: UIViewController { return collectionView }() - // MARK: - Variables - - 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: "마라톤 선수") - ] - - // MARK: - Constants - - final let stampInset: UIEdgeInsets = UIEdgeInsets(top: 32, left: 34, bottom: 10, right: 34) - final let stampLineSpacing: CGFloat = 20 - final let stampItemSpacing: CGFloat = 26 - final let stampCellHeight: CGFloat = 112 - // MARK: - View Life Cycle override func viewDidLoad() { @@ -74,15 +73,8 @@ final class GoalRewardInfoVC: UIViewController { setLayout() register() } - } -// MARK: - Methods - -// MARK: - @objc Function - -// MARK: - UI & Layout - extension GoalRewardInfoVC { // MARK: - Layout Helpers @@ -98,12 +90,11 @@ extension GoalRewardInfoVC { private func setUI() { view.backgroundColor = .w1 - stampBottomView.backgroundColor = .m3 stampCollectionView.backgroundColor = .m3 } private func setLayout() { - view.addSubviews(stampTopView, stampBottomView) + view.addSubviews(stampTopView, stampCollectionView) stampTopView.snp.makeConstraints { make in make.top.equalTo(navibar.snp.bottom) @@ -125,17 +116,10 @@ extension GoalRewardInfoVC { make.centerX.equalToSuperview() } - stampBottomView.snp.makeConstraints { make in + stampCollectionView.snp.makeConstraints { make in make.top.equalTo(stampTopView.snp.bottom) make.leading.trailing.equalTo(view.safeAreaLayoutGuide) - make.height.equalTo(view.safeAreaLayoutGuide).inset(80) - } - - stampBottomView.addSubview(stampCollectionView) - - stampCollectionView.snp.makeConstraints { make in - make.top.leading.trailing.equalToSuperview() - make.height.equalTo(calculateCellHeight()) + make.bottom.equalToSuperview() } } @@ -143,15 +127,8 @@ extension GoalRewardInfoVC { private func register() { stampCollectionView.register(GoalRewardInfoCVC.self, - forCellWithReuseIdentifier: GoalRewardInfoCVC.identifier) + forCellWithReuseIdentifier: GoalRewardInfoCVC.className) } - - func calculateCellHeight() -> CGFloat { - let count = CGFloat(stampList.count) - let heightCount = count / 3 + count.truncatingRemainder(dividingBy: 3) - return heightCount * stampCellHeight + (heightCount - 1) * stampLineSpacing + stampInset.top + stampInset.bottom - } - } // MARK: - UICollectionViewDelegateFlowLayout @@ -184,9 +161,8 @@ extension GoalRewardInfoVC: UICollectionViewDataSource { } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let stampCell = collectionView.dequeueReusableCell(withReuseIdentifier: GoalRewardInfoCVC.identifier, for: indexPath) as? GoalRewardInfoCVC else { return UICollectionViewCell()} + guard let stampCell = collectionView.dequeueReusableCell(withReuseIdentifier: GoalRewardInfoCVC.className, for: indexPath) as? GoalRewardInfoCVC else { return UICollectionViewCell()} stampCell.dataBind(model: stampList[indexPath.item]) return stampCell } - } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift index 03b13596..933123bd 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift @@ -80,7 +80,7 @@ final class MyPageVC: UIViewController { $0.addGestureRecognizer(tap) } - // MARK: - View Life Cycle + // MARK: - override func viewDidLoad() { super.viewDidLoad()