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

πŸ”€ :: DesignSystem SMSSelectionControls μ œμž‘ #37

Merged
merged 17 commits into from
May 22, 2023

Conversation

kimsh153
Copy link
Member

@kimsh153 kimsh153 commented May 9, 2023

πŸ’‘ κ°œμš”

DesignSystem SMSSelectionControls μ œμž‘

πŸ“ƒ μž‘μ—…λ‚΄μš©

DesignSystem SMSSelectionControls μ œμž‘

2023-05-09.7.49.54.mov

@kimsh153 kimsh153 added 1️⃣ Priority: High μš°μ„ μˆœμœ„ - 상 βš™ Setting ν™˜κ²½ μ„ΈνŒ… labels May 9, 2023
@kimsh153 kimsh153 self-assigned this May 9, 2023
@kimsh153 kimsh153 linked an issue May 9, 2023 that may be closed by this pull request
@kimsh153 kimsh153 requested a review from baekteun May 9, 2023 11:12
@baekteun
Copy link
Member

baekteun commented May 9, 2023

...()
  .radioTag(0)

μ΄λŸ°μ‹μœΌλ‘œ TabView같은 λ°©μ‹μœΌλ‘œ Selection Controls μ‚¬μš©ν•  수 있게 ν•˜λŠ”κ±° μ–΄λ•Œμš”?

}
}

private struct CustomButtonStyle: ButtonStyle {
Copy link
Member

Choose a reason for hiding this comment

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

private이긴 ν•˜μ§€λ§Œ CustomButotnStyle보닀 더 직관적인 이름은 μ—†μ„κΉŒμš”?

Copy link
Member Author

Choose a reason for hiding this comment

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

SMSelectionControlsStyle둜 μˆ˜μ •ν• κΉŒμš”?

Copy link
Member

Choose a reason for hiding this comment

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

μ΄κ±°λŠ” νŠΉμ • SelectionControl κ·Έ μžμ²΄λ³΄λ‹€λŠ” SelectionControl이 λˆŒλ Έμ„ λ•Œ gray색이 μƒκΈ°λŠ” styleμ•„λ‹Œκ°€μš”? μ’€ λ‹€λ₯Έ 이름은 μ—†λ‚˜μš”?

Comment on lines 14 to 29
extension RadioComponent where T: Hashable, Content: View {
public init(
selection: Binding<T?>,
@ViewBuilder _ content: @escaping () -> Content
) {
self.value = RadioValue(selection: selection)
self.content = content
}

public init(
selection: Binding<T?>,
@ViewBuilder _ content: @escaping () -> Content,
onTapReceive: ((T?) -> Void)?
) {
self.value = RadioValue(selection: selection, onTapReceive: onTapReceive)
self.content = content
Copy link
Member

Choose a reason for hiding this comment

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

바인딩이 μ™œ λ‹€ Optional둜 λž˜ν•‘λ˜μ–΄ μžˆλ‚˜μš”?

Copy link
Member Author

Choose a reason for hiding this comment

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

selection이 μ„ νƒλ˜μ§€ μ•Šμ„ κ²½μš°λ„ μžˆλ‹€κ³  μƒκ°ν•˜μ—¬ Optional 처리λ₯Ό ν•˜μ˜€μŠ΅λ‹ˆλ‹€.

Copy link
Member

Choose a reason for hiding this comment

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

μ„ νƒλ˜μ§€ μ•Šμ€ κ²½μš°λŠ” value.selectionκ³Ό λ‹€λ₯Έ 경우 μ•„λ‹Œκ°€μš”?

Copy link
Member Author

Choose a reason for hiding this comment

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

value.seletion은 Tagλ₯Ό μœ„ν•΄ μ‘΄μž¬ν•˜κ³  Binding<T?>은 아무것도 선택을 ν•˜μ§€ μ•Šμ€ μƒνƒœλ₯Ό μœ„ν•΄ λ§Œλ“ κ²ƒμž…λ‹ˆλ‹€.

Comment on lines 13 to 17
HStack {
SMSSelectionControls(tag: index)
Text("asdfasdf")
}
.radioTag(index)
Copy link
Member

Choose a reason for hiding this comment

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

근데 이거 .radioTagκ°€

Button {
             value.selection = tag
             value.onTapReceive?(tag)
         } label: {
             content
         }
         .buttonStyle(.plain)

이거둜 감싸고 SMSSelectionControls νƒœκ·Έλ„

 Button {
             value.selection = tag
             value.onTapReceive?(tag)
         } label: {
             ZStack {
                 Circle()
                     .stroke(tag == value.selection ? Color.sms(.primary(.p2)) : Color.sms(.neutral(.n20)), lineWidth: 2)
                     .frame(width: 20, height: 20)

                 Circle()
                     .fill(tag == value.selection ? Color.sms(.primary(.p2)) : .clear)
                     .frame(width: 12, height: 12)
             }
         }
         .buttonStyle(CustomButtonStyle(isOn: tag == value.selection))

μ΄λ ‡κ²Œ κ°μ‹Έλ†“λŠ”κ±°λ©΄ μ—„ λ―Έλ¬˜ν•˜μ§€ μ•Šμ•„μš”?

Copy link
Member Author

Choose a reason for hiding this comment

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

κ·Έ λ””μžμ΄λ„ˆλΆ„μ΄ λ§μ”€ν•˜μ‹ κ±Έλ‘œλŠ” λ²„νŠΌλ§Œ λˆŒλŸ¬μ Έμ•Όν•œλ‹€κ³  ν•˜μ‹œκΈΈλž˜ μš”μ²­μ‚¬ν•­λŒ€λ‘œ μˆ˜μ •ν–ˆμŠ΅λ‹ˆλ‹€

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
Member Author

Choose a reason for hiding this comment

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

λ„€.

Copy link
Member

Choose a reason for hiding this comment

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

μ§€κΈˆλ„ textλž‘ 같이 λˆŒλ¦¬λŠ”λ°μš”?

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
Member Author

Choose a reason for hiding this comment

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

쩝 죄솑함닀


public init(
selection: Binding<T?>,
@ViewBuilder _ content: @escaping () -> Content,
Copy link
Member

Choose a reason for hiding this comment

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

content 이 친ꡬ label이 μ™œ _ 인거죠?

}
}

class RadioValue<T: Hashable>: ObservableObject {
Copy link
Member

Choose a reason for hiding this comment

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

상속할 여지가 μ—†μœΌλ‹ˆ final둜 μ²˜λ¦¬ν•˜λŠ”κ²Œ 쒋지 μ•Šμ„κΉŒμš”?

Comment on lines 48 to 65
public struct RadioTag<T: Hashable>: ViewModifier {
@EnvironmentObject private var value: RadioValue<T>
private var tag: T?

init(_ tag: T?) {
self.tag = tag
}

public func body(content: Content) -> some View {
content
}
}

extension View {
public func radioTag<T: Hashable>(_ tag: T?) -> some View {
self.modifier(RadioTag(tag))
}
}
Copy link
Member

Choose a reason for hiding this comment

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

근데 이러면면 .radioTag의 modifierκ°€ 아무 μ˜λ―Έκ°€ 없지 μ•Šμ•„μš”?

} label: {
content
}
.buttonStyle(CustomButtonStyle.init(isOn: tag == value.selection))
Copy link
Member

Choose a reason for hiding this comment

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

CustomButtonStyle 이거 μ™œ 혼자 λ”°λ‘œ λ†€μ•„μš”?

}
}

private struct CustomButtonStyle: ButtonStyle {
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
Member Author

Choose a reason for hiding this comment

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

PressedButtonStyle μ–΄λ–€κ°€μš”

Copy link
Member

Choose a reason for hiding this comment

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

Selection μ „μš©μ΄λ‹ˆ PressedSelectionButtonStyle μ–΄λ–€κ°€μš”.

} label: {
content
}
.buttonStyle(CustomButtonStyle(isOn: tag == value.selection))
Copy link
Member

Choose a reason for hiding this comment

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

이거 RadioTag에 λ‹€λŠ”κ±΄ μ’€ λ¬Έμ œκ°€ λ§Žμ§€ μ•Šμ•„μš”?

@kimsh153 kimsh153 merged commit e7daad0 into master May 22, 2023
@kimsh153 kimsh153 deleted the 36-selection-controls-design-system branch May 22, 2023 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1️⃣ Priority: High μš°μ„ μˆœμœ„ - 상 βš™ Setting ν™˜κ²½ μ„ΈνŒ…
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DesignSystem Selection Controls μ œμž‘
2 participants