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] Domain - UserUseCase 관련 로직 작성 #35

Merged
merged 22 commits into from
Jan 26, 2025

Conversation

FpRaArNkK
Copy link
Contributor

📌 What is the PR?

원활한 PR 리뷰를 위해 내용을 분리했습니다.

Domain단의 UserUseCase를 작성하고, 이에 필요한 코드들을 작성했습니다.

🪄 Changes

  • User관련 Entity, Policy 작성
  • TDateFormatUtility 작성
  • TextValidator 작성
  • UserUseCase 작성

🌐 Common Changes

  • 디자인 시스템 관련 TTextEditor UI 수정
  • KeyboardDismiss 유틸리티 추가

🔥 PR Point

  1. TDateFormatUtility를 작성했습니다. Notion 개발 문서 관련 트러블 슈팅
    초기화 비용이 큰 DateFormatter의 특성 + 서비스에서 날짜를 빈번하게 사용하는 특성을 고려하여,
    DateFormatter를 특정 Format 별로 캐싱하고 이를 재사용할 수 있게 했습니다.
    사용법은 다음과 같습니다.
// Utility에서 직접 사용
TDateFormatUtility.formatter(.yyyyMMddSlash).date(from: "2000/01/01")
TDateFormatUtility.formatter(.yyyyMMddSlash).string(from: someDate)

// Date/String Extension에서 간편하게 사용
let date = Date()
date.toString(format: .yyyyMMddSlash)
let str = "2000/01/01"
str.toDate(format: .yyyyMMddSlash)
  1. TextValidator를 작성했습니다.
    String이 검증이 필요한 경우 - regex를 통한 경우와 dateFormat을 통한 경우를 고려하여 각 케이스를 포함한 validator를 작성했습니다.
    사용법은 다음과 같습니다.
TextValidator.isValidDate(text: "2000/01/01", format: .yyyyMMddSlash)
TextValidator.isValidInput("200", maxLength: 3, regexPattern: #"^\d{3}$"#)
  1. UserUseCase를 작성했습니다. 관련 트러블 슈팅
    Domain <-> Presentation 레이어간 비즈니스 로직 인터페이스의 역할을 담당하며, Swift-Dependencies 등록을 통해 Reducer에 쉽게 주입이 가능합니다.
    사용법은 다음과 같습니다.
// Reducer 내부 선언, 사용
@Dependency(\.userUseCase) private var userUseCase: UserUseCase
userUseCase.validateUserName("name")

🙆🏻 To Reviewers

  • 전체적으로 구조를 다시 잡느라 PR 분리도 어색하고, 많이 난잡합니다 죄송합니다 ㅠㅠ

💭 Related Issues

@FpRaArNkK FpRaArNkK added the ✨Feat 새로운 기능 구현 (새로운 로직 추가, UI 구현 등) label Jan 25, 2025
@FpRaArNkK FpRaArNkK self-assigned this Jan 25, 2025
Copy link
Member

@syss220211 syss220211 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

Comment on lines +12 to +39
struct KeyboardDismissModifier: ViewModifier {
var dismissOnDrag: Bool = true

func body(content: Content) -> some View {
content
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.clear)
.onTapGesture {
dismissKeyboard()
}
.simultaneousGesture(
dismissOnDrag ? DragGesture().onChanged { _ in dismissKeyboard() } : nil
)
}

/// Modifier 내부에서 직접 키보드 내리는 함수
private func dismissKeyboard() {
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene else { return }
windowScene.windows.forEach { $0.endEditing(true) }
}
}

/// `View`에 `.keyboardDismissOnTap()`을 추가할 수 있도록 Extension
extension View {
func keyboardDismissOnTap(dismissOnDrag: Bool = true) -> some View {
self.modifier(KeyboardDismissModifier(dismissOnDrag: dismissOnDrag))
}
}
Copy link
Member

Choose a reason for hiding this comment

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

오호 이거 UIKit에서 firstResponse 대신에 이런 방법이 있는건가요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

넵 이 친구도 되는데 생각해보니 firstResponseResign도 있었네요
이 방법은 해당 화면의 모든 작성 상태를 끝내는 방식인데 추후 수정해야할 수도 있을 것 같습니다!

@FpRaArNkK FpRaArNkK merged commit 834cd79 into develop Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨Feat 새로운 기능 구현 (새로운 로직 추가, UI 구현 등)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants