Skip to content

Commit

Permalink
fix: SegmentedButton
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhello0507 committed Jul 21, 2024
1 parent d147f40 commit fd7ecf7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
29 changes: 22 additions & 7 deletions Source/DDS/Component/Button/SegmentedButton.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI
import Combine

public struct SegmentedButton: View {
public struct DodamSegmentedButton: View {

private let labels: [String]

Expand All @@ -22,7 +22,7 @@ public struct SegmentedButton: View {
@State private var animatedSelection: Int

public var body: some View {
HStack(spacing: 8) {
HStack(spacing: 0) {
ForEach(Array(labels.enumerated()), id: \.offset) { idx, label in
let isSelected = animatedSelection == idx
Button {
Expand All @@ -39,7 +39,7 @@ public struct SegmentedButton: View {
.background {
if isSelected {
RoundedRectangle(cornerRadius: 10)
.dodamFill(DodamColor.Background.normal)
.dodamFill(DodamColor.Fill.assistive)
.matchedGeometryEffect(
id: 0,
in: animation
Expand All @@ -52,9 +52,9 @@ public struct SegmentedButton: View {
)
}
}
.padding(4)
}
}
.padding(4)
.frame(maxWidth: .infinity)
.background(DodamColor.Fill.neutral)
.clipShape(.medium)
Expand All @@ -74,8 +74,23 @@ public struct SegmentedButton: View {
}
}

#Preview {
SegmentedButton(labels: ["외출", "외박"], selection: .constant(0))
.padding(.horizontal, 16)
private struct SegmentedButtonPreview: View {
var body: some View {
VStack {
DodamSegmentedButton(labels: ["외출", "외박"], selection: .constant(1))
.padding(.horizontal, 16)
DodamSegmentedButton(labels: ["외출", "외박"], selection: .constant(0))
.padding(.horizontal, 16)
}
.registerSUIT()
}
}

#Preview {
SegmentedButtonPreview()
}

#Preview {
SegmentedButtonPreview()
.preferredColorScheme(.dark)
}
8 changes: 4 additions & 4 deletions Source/DDS/Component/CheckBox/Checkbox.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI

@available(macOS 12, iOS 15, *)
public struct Checkbox: View {
public struct DodamCheckbox: View {

public enum CheckType {
case primary, error
Expand Down Expand Up @@ -62,9 +62,9 @@ public struct Checkbox: View {

var body: some View {
VStack(spacing: 20) {
Checkbox(isChecked: $isChecked)
Checkbox(isChecked: $isChecked, type: .error)
Checkbox(isChecked: $isChecked, isDisabled: true)
DodamCheckbox(isChecked: $isChecked)
DodamCheckbox(isChecked: $isChecked, type: .error)
DodamCheckbox(isChecked: $isChecked, isDisabled: true)
}
.padding(16)
.background(DodamColor.Background.normal)
Expand Down
2 changes: 2 additions & 0 deletions Source/DDS/Foundation/Color/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public struct DodamColor: RawRepresentable {
case normal
case neutral
case alternative
case assistive
}
public enum Background {
case normal
Expand Down Expand Up @@ -102,6 +103,7 @@ extension DodamColor.Fill: DodamColorable, CaseIterable {
case .normal: .init(P.neutral99, P.neutral25)
case .neutral: .init(P.neutral97, P.neutral25)
case .alternative: .init(P.neutral95, P.neutral30)
case .assistive: .init(P.common100, P.neutral60)
}
}
}
Expand Down

0 comments on commit fd7ecf7

Please sign in to comment.