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

[TNT-142] 트레이너/트레이니 선택 화면, 프로필 만들기 화면 작성 #24

Merged
merged 16 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 9 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"images" : [
{
"filename" : "img_default_profile_image.png",
"filename" : "basic profile_trainee.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "img_default_profile_image@2x.png",
"filename" : "basic profile_trainee@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "img_default_profile_image@3x.png",
"filename" : "basic profile_trainee@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@
{
"images" : [
{
"filename" : "basic profile_trainer.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "basic [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "basic [email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Expand Up @@ -20,6 +20,8 @@ public struct TTextField: View {
@Binding private var text: String
/// 텍스트 필드 상태
@Binding private var status: Status
/// 텍스트 컬러 상태
@State private var textColor: Color = .neutral400
/// 텍스트 필드 포커스 상태
@FocusState var isFocused: Bool

Expand Down Expand Up @@ -51,9 +53,12 @@ public struct TTextField: View {
.lineSpacing(Typography.FontStyle.body1Medium.lineSpacing)
.kerning(Typography.FontStyle.body1Medium.letterSpacing)
.tint(Color.neutral800)
.foregroundStyle(status.textColor)
.foregroundStyle(textColor)
.padding(8)
.frame(height: 42)
.onChange(of: status) {
textColor = status.textColor(isFocused: isFocused)
}

if let rightView {
rightView
Expand All @@ -66,7 +71,6 @@ public struct TTextField: View {
}

public extension TTextField.RightView {
///
enum Style {
case unit(text: String, status: TTextField.Status)
case button(title: String, tapAction: () -> Void)
Expand All @@ -88,7 +92,7 @@ public extension TTextField {
switch style {
case let .unit(text, status):
Text(text)
.typographyStyle(.body1Medium, with: status.textColor)
.typographyStyle(.body1Medium, with: status.textColor(isFocused: true))
.padding(.horizontal, 12)
.padding(.vertical, 3)

Expand All @@ -115,19 +119,19 @@ public extension TTextField {
private let title: String
/// 입력 가능한 글자 수 제한
private let limitCount: Int?
/// 입력된 텍스트
@Binding private var text: String
/// 입력된 텍스트 카운트
private var textCount: Int?

public init(
isRequired: Bool,
title: String,
limitCount: Int?,
text: Binding<String>
textCount: Int?
) {
self.isRequired = isRequired
self.title = title
self.limitCount = limitCount
self._text = text
self.textCount = textCount
}

public var body: some View {
Expand All @@ -141,9 +145,9 @@ public extension TTextField {

Spacer()

if let limitCount {
Text("\(text.count)/\(limitCount)자")
.typographyStyle(.label1Medium, with: .neutral400)
if let limitCount, let textCount {
Text("\(textCount)/\(limitCount)자")
.typographyStyle(.label1Medium, with: textCount > limitCount ? .red500 : .neutral400)
.padding(.horizontal, 4)
.padding(.vertical, 2)
}
Expand All @@ -156,11 +160,11 @@ public extension TTextField {
/// 푸터 텍스트
private let footerText: String
/// 텍스트 필드 상태
@Binding private var status: Status
private var status: Status

public init(footerText: String, status: Binding<Status>) {
public init(footerText: String, status: Status) {
self.footerText = footerText
self._status = status
self.status = status
}

public var body: some View {
Expand All @@ -172,7 +176,7 @@ public extension TTextField {

public extension TTextField {
/// TextField에 표시되는 상태입니다
enum Status {
enum Status: Equatable {
case empty
case filled
case invalid
Expand All @@ -181,9 +185,7 @@ public extension TTextField {
/// 밑선 색상 설정
func underlineColor(isFocused: Bool) -> Color {
switch self {
case .empty:
return isFocused ? .neutral600 : .neutral200
case .filled:
case .empty, .filled:
return isFocused ? .neutral600 : .neutral200
case .invalid:
return .red500
Expand All @@ -193,7 +195,7 @@ public extension TTextField {
}

/// 텍스트 색상 설정
var textColor: Color {
func textColor(isFocused: Bool) -> Color {
switch self {
case .empty:
return .neutral400
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public extension ImageResource {
// MARK: Image
public extension ImageResource {
static let imgAppSplash: ImageResource = DesignSystemAsset.imgAppSplash.imageResource
static let imgDefaultProfileImage: ImageResource = DesignSystemAsset.imgDefaultProfileImage.imageResource
static let imgDefaultTraineeImage: ImageResource = DesignSystemAsset.imgDefaultTraineeImage.imageResource
static let imgDefaultTrainerImage: ImageResource = DesignSystemAsset.imgDefaultTrainerImage.imageResource
static let imgOnboardingLogin: ImageResource = DesignSystemAsset.imgOnboardingLogin.imageResource
static let imgOnboardingTrainee: ImageResource = DesignSystemAsset.imgOnboardingTrainee.imageResource
static let imgOnboardingTrainer: ImageResource = DesignSystemAsset.imgOnboardingTrainer.imageResource
Expand Down
21 changes: 21 additions & 0 deletions TnT/Projects/Domain/Sources/Entity/UserType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// UserType.swift
// Domain
//
// Created by 박민서 on 1/17/25.
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
//

public enum UserType {
case trainer
case trainee

public var koreanName: String {
switch self {
case .trainer:
return "트레이너"
case .trainee:
return "트레이니"
}
}
}
15 changes: 15 additions & 0 deletions TnT/Projects/Domain/Sources/Policy/UserPolicy.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// UserPolicy.swift
// Domain
//
// Created by 박민서 on 1/17/25.
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
//

public struct UserPolicy {
/// 사용자 이름 최대 길이 제한 (공백 포함)
public static let maxNameLength: Int = 15

/// 사용자 이름 가능 문자: 한글/영어/공백만 허용 (특수문자 불가)
public static let allowedCharactersRegex = "^[ㄱ-ㅎㅏ-ㅣ가-힣a-zA-Z ]*$"
}
Comment on lines +9 to +15
Copy link
Member

Choose a reason for hiding this comment

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

구조체로 만드신 이유가 궁금합니다!

Copy link
Contributor Author

@FpRaArNkK FpRaArNkK Jan 18, 2025

Choose a reason for hiding this comment

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

정책 관련 특정 값들을 저장해놓는 것을 요구 사항으로 생각하고, enun과 struct 중에 고민했었습니다.

  1. enum의 경우애는 enum-case + 연관값으로 각 케이스에 해당하는 함수 결과값을 끌어오거나, 필요한 경우 해당 내용을 가져오는 방향으로 생각했습니다.
  2. struct의 경우에는 본 코드와 같이 static으로 선언한 해당 내용을 바로 끌어오고, 필요한 경우 해당 케이스의 함수 결과값을 가져오는 방향으로 생각했습니다.

추후 추가/수정 시에도 - 정책 내부에 별도의 구조체를 갖거나, 중첩 타입이 있을 경우 enum보다는 struct가 더 자연스럽지 않을까
.. 싶은 이유에서 struct로 작성했습니다!

31 changes: 31 additions & 0 deletions TnT/Projects/Domain/Sources/Utility/TextValidator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// TextValidator.swift
// Domain
//
// Created by 박민서 on 1/17/25.
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
//

import Foundation

public enum TextValidator {
/// 사용자가 입력할 때 즉각적인 유효성 검사를 수행하는 함수
/// - Parameters:
/// - text: 검증할 문자열
/// - maxLength: 최대 입력 가능 길이
/// - regexPattern: 허용할 문자에 대한 정규식
/// - Returns: 입력이 유효한지 여부 (`true` = 허용, `false` = 입력 불가)
public static func isValidInput(
_ text: String,
maxLength: Int,
regexPattern: String
) -> Bool {
guard text.count <= maxLength,
let regex = try? NSRegularExpression(pattern: regexPattern) else {
return false
}

let range: NSRange = .init(location: 0, length: text.utf16.count)
return regex.firstMatch(in: text, options: [], range: range) != nil
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// CreateProfileFeature.swift
// Presentation
//
// Created by 박민서 on 1/17/25.
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
//

import Foundation
Copy link
Member

Choose a reason for hiding this comment

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

얘 파일이름 똑같은애가 2개가 있는데 컴파일러가 안잡아줬나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

엇.. 브랜치를 바꾸면서 작업하다보니 놓쳤던 것 같습니다..! 수정하겠습니다 감사합니다!

Loading