Skip to content

Commit

Permalink
Merge pull request #196 from devxsby/feat/#184-월선택뷰-동기화
Browse files Browse the repository at this point in the history
[Feat] 월 선택 뷰 동기화 및 터치영역 수정 (#184)
  • Loading branch information
devxsby committed Jul 23, 2022
2 parents 71dd6ac + 4839c0f commit 743648a
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//
// CharacterNameViewController.swift
// Happic-iOS
//
// Created by Zaid Kang on 2022/07/20.
//

import UIKit

class CharacterNameViewController: UIViewController {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//
// CreateCharacterViewController.swift
// Happic-iOS
//
// Created by Zaid Kang on 2022/07/20.
//

import UIKit

class CreateCharacterViewController: UIViewController, Storyboarded {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ final class HaruHappicController: BaseUploadViewController {

// MARK: - Properties
var models = [HaruHappicModel]()
var currentMonth: String = "7"
private lazy var haruHappicPhotoController = HaruHappicPhotoController()
private lazy var haruHappicTagController = HaruHappicTagController()

Expand Down Expand Up @@ -70,6 +71,13 @@ extension HaruHappicController: HaruHappicPhotoControllerDelegate, HaruHappicTag
detailViewController.setData(models: models, index: index)
self.navigationController?.pushViewController(detailViewController, animated: true)
}

func changeMonth(month: String) {
self.currentMonth = month
haruHappicPhotoController.setMonthData(month: month)
haruHappicTagController.setMonthData(month: month)
getHaruHappicPhoto(year: 2022, month: Int(currentMonth)!)
}
}

// MARK: - Network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,12 @@ final class TagCollectionViewCell: UICollectionViewCell {
whereLabel.text = model.place
whoLabel.text = model.who
whatLabel.text = model.what

let date = Date()
let todayDay = Calendar.current.dateComponents([.day], from: date)

if model.day == todayDay.day {
dailyLabel.textColor = .hpOrange
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import UIKit
// MARK: - Protocols
protocol HaruHappicPhotoControllerDelegate: AnyObject {
func showDetailView(index: Int)
func changeMonth(month: String)
}

final class HaruHappicPhotoController: UIViewController {
Expand Down Expand Up @@ -80,6 +81,33 @@ final class HaruHappicPhotoController: UIViewController {
self.models = models
containerCollectionView.reloadData()
}

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
if let touch = touches.first,
touch.view == self.view || touch.view == containerCollectionView {
customMonthPickerView.isHidden = true
}
}

func setMonthData(month: String) {
setCustomMonthViewText(month: month)
setCustomMonthPickerViewSelected(month: month)
}

func setCustomMonthViewText(month: String) {
if month.count == 1 {
customMonthView.monthLabel.text = "2022 . 0\(month)"
} else {
customMonthView.monthLabel.text = "2022 . \(month)"
}
}

func setCustomMonthPickerViewSelected(month: String) {
if let currentMonth = Int(month) {
customMonthPickerView.setButtonStatus(month: currentMonth)
}
}
}

// MARK: - Extensions
Expand All @@ -96,7 +124,11 @@ extension HaruHappicPhotoController: UICollectionViewDelegate, UICollectionViewD
}

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
delegate?.showDetailView(index: indexPath.row)
if customMonthPickerView.isHidden {
delegate?.showDetailView(index: indexPath.row)
} else {
customMonthPickerView.isHidden = true
}
}
}

Expand All @@ -122,6 +154,7 @@ extension HaruHappicPhotoController: CustomMonthViewDelegate {

extension HaruHappicPhotoController: CustomMonthPickerViewDelegate {
func changeMonthStatus(_ month: String) {
delegate?.changeMonth(month: month)
if month.count == 1 {
customMonthView.monthLabel.text = "2022 . 0\(month)"
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import UIKit
// MARK: - Protocols
protocol HaruHappicTagControllerDelegate: AnyObject {
func showDetailView(index: Int)
func changeMonth(month: String)
}

final class HaruHappicTagController: UIViewController {
Expand Down Expand Up @@ -81,6 +82,33 @@ final class HaruHappicTagController: UIViewController {
self.models = models
containerCollectionView.reloadData()
}

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
if let touch = touches.first,
touch.view == self.view || touch.view == containerCollectionView {
customMonthPickerView.isHidden = true
}
}

func setMonthData(month: String) {
setCustomMonthViewText(month: month)
setCustomMonthPickerViewSelected(month: month)
}

func setCustomMonthViewText(month: String) {
if month.count == 1 {
customMonthView.monthLabel.text = "2022 . 0\(month)"
} else {
customMonthView.monthLabel.text = "2022 . \(month)"
}
}

func setCustomMonthPickerViewSelected(month: String) {
if let currentMonth = Int(month) {
customMonthPickerView.setButtonStatus(month: currentMonth)
}
}
}

// MARK: - Extensions
Expand All @@ -97,7 +125,11 @@ extension HaruHappicTagController: UICollectionViewDelegate, UICollectionViewDat
}

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
delegate?.showDetailView(index: indexPath.row)
if customMonthPickerView.isHidden {
delegate?.showDetailView(index: indexPath.row)
} else {
customMonthPickerView.isHidden = true
}
}
}

Expand All @@ -119,6 +151,7 @@ extension HaruHappicTagController: CustomMonthViewDelegate {

extension HaruHappicTagController: CustomMonthPickerViewDelegate {
func changeMonthStatus(_ month: String) {
delegate?.changeMonth(month: month)
if month.count == 1 {
customMonthView.monthLabel.text = "2022 . 0\(month)"
} else {
Expand Down

0 comments on commit 743648a

Please sign in to comment.