Skip to content

Commit

Permalink
Merge pull request #90 from YAPP-Github/TNT-254-commonQA
Browse files Browse the repository at this point in the history
[TNT-254] commonQA μ™„λ£Œ
  • Loading branch information
FpRaArNkK authored Feb 14, 2025
2 parents 6dd9995 + 4766ef8 commit d64f873
Show file tree
Hide file tree
Showing 37 changed files with 414 additions and 199 deletions.
12 changes: 6 additions & 6 deletions TnT/Projects/DesignSystem/Sources/Button/TBottomButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public struct TBottomButton: View {
}

public var body: some View {
Button(title) {
action()
Button(action: { action() }) {
Text(title)
.typographyStyle(.heading4, with: isEnable ? ButtonState.true.textColor : ButtonState.false.textColor)
.padding(.vertical, 20)
.frame(maxWidth: .infinity)
.background(isEnable ? ButtonState.true.background : ButtonState.false.background)
}
.typographyStyle(.heading4, with: isEnable ? ButtonState.true.textColor : ButtonState.false.textColor)
.padding(.vertical, 20)
.frame(maxWidth: .infinity)
.background(isEnable ? ButtonState.true.background : ButtonState.false.background)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import SwiftUI
/// - λ‚ μ§œ 선택할 수 μžˆλŠ” DatePicker View
public struct TDatePickerView: View {

/// μ»€μŠ€ν…€/μ‹œμŠ€ν…œ μΊ˜λ¦°λ” 선택
private let calendarType: CalendarType
/// picker 제λͺ©
private let title: String
/// λ²„νŠΌ μ‹€ν–‰ action
Expand All @@ -20,25 +22,29 @@ public struct TDatePickerView: View {
/// 선택 λ‚ μ§œ
@State private var selectedDate: Date = .now
/// ν‘œμ‹œ λ‚ μ§œ
@State private var currentDate: Date = .now
@State private var currentPageDate: Date = .now

@Environment(\.dismiss) var dismiss

/// `TDatePickerView` μƒμ„±μž
/// - Parameters:
/// - calendarType: μ‹œμŠ€ν…œ μΊ˜λ¦°λ” / μ»€μŠ€ν…€ μΊ˜λ¦°λ” 선택 (κΈ°λ³Έκ°’: μ»€μŠ€ν…€)
/// - selectedDate: 초기 선택 λ‚ μ§œ (κΈ°λ³Έκ°’: ν˜„μž¬ λ‚ μ§œ)
/// - title: DatePicker의 제λͺ©
/// - buttonAction: λ‚ μ§œ 선택 ν›„ μ‹€ν–‰ν•  μ•‘μ…˜
public init(
calendarType: CalendarType = .custom,
selectedDate: Date = .now,
title: String,
monthFormatter: @escaping (Date) -> String,
buttonAction: @escaping (Date) -> Void
) {
self.calendarType = calendarType
self.selectedDate = selectedDate
self.title = title
self.monthFormatter = monthFormatter
self.buttonAction = buttonAction
currentPageDate = selectedDate
}

public var body: some View {
Expand All @@ -59,28 +65,59 @@ public struct TDatePickerView: View {
}
.padding(20)

Calendar(calendarType)

TButton(
title: "확인",
config: .large,
state: .default(.primary(isEnabled: true)),
action: {
buttonAction(selectedDate)
}
)
.padding(20)
}
}

@ViewBuilder
private func Calendar(_ calendarType: CalendarType) -> some View {
switch calendarType {
case .custom:
TCalendarHeader<EmptyView>(
currentPage: $currentDate,
currentPage: $currentPageDate,
formatter: monthFormatter
)
.padding(.top, 20)

TCalendarView(
selectedDate: $selectedDate,
currentPage: $currentDate,
currentPage: $currentPageDate,
mode: .compactMonth
)
.padding(.horizontal, 16)

TButton(
title: "확인",
config: .large,
state: .default(.primary(isEnabled: true)),
action: {
buttonAction(selectedDate)
case let .system(range):
Group {
if let range {
DatePicker(title, selection: $selectedDate, in: range, displayedComponents: .date)
.datePickerStyle(GraphicalDatePickerStyle())
.environment(\.locale, Locale(identifier: "ko_KR"))

} else {
DatePicker(title, selection: $selectedDate, displayedComponents: .date)
.datePickerStyle(GraphicalDatePickerStyle())
.environment(\.locale, Locale(identifier: "ko_KR"))
}
)
.padding(20)
}
.tint(.red400)
.padding(.top, 20)
.padding(.horizontal, 16)
}
}
}

public extension TDatePickerView {
enum CalendarType {
case system(in: PartialRangeThrough<Date>? = nil)
case custom
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public struct ConnectedTraineeProfileEntity: Equatable, Sendable {
/// λ‚˜μ΄
public let age: Int?
/// ν‚€
public let height: Double
public let height: Double?
/// λͺΈλ¬΄κ²Œ
public let weight: Double
public let weight: Double?
/// PT λͺ©ν‘œ
public let ptGoal: String
/// 주의 사항
Expand All @@ -29,8 +29,8 @@ public struct ConnectedTraineeProfileEntity: Equatable, Sendable {
traineeName: String,
imageUrl: String,
age: Int?,
height: Double,
weight: Double,
height: Double?,
weight: Double?,
ptGoal: String,
cautionNote: String?
) {
Expand Down
6 changes: 4 additions & 2 deletions TnT/Projects/Domain/Sources/Mapper/TrainerMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import Foundation

public extension ConnectTraineeInfoDTO {
func toEntity() -> ConnectedTraineeProfileEntity {
let height = self.height == 0 ? nil : self.height
let weight = self.weight == 0 ? nil : self.weight
return .init(
traineeName: self.traineeName,
imageUrl: self.traineeProfileImageUrl,
age: self.age,
height: self.height,
weight: self.weight,
height: height,
weight: weight,
ptGoal: self.ptGoal,
cautionNote: self.cautionNote
)
Expand Down
6 changes: 3 additions & 3 deletions TnT/Projects/Domain/Sources/Policy/AppLinks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public enum AppLinks {
public static let termsOfService: String = "https://yapp25thteam.com/terms"
public static let privacyPolicy: String = "https://yapp25thteam.com/privacy"
public static let openSourceLicense: String = "https://yapp25thteam.com/license"
public static let termsOfService: String = "https://www.notion.so/f1ee7a43b6d941068723163fda127699?pvs=4"
public static let privacyPolicy: String = "https://www.notion.so/775bc037dd1b4e8ba56679e51a7321e5?pvs=4"
public static let openSourceLicense: String = "https://www.notion.so/197cabde9e4b800d8e8ec6c22d343b32?pvs=4"
}
8 changes: 4 additions & 4 deletions TnT/Projects/Domain/Sources/Policy/UserPolicy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ struct UserPolicy {
isRequired: false
)

/// ν‚€ μž…λ ₯ 검증 (μ •μˆ˜ 3자리, ν•„μˆ˜)
/// ν‚€ μž…λ ₯ 검증 (μ •μˆ˜ 3자리)
static let heightInput: PolicyInputInfo = .init(
textValidation: { TextValidator.isValidInput($0, maxLength: 3, regexPattern: #"^\d{3}$"#) },
isRequired: true
isRequired: false
)

/// λͺΈλ¬΄κ²Œ μž…λ ₯ 검증 (μ •μˆ˜ 3자리 + μ†Œμˆ˜μ  1자리, ν•„μˆ˜)
/// λͺΈλ¬΄κ²Œ μž…λ ₯ 검증 (μ •μˆ˜ 3자리 + μ†Œμˆ˜μ  1자리)
/// μ •μˆ˜ μ΅œμ†Œ 2자리 이상, μ†Œμˆ˜μ  1μžλ¦¬κΉŒμ§€λ§Œ
static let weightInput: PolicyInputInfo = .init(
textValidation: { TextValidator.isValidInput($0, maxLength: 5, regexPattern: #"^\d{2,3}(\.\d{1})?$"#) },
isRequired: true
isRequired: false
)

/// μ£Όμ˜μ‚¬ν•­ μ΅œλŒ€ 길이 μ œν•œ (곡백 포함)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public struct TraineeAddDietRecordView: View {
),
leftAction: { send(.tapNavBackButton) }
)
TDivider(color: .neutral200)

ScrollView {
VStack(alignment: .leading, spacing: 8) {
DietPhotoSection()
Expand All @@ -57,22 +59,24 @@ public struct TraineeAddDietRecordView: View {
.onTapGesture { focusedField = nil }
.navigationBarBackButtonHidden()
.keyboardDismissOnTap()
.safeAreaInset(edge: .bottom) {
if store.view_focusField == nil {
TButton(
title: "μ €μž₯",
config: .xLarge,
state: .default(.primary(isEnabled: store.view_isSubmitButtonEnabled))
) {
send(.tapSubmitButton)
}
.padding(.horizontal, 16)
.bottomFixWith {
TButton(
title: "μ €μž₯",
config: .xLarge,
state: .default(.primary(isEnabled: store.view_isSubmitButtonEnabled))
) {
send(.tapSubmitButton)
}
.padding(.bottom, .safeAreaBottom)
.disabled(!store.view_isSubmitButtonEnabled)
.debounce()
.padding(.horizontal, 16)
}
.sheet(item: $store.view_bottomSheetItem) { item in
switch item {
case .datePicker(let field):
TDatePickerView(
selectedDate: store.dietDate ?? .now,
title: field.title,
monthFormatter: { TDateFormatUtility.formatter(for: .yyyyλ…„_MMμ›”).string(from: $0) },
buttonAction: {
Expand All @@ -82,9 +86,9 @@ public struct TraineeAddDietRecordView: View {
.autoSizingBottomSheet(presentationDragIndicator: .hidden)
case .timePicker(let field):
TTimePickerView(
selectedTime: store.dietDate ?? .now,
selectedTime: store.dietTime ?? .now,
title: field.title,
minuteStep: 10,
minuteStep: 1,
buttonAction: {
send(.tapBottomSheetSubmitButton(field, $0))
}
Expand Down Expand Up @@ -163,7 +167,7 @@ public struct TraineeAddDietRecordView: View {
@ViewBuilder
private func DietDateSection() -> some View {
TTextField(
placeholder: "2025/11/19",
placeholder: Date().toString(format: .yyyyMMddSlash),
text: Binding(get: {
store.dietDate?.toString(format: .yyyyMMddSlash) ?? ""
}, set: { _ in }),
Expand All @@ -185,7 +189,7 @@ public struct TraineeAddDietRecordView: View {
@ViewBuilder
private func DietTimeSection() -> some View {
TTextField(
placeholder: "09:00",
placeholder: Date().toString(format: .HHmm),
text: Binding(get: {
store.dietTime?.toString(format: .HHmm) ?? ""
}, set: { _ in }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public struct TrainerAddPTSessionView: View {
leftAction: { send(.tapNavBackButton) }
)
TDivider(height: 1, color: .neutral200)

ScrollView {
VStack(alignment: .leading, spacing: 0) {
Header()
Expand All @@ -62,19 +63,20 @@ public struct TrainerAddPTSessionView: View {
.padding(.bottom, .safeAreaBottom + 20)
}
}
.bottomFixWith {
TBottomButton(
title: "μ™„λ£Œ",
isEnable: store.view_isSubmitButtonEnabled
) {
send(.tapSubmitButton)
}
.padding(.bottom, .safeAreaBottom)
.disabled(!store.view_isSubmitButtonEnabled)
.debounce()
}
.onTapGesture { focusedField = nil }
.navigationBarBackButtonHidden()
.keyboardDismissOnTap()
.safeAreaInset(edge: .bottom) {
if store.view_focusField == nil {
TBottomButton(
title: "μ™„λ£Œ",
isEnable: store.view_isSubmitButtonEnabled
) {
send(.tapSubmitButton)
}
}
}
.sheet(item: $store.view_bottomSheetItem) { item in
switch item {
case .traineeList:
Expand All @@ -86,6 +88,7 @@ public struct TrainerAddPTSessionView: View {
)
case .datePicker(let field):
TDatePickerView(
selectedDate: store.ptDate ?? .now,
title: field.title,
monthFormatter: { TDateFormatUtility.formatter(for: .yyyyλ…„_MMμ›”).string(from: $0) },
buttonAction: {
Expand Down Expand Up @@ -196,7 +199,7 @@ public struct TrainerAddPTSessionView: View {
HStack(alignment: .bottom, spacing: 12) {
// StartTime
TTextField(
placeholder: "09:00",
placeholder: Date().toString(format: .HHmm),
text: Binding(get: {
store.startTime?.toString(format: .HHmm) ?? ""
}, set: { _ in }),
Expand Down Expand Up @@ -227,7 +230,7 @@ public struct TrainerAddPTSessionView: View {

// EndTime
TTextField(
placeholder: "10:00",
placeholder: Date().addingTimeInterval(3600).toString(format: .HHmm),
text: Binding(get: {
store.endTime?.toString(format: .HHmm) ?? ""
}, set: { _ in }),
Expand Down
3 changes: 2 additions & 1 deletion TnT/Projects/Presentation/Sources/Alarm/AlarmCheckView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ComposableArchitecture
import Domain
import DesignSystem

/// μ•ŒλžŒ λͺ©λ‘μ„ μž…λ ₯ν•˜λŠ” ν™”λ©΄
/// μ•ŒλžŒ λͺ©λ‘μ„ ν™•μΈν•˜λŠ” ν™”λ©΄
/// μœ μ €μ—κ²Œ λ„μ°©ν•œ μ•ŒλžŒμ„ ν‘œμ‹œ - μœ μ € νƒ€μž…μ— 따라 λΆ„λ₯˜
@ViewAction(for: AlarmCheckFeature.self)
public struct AlarmCheckView: View {
Expand All @@ -30,6 +30,7 @@ public struct AlarmCheckView: View {
type: .LButtonWithTitle(leftImage: .icnArrowLeft, centerTitle: "μ•Œλ¦Ό"),
leftAction: { send(.tapNavBackButton) }
)
TDivider(color: .neutral200)

ScrollView(showsIndicators: false) {
AlarmList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public struct OnboardingFlowFeature {

/// νŠΈλ ˆμ΄λ‹ˆ νšŒμ›κ°€μž… μ™„λ£Œ ν™”λ©΄ -> νŠΈλ ˆμ΄λ„ˆ μ΄ˆλŒ€μ½”λ“œ μž…λ ₯ ν™”λ©΄ 이동
case .element(id: _, action: .traineeProfileCompletion(.setNavigating)):
state.path.append(.traineeInvitationCodeInput(.init(view_popUp: .invitePopUp, view_isPopupPresented: true)))
state.path.append(.traineeInvitationCodeInput(.init()))
return .none

/// νŠΈλ ˆμ΄λ‹ˆ μ΄ˆλŒ€μ½”λ“œ μž…λ ₯ ν™”λ©΄ -> νŠΈλ ˆμ΄λ‹ˆ ν™ˆν™”λ©΄/PT 정보 μž…λ ₯ ν™”λ©΄
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ public struct TraineeMainFlowFeature {

/// 식단 기둝 ν™”λ©΄ 등둝 -> ν™ˆν™”λ©΄μœΌλ‘œ 이동
case .element(id: _, action: .addDietRecordPage(.setNavigating)):
state.path.removeLast()
state.path.removeSubrange(1...)
return .none

/// λ§ˆμ΄νŽ˜μ΄μ§€ μ΄ˆλŒ€μ½”λ“œ μž…λ ₯ν™”λ©΄ λ‹€μŒ λ²„νŠΌ νƒ­ - > PT 정보 μž…λ ₯ ν™”λ©΄ or ν™ˆ 이동
case .element(_, action: .traineeInvitationCodeInput(.setNavigating(let screen))):
switch screen {
case .traineeHome:
state.path.removeLast()
state.path.removeSubrange(1...)
case let .trainingInfoInput(trainerName, invitationCode):
state.path.append(.traineeTrainingInfoInput(.init(trainerName: trainerName, invitationCode: invitationCode)))
}
Expand All @@ -119,7 +119,7 @@ public struct TraineeMainFlowFeature {

/// μ—°κ²° μ™„λ£Œ ν™”λ©΄ -> ν™ˆμœΌλ‘œ 이동
case .element(id: _, action: .traineeConnectionComplete(.setNavigating)):
state.path.removeLast(2)
state.path.removeSubrange(1...)
return .none

default:
Expand Down
Loading

0 comments on commit d64f873

Please sign in to comment.