forked from DO-NOTTO-DO/NotToDo-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Merge] 'develop' into feature/DO-NOTTO-DO#84
- Loading branch information
Showing
3 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
NotToDo/NotToDo/Presentation/Common/Calendar/MissionCalendarCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters