Skip to content

Commit

Permalink
[Merge] 'develop' into feature/DO-NOTTO-DO#84
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongdung-eo committed Jan 13, 2023
2 parents 46431f7 + cc3eb15 commit 2b725eb
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 2 deletions.
11 changes: 11 additions & 0 deletions NotToDo/NotToDo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
3B3405BE295B0A8200D44722 /* Pretendard-Medium.otf in Resources */ = {isa = PBXBuildFile; fileRef = 3B3405BD295B0A8200D44722 /* Pretendard-Medium.otf */; };
3B3405C0295B0A8C00D44722 /* Pretendard-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 3B3405BF295B0A8C00D44722 /* Pretendard-Regular.otf */; };
3B3405C2295B0AAE00D44722 /* Pretendard-SemiBold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 3B3405C1295B0AAD00D44722 /* Pretendard-SemiBold.otf */; };
3B388E0D29716C4D0073CB5E /* MissionCalendarCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B388E0C29716C4D0073CB5E /* MissionCalendarCell.swift */; };
3B4187D5296D5D8700F0FBF4 /* IQKeyboardManagerSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 3B4187D4296D5D8700F0FBF4 /* IQKeyboardManagerSwift */; };
3B42D1EE2966A1C20012898E /* myInfoMenuCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B42D1ED2966A1C20012898E /* myInfoMenuCollectionViewCell.swift */; };
3B42D1F02966A6320012898E /* myInfoFooterCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B42D1EF2966A6320012898E /* myInfoFooterCollectionReusableView.swift */; };
Expand Down Expand Up @@ -214,6 +215,7 @@
3B3405DB295B146E00D44722 /* TabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarController.swift; sourceTree = "<group>"; };
3B3405DD295B162600D44722 /* UITabBar+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITabBar+.swift"; sourceTree = "<group>"; };
3B3405DF295B1B8E00D44722 /* CustomTabBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTabBar.swift; sourceTree = "<group>"; };
3B388E0C29716C4D0073CB5E /* MissionCalendarCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MissionCalendarCell.swift; sourceTree = "<group>"; };
3B4187CE296D342900F0FBF4 /* UIViewController+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+.swift"; sourceTree = "<group>"; };
3B42D1ED2966A1C20012898E /* myInfoMenuCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = myInfoMenuCollectionViewCell.swift; sourceTree = "<group>"; };
3B42D1EF2966A6320012898E /* myInfoFooterCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = myInfoFooterCollectionReusableView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -761,6 +763,14 @@
path = UI;
sourceTree = "<group>";
};
3B388E0B29716C290073CB5E /* Calendar */ = {
isa = PBXGroup;
children = (
3B388E0C29716C4D0073CB5E /* MissionCalendarCell.swift */,
);
path = Calendar;
sourceTree = "<group>";
};
3B4B90C02965B5AF008C5CA8 /* Cells */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1267,6 +1277,7 @@
6CCBCF95297075590093C0F3 /* AddMissionAPI.swift in Sources */,
3B162876295AD7860077AE7B /* SceneDelegate.swift in Sources */,
3B90A42C296F28D2000D6852 /* HomeService.swift in Sources */,
3B388E0D29716C4D0073CB5E /* MissionCalendarCell.swift in Sources */,
3BE07009296F43A2002CC50A /* UITabBar+.swift in Sources */,
6C8826162968221C0005E222 /* AddSituationHeaderView.swift in Sources */,
099F06CF296732970036CF55 /* CustomTabBarView.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
//
// MissionCalendarCell.swift
// NotToDo
//
// Created by 강윤서 on 2023/01/13.
//

import UIKit

import FSCalendar
import SnapKit
import Then

enum ToDoState {
case none
case step1
case step2
case step3
case bordered
}

extension ToDoState {
var bgColor: UIColor? {
switch self {
case .none:
return .clear
case .step1:
return .yellow_mild
case .step2:
return .yellow_basic
case .step3:
return .yellow_deep
case .bordered:
return .brown
}
}
}

final class MissionCalendarCell: FSCalendarCell {

// MARK: - Properties

var state: ToDoState = .none {
didSet {
updateUI()
}
}

// MARK: - UI Components

private let stateView = UIView().then {
$0.layer.cornerRadius = 8
}
private var padding = 8

// MARK: - Life Cycle

override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}

required init!(coder aDecoder: NSCoder!) {
fatalError("init(coder:) has not been implemented")
}

private func setupUI() {
titleLabel.snp.remakeConstraints {
$0.center.equalToSuperview()
}

contentView.insertSubview(stateView, at: 0)
stateView.snp.makeConstraints {
$0.edges.equalToSuperview().inset(padding)
}
}

private func updateUI() {
stateView.backgroundColor = state.bgColor
}
}

extension MissionCalendarCell {
func configure(_ state: ToDoState) {
self.state = state
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import Then

final class HomeCalendarCollectionViewCell: UICollectionViewCell {

// TODO: 해당 데이터 가지고 셀 각각에 데이터 뿌려주면 될듯
// 딕셔너리나 배열 적절하게 선택해서 사용하기 -> 배열이 더 익숙하니까 배열 사용하는 것이 더 편할 것임
// 아마 서버에서 [날짜(String), Int] 값을 배열 형태로 같이 넘겨줄 것 같은데 그거 가지고 사용하면 됨
var dataSource: [String: Int] = [:]

// MARK: - Properties

static let identifier = "HomeCalendarCollectionViewCell"
Expand Down Expand Up @@ -52,9 +57,19 @@ extension HomeCalendarCollectionViewCell {

private func setCalendar() {
calendar.do {

/* */
$0.dataSource = self
$0.delegate = self
$0.register(MissionCalendarCell.self, forCellReuseIdentifier: String(describing: MissionCalendarCell.self))

$0.appearance.titleTodayColor = .nottodoBlack
$0.appearance.todayColor = .none
$0.appearance.todaySelectionColor = .none
$0.appearance.selectionColor = .none

$0.appearance.weekdayTextColor = .nottodoBlack
$0.appearance.titleSelectionColor = .nottodoBlack
$0.appearance.selectionColor = .yellow_basic
$0.appearance.borderRadius = 0.4.adjusted
$0.appearance.titleFont = .PretendardMedium(size: 14.adjusted)
$0.appearance.weekdayFont = .PretendardMedium(size: 14.adjusted)
Expand All @@ -64,7 +79,7 @@ extension HomeCalendarCollectionViewCell {
$0.calendarWeekdayView.fs_height = 0
$0.headerHeight = 0
$0.scope = .week
$0.firstWeekday = 2
$0.firstWeekday = 2
$0.locale = Locale(identifier: "ko_KR")
$0.placeholderType = .fillHeadTail
$0.collectionView.snp.makeConstraints {
Expand All @@ -84,3 +99,33 @@ extension HomeCalendarCollectionViewCell {
}
}
}

extension HomeCalendarCollectionViewCell: FSCalendarDataSource {

// 서버에서 넘어온 dateString이랑 이 메서드의 date를 잘 매칭시켜줘야 함
// date 매칭된 것에 맞게 데이터를 넘겨줘야 함
func calendar(_ calendar: FSCalendar, cellFor date: Date, at position: FSCalendarMonthPosition) -> FSCalendarCell {
let cell = calendar.dequeueReusableCell(withIdentifier: String(describing: MissionCalendarCell.self), for: date, at: position) as! MissionCalendarCell

// MARK: 서버에서 넘어온 값에 따라 셀 상태 변화시켜주기
// Date : Int(Enum)
/*
NotToDoCalendarCell에 가보면 Enum이 보일 것임
프로젝트 상황에 따라 적절하게 바꿔서 사용하기
현재는 5개의 case가 있음
- none, step1, step2, step3, bordered
case에 따라서 backgroundColor 변화시키는 식으로 구현되어 있는데 UI 디테일을 살리고 싶으면
그냥 case에 따라 이미지를 넣는 것이 더 쉬움
*/

// 캘린더 셀 설정해주는 코드 : CollectionViewCell이랑 동일하게 생각하면 됨
cell.configure(.bordered)
return cell
}
}

extension HomeCalendarCollectionViewCell: FSCalendarDelegate {

}

0 comments on commit 2b725eb

Please sign in to comment.