From a10cf67c582e54f15461f1b428934fe885f6862a Mon Sep 17 00:00:00 2001 From: ahhyun1015 <121007805+ahhyun1015@users.noreply.github.com> Date: Sun, 14 Jul 2024 16:18:20 +0900 Subject: [PATCH 1/3] QA-I-17 --- CoNet/Main/Home/HomeViewController.swift | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/CoNet/Main/Home/HomeViewController.swift b/CoNet/Main/Home/HomeViewController.swift index f2982c0..f9e1574 100644 --- a/CoNet/Main/Home/HomeViewController.swift +++ b/CoNet/Main/Home/HomeViewController.swift @@ -133,7 +133,7 @@ class HomeViewController: UIViewController { self.planNum.text = String(count) self.dayPlanData = plans self.dayPlanCollectionView.reloadData() - self.layoutConstraints() + self.updataPlanCollectionViewHeight() } } @@ -143,7 +143,7 @@ class HomeViewController: UIViewController { self.waitingPlanNum.text = String(count) self.waitingPlanData = plans self.waitingPlanCollectionView.reloadData() - self.layoutConstraints() + self.updataPlanCollectionViewHeight() } } @@ -173,6 +173,19 @@ class HomeViewController: UIViewController { dayPlanLabel.text = month + "월 " + day + "일의 약속" } } + + // 높이 업데이트 + func updataPlanCollectionViewHeight() { + let dayPlanHeight = (dayPlanData.count - 1) * 100 + 90 + dayPlanCollectionView.snp.updateConstraints { make in + make.height.equalTo(dayPlanHeight) + } + + let waitingPlanHeight = waitingPlanData.count * 100 - 1 + waitingPlanCollectionView.snp.updateConstraints { make in + make.height.equalTo(waitingPlanHeight) + } + } } extension HomeViewController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { From c05c8a43c9c4277eb4f4a92f883a54543c68cc3f Mon Sep 17 00:00:00 2001 From: ahhyun1015 <121007805+ahhyun1015@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:23:18 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=EC=95=BD=EC=86=8D=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=86=92=EC=9D=B4=20=EC=A1=B0=EC=A0=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Meeting/MeetingMain/MeetingMainViewController.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CoNet/Main/Meeting/MeetingMain/MeetingMainViewController.swift b/CoNet/Main/Meeting/MeetingMain/MeetingMainViewController.swift index f73ed68..cd7d40a 100644 --- a/CoNet/Main/Meeting/MeetingMain/MeetingMainViewController.swift +++ b/CoNet/Main/Meeting/MeetingMain/MeetingMainViewController.swift @@ -185,7 +185,7 @@ class MeetingMainViewController: UIViewController { self.planNum.text = String(count) self.dayPlanData = plans self.dayPlanCollectionView.reloadData() - self.layoutContraints() + self.updataPlanCollectionViewHeight() } } @@ -312,6 +312,13 @@ class MeetingMainViewController: UIViewController { present(getMemberBottomSheet, animated: true, completion: nil) } + + func updataPlanCollectionViewHeight() { + let dayPlanHeight = dayPlanData.count * 80 - 1 + dayPlanCollectionView.snp.updateConstraints { make in + make.height.equalTo(dayPlanHeight) + } + } } // 사이드바 화면 전환 From f1e236eea46d29ff8503b20f7c67c890b2ab788a Mon Sep 17 00:00:00 2001 From: ahhyun1015 <121007805+ahhyun1015@users.noreply.github.com> Date: Sat, 20 Jul 2024 09:31:23 +0900 Subject: [PATCH 3/3] =?UTF-8?q?QA-I-19:=20=EB=AA=A8=EC=9E=84-=EC=95=BD?= =?UTF-8?q?=EC=86=8D=EC=83=81=EC=84=B8=20=EB=82=A0=EC=A7=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CoNet/Main/Home/CalendarDateFormatter.swift | 6 ++-- CoNet/Main/Home/CalendarViewController.swift | 29 +++++++++++++++++-- .../MeetingMainViewController.swift | 6 +++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/CoNet/Main/Home/CalendarDateFormatter.swift b/CoNet/Main/Home/CalendarDateFormatter.swift index 359a8d8..ddf4e0c 100644 --- a/CoNet/Main/Home/CalendarDateFormatter.swift +++ b/CoNet/Main/Home/CalendarDateFormatter.swift @@ -8,9 +8,9 @@ import Foundation class CalendarDateFormatter { - private var calendar = Calendar.current // Calendar 구조체를 현재 달력으로 초기화 - private let dateFormatter = DateFormatter() // 원하는 String 타입으로 변화시켜줄 formatter - private var nowCalendarDate = Date() // 현재 시간 + var calendar = Calendar.current // Calendar 구조체를 현재 달력으로 초기화 + let dateFormatter = DateFormatter() // 원하는 String 타입으로 변화시켜줄 formatter + var nowCalendarDate = Date() // 현재 시간 private(set) var days = [String]() // 달력에 표시할 날짜를 담을 배열 init() { diff --git a/CoNet/Main/Home/CalendarViewController.swift b/CoNet/Main/Home/CalendarViewController.swift index e37e86d..c080f1c 100644 --- a/CoNet/Main/Home/CalendarViewController.swift +++ b/CoNet/Main/Home/CalendarViewController.swift @@ -11,7 +11,7 @@ import UIKit class CalendarViewController: UIViewController { var meetingId = 0 - + var selectedDate: String? // MARK: UIComponents // 이전 달로 이동 버튼 @@ -76,7 +76,8 @@ class CalendarViewController: UIViewController { format.dateFormat = "yyyy. MM" // api 호출 - getMonthPlanAPI(date: format.string(from: Date())) + getMonthPlanAPI(date: format.string(from: calendarDateFormatter.nowCalendarDate)) + } private func setupCollectionView() { @@ -176,6 +177,22 @@ class CalendarViewController: UIViewController { // api: 특정 달 약속 조회 getMonthPlanAPI(date: changedHeader) + + // 캘린더에서 날짜 선택 + selectDateOnCalendar() + } + + func selectDateOnCalendar() { + if let selectedDate = selectedDate { + let dateComponents = selectedDate.split(separator: ".").map { String($0) } + if dateComponents.count == 3 { + let day = dateComponents[2] + if let index = calendarDateFormatter.days.firstIndex(of: day) { + let indexPath = IndexPath(item: index, section: 0) + calendarCollectionView.selectItem(at: indexPath, animated: false, scrollPosition: []) + } + } + } } } @@ -207,6 +224,8 @@ extension CalendarViewController: UICollectionViewDataSource, UICollectionViewDe // yyyy. MM. dd 형식 let clickDate = calendarDateFormatter.changeDateType(date: calendarDate) + calendarDay + selectedDate = clickDate + if let parentVC = parent { if parentVC is HomeViewController { // 부모 뷰컨트롤러가 HomeViewController @@ -282,6 +301,12 @@ extension CalendarViewController: UICollectionViewDataSource, UICollectionViewDe cell.reloadPlanMark() } + // 셀의 날짜가 선택된 날짜와 일치하는지 확인 + let cellDate = calendarDateFormatter.changeDateType(date: calendarDate) + calendarDateFormatter.formatNumberToTwoDigit(Int(cellDay) ?? 0) + if cellDate == selectedDate { + collectionView.selectItem(at: indexPath, animated: false, scrollPosition: []) + } + return cell } } diff --git a/CoNet/Main/Meeting/MeetingMain/MeetingMainViewController.swift b/CoNet/Main/Meeting/MeetingMain/MeetingMainViewController.swift index cd7d40a..f27fc72 100644 --- a/CoNet/Main/Meeting/MeetingMain/MeetingMainViewController.swift +++ b/CoNet/Main/Meeting/MeetingMain/MeetingMainViewController.swift @@ -138,7 +138,11 @@ class MeetingMainViewController: UIViewController { format.locale = Locale(identifier: "ko_KR") format.timeZone = TimeZone(abbreviation: "KST") - dayPlanAPI(date: format.string(from: Date())) + if let selectedDate = calendarVC.selectedDate { + dayPlanAPI(date: selectedDate) + } else { + dayPlanAPI(date: format.string(from: Date())) + } } override func viewWillDisappear(_ animated: Bool) {