Skip to content

Commit

Permalink
[Feat/#30] PR 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
oyslucy committed Feb 8, 2025
1 parent d6240f1 commit 1fcba75
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 62 deletions.
46 changes: 19 additions & 27 deletions Noostak_iOS/Noostak_iOS/Global/Utils/NSTDateUtility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public extension NSTDateUtility {
case yyyyMM
case EE
case HH
case HHmm
case EEMMdd
case MMddEE

var format: String {
Expand All @@ -69,8 +71,12 @@ public extension NSTDateUtility {
return "EE"
case .HH:
return "HH"
case .MMddEE:
case .HHmm:
return "HH:mm"
case .EEMMdd:
return "EE\nMM/dd"
case .MMddEE:
return "M월 d일 (EE)"
}
}
}
Expand All @@ -91,7 +97,7 @@ extension NSTDateUtility {
///타임테이블 뷰 : "요일 월/일"
static func dateList(_ dateStrings: [String]) -> [String] {
let formatter = NSTDateUtility(format: .yyyyMMddTHHmmss) // ISO 8601 형식
let displayFormatter = NSTDateUtility(format: .MMddEE) // 출력 형식
let displayFormatter = NSTDateUtility(format: .EEMMdd) // 출력 형식

return dateStrings.compactMap { dateString in
switch formatter.date(from: dateString) {
Expand Down Expand Up @@ -129,33 +135,19 @@ extension NSTDateUtility {
return result
}

///약속상세뷰 : "9월 7일 (일) 10:00~12:00"
static func durationList(_ startTime: String, _ endTime: String) -> String {
let formatter = NSTDateUtility(format: .yyyyMMddTHHmmss) // ISO 8601 형식
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "ko_KR")
dateFormatter.timeZone = TimeZone(identifier: "Asia/Seoul")

// 날짜 포맷: "9월 7일 (일)"
dateFormatter.dateFormat = "M월 d일 (E)"

// 시간 포맷: "10:00"
let timeFormatter = DateFormatter()
timeFormatter.locale = Locale(identifier: "ko_KR")
timeFormatter.timeZone = TimeZone(identifier: "Asia/Seoul")
timeFormatter.dateFormat = "HH:mm"

switch (formatter.date(from: startTime), formatter.date(from: endTime)) {
case (.success(let start), .success(let end)):
let dateString = dateFormatter.string(from: start) // "9월 7일 (일)"
let startTimeString = timeFormatter.string(from: start) // "10:00"
let endTimeString = timeFormatter.string(from: end) // "12:00"

return "\(dateString) \(startTimeString)~\(endTimeString)"

default:
print("Failed to parse start or end time.")
return ""
let dateFormatter = NSTDateUtility(format: .MMddEE) // "9월 7일 (일)"
let timeFormatter = NSTDateUtility(format: .HHmm) // "10:00"

let startDateResult = formatter.date(from: startTime)
let endDateResult = formatter.date(from: endTime)

guard case .success(let startDate) = startDateResult,
case .success(let endDate) = endDateResult else {
return "Invalid date format"
}
return "\(dateFormatter.string(from: startDate)) \(timeFormatter.string(from: startDate))~\(timeFormatter.string(from: endDate))"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class InProgressCVC: UICollectionViewCell, View {
private let availabilityLabel = UILabel()
private let backgroundProgressBar = UIView()
private let progressBar = UIView()

// MARK: Init
override init(frame: CGRect) {
super.init(frame: frame)
Expand Down Expand Up @@ -60,7 +60,7 @@ final class InProgressCVC: UICollectionViewCell, View {
}

moveButton.do {
$0.setImage(.icVector, for: .normal)
$0.setImage(.icArrowRight, for: .normal)
}

timeLabel.do {
Expand Down Expand Up @@ -130,11 +130,11 @@ extension InProgressCVC {
let schedule = reactor.currentState.schedule
scheduleTitleLabel.text = schedule.schedule.name
timeLabel.text = NSTDateUtility.durationList(schedule.startTime, schedule.endTime)
availabilityLabel.text = "\(schedule.availableMemberCount)명/ \(schedule.groupMemberCount)"
availabilityLabel.text = "\(schedule.availableMemberCount)명/\(schedule.groupMemberCount)"
progressBar.snp.makeConstraints {
$0.top.equalTo(timeLabel.snp.bottom).offset(10)
$0.leading.equalTo(backgroundProgressBar)
$0.width.equalTo(50)
$0.width.equalTo((Int(self.frame.width) - 32) * schedule.availableMemberCount/schedule.groupMemberCount)
$0.height.equalTo(4)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import RxSwift
import RxCocoa

final class GroupDetailView: UIView {

// MARK: Properties
private let disposeBag = DisposeBag()

Expand All @@ -26,32 +26,28 @@ final class GroupDetailView: UIView {
private let underlineView = UIView()
private let selectedUnderlineView = UIView()
let defaultLabel = UILabel()
let inProgressCollectionView: UICollectionView
let confirmedCollectionView: UICollectionView
var inProgressCollectionView: UICollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
var confirmedCollectionView: UICollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())

// MARK: Init
override init(frame: CGRect) {
let inProgressLayout = UICollectionViewFlowLayout()
let confirmedLayout = UICollectionViewFlowLayout()
self.inProgressCollectionView = UICollectionView(frame: .zero, collectionViewLayout: inProgressLayout)
self.confirmedCollectionView = UICollectionView(frame: .zero, collectionViewLayout: confirmedLayout)
super.init(frame: frame)
setUpFoundation()
setUpHierarchy()
setUpUI()
setUpLayout()
bindSegmentControl()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: setUpHierarchy
private func setUpHierarchy() {
[profileImageView, groupNameLabel, shareButton, groupMemberButton, scheduleListLabel,
segmentedControl, underlineView, selectedUnderlineView,
inProgressCollectionView, confirmedCollectionView, defaultLabel].forEach {
inProgressCollectionView, confirmedCollectionView, defaultLabel].forEach {
self.addSubview($0)
}
}
Expand Down Expand Up @@ -82,12 +78,12 @@ final class GroupDetailView: UIView {
config.baseForegroundColor = .appGray800
config.attributedTitle = AttributedString("그룹 멤버 8",
attributes: AttributeContainer([.font: UIFont.PretendardStyle.b2_r.font]))
config.image = .icVector
config.image = .icArrowRight
config.imagePlacement = .trailing
config.imagePadding = 5
config.contentInsets = .zero
$0.configuration = config

}

scheduleListLabel.do {
Expand Down Expand Up @@ -126,12 +122,12 @@ final class GroupDetailView: UIView {
inProgressCollectionView.do {
$0.isHidden = false
}

confirmedCollectionView.do {
$0.isHidden = true
}
}

// MARK: setUpLayout
private func setUpLayout() {
profileImageView.snp.makeConstraints {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,17 @@ final class GroupDetailViewController: UIViewController, View {
rootView.confirmedCollectionView.register(ConfirmedCVC.self, forCellWithReuseIdentifier: ConfirmedCVC.identifier)
rootView.inProgressCollectionView.rx.setDelegate(self).disposed(by: disposeBag)
rootView.confirmedCollectionView.rx.setDelegate(self).disposed(by: disposeBag)
DispatchQueue.main.async {
self.rootView.layoutIfNeeded()
}
}

// MARK: - Bind Reactor
func bind(reactor: GroupDetailReactor) {
rootView.segmentedControl.rx.selectedSegmentIndex
.distinctUntilChanged()
.flatMapLatest { index -> Observable<Reactor.Action> in
if index == 0 {
return Observable.concat([
.just(.selectSegment(index)),
.just(.loadInProgressData)
])
} else {
return Observable.concat([
.just(.selectSegment(index)),
.just(.loadConfirmedData)
])
}
Observable.concat([
.just(.selectSegment(index)),
.just(index == 0 ? .loadInProgressData : .loadConfirmedData)
])
}
.bind(to: reactor.action)
.disposed(by: disposeBag)
Expand All @@ -90,21 +80,22 @@ final class GroupDetailViewController: UIViewController, View {
.do(onNext: { _ in
self.rootView.inProgressCollectionView.reloadData()
})
.bind(to: rootView.inProgressCollectionView.rx.items(cellIdentifier: InProgressCVC.identifier, cellType: InProgressCVC.self)) { index, reactor, cell in
.bind(to: rootView.inProgressCollectionView.rx.items(cellIdentifier: InProgressCVC.identifier, cellType: InProgressCVC.self)) { _, reactor, cell in
cell.reactor = reactor
}
.disposed(by: disposeBag)

// 확정된 약속 바인딩
reactor.state.map { $0.confirmedCellReactors }
.do(onNext: { _ in self.rootView.confirmedCollectionView.reloadData() })
.bind(to: rootView.confirmedCollectionView.rx.items(cellIdentifier: ConfirmedCVC.identifier, cellType: ConfirmedCVC.self)) { index, reactor, cell in
.bind(to: rootView.confirmedCollectionView.rx.items(cellIdentifier: ConfirmedCVC.identifier, cellType: ConfirmedCVC.self)) { _, reactor, cell in
cell.reactor = reactor
}
.disposed(by: disposeBag)
}
}

// MARK: - CollectionViewDelegateFlowLayout
extension GroupDetailViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
switch collectionView {
Expand Down

0 comments on commit 1fcba75

Please sign in to comment.