diff --git a/Cherrish-iOS/Cherrish-iOS/Presentation/Global/Components/CherrishTextBox/CherrishTextBox.swift b/Cherrish-iOS/Cherrish-iOS/Presentation/Global/Components/CherrishTextBox/CherrishTextBox.swift new file mode 100644 index 00000000..a1ac9ed5 --- /dev/null +++ b/Cherrish-iOS/Cherrish-iOS/Presentation/Global/Components/CherrishTextBox/CherrishTextBox.swift @@ -0,0 +1,26 @@ +// +// AgeTextBox.swift +// Cherrish-iOS +// +// Created by 어재선 on 1/13/26. +// + +import SwiftUI + +struct CherrishTextBox: View { + var title: String + @Binding var text: String + let placeholder: String + + var body: some View { + VStack(spacing: 0) { + HStack(spacing: 0) { + TypographyText(title, style: .body1_sb_14,color: .gray1000) + Spacer() + } + Spacer() + .frame(height: 8.adjustedH) + CherrishTextField(text: $text, style: .plain(placeholder: placeholder)) + } + } +} diff --git a/Cherrish-iOS/Cherrish-iOS/Presentation/Global/Components/CherrishTextBox/DateTextBox.swift b/Cherrish-iOS/Cherrish-iOS/Presentation/Global/Components/CherrishTextBox/DateTextBox.swift new file mode 100644 index 00000000..d30222c6 --- /dev/null +++ b/Cherrish-iOS/Cherrish-iOS/Presentation/Global/Components/CherrishTextBox/DateTextBox.swift @@ -0,0 +1,49 @@ +// +// DateTextBox.swift +// Cherrish-iOS +// +// Created by 어재선 on 1/13/26. +// + +import SwiftUI + +struct DateTextBox: View { + @Binding var year: String + @Binding var month: String + @Binding var day: String + + var body: some View { + VStack(spacing: 8) { + HStack(spacing: 0) { + TypographyText("날짜", style: .body1_sb_14, color: .gray1000) + Spacer() + } + HStack{ + DateLabel(text: $year, placeholderStyle: .year) + DateLabel(text: $month, placeholderStyle: .month) + DateLabel(text: $day, placeholderStyle: .day) + } + } + } +} + +private struct DateLabel: View { + @Binding var text: String + let placeholderStyle: DateTextFieldStyle + var body: some View { + HStack { + CherrishTextField( + text: $text, + style: .date( + placeholder: placeholderStyle + ) + ) + TypographyText( + placeholderStyle.kr, + style: .title2_m_16, + color: .gray700 + ) + } + } +} + diff --git a/Cherrish-iOS/Cherrish-iOS/Presentation/Global/Components/CherrishTextField/CherrishTextField.swift b/Cherrish-iOS/Cherrish-iOS/Presentation/Global/Components/CherrishTextField/CherrishTextField.swift new file mode 100644 index 00000000..0608a8c9 --- /dev/null +++ b/Cherrish-iOS/Cherrish-iOS/Presentation/Global/Components/CherrishTextField/CherrishTextField.swift @@ -0,0 +1,160 @@ +// +// AgeTextField.swift +// Cherrish-iOS +// +// Created by 어재선 on 1/13/26. +// + +import SwiftUI + +enum CherrishTextFieldStyle { + + case plain(placeholder: String) + case date(placeholder: DateTextFieldStyle) + + var placeholder: String { + switch self { + case .plain(placeholder: let placeholder): + return placeholder + case .date(placeholder: let placeholder): + return placeholder.rawValue + } + } + + var placeholderFont: Typography { + switch self { + case .plain: + return .body1_r_14 + case .date: + return .title2_r_16 + } + } + + var placeholderColor: Color { + switch self { + case .plain: + return .gray600 + case .date: + return .gray500 + } + } + + var textFont: Typography { + switch self { + case .plain: + return .body1_m_14 + case .date: + return .title2_m_16 + } + } + + var textColor: Color { + switch self { + default: + return .gray1000 + } + } + + var fontHeight: CGFloat { + switch self { + default: + return 24.adjustedH + } + } + + var horizontalPadding: CGFloat { + switch self { + case .plain: + return 16.adjustedW + case .date: + return 18.5.adjustedW + } + } + + var verticalPadding: CGFloat { + switch self { + case .plain: + return 10.adjustedH + case .date: + return 8.adjustedH + } + } + + var backgroundStrokeColor: Color { + switch self { + default: + return .gray500 + } + } + + var textAlinement: TextAlignment { + switch self { + case .plain: + return .leading + case .date: + return .center + } + } +} + +enum DateTextFieldStyle: String { + case year = "YYYY" + case month = "MM" + case day = "DD" + + var kr: String { + switch self { + case .year: + "년" + case .month: + "월" + case .day: + "일" + } + } +} + + +struct CherrishTextField: View { + @Binding var text: String + let style: CherrishTextFieldStyle + var body: some View { + + HStack(spacing: 0){ + ZStack { + if text.isEmpty { + HStack{ + switch style { + case .plain: + EmptyView() + case .date: + Spacer() + } + TypographyText( + style.placeholder, + style: style.placeholderFont , + color: style.placeholderColor + ) + Spacer() + } + } + TextField("" ,text: $text) + .foregroundStyle(style.textColor) + .multilineTextAlignment(style.textAlinement) + .keyboardType(.numberPad) + .typography(style.textFont) + .tint(style.textColor) + } + .frame(height: style.fontHeight) + } + .padding(.horizontal, style.horizontalPadding) + .padding(.vertical, style.verticalPadding) + .background { + RoundedRectangle(cornerRadius: 10) + .stroke(style.backgroundStrokeColor, lineWidth: 1) + } + .frame(height: 44) + } +} + +