Skip to content

Commit

Permalink
[FEAT] DO-NOTTO-DO#88 - 홈 뷰 헤더 텍스트 캘린더 값으로 변경
Browse files Browse the repository at this point in the history
[FEAT] DO-NOTTO-DO#88 - 홈 뷰 헤더 텍스트 캘린더 값으로 변경
  • Loading branch information
yungu0010 authored Jan 13, 2023
2 parents aeee3cc + 98139b1 commit 0075f54
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ final class HomeCollectionReusableView: UICollectionReusableView {

// MARK: - UI Components

private lazy var dateFormatter = DateFormatter()
private var dateLabel = UILabel()
var dateLabel = UILabel()
private let dateView = UIView()
private var motivationLabel = UILabel()
private var graphicImageView = UIImageView()
Expand All @@ -42,15 +41,10 @@ final class HomeCollectionReusableView: UICollectionReusableView {
extension HomeCollectionReusableView {
private func setUI() {
backgroundColor = .nottodoWhite
dateFormatter.do {
$0.locale = Locale(identifier: "ko_KR")
$0.dateFormat = "YYYY년 M월"
$0.timeZone = TimeZone(identifier: "KST")
}
dateLabel.do {
$0.textColor = .nottodoBlack
$0.font = .PretendardBold(size: 18.adjusted)
$0.text = "2023년 1월" // dateFormatter로 수정
// $0.text = "2023년 1월" // dateFormatter로 수정
}
dateView.backgroundColor = .yellow_basic
motivationLabel.do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ final class HomeViewController: UIViewController {
var banner: BannerResponseDTO?
var missionId: Int?
private var clickedDay: String?
private let dateFormatter = DateFormatter()
private let todayDateFormatter = DateFormatter()
private let mothlyDateFormatter = DateFormatter()
private var currentPage: Date? = Date()

// MARK: - UI Components

Expand All @@ -44,7 +46,7 @@ final class HomeViewController: UIViewController {
super.viewWillAppear(animated)
requestBannerAPI()
requestWeeklyMissoinAPI(startDate: "2023-01-23")
requestDailyMissionAPI(date: "2023-01-25")
requestDailyMissionAPI(date: clickedDay ?? "")
}
}

Expand Down Expand Up @@ -73,10 +75,15 @@ extension HomeViewController: UICollectionViewDelegate {
for: .valueChanged)
}

dateFormatter.do {
todayDateFormatter.do {
$0.locale = Locale(identifier: "ko_KR")
$0.dateFormat = "yyyy-MM-dd"
}

mothlyDateFormatter.do {
$0.locale = Locale(identifier: "ko_KR")
$0.dateFormat = "yyyy년 M월"
}
}

private func setAddTarget() {
Expand Down Expand Up @@ -152,7 +159,7 @@ extension HomeViewController: UICollectionViewDelegate {
@objc func handleRefreshControl() {
// 컨텐츠를 업데이트하세요.
requestBannerAPI()
requestDailyMissionAPI(date: "2023-01-25")
requestDailyMissionAPI(date: clickedDay ?? "")
homeView.homeCollectionView.reloadData()

DispatchQueue.main.async {
Expand All @@ -171,6 +178,7 @@ extension HomeViewController: UICollectionViewDataSource {
case 0:
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HomeCalendarCollectionViewCell.identifier, for: indexPath) as? HomeCalendarCollectionViewCell else { return UICollectionViewCell() }
cell.calendar.delegate = self
self.currentPage = cell.calendar.currentPage
return cell
default:
if missionList.isEmpty {
Expand Down Expand Up @@ -233,6 +241,7 @@ extension HomeViewController: UICollectionViewDataSource {
withReuseIdentifier: HomeCollectionReusableView.identifier,
for: indexPath
) as? HomeCollectionReusableView else { return UICollectionReusableView() }
header.dateLabel.text = mothlyDateFormatter.string(from: self.currentPage ?? Date())
if let banner = banner {
header.setRandomData(banner: banner)
}
Expand Down Expand Up @@ -284,7 +293,7 @@ extension HomeViewController: UICollectionViewDelegateFlowLayout {

extension HomeViewController: FSCalendarDelegate {
func calendar(_ calendar: FSCalendar, didSelect date: Date, at monthPosition: FSCalendarMonthPosition) {
clickedDay = dateFormatter.string(from: date)
clickedDay = todayDateFormatter.string(from: date)
requestDailyMissionAPI(date: clickedDay ?? "")
}
}
2 changes: 0 additions & 2 deletions NotToDo/NotToDo/Presentation/HomeScene/Views/HomeView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import UIKit

import FSCalendar
import SnapKit
import Then

Expand All @@ -9,7 +8,6 @@ final class HomeView: UIView {
// MARK: - UI Components

lazy var homeCollectionView = UICollectionView(frame: .zero, collectionViewLayout: layout())
var calendar = FSCalendar(frame: .zero)
let addMissionButton = NotTodoButton(frame: CGRect(), mode: .withImage, text: I18N.addMissoinButton, image: .plus, font: .semiBold, size: 16)

// MARK: - Life Cycle
Expand Down

0 comments on commit 0075f54

Please sign in to comment.