Skip to content

Commit

Permalink
[Fix] 체크박스의 Nested에 여러 뷰가 들어갈수 있도록 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
bonoogi committed Sep 25, 2024
1 parent db9759b commit fc73760
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private enum Metric {

/// 최소 1가지 이상의 옵션을 선택 또는 해제할 수 있는 컨트롤 컴포넌트로, 일반적으로 사용하는 체크박스 아이템입니다.
// MARK: - BezierPrimaryCheckbox
public struct BezierPrimaryCheckbox<Nested: View>: View {
public struct BezierPrimaryCheckbox<Nested>: View where Nested: View {
public typealias Color = BezierCheckboxColor
public typealias Checked = BezierCheckboxChecked
public typealias NestedBuilder = () -> Nested
Expand All @@ -39,7 +39,7 @@ public struct BezierPrimaryCheckbox<Nested: View>: View {
color: Color,
checked: Checked,
showRequired: Bool,
nestedBuilder: @escaping NestedBuilder
@ViewBuilder nestedBuilder: @escaping NestedBuilder
) {
self.label = label
self.color = color
Expand Down Expand Up @@ -97,8 +97,9 @@ public struct BezierPrimaryCheckbox<Nested: View>: View {
.padding(.vertical, Metric.labelTop)
}

self.nestedBuilder()
.padding(.leading, Metric.minHeight)
VStack(alignment: .leading, spacing: 0) {
self.nestedBuilder()
}.padding(.leading, Metric.minHeight)
}
.frame(minHeight: Metric.minHeight)
.compositingGroup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@ struct BezierCheckboxExample: View {
checked: .indeterminate,
showRequired: true
) {
VStack {
BezierSecondaryCheckbox(
label: "Secondary",
color: .blue,
checked: false
)
BezierSecondaryCheckbox(
label: "Secondary",
color: .green,
checked: true
)
}
BezierSecondaryCheckbox(
label: "Secondary",
color: .blue,
checked: false
)
BezierSecondaryCheckbox(
label: "Secondary",
color: .green,
checked: true
)
}
BezierPrimaryCheckbox(
label: "Green No Nested Indeterminate",
Expand Down

0 comments on commit fc73760

Please sign in to comment.