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 efcc6b6 + bc40854 commit 570b66c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 33 deletions.
13 changes: 0 additions & 13 deletions NotToDo/NotToDo/Global/Extensions/UIView+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,4 @@ extension UIView {
func addSubviews(_ views: UIView...) {
views.forEach { self.addSubview($0) }
}

/// 최상위 뷰 컨트롤러를 return 하는 함수
class func topViewController() -> UIViewController? {
if let keyWindow = UIApplication.shared.keyWindow {
if var viewController = keyWindow.rootViewController {
while viewController.presentedViewController != nil {
viewController = viewController.presentedViewController!
}
return viewController
}
}
return nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ extension SituationStatisticsView: UITableViewDataSource, UITableViewDelegate {
default:
cell.backGroundImage.layer.addBorder([.bottom, .left, .right], color: .nottodoGray2!, width: 0.5)
}
cell.titleLabel.text = (situationList[indexPath.section].missions[indexPath.row].title as! String)
cell.titleLabel.text = (situationList[indexPath.section].missions[indexPath.row].title)
cell.numberLabel.text = "\(situationList[indexPath.section].missions[indexPath.row].count)"
cell.selectionStyle = .none
return cell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

import UIKit

protocol AddMissoinViewDelegate: AnyObject {
func homeViewReload()
}

final class AddMissionViewController: UIViewController {

// MARK: - Properties
Expand All @@ -18,8 +22,8 @@ final class AddMissionViewController: UIViewController {
}
}
var addMissionRequest: AddMissionRequest?

var behavior: String?
weak var delegate: AddMissoinViewDelegate?

// MARK: - UI Components

Expand Down Expand Up @@ -57,35 +61,35 @@ extension AddMissionViewController {
addMissionView.situationView.AddMissionButton.addTarget(self, action: #selector(checkEnable), for: .touchUpInside)
addMissionView.goalTextField.addTarget(self, action: #selector(checkEnable), for: .editingChanged)
addMissionView.dateButton.addTarget(self, action: #selector(presentToActionSheet), for: .touchUpInside)
addMissionView.addMissionButton.addTarget(self, action: #selector(requestAddMissionAPI), for: .touchUpInside)
addMissionView.addMissionButton.addTarget(self, action: #selector(dismissAddMissionViewController), for: .touchUpInside)
}

func resetBehaviorModel() {
behaviorList.removeAll()
}

// MARK: - @objc Methods

@objc private func requestAddMissionAPI() {
private func requestAddMissionAPI() {
AddMissionAPI.shared.postAddMission(
newMission: AddMissionRequest(title: addMissionView.missionText.text!,
situation: (addMissionView.situationView.AddMissionButton.titleLabel?.text)!,
actions: behaviorList.map { $0.behavior },
goal: addMissionView.goalTextField.text!,
actionDate: (addMissionView.dateButton.titleLabel?.text)!)) { [weak self] _ in
guard self != nil else { return }
guard let self = self else { return }
self.delegate?.homeViewReload()
self.dismiss(animated: true)
}
}

// MARK: - @objc Methods

@objc func checkEnable() {
checkButtonEnable = addMissionView.missionText.text!.count > 0 && behaviorList.count > 0
&& (addMissionView.situationView.AddMissionButton.titleLabel?.text)! != I18N.input && addMissionView.goalTextField.text!.count > 0
}

@objc private func dismissAddMissionViewController() {
// behaviorList.removeAll()
dismiss(animated: true)
requestAddMissionAPI()
}

@objc private func pushToRecommendViewController() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ 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.placeholderType = .fillHeadTail
$0.collectionView.snp.makeConstraints {
$0.edges.equalToSuperview()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ extension HomeCollectionReusableView {
dateLabel.do {
$0.textColor = .nottodoBlack
$0.font = .PretendardBold(size: 18.adjusted)
// $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 @@ -18,7 +18,8 @@ final class HomeViewController: UIViewController {
var missionList: [DailyMissionResponseDTO] = []
var banner: BannerResponseDTO?
var missionId: Int?
private var clickedDay: String?
private let todayDate = Date()
private lazy var clickedDay: String? = todayDateFormatter.string(from: self.todayDate)
private let todayDateFormatter = DateFormatter()
private let mothlyDateFormatter = DateFormatter()
private var currentPage: Date? = Date()
Expand Down Expand Up @@ -109,7 +110,7 @@ extension HomeViewController: UICollectionViewDelegate {
}
}

private func requestDailyMissionAPI(date: String) {
fileprivate func requestDailyMissionAPI(date: String) {
HomeAPI.shared.getDailyMission(date: date) { [weak self] result in
switch result {
case let .success(data):
Expand Down Expand Up @@ -150,6 +151,7 @@ extension HomeViewController: UICollectionViewDelegate {

@objc private func addMission() {
let addMissionViewController = AddMissionViewController()
addMissionViewController.delegate = self
let navigationController = UINavigationController(rootViewController: addMissionViewController)
navigationController.modalPresentationStyle = .overFullScreen
navigationController.isNavigationBarHidden = true
Expand Down Expand Up @@ -245,7 +247,6 @@ extension HomeViewController: UICollectionViewDataSource {
if let banner = banner {
header.setRandomData(banner: banner)
}

return header
}
}
Expand Down Expand Up @@ -297,3 +298,10 @@ extension HomeViewController: FSCalendarDelegate {
requestDailyMissionAPI(date: clickedDay ?? "")
}
}

extension HomeViewController: AddMissoinViewDelegate {
func homeViewReload() {
requestDailyMissionAPI(date: clickedDay ?? "")
homeView.homeCollectionView.reloadData()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,6 @@ extension MissionHistoryView: UICollectionViewDelegateFlowLayout {

extension MissionHistoryView: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let cell = collectionView.dequeueReusableCell(
withReuseIdentifier: MissionHistoryCollectionViewCell.identifier, for: indexPath)
as? MissionHistoryCollectionViewCell

print(historyList[indexPath.row].title)
changedText = historyList[indexPath.row].title
inputTextField.text = historyList[indexPath.row].title
}
Expand Down

0 comments on commit 570b66c

Please sign in to comment.