Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat/NST-13] 그룹상세화면 구현 #33

Merged
merged 4 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions Noostak_iOS/Noostak_iOS/Domain/Entity/Schedule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,40 @@ struct Schedule {
///약속 카테고리
let category: ScheduleCategory
///약속 생성기간
let dates: [Date]
let selectionDates: [Date]
///약속생성 시작일
var startDate: Date? {
return dates.sorted().first
var selectionStartDate: Date? {
return selectionDates.sorted().first
}
///약속생성 종료일
var endDate: Date? {
return dates.sorted().last
var selectionEndDate: Date? {
return selectionDates.sorted().last
}
///약속 시작시각
let startTime: Date
///약속 종료시각
let endTime: Date
///약속생성 시작시각
let selectionStartTime: Date
///약속생성 종료시각
let selectionEndTime: Date
///소요시간
var duration: Int?
}

struct ExtendedSchedule {
///스케쥴
let schedule: Schedule
///약속 날짜(1순위, 확정)
let date: String
///약속 시작시각(1순위, 확정)
let startTime: String
///약속 종료시각(1순위, 확정)
let endTime: String
///가능한 친구
let availableMembers: [User]
///불가능한 친구
let unavailableMembers: [User]
///그룹 총인원
var groupMemberCount: Int
///가능한 인원
var availableMemberCount: Int
}

extension ScheduleCategory {
Expand Down
20 changes: 11 additions & 9 deletions Noostak_iOS/Noostak_iOS/Global/Extension/UIFont+.swift
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 폰트 시스템은 언제 한번 날잡아서 기강 잡아야겠네요..

Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extension UIFont {
case h1_sb
case h2_b
case h3_sb
case h3_22_SB
case h4_b
case h4_sb
case h5_b
Expand All @@ -63,14 +64,15 @@ extension UIFont {
case c2_sb
case c3_r
case c4_r

var font: UIFont {
switch self {
case .h1_b: return UIFont.pretendard(.bold, size: 56)
case .h1_sb: return UIFont.pretendard(.semibold, size: 56)
case .h2_b: return UIFont.pretendard(.bold, size: 27)
case .h1_b: return UIFont.pretendard(.bold, size: 27)
case .h1_sb: return UIFont.pretendard(.semibold, size: 27)
case .h2_b: return UIFont.pretendard(.bold, size: 24)
case .h3_sb: return UIFont.pretendard(.semibold, size: 24)
case .h4_b: return UIFont.pretendard(.bold, size: 24)
case .h3_22_SB: return UIFont.pretendard(.semibold, size: 22)
case .h4_b: return UIFont.pretendard(.bold, size: 20)
case .h4_sb: return UIFont.pretendard(.semibold, size: 20)
case .h5_b: return UIFont.pretendard(.bold, size: 18)
case .t1_sb: return UIFont.pretendard(.semibold, size: 18)
Expand All @@ -89,13 +91,13 @@ extension UIFont {
case .c4_r: return UIFont.pretendard(.regular, size: 11)
}
}

// Line Height (LHLHUnit)
var lineHeightUnit: CGFloat {
switch self {
case .h1_b, .h1_sb, .h2_b, .h3_sb, .h4_b, .h4_sb, .h5_b,
.t1_sb, .t2_r, .t3_b, .t4_b, .b1_sb, .b2_r, .b4_sb,
.b4_sb_1percent, .b4_r, .b5_r, .c1_b, .c2_sb, .c3_r, .c4_r:
case .h1_b, .h1_sb, .h2_b, .h3_sb, .h3_22_SB, .h4_b, .h4_sb, .h5_b,
.t1_sb, .t2_r, .t3_b, .t4_b, .b1_sb, .b2_r, .b4_sb,
.b4_sb_1percent, .b4_r, .b5_r, .c1_b, .c2_sb, .c3_r, .c4_r:
return 140
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Supervisor account.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "icon_share.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vector는 너무 포괄적인 이름 같아요! ic_arrow_right 같은 네이밍도 괜찮지 않을까요?

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Vector.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 33 additions & 1 deletion Noostak_iOS/Noostak_iOS/Global/Utils/NSTDateUtility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public extension NSTDateUtility {
}

extension NSTDateUtility {
///타임테이블 뷰 : "요일 월/일"
static func dateList(_ dateStrings: [String]) -> [String] {
Comment on lines +97 to 98
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NSTDateUtility는 모든 개발자들이 사용하는 유틸리티일거에요.
본 유틸리티에서 static func으로 추가하여 사용한다면, 불특정 다수의 개발자가 해당 함수를 사용할 수 있겠죠?

  1. 다른 영역에서도 넓게 쓰일 수 있도록 함수 이름과 사용 예시를 명확히 정해주세요
    or
  2. 사용하는 뷰 내부에서 private하게 자체적으로 만들어 써도 될 것 같아요

둘 중 하나로 골라서 진행해보시면 좋을 것 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오우 이거 수정한다는걸 깜먹고 올렸네요 수정하고 올리겠슴당

let formatter = NSTDateUtility(format: .yyyyMMddTHHmmss) // ISO 8601 형식
let displayFormatter = NSTDateUtility(format: .MMddEE) // 출력 형식
Expand All @@ -102,7 +103,8 @@ extension NSTDateUtility {
}
}
}


///타임테이블 뷰 : "00시"
static func timeList(_ startTime: String, _ endTime: String) -> [String] {
let formatter = NSTDateUtility(format: .yyyyMMddTHHmmss) // ISO 8601 형식
var result: [String] = []
Expand All @@ -126,4 +128,34 @@ 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)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NSTDateUtility에 이 포맷 case로 추가 하면 돼요!


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 코드를 막기 위해 본 NSTDateUtility 코드가 존재한답니다!
해당 코드 문서와 PR 한번 읽고오시면 도움이 될거에요 :)


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 ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

import UIKit

class ViewController: UIViewController {

final class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CollectionViewCell은 작성하실 때 prepareForReuse가 필요한 부분은 없는지 한 번씩 확인해보세요!
해당 코드에서 disposeBag은 사용되지 않아 지워도 되겠지만, 만약 실제 Rx subscribe나 bind가 되어 있는경우 PrepareForReuse에서 disposeBag을 초기화해주세요.

Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//
// ConfirmedCVC.swift
// Noostak_iOS
//
// Created by 오연서 on 2/1/25.
//

import UIKit
import SnapKit
import Then
import ReactorKit

final class ConfirmedCVC: UICollectionViewCell, View {

// MARK: Properties
static let identifier = "ConfirmedCVC"
var disposeBag = DisposeBag()

// MARK: Views
private let chip = UIView()
private let scheduleTitleLabel = UILabel()
private let timeLabel = UILabel()
private let divider = UIView()

// MARK: Init
override init(frame: CGRect) {
super.init(frame: frame)
setUpHierarchy()
setUpUI()
setUpLayout()
}

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

// MARK: setUpHierarchy
private func setUpHierarchy() {
[chip, scheduleTitleLabel, timeLabel, divider].forEach {
self.addSubview($0)
}
}

// MARK: setUpUI
private func setUpUI() {
chip.do {
$0.layer.cornerRadius = 6.5
}

scheduleTitleLabel.do {
$0.font = .PretendardStyle.b1_sb.font
$0.textColor = .appGray900
}

timeLabel.do {
$0.font = .PretendardStyle.c3_r.font
$0.textColor = .appGray700
}

divider.do {
$0.backgroundColor = .appGray200
}
}

// MARK: setUpLayout
private func setUpLayout() {
chip.snp.makeConstraints {
$0.top.equalToSuperview().offset(15)
$0.leading.equalToSuperview().offset(6)
$0.size.equalTo(13)
}

scheduleTitleLabel.snp.makeConstraints {
$0.top.equalToSuperview().offset(10)
$0.leading.equalTo(chip.snp.trailing).offset(9)
}

timeLabel.snp.makeConstraints {
$0.top.equalTo(scheduleTitleLabel.snp.bottom).offset(4)
$0.leading.equalTo(scheduleTitleLabel)
}

divider.snp.makeConstraints {
$0.bottom.equalToSuperview()
$0.horizontalEdges.equalToSuperview()
$0.height.equalTo(1)
}
}
}

extension ConfirmedCVC {
func bind(reactor: ConfirmedCellReactor) {
let schedule = reactor.currentState.schedule
chip.backgroundColor = schedule.schedule.category.displayColor
scheduleTitleLabel.text = schedule.schedule.name
timeLabel.text = NSTDateUtility.durationList(schedule.startTime, schedule.endTime)
}
Comment on lines +92 to +97
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rx 바인드하는 내용은 없으니 이름을 바꿔도 괜찮지 않을까요?!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

뷰컨트롤러에서 self.reactor=reactor 로 할당하기 위해 bind 메소드를 썼습미다

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// ConfirmedCellReactor.swift
// Noostak_iOS
//
// Created by 오연서 on 2/3/25.
//

import ReactorKit
import RxSwift

final class ConfirmedCellReactor: Reactor {
typealias Action = NoAction
struct State {
let schedule: ExtendedSchedule
}

let initialState: State

init(schedule: ExtendedSchedule) {
self.initialState = State(schedule: schedule)
}
}
Loading