-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
μ΄λ°μμΌλ‘ TabViewκ°μ λ°©μμΌλ‘ Selection Controls μ¬μ©ν μ μκ² νλκ±° μ΄λμ? |
β¦election-controls-design-system
β¦election-controls-design-system
Projects/Core/DesignSystem/Sources/SelectionControls/SMSSelectionControls.swift
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
private struct CustomButtonStyle: ButtonStyle { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
privateμ΄κΈ΄ νμ§λ§ CustomButotnStyleλ³΄λ€ λ μ§κ΄μ μΈ μ΄λ¦μ μμκΉμ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SMSelectionControlsStyleλ‘ μμ ν κΉμ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ΄κ±°λ νΉμ SelectionControl κ·Έ μ체보λ€λ SelectionControlμ΄ λλ Έμ λ grayμμ΄ μκΈ°λ styleμλκ°μ? μ’ λ€λ₯Έ μ΄λ¦μ μλμ?
Projects/Core/DesignSystem/Sources/SelectionControls/SMSSelectionControls.swift
Outdated
Show resolved
Hide resolved
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λ°μΈλ©μ΄ μ λ€ Optionalλ‘ λνλμ΄ μλμ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selectionμ΄ μ νλμ§ μμ κ²½μ°λ μλ€κ³ μκ°νμ¬ Optional μ²λ¦¬λ₯Ό νμμ΅λλ€.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ νλμ§ μμ κ²½μ°λ value.selectionκ³Ό λ€λ₯Έ κ²½μ° μλκ°μ?
There was a problem hiding this comment.
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?>μ μ무κ²λ μ νμ νμ§ μμ μνλ₯Ό μν΄ λ§λ κ²μ λλ€.
HStack { | ||
SMSSelectionControls(tag: index) | ||
Text("asdfasdf") | ||
} | ||
.radioTag(index) |
There was a problem hiding this comment.
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))
μ΄λ κ² κ°μΈλλκ±°λ©΄ μ λ―Έλ¬νμ§ μμμ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
κ·Έ λμμ΄λλΆμ΄ λ§μνμ κ±Έλ‘λ λ²νΌλ§ λλ¬μ ΈμΌνλ€κ³ νμκΈΈλ μμ²μ¬νλλ‘ μμ νμ΅λλ€
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μμ λ μ½λ λ§λμ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λ€.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ§κΈλ textλ κ°μ΄ λ리λλ°μ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ μλλ€, μ΄λ¬ 컀λ°μ΄ λ무 μ½λκ° ν·κ°λ¦¬κ² 컀λ°λΌμ;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ© μ£μ‘ν¨λ€
β¦election-controls-design-system
|
||
public init( | ||
selection: Binding<T?>, | ||
@ViewBuilder _ content: @escaping () -> Content, |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μμν μ¬μ§κ° μμΌλ finalλ‘ μ²λ¦¬νλκ² μ’μ§ μμκΉμ?
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)) | ||
} | ||
} |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
κ·Έλμ μ΄ μΉκ΅¬ μ΄λ¦μ΄ μ΄λ»κ² λλμ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PressedButtonStyle μ΄λ€κ°μ
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ΄κ±° RadioTagμ λ€λ건 μ’ λ¬Έμ κ° λ§μ§ μμμ?
π‘ κ°μ
DesignSystem SMSSelectionControls μ μ
π μμ λ΄μ©
DesignSystem SMSSelectionControls μ μ
2023-05-09.7.49.54.mov