Skip to content

Commit c8a8668

Browse files
authored
Merge pull request #59 from YAPP-Github/TNT-214-trainerAddSession
[TNT-214] TrainerAddPTSession ๊ด€๋ จ ์‹ ๊ทœ ๋””์ž์ธ ์ปดํฌ๋„ŒํŠธ ์ถ”๊ฐ€
2 parents b733379 + 822f7f0 commit c8a8668

File tree

13 files changed

+429
-57
lines changed

13 files changed

+429
-57
lines changed

โ€ŽTnT/Projects/DesignSystem/Sources/Components/BottomSheet/AutoSizingBottomSheetModifier.swiftโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ struct AutoSizingBottomSheetModifier: ViewModifier {
2626
GeometryReader { proxy in
2727
Color.clear
2828
.onAppear {
29-
contentHeight = proxy.size.height + 50
29+
contentHeight = proxy.size.height + 10
3030
}
3131
.onChange(of: proxy.size.height) { _, newHeight in
32-
contentHeight = newHeight + 50
32+
contentHeight = newHeight + 10
3333
}
3434
}
3535
)

โ€ŽTnT/Projects/DesignSystem/Sources/Components/Calendar/TCalendarCell.swiftโ€Ž

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import FSCalendar
1212
final class TCalendarCell: FSCalendarCell {
1313
// MARK: Properties
1414
static let identifier: String = "TCalendarCell"
15-
static let cellSize: CGSize = CGSize(width: 51, height: 54)
1615

1716
/// Cell์— ํ‘œ์‹œ๋˜๋Š” ๋‚ ์งœ
1817
private var customDate: Date?
@@ -22,8 +21,8 @@ final class TCalendarCell: FSCalendarCell {
2221
private var style: Style = .default
2322
/// Cell์— ํ‘œ์‹œ๋˜๋Š” ์ผ์ • ์นด์šดํŠธ
2423
private var eventCount: Int = 0
25-
/// ์ฃผ๊ฐ„/์›”๊ฐ„ ๋ชจ๋“œ์ธ์ง€ ํ‘œ์‹œ
26-
private var isWeekMode: Bool = false
24+
/// ์ฃผ๊ฐ„/์›”๊ฐ„/์ปดํŒฉํŠธ ๋ชจ๋“œ์ธ์ง€ ํ‘œ์‹œ
25+
private var mode: TCalendarType = .month
2726

2827
// MARK: UI Elements
2928
private let dayLabel: UILabel = UILabel()
@@ -100,10 +99,14 @@ final class TCalendarCell: FSCalendarCell {
10099

101100
/// ์ผ์ • ์นด์šดํŠธ ํ‘œ์‹œ ์—…๋ฐ์ดํŠธ
102101
private func updateEventDisplay() {
102+
guard mode != .compactMonth else {
103+
eventStackView.isHidden = true
104+
return
105+
}
103106
eventCountLabel.text = "\(eventCount)"
104107
let eventExists: Bool = eventCount > 0
105108
eventStackView.isHidden = !eventExists
106-
let presentCount: Bool = !isWeekMode && eventExists
109+
let presentCount: Bool = mode == .month && eventExists
107110
eventCountLabel.isHidden = !presentCount
108111
}
109112

@@ -112,7 +115,7 @@ final class TCalendarCell: FSCalendarCell {
112115
// ๋‚ ์งœ ๋ฐ ์„ ํƒ ์ƒํƒœ ์ดˆ๊ธฐํ™”
113116
customDate = nil
114117
isCellSelected = false
115-
isWeekMode = false
118+
mode = .month
116119

117120
// ์ผ์ • ๊ด€๋ จ ์ดˆ๊ธฐํ™”
118121
eventCount = 0
@@ -132,12 +135,12 @@ extension TCalendarCell {
132135
with date: Date,
133136
isCellSelected: Bool,
134137
eventCount: Int = 0,
135-
isWeekMode: Bool = false
138+
mode: TCalendarType = .month
136139
) {
137140
self.customDate = date
138141
self.isCellSelected = isCellSelected
139142
self.eventCount = eventCount
140-
self.isWeekMode = isWeekMode
143+
self.mode = mode
141144

142145
// ํ˜„์žฌ ๋‚ ์งœ ๋ฐ ์„ ํƒ ์ƒํƒœ๋ฅผ ๋ฐ˜์˜, Style ์„ค์ •
143146
if isCellSelected {

โ€ŽTnT/Projects/DesignSystem/Sources/Components/Calendar/TCalendarRepresentable.swiftโ€Ž

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ public struct TCalendarRepresentable: UIViewRepresentable {
1616
@Binding private var currentPage: Date
1717
/// ์บ˜๋ฆฐ๋” ๋†’์ด
1818
@Binding var calendarHeight: CGFloat
19-
/// ์ฃผ๊ฐ„/์›”๊ฐ„ ํ‘œ์‹œ ์—ฌ๋ถ€
20-
private var isWeekMode: Bool
19+
/// ์ฃผ๊ฐ„/์›”๊ฐ„/์ปดํŒฉํŠธ ๋ชจ๋“œ์ธ์ง€ ํ‘œ์‹œ
20+
private var mode: TCalendarType = .month
2121
/// ์บ˜๋ฆฐ๋” ํ‘œ์‹œ ์ด๋ฒคํŠธ ๋”•์…”๋„ˆ๋ฆฌ
2222
private var events: [Date: Int]
2323

2424
public init(
2525
selectedDate: Binding<Date>,
2626
currentPage: Binding<Date>,
2727
calendarHeight: Binding<CGFloat>,
28-
isWeekMode: Bool = false,
28+
mode: TCalendarType = .month,
2929
events: [Date: Int] = [:]
3030
) {
3131
self._selectedDate = selectedDate
3232
self._currentPage = currentPage
3333
self._calendarHeight = calendarHeight
34-
self.isWeekMode = isWeekMode
34+
self.mode = mode
3535
self.events = events
3636
}
3737

@@ -44,7 +44,7 @@ public struct TCalendarRepresentable: UIViewRepresentable {
4444

4545
// Cell ์„ค์ •
4646
calendar.register(TCalendarCell.self, forCellReuseIdentifier: TCalendarCell.identifier)
47-
calendar.collectionView.contentSize = TCalendarCell.cellSize
47+
calendar.collectionView.contentSize = mode.cellSize
4848

4949
// ๊ธฐ๋ณธ ์„ค์ •
5050
calendar.delegate = context.coordinator
@@ -55,7 +55,7 @@ public struct TCalendarRepresentable: UIViewRepresentable {
5555
calendar.placeholderType = .none
5656
calendar.headerHeight = 0
5757
calendar.weekdayHeight = 18
58-
calendar.rowHeight = TCalendarCell.cellSize.height
58+
calendar.rowHeight = mode.cellSize.height
5959
calendar.appearance.weekdayTextColor = UIColor(.neutral400)
6060
calendar.appearance.weekdayFont = Typography.FontStyle.label2Medium.uiFont
6161
calendar.appearance.selectionColor = .clear
@@ -77,7 +77,7 @@ public struct TCalendarRepresentable: UIViewRepresentable {
7777
}
7878

7979
// `isWeekMode` ๋ฐ˜์˜
80-
let targetScope: FSCalendarScope = isWeekMode ? .week : .month
80+
let targetScope: FSCalendarScope = mode.scope
8181
if uiView.scope != targetScope {
8282
uiView.scope = targetScope
8383
}
@@ -137,7 +137,7 @@ public extension TCalendarRepresentable {
137137
with: date,
138138
isCellSelected: isSelected,
139139
eventCount: eventCount,
140-
isWeekMode: parent.isWeekMode
140+
mode: parent.mode
141141
)
142142

143143
return cell
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//
2+
// TCalendarType.swift
3+
// DesignSystem
4+
//
5+
// Created by ๋ฐ•๋ฏผ์„œ on 2/6/25.
6+
// Copyright ยฉ 2025 yapp25thTeamTnT. All rights reserved.
7+
//
8+
9+
import FSCalendar
10+
11+
/// TCalendar์— ์‚ฌ์šฉ๋˜๋Š” ์บ˜๋ฆฐ๋” ํƒ€์ž…์ž…๋‹ˆ๋‹ค
12+
public enum TCalendarType {
13+
/// ์ฃผ๊ฐ„ ์บ˜๋ฆฐ๋” - ์ผ์ • ํ‘œ์‹œ
14+
case week
15+
/// ์›”๊ฐ„ ์บ˜๋ฆฐ๋” - ์ผ์ • ํ‘œ์‹œ
16+
case month
17+
/// ์›”๊ฐ„ ์บ˜๋ฆฐ๋” - ๋‚ ์งœ์™€ ์„ ํƒ ํ‘œ์‹œ๋งŒ
18+
case compactMonth
19+
20+
var scope: FSCalendarScope {
21+
switch self {
22+
case .week:
23+
return .week
24+
case .month, .compactMonth:
25+
return .month
26+
}
27+
}
28+
29+
var calendarHeight: CGFloat {
30+
switch self {
31+
case .week:
32+
return 80
33+
case .month:
34+
return 340
35+
case .compactMonth:
36+
return 320
37+
}
38+
}
39+
40+
var cellSize: CGSize {
41+
switch self {
42+
case .week, .month:
43+
return CGSize(width: 51, height: 54)
44+
case .compactMonth:
45+
return CGSize(width: 51, height: 40)
46+
}
47+
}
48+
}

โ€ŽTnT/Projects/DesignSystem/Sources/Components/Calendar/TCalendarView.swiftโ€Ž

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,32 @@ import SwiftUI
1111
/// ์•ฑ ์ „๋ฐ˜์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” ์บ˜๋ฆฐ๋”์ž…๋‹ˆ๋‹ค.
1212
/// ์ฃผ๊ฐ„/์›”๊ฐ„ ํ‘œ์‹œ๋ฅผ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.
1313
public struct TCalendarView: View {
14-
15-
/// ์ฃผ๊ฐ„ ์บ˜๋ฆฐ๋” ๋†’์ด
16-
static let weeklyCalendarHeight: CGFloat = 80
17-
/// ์›”๊ฐ„ ์บ˜๋ฆฐ๋” ๋†’์ด
18-
static let monthlyCalendarHeight: CGFloat = 340
14+
1915
/// ์„ ํƒํ•œ ๋‚ ์งœ
2016
@Binding var selectedDate: Date
2117
/// ํ˜„์žฌ ํŽ˜์ด์ง€
2218
@Binding var currentPage: Date
2319
/// ์—…๋ฐ์ดํŠธ ํ”Œ๋ž˜๊ทธ
2420
@State private var forceUpdate: UUID = UUID()
2521
/// ์บ˜๋ฆฐ๋” ๋†’์ด
26-
@State private var calendarHeight: CGFloat = monthlyCalendarHeight
27-
/// ์ฃผ๊ฐ„/์›”๊ฐ„ ํ‘œ์‹œ ์—ฌ๋ถ€
28-
private var isWeekMode: Bool
22+
@State private var calendarHeight: CGFloat = TCalendarType.month.calendarHeight
23+
/// ์ฃผ๊ฐ„/์›”๊ฐ„/์ปดํŒฉํŠธ ๋ชจ๋“œ์ธ์ง€ ํ‘œ์‹œ
24+
private var mode: TCalendarType = .month
2925
/// ์บ˜๋ฆฐ๋” ํ‘œ์‹œ ์ด๋ฒคํŠธ ๋”•์…”๋„ˆ๋ฆฌ
3026
private var events: [Date: Int]
3127

3228
public init(
3329
selectedDate: Binding<Date>,
3430
currentPage: Binding<Date>,
3531
forceUpdate: UUID = UUID(),
36-
events: [Date: Int],
37-
isWeekMode: Bool = false
32+
events: [Date: Int] = [:],
33+
mode: TCalendarType = .month
3834
) {
3935
self._selectedDate = selectedDate
4036
self._currentPage = currentPage
4137
self.events = events
4238
self.forceUpdate = forceUpdate
43-
self.isWeekMode = isWeekMode
39+
self.mode = mode
4440
}
4541

4642
public var body: some View {
@@ -49,23 +45,19 @@ public struct TCalendarView: View {
4945
selectedDate: $selectedDate,
5046
currentPage: $currentPage,
5147
calendarHeight: $calendarHeight,
52-
isWeekMode: isWeekMode,
48+
mode: mode,
5349
events: events
5450
)
55-
.frame(width: proxy.size.width, height: TCalendarView.monthlyCalendarHeight)
51+
.frame(width: proxy.size.width, height: TCalendarType.month.calendarHeight)
5652
.id(forceUpdate)
5753
.onChange(of: events) {
5854
forceUpdate = UUID()
5955
}
6056
.onAppear {
61-
calendarHeight = isWeekMode
62-
? TCalendarView.weeklyCalendarHeight
63-
: TCalendarView.monthlyCalendarHeight
57+
calendarHeight = mode.calendarHeight
6458
}
65-
.onChange(of: isWeekMode) {
66-
calendarHeight = isWeekMode
67-
? TCalendarView.weeklyCalendarHeight
68-
: TCalendarView.monthlyCalendarHeight
59+
.onChange(of: mode) {
60+
calendarHeight = mode.calendarHeight
6961
}
7062
}
7163
.frame(height: calendarHeight)

โ€ŽTnT/Projects/DesignSystem/Sources/Components/DatePickerView/TDatePickerView.swiftโ€Ž

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ public struct TDatePickerView: View {
1515
private let title: String
1616
/// ๋ฒ„ํŠผ ์‹คํ–‰ action
1717
private let buttonAction: (Date) -> Void
18+
/// ํ—ค๋” formatter
19+
private let monthFormatter: (Date) -> String
1820
/// ์„ ํƒ ๋‚ ์งœ
1921
@State private var selectedDate: Date = .now
22+
/// ํ‘œ์‹œ ๋‚ ์งœ
23+
@State private var currentDate: Date = .now
24+
25+
@Environment(\.dismiss) var dismiss
2026

2127
/// `TDatePickerView` ์ƒ์„ฑ์ž
2228
/// - Parameters:
@@ -26,33 +32,55 @@ public struct TDatePickerView: View {
2632
public init(
2733
selectedDate: Date = .now,
2834
title: String,
35+
monthFormatter: @escaping (Date) -> String,
2936
buttonAction: @escaping (Date) -> Void
3037
) {
3138
self.selectedDate = selectedDate
3239
self.title = title
40+
self.monthFormatter = monthFormatter
3341
self.buttonAction = buttonAction
3442
}
3543

3644
public var body: some View {
37-
VStack {
38-
DatePicker(
39-
title,
40-
selection: $selectedDate,
41-
displayedComponents: [.date]
45+
VStack(spacing: 12) {
46+
HStack {
47+
Text(title)
48+
.typographyStyle(.heading3, with: .neutral900)
49+
Spacer()
50+
Button(action: {
51+
dismiss()
52+
}, label: {
53+
Image(.icnDelete)
54+
.renderingMode(.template)
55+
.resizable()
56+
.tint(.neutral400)
57+
.frame(width: 32, height: 32)
58+
})
59+
}
60+
.padding(20)
61+
62+
TCalendarHeader<EmptyView>(
63+
currentPage: $currentDate,
64+
formatter: monthFormatter
65+
)
66+
.padding(.top, 20)
67+
68+
TCalendarView(
69+
selectedDate: $selectedDate,
70+
currentPage: $currentDate,
71+
mode: .compactMonth
4272
)
43-
.tint(Color.red500)
44-
.datePickerStyle(.graphical)
45-
.labelsHidden()
46-
.padding()
73+
.padding(.horizontal, 16)
4774

48-
TBottomButton(
49-
title: "์™„๋ฃŒ",
50-
isEnable: true,
75+
TButton(
76+
title: "ํ™•์ธ",
77+
config: .large,
78+
state: .default(.primary(isEnabled: true)),
5179
action: {
5280
buttonAction(selectedDate)
5381
}
5482
)
55-
.ignoresSafeArea(.all, edges: .bottom)
83+
.padding(20)
5684
}
5785
}
5886
}

0 commit comments

Comments
ย (0)