From ffc09c82912d7194c14f7c5cbcf2f5c68d30bcc9 Mon Sep 17 00:00:00 2001 From: iamcho2 Date: Fri, 1 Oct 2021 18:51:15 +0900 Subject: [PATCH] =?UTF-8?q?[#43]=20=EC=BA=98=EB=A6=B0=EB=8D=94=20=EB=B7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Description - 캘린더 뷰 컴포넌트 배치 - dummy data 생성 - AppMonth Enum 생성 - KingFisher 설치 - View Transition 연결을 위해 CoverUserPhotoVC에 Navi init 함수 추가 - Calendar, Tracker Data Model struct 추가 ### Related Issue close #43 --- popo/Podfile | 1 + popo/Podfile.lock | 6 +- popo/popo.xcodeproj/project.pbxproj | 89 ++++++++-- .../emptyCalendarBg.colorset/Contents.json | 38 ++++ popo/popo/Resources/Constant/Storyboard.swift | 1 + .../Resources/Constant/ViewController.swift | 1 + popo/popo/Resources/Constant/Xib.swift | 1 + .../Storyboard/Calendar/Calendar.storyboard | 111 ++++++++++++ .../Sources/APIModel/Calendar/Calendar.swift | 15 ++ .../Sources/APIModel/Calendar/Tracker.swift | 16 ++ popo/popo/Sources/AppModel/AppMonth.swift | 44 +++++ .../Calendar/CalendarCollectionViewCell.swift | 54 ++++++ .../Calendar/CalendarCollectionViewCell.xib | 68 +++++++ .../Sources/Extension/UIColor+Extension.swift | 6 + .../Calendar/CalendarViewController.swift | 168 ++++++++++++++++++ .../CoverUserPhotoViewController.swift | 13 ++ 16 files changed, 617 insertions(+), 15 deletions(-) create mode 100644 popo/popo/Resources/Colors.xcassets/emptyCalendarBg.colorset/Contents.json create mode 100644 popo/popo/Resources/Storyboard/Calendar/Calendar.storyboard create mode 100644 popo/popo/Sources/APIModel/Calendar/Calendar.swift create mode 100644 popo/popo/Sources/APIModel/Calendar/Tracker.swift create mode 100644 popo/popo/Sources/AppModel/AppMonth.swift create mode 100644 popo/popo/Sources/Cell/Calendar/CalendarCollectionViewCell.swift create mode 100644 popo/popo/Sources/Cell/Calendar/CalendarCollectionViewCell.xib create mode 100644 popo/popo/Sources/ViewController/Calendar/CalendarViewController.swift diff --git a/popo/Podfile b/popo/Podfile index 3d9db57..7ff918e 100644 --- a/popo/Podfile +++ b/popo/Podfile @@ -8,4 +8,5 @@ target 'popo' do # Pods for popo pod 'SwiftLint' pod 'Moya', '~> 15.0' + pod 'Kingfisher', '~> 7.0' end diff --git a/popo/Podfile.lock b/popo/Podfile.lock index 711342c..f36a32d 100644 --- a/popo/Podfile.lock +++ b/popo/Podfile.lock @@ -1,5 +1,6 @@ PODS: - Alamofire (5.4.4) + - Kingfisher (7.0.0) - Moya (15.0.0): - Moya/Core (= 15.0.0) - Moya/Core (15.0.0): @@ -7,20 +8,23 @@ PODS: - SwiftLint (0.42.0) DEPENDENCIES: + - Kingfisher (~> 7.0) - Moya (~> 15.0) - SwiftLint SPEC REPOS: trunk: - Alamofire + - Kingfisher - Moya - SwiftLint SPEC CHECKSUMS: Alamofire: f3b09a368f1582ab751b3fff5460276e0d2cf5c9 + Kingfisher: 5efc54fec3980f92354898532e562cc17f31efb4 Moya: 138f0573e53411fb3dc17016add0b748dfbd78ee SwiftLint: 4fa9579c63416865179bc416f0a92d55f009600d -PODFILE CHECKSUM: 5797af67ac481a532a89cfd8f9fae200c9347584 +PODFILE CHECKSUM: 624d5255892bc85462208d36a7c76920b48d766c COCOAPODS: 1.10.1 diff --git a/popo/popo.xcodeproj/project.pbxproj b/popo/popo.xcodeproj/project.pbxproj index 2bf986e..2b4a753 100644 --- a/popo/popo.xcodeproj/project.pbxproj +++ b/popo/popo.xcodeproj/project.pbxproj @@ -16,6 +16,14 @@ 562F556E26452218000F8CAB /* Const.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562F556D26452218000F8CAB /* Const.swift */; }; 562F557A26452252000F8CAB /* ViewExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562F557926452252000F8CAB /* ViewExample.swift */; }; 562F557D26452408000F8CAB /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = 562F557C26452408000F8CAB /* .swiftlint.yml */; }; + 565A1F0527056C47000CAB1B /* CalendarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565A1F0427056C47000CAB1B /* CalendarViewController.swift */; }; + 565A1F0827056C7E000CAB1B /* Calendar.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 565A1F0727056C7E000CAB1B /* Calendar.storyboard */; }; + 565A1F0B2705EEC8000CAB1B /* LoginMethod.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 565A1F0A2705EEC8000CAB1B /* LoginMethod.storyboard */; }; + 565A1F152706F58F000CAB1B /* CalendarCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565A1F132706F58F000CAB1B /* CalendarCollectionViewCell.swift */; }; + 565A1F162706F58F000CAB1B /* CalendarCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 565A1F142706F58F000CAB1B /* CalendarCollectionViewCell.xib */; }; + 565A1F182706FC22000CAB1B /* AppMonth.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565A1F172706FC22000CAB1B /* AppMonth.swift */; }; + 565A1F1B2707073E000CAB1B /* Calendar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565A1F1A2707073E000CAB1B /* Calendar.swift */; }; + 565A1F1D27070768000CAB1B /* Tracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565A1F1C27070768000CAB1B /* Tracker.swift */; }; 567840FD265E211300BDBF26 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567840FC265E211300BDBF26 /* UINavigationController+Extension.swift */; }; 567BF244265A571300285956 /* CoverCalendar.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 567BF243265A571300285956 /* CoverCalendar.storyboard */; }; 567BF246265A5BBE00285956 /* CoverUserPhoto.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 567BF245265A5BBE00285956 /* CoverUserPhoto.storyboard */; }; @@ -23,7 +31,6 @@ 567BF24A265A626100285956 /* Storyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567BF249265A626100285956 /* Storyboard.swift */; }; 567BF24C265A62C000285956 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567BF24B265A62C000285956 /* ViewController.swift */; }; 5686FA4E265A728600B7B9D5 /* CoverUserPhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5686FA4D265A728600B7B9D5 /* CoverUserPhotoViewController.swift */; }; - 56924E07265635DA00745273 /* LoginMethod.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 56924E06265635DA00745273 /* LoginMethod.storyboard */; }; 56924E09265635ED00745273 /* LoginMethodViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56924E08265635ED00745273 /* LoginMethodViewController.swift */; }; 56924E0B265648EB00745273 /* UIView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56924E0A265648EB00745273 /* UIView+Extension.swift */; }; 56EE71BB265E165B005AC12A /* Concept.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 56EE71BA265E165B005AC12A /* Concept.storyboard */; }; @@ -70,6 +77,14 @@ 562F556D26452218000F8CAB /* Const.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Const.swift; sourceTree = ""; }; 562F557926452252000F8CAB /* ViewExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExample.swift; sourceTree = ""; }; 562F557C26452408000F8CAB /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = ""; }; + 565A1F0427056C47000CAB1B /* CalendarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarViewController.swift; sourceTree = ""; }; + 565A1F0727056C7E000CAB1B /* Calendar.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Calendar.storyboard; sourceTree = ""; }; + 565A1F0A2705EEC8000CAB1B /* LoginMethod.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LoginMethod.storyboard; sourceTree = ""; }; + 565A1F132706F58F000CAB1B /* CalendarCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarCollectionViewCell.swift; sourceTree = ""; }; + 565A1F142706F58F000CAB1B /* CalendarCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CalendarCollectionViewCell.xib; sourceTree = ""; }; + 565A1F172706FC22000CAB1B /* AppMonth.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppMonth.swift; sourceTree = ""; }; + 565A1F1A2707073E000CAB1B /* Calendar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Calendar.swift; sourceTree = ""; }; + 565A1F1C27070768000CAB1B /* Tracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tracker.swift; sourceTree = ""; }; 567840FC265E211300BDBF26 /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = ""; }; 567BF243265A571300285956 /* CoverCalendar.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = CoverCalendar.storyboard; sourceTree = ""; }; 567BF245265A5BBE00285956 /* CoverUserPhoto.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = CoverUserPhoto.storyboard; sourceTree = ""; }; @@ -77,7 +92,6 @@ 567BF249265A626100285956 /* Storyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Storyboard.swift; sourceTree = ""; }; 567BF24B265A62C000285956 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 5686FA4D265A728600B7B9D5 /* CoverUserPhotoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoverUserPhotoViewController.swift; sourceTree = ""; }; - 56924E06265635DA00745273 /* LoginMethod.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LoginMethod.storyboard; sourceTree = ""; }; 56924E08265635ED00745273 /* LoginMethodViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginMethodViewController.swift; sourceTree = ""; }; 56924E0A265648EB00745273 /* UIView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Extension.swift"; sourceTree = ""; }; 56EE71BA265E165B005AC12A /* Concept.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Concept.storyboard; sourceTree = ""; }; @@ -182,6 +196,7 @@ children = ( F873648926A6A61300F121DC /* Login */, F873648826A6A60A00F121DC /* Onboarding */, + 565A1F0327056C2F000CAB1B /* Calendar */, F8967D8126F9F66A00F034E3 /* PopoConcept */, ); path = ViewController; @@ -200,6 +215,7 @@ children = ( F8967D9026FA01C400F034E3 /* PopoConcept */, F873648726A6A60100F121DC /* Onboarding */, + 565A1F122706F577000CAB1B /* Calendar */, ); path = Cell; sourceTree = ""; @@ -218,6 +234,7 @@ isa = PBXGroup; children = ( F873648C26A6A92900F121DC /* Onboarding */, + 565A1F172706FC22000CAB1B /* AppMonth.swift */, ); path = AppModel; sourceTree = ""; @@ -228,6 +245,7 @@ F881A74126FC588400AEE21E /* NetworkResult.swift */, F881A73F26FC50B200AEE21E /* GenericResponse.swift */, F881A73C26FC18E100AEE21E /* PopoConcept */, + 565A1F1927070730000CAB1B /* Calendar */, ); path = APIModel; sourceTree = ""; @@ -256,11 +274,12 @@ 562F5569264521ED000F8CAB /* Storyboard */ = { isa = PBXGroup; children = ( - F8967D8626F9F6B000F034E3 /* Login */, - F88491BF26B2DF28007590E9 /* Onboarding */, - F8967D8726F9F6B500F034E3 /* PopoConcept */, 562F555726452103000F8CAB /* LaunchScreen.storyboard */, 562F555226452101000F8CAB /* Main.storyboard */, + 565A1F092705EEC8000CAB1B /* Login */, + F88491BF26B2DF28007590E9 /* Onboarding */, + 565A1F0627056C6C000CAB1B /* Calendar */, + F8967D8726F9F6B500F034E3 /* PopoConcept */, ); path = Storyboard; sourceTree = ""; @@ -277,6 +296,48 @@ path = Constant; sourceTree = ""; }; + 565A1F0327056C2F000CAB1B /* Calendar */ = { + isa = PBXGroup; + children = ( + 565A1F0427056C47000CAB1B /* CalendarViewController.swift */, + ); + path = Calendar; + sourceTree = ""; + }; + 565A1F0627056C6C000CAB1B /* Calendar */ = { + isa = PBXGroup; + children = ( + 565A1F0727056C7E000CAB1B /* Calendar.storyboard */, + ); + path = Calendar; + sourceTree = ""; + }; + 565A1F092705EEC8000CAB1B /* Login */ = { + isa = PBXGroup; + children = ( + 565A1F0A2705EEC8000CAB1B /* LoginMethod.storyboard */, + ); + path = Login; + sourceTree = ""; + }; + 565A1F122706F577000CAB1B /* Calendar */ = { + isa = PBXGroup; + children = ( + 565A1F142706F58F000CAB1B /* CalendarCollectionViewCell.xib */, + 565A1F132706F58F000CAB1B /* CalendarCollectionViewCell.swift */, + ); + path = Calendar; + sourceTree = ""; + }; + 565A1F1927070730000CAB1B /* Calendar */ = { + isa = PBXGroup; + children = ( + 565A1F1A2707073E000CAB1B /* Calendar.swift */, + 565A1F1C27070768000CAB1B /* Tracker.swift */, + ); + path = Calendar; + sourceTree = ""; + }; 8FD1E6BDEB079F1C802D413D /* Frameworks */ = { isa = PBXGroup; children = ( @@ -372,14 +433,6 @@ path = PopoConcept; sourceTree = ""; }; - F8967D8626F9F6B000F034E3 /* Login */ = { - isa = PBXGroup; - children = ( - 56924E06265635DA00745273 /* LoginMethod.storyboard */, - ); - path = Login; - sourceTree = ""; - }; F8967D8726F9F6B500F034E3 /* PopoConcept */ = { isa = PBXGroup; children = ( @@ -462,14 +515,16 @@ 562F557D26452408000F8CAB /* .swiftlint.yml in Resources */, 562F555926452103000F8CAB /* LaunchScreen.storyboard in Resources */, F8731B02265BE4B400770760 /* Onboarding.storyboard in Resources */, + 565A1F0827056C7E000CAB1B /* Calendar.storyboard in Resources */, 562F556C26452208000F8CAB /* Colors.xcassets in Resources */, F8967D9426FA01F300F034E3 /* CategoryCell.xib in Resources */, F8967D9626FA090500F034E3 /* Category.storyboard in Resources */, + 565A1F162706F58F000CAB1B /* CalendarCollectionViewCell.xib in Resources */, F8731B0C265C01A800770760 /* ConceptSelect.storyboard in Resources */, + 565A1F0B2705EEC8000CAB1B /* LoginMethod.storyboard in Resources */, F8C284DC265CCD2300B41054 /* CoverColor.storyboard in Resources */, F8731B10265C05E900770760 /* ConceptSelectCell.xib in Resources */, F873648626A6A5E500F121DC /* OnboardingCell.xib in Resources */, - 56924E07265635DA00745273 /* LoginMethod.storyboard in Resources */, 562F555626452103000F8CAB /* Assets.xcassets in Resources */, F8C284E0265CD4DE00B41054 /* CoverGradient.storyboard in Resources */, 567BF244265A571300285956 /* CoverCalendar.storyboard in Resources */, @@ -545,6 +600,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 565A1F182706FC22000CAB1B /* AppMonth.swift in Sources */, + 565A1F0527056C47000CAB1B /* CalendarViewController.swift in Sources */, F881A74026FC50B200AEE21E /* GenericResponse.swift in Sources */, 567BF24C265A62C000285956 /* ViewController.swift in Sources */, 56EE71BD265E18BA005AC12A /* ConceptViewController.swift in Sources */, @@ -555,6 +612,7 @@ F816E65D26FC631F000C0270 /* FetchPopoListAPI.swift in Sources */, 562F557A26452252000F8CAB /* ViewExample.swift in Sources */, F84AA56C27057633008D77ED /* Xib.swift in Sources */, + 565A1F1D27070768000CAB1B /* Tracker.swift in Sources */, F816E66026FC6441000C0270 /* TempAPI.swift in Sources */, 562F556E26452218000F8CAB /* Const.swift in Sources */, F873648B26A6A92600F121DC /* OnboardingDescriptionModel.swift in Sources */, @@ -570,10 +628,13 @@ 562F554D26452101000F8CAB /* AppDelegate.swift in Sources */, F8731B0A265C019200770760 /* ConceptSelectViewController.swift in Sources */, F881A74226FC588400AEE21E /* NetworkResult.swift in Sources */, + 565A1F1B2707073E000CAB1B /* Calendar.swift in Sources */, 567BF24A265A626100285956 /* Storyboard.swift in Sources */, 567840FD265E211300BDBF26 /* UINavigationController+Extension.swift in Sources */, F873648526A6A5E500F121DC /* OnboardingCell.swift in Sources */, 562F554F26452101000F8CAB /* SceneDelegate.swift in Sources */, + 565A1F152706F58F000CAB1B /* CalendarCollectionViewCell.swift in Sources */, + 565A1F0227056B9F000CAB1B /* AppDate.swift in Sources */, 5686FA4E265A728600B7B9D5 /* CoverUserPhotoViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/popo/popo/Resources/Colors.xcassets/emptyCalendarBg.colorset/Contents.json b/popo/popo/Resources/Colors.xcassets/emptyCalendarBg.colorset/Contents.json new file mode 100644 index 0000000..6773136 --- /dev/null +++ b/popo/popo/Resources/Colors.xcassets/emptyCalendarBg.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.949", + "green" : "0.949", + "red" : "0.949" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.949", + "green" : "0.949", + "red" : "0.949" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/popo/popo/Resources/Constant/Storyboard.swift b/popo/popo/Resources/Constant/Storyboard.swift index 57423db..ef1ed28 100644 --- a/popo/popo/Resources/Constant/Storyboard.swift +++ b/popo/popo/Resources/Constant/Storyboard.swift @@ -20,6 +20,7 @@ extension Const { static let onboarding = "Onboarding" static let conceptSelect = "ConceptSelect" static let category = "Category" + static let calendar = "Calendar" } } diff --git a/popo/popo/Resources/Constant/ViewController.swift b/popo/popo/Resources/Constant/ViewController.swift index c72bcbe..6d4a186 100644 --- a/popo/popo/Resources/Constant/ViewController.swift +++ b/popo/popo/Resources/Constant/ViewController.swift @@ -20,6 +20,7 @@ extension Const { static let onboarding = "OnboardingViewController" static let conseptSelect = "ConceptSelectViewController" static let category = "CategoryViewController" + static let calendar = "CalendarViewController" } } diff --git a/popo/popo/Resources/Constant/Xib.swift b/popo/popo/Resources/Constant/Xib.swift index cdecc28..c4d0d10 100644 --- a/popo/popo/Resources/Constant/Xib.swift +++ b/popo/popo/Resources/Constant/Xib.swift @@ -12,5 +12,6 @@ extension Const { static let CategoryCell = "CategoryCell" static let OnboardingCell = "OnboardingCell" static let ConceptSelectCell = "ConceptSelectCell" + static let calendarCollectionViewCell = "CalendarCollectionViewCell" } } diff --git a/popo/popo/Resources/Storyboard/Calendar/Calendar.storyboard b/popo/popo/Resources/Storyboard/Calendar/Calendar.storyboard new file mode 100644 index 0000000..a6dc8a2 --- /dev/null +++ b/popo/popo/Resources/Storyboard/Calendar/Calendar.storyboard @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/popo/popo/Sources/APIModel/Calendar/Calendar.swift b/popo/popo/Sources/APIModel/Calendar/Calendar.swift new file mode 100644 index 0000000..b598ee1 --- /dev/null +++ b/popo/popo/Sources/APIModel/Calendar/Calendar.swift @@ -0,0 +1,15 @@ +// +// Tracker.swift +// popo +// +// Created by 초이 on 2021/10/01. +// + +import Foundation + +// MARK: - Calendar + +struct Calendar: Codable { + let category: Int + let tracker: [Tracker] +} diff --git a/popo/popo/Sources/APIModel/Calendar/Tracker.swift b/popo/popo/Sources/APIModel/Calendar/Tracker.swift new file mode 100644 index 0000000..16d192d --- /dev/null +++ b/popo/popo/Sources/APIModel/Calendar/Tracker.swift @@ -0,0 +1,16 @@ +// +// Tracker.swift +// popo +// +// Created by 초이 on 2021/10/01. +// + +import Foundation + +// MARK: - Tracker + +struct Tracker: Codable { + let id: Int + let date: Int + let image: String +} diff --git a/popo/popo/Sources/AppModel/AppMonth.swift b/popo/popo/Sources/AppModel/AppMonth.swift new file mode 100644 index 0000000..16d9cda --- /dev/null +++ b/popo/popo/Sources/AppModel/AppMonth.swift @@ -0,0 +1,44 @@ +// +// AppMonth.swift +// popo +// +// Created by 초이 on 2021/10/01. +// + +import Foundation + +enum AppMonth: Int { + case jan = 1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec + + func getNumber() -> Int { + return rawValue + } + + func getDayCount() -> Int { + switch self { + case .jan, .mar, .may, .jul, .aug, .oct, .dec: + return 31 + case .apr, .jun, .sep, .nov: + return 30 + case .feb: + return 28 + } + } + + func getFullEnglish() -> String { + switch self { + case .jan: return "january" + case .feb: return "february" + case .mar: return "march" + case .apr: return "april" + case .may: return "may" + case .jun: return "june" + case .jul: return "july" + case .aug: return "august" + case .sep: return "september" + case .oct: return "october" + case .nov: return "november" + case .dec: return "december" + } + } +} diff --git a/popo/popo/Sources/Cell/Calendar/CalendarCollectionViewCell.swift b/popo/popo/Sources/Cell/Calendar/CalendarCollectionViewCell.swift new file mode 100644 index 0000000..4a41b14 --- /dev/null +++ b/popo/popo/Sources/Cell/Calendar/CalendarCollectionViewCell.swift @@ -0,0 +1,54 @@ +// +// CalendarCollectionViewCell.swift +// popo +// +// Created by 초이 on 2021/10/01. +// + +import UIKit +import Kingfisher + +class CalendarCollectionViewCell: UICollectionViewCell { + + // MARK: - @IBOutlet Properties + + @IBOutlet weak var imageBgView: UIView! + @IBOutlet weak var thumbImageView: UIImageView! + @IBOutlet weak var dateLabel: UILabel! + + // MARK: - View Life Cycle + + override func awakeFromNib() { + super.awakeFromNib() + + initViewRounding() + } + + // MARK: - Functions + + private func initViewRounding() { + self.imageBgView.makeRounded(radius: 5) + self.thumbImageView.makeRounded(radius: 5) + } + + private func initEmptyCell() { + + } + + func setCell(tracker: Tracker) { + + if tracker.id != -1 { + dateLabel.isHidden = true + thumbImageView.isHidden = false + thumbImageView.kf.setImage(with: URL(string: tracker.image)) + imageBgView.backgroundColor = UIColor.white + } else { + dateLabel.isHidden = false + dateLabel.text = "\(tracker.date)" + thumbImageView.isHidden = true + imageBgView.backgroundColor = UIColor.emptyCalendarBg + + } + } + +} diff --git a/popo/popo/Sources/Cell/Calendar/CalendarCollectionViewCell.xib b/popo/popo/Sources/Cell/Calendar/CalendarCollectionViewCell.xib new file mode 100644 index 0000000..6f9e62c --- /dev/null +++ b/popo/popo/Sources/Cell/Calendar/CalendarCollectionViewCell.xib @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/popo/popo/Sources/Extension/UIColor+Extension.swift b/popo/popo/Sources/Extension/UIColor+Extension.swift index 8f9b6f6..014596f 100644 --- a/popo/popo/Sources/Extension/UIColor+Extension.swift +++ b/popo/popo/Sources/Extension/UIColor+Extension.swift @@ -9,6 +9,12 @@ import Foundation import UIKit extension UIColor { + + // MARK: - Properties + + static let emptyCalendarBg = UIColor(named: "emptyCalendarBg") + + // MARK: - Functions convenience init(hex: String, alpha: CGFloat = 1.0) { var hexFormatted: String = hex.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).uppercased() diff --git a/popo/popo/Sources/ViewController/Calendar/CalendarViewController.swift b/popo/popo/Sources/ViewController/Calendar/CalendarViewController.swift new file mode 100644 index 0000000..e9b712e --- /dev/null +++ b/popo/popo/Sources/ViewController/Calendar/CalendarViewController.swift @@ -0,0 +1,168 @@ +// +// CalendarViewController.swift +// popo +// +// Created by 초이 on 2021/09/30. +// + +import UIKit + +class CalendarViewController: UIViewController { + + // dummy data + var data = Calendar(category: 0, tracker: [ + Tracker(id: -1, date: 1, image: ""), + Tracker(id: 0, date: 2, image: "https://miro.medium.com/max/531/0*ODOq4YoezGa42saH.jpg"), + Tracker(id: -1, date: 3, image: ""), + Tracker(id: 0, date: 4, image: "https://i.imgur.com/8orhXgvb.jpg"), + Tracker(id: 0, date: 5, image: "https://i.imgur.com/emWIrPZb.jpg"), + Tracker(id: 0, date: 6, image: "https://i.imgur.com/6EJI7b.jpg"), + Tracker(id: 0, date: 7, image: "https://i.imgur.com/LF5Y90yb.jpg"), + Tracker(id: 0, date: 8, image: "https://i.imgur.com/rdSGowpb.jpg"), + Tracker(id: 0, date: 9, image: "https://i.imgur.com/zMd4EZ4b.jpg"), + Tracker(id: 0, date: 10, image: "https://i.imgur.com/ITwKqOWb.jpg"), + Tracker(id: 0, date: 11, image: "https://i.imgur.com/FYxuRyQb.jpg"), + Tracker(id: 0, date: 12, image: "https://i.imgur.com/RMlBYTab.jpg"), + Tracker(id: 0, date: 13, image: "https://i.imgur.com/lJbhoXRb.jpg"), + Tracker(id: 0, date: 14, image: "https://i.imgur.com/1gk0bavb.jpg"), + Tracker(id: 0, date: 15, image: "https://i.imgur.com/1cQaAgCb.jpg"), + Tracker(id: 0, date: 16, image: "https://i.imgur.com/p4UOAkrb.jpg"), + Tracker(id: 0, date: 17, image: "https://i.imgur.com/VnbOWZZb.jpg"), + Tracker(id: 0, date: 18, image: "https://i.imgur.com/ypCOswFb.jpg"), + Tracker(id: 0, date: 19, image: "https://i.imgur.com/8Dud2uIb.jpg"), + Tracker(id: 0, date: 20, image: "https://i.imgur.com/m2JAoDqb.jpg"), + Tracker(id: 0, date: 21, image: "https://i.imgur.com/1vHhn6sb.jpg"), + Tracker(id: -1, date: 22, image: ""), + Tracker(id: 0, date: 23, image: "https://i.imgur.com/ufHTxWVb.jpg"), + Tracker(id: 0, date: 24, image: "https://i.imgur.com/g3ynoCOb.jpg"), + Tracker(id: 0, date: 25, image: "https://i.imgur.com/eTeppWOb.jpg"), + Tracker(id: -1, date: 26, image: ""), + Tracker(id: 0, date: 27, image: "https://i.imgur.com/ahcnBy5b.jpg"), + Tracker(id: -1, date: 28, image: ""), + Tracker(id: 0, date: 29, image: "https://i.imgur.com/fvJXuvj.jpg"), + Tracker(id: 0, date: 30, image: "https://i.imgur.com/M1MHdezb.jpg"), + Tracker(id: 0, date: 31, image: "https://i.imgur.com/HNWMaIvb.jpg") + ]) + + // MARK: - @IBOutlet Properties + + @IBOutlet weak var yearMonthLabel: UILabel! + @IBOutlet weak var backgroundImageView: UIImageView! + @IBOutlet weak var calendarBgView: UIView! + @IBOutlet weak var calendarCollectionView: UICollectionView! + @IBOutlet weak var bgViewTopConstraint: NSLayoutConstraint! + + // MARK: - Properties + var year: Int = 2021 + var month: Int = 12 + + enum Size { + static let screenWidth = UIScreen.main.bounds.width + static let topSpacing = UIScreen.main.bounds.height * 0.2 + + static let collectionViewSpacing: CGFloat = 22 * 2 + static let cellSpacing: CGFloat = 12 + static let cellWidth = ( screenWidth - collectionViewSpacing - cellSpacing * 4 ) / 5 + static let cellHeight = cellWidth * 1.3 + } + + // MARK: - View Life Cycle + + override func viewDidLoad() { + super.viewDidLoad() + + initNavigationBar() + initView() + initYearMonthLabel() + assignDelegation() + registerXib() + } + + // MARK: - Functions + + // init functions + private func initNavigationBar() { + self.navigationController?.initWithTwoCustomButtons( + navigationItem: self.navigationItem, + firstButtonImage: UIImage(systemName: "photo.on.rectangle.angled")!, + secondButtonImage: UIImage(systemName: "calendar")!, + firstButtonClosure: #selector(touchChangeBackgroundButton(_:)), + secondButtonClosure: #selector(touchCalendarButton(_:))) + } + + private func initView() { + calendarBgView.makeRounded(radius: 30) + bgViewTopConstraint.constant = Size.topSpacing + } + + private func initYearMonthLabel() { + guard let monthName = AppMonth(rawValue: month)?.getFullEnglish() else { return } + + yearMonthLabel.text = "\(self.year)\n\(monthName)" + } + + // assign, register functions + private func assignDelegation() { + self.calendarCollectionView.delegate = self + self.calendarCollectionView.dataSource = self + } + + private func registerXib() { + calendarCollectionView.register(UINib(nibName: Const.Xib.calendarCollectionViewCell, bundle: nil), forCellWithReuseIdentifier: Const.Xib.calendarCollectionViewCell) + } + + // @objc functions + @objc func touchChangeBackgroundButton(_ sender: UIBarButtonItem) { + // TODO: - 갤러리 열기 + } + + @objc func touchCalendarButton(_ sender: UIBarButtonItem) { + // TODO: - present popup + } + +} + +// MARK: - UICollectionViewDelegateFlowLayout + +extension CalendarViewController: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { + return Size.cellSpacing + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { + return Size.cellSpacing + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { + return UIEdgeInsets(top: 0, left: 0, bottom: 20, right: 0) + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + return CGSize(width: Size.cellWidth, height: Size.cellHeight) + } +} + +// MARK: - UICollectionViewDataSource + +extension CalendarViewController: UICollectionViewDataSource { + + // numberOfItemsInSection + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + + guard let dayCount = AppMonth(rawValue: month)?.getDayCount() else { return 30 } + + return dayCount + } + + // cellForItemAt + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: Const.Xib.calendarCollectionViewCell, for: indexPath) as? CalendarCollectionViewCell else { + return UICollectionViewCell() + } + + cell.setCell(tracker: data.tracker[indexPath.row]) + + return cell + } + +} diff --git a/popo/popo/Sources/ViewController/Onboarding/CoverUserPhotoViewController.swift b/popo/popo/Sources/ViewController/Onboarding/CoverUserPhotoViewController.swift index 7818608..88a34a6 100644 --- a/popo/popo/Sources/ViewController/Onboarding/CoverUserPhotoViewController.swift +++ b/popo/popo/Sources/ViewController/Onboarding/CoverUserPhotoViewController.swift @@ -42,6 +42,7 @@ class CoverUserPhotoViewController: UIViewController { // Do any additional setup after loading the view. makeImageViewArray() initViewRounding() + initNavigationBar() assignDelegate() initTapGesterRecognizer() } @@ -67,6 +68,12 @@ class CoverUserPhotoViewController: UIViewController { whiteBgView.makeRounded(radius: 30) } + private func initNavigationBar() { + self.navigationController?.initWithBackAndDoneButton( + navigationItem: self.navigationItem, + doneButtonClosure: #selector(touchDoneButton(_:))) + } + private func assignDelegate() { imagePicker.delegate = self } @@ -89,6 +96,12 @@ class CoverUserPhotoViewController: UIViewController { currentPickerIndex = senderTag present(imagePicker, animated: true, completion: nil) } + + @objc func touchDoneButton(_ sender: UIBarButtonItem) { + let calendarStoryboard = UIStoryboard(name: Const.Storyboard.Name.calendar, bundle: nil) + guard let calendarViewController = calendarStoryboard.instantiateViewController(withIdentifier: Const.ViewController.Identifier.calendar) as? CalendarViewController else { return } + self.navigationController?.pushViewController(calendarViewController, animated: true) + } } // MARK: - UIImagePickerControllerDelegate & UINavigationControllerDelegate