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

[#255] YDSLabel SwiftUI로 리팩토링 #261

Merged
merged 5 commits into from
Jan 26, 2024
Merged

[#255] YDSLabel SwiftUI로 리팩토링 #261

merged 5 commits into from
Jan 26, 2024

Conversation

iiuoon
Copy link
Member

@iiuoon iiuoon commented Jan 15, 2024

📌 Summary

  1. 기존 UIKit 요소들을 없애고 SwiftUI에 정의된 속성 중 최대한 유사한 속성으로 교체해주었습니다.
  • numberOfLines -> lineLimits
  • textAlignment -> multilineTextAlignment
  • lineBreakMode, lineBreakStrategy -> truncationMode, allowsTightening
  1. 모든 속성을 설정하지 않고도 원하는 속성만 골라 적용할 수 있습니다.
  • 설정하지 않은 속성은 기본값으로 적용됩니다.
  1. UIKit에서의 numberOfLines = 0은 SwiftUI에서의 lineLimits = nil과 같아
    lineLimits의 기본값을 nil로 설정하기 위해 IntOptionViewOptionalIntOptionView로 수정하였습니다.
  2. StorybookPageView의 backgroundColor를 기존 스토리북과 동일하게 변경하였습니다.
  3. OptionalStringOptionView의 toggle이 false일 때의 placeholder의 색상(foregroundColor)을 변경하였습니다.

✍️ Description

💡 PR Point

📚 Reference

🔥 Test

Simulator Screen Recording - iPhone 15 Pro - 2024-01-16 at 03.56.30.mp4.zip

@iiuoon iiuoon added fix 🛠 버그, 오류 해결 refactor😊 리팩토링 labels Jan 15, 2024
@iiuoon iiuoon self-assigned this Jan 15, 2024
}
var selectedTruncationMode: Text.TruncationMode {
return Text.TruncationMode.allCases[truncationModeSelectedIndex]
}

public var body: some View {
StorybookPageView(sample: {
VStack {
Copy link
Contributor

Choose a reason for hiding this comment

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

VStack은 없어도 될 것 같아요

Copy link
Member Author

@iiuoon iiuoon Jan 16, 2024

Choose a reason for hiding this comment

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

없애면 string 숨기기 했을 때 텍스트를 담은 뷰가 아예 사라집니다

Copy link
Contributor

Choose a reason for hiding this comment

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

그렇군요~

struct IntOptionView: View {
struct OptionalIntOptionView: View {
Copy link
Contributor

Choose a reason for hiding this comment

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

나중에 optional값이 아닌 Int를 받는 경우가 생길 수도 있으니 기존 IntOptionView는 놔두고 새로 추가하는 것은 어떤가요?

Copy link
Member Author

@iiuoon iiuoon Jan 16, 2024

Choose a reason for hiding this comment

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

원래 그러려고도 했는데 사용할 때 추가하는 편이 나을 것 같아 일단 뺐습니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

굿굿굿

lineBreakStrategy: NSParagraphStyle.LineBreakStrategy = .hangulWordPriority) {
public struct YDSLabel: View {
let text: String?
let style: Font
Copy link
Contributor

Choose a reason for hiding this comment

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

style이라는 이름은 오해의 소지가 있어 보입니다. 다른 이름을 생각해주세요~

Copy link
Member Author

Choose a reason for hiding this comment

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

네이밍은 기존 YDS를 참고했습니다~

Copy link
Contributor

Choose a reason for hiding this comment

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

저도 처음에 style로 했었는데 style이 무슨 스타일을 의미하는지 제대로 네이밍 하는게 좋을 것 같다는 의견이 있어서 알려드렸어요!!

@State var typoStyleSelectedIndex = 0
@State var lineLimit: Int? = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

옵셔널로 선언하면 nil로 초기화를 안해줘도 될 것 같아요
SwiftLint에서도 경고를 띄우네요

Suggested change
@State var lineLimit: Int? = nil
@State var lineLimit: Int?

Copy link
Member Author

Choose a reason for hiding this comment

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

넵 반영하겠습니다!

@iiuoon iiuoon removed the fix 🛠 버그, 오류 해결 label Jan 22, 2024
@iiuoon iiuoon merged commit 49bb022 into main Jan 26, 2024
@iiuoon iiuoon deleted the fix/#250 branch January 26, 2024 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor😊 리팩토링
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants