diff --git a/Projects/Core/DesignSystem/Demo/Sources/DemoView.swift b/Projects/Core/DesignSystem/Demo/Sources/DemoView.swift index aff24afc..f32d0145 100644 --- a/Projects/Core/DesignSystem/Demo/Sources/DemoView.swift +++ b/Projects/Core/DesignSystem/Demo/Sources/DemoView.swift @@ -1,41 +1,21 @@ import DesignSystem import SwiftUI -struct DemoView: View { - @State var isPresentedBottomSheet = false - var body: some View { +public struct DemoView: View { + @State var isSeleted = true + @State var selection: Int? = 0 + + public var body: some View { VStack { Group { - CTAButton(text: "CTA Default", style: .default) { - withAnimation { - isPresentedBottomSheet = true + ForEach(0..<4) { index in + HStack { + SMSSelectionControls(isSeleted: $isSeleted) + Text("asdfasdf") + } } } - } - .padding(8) - - NavigationLink { - AView() - } label: { - Text("A") - } } - .smsBottomSheet(isShowing: $isPresentedBottomSheet) { - RoundedRectangle(cornerRadius: 8) - .fill(Color.sms(.neutral(.n20))) - .frame(maxWidth: .infinity) - .frame(height: 500) - .padding(.horizontal) - } - } -} - -struct AView: View { - @Environment(\.dismiss) var dismiss - - var body: some View { - Text("A") - .smsBackButton(dismiss: dismiss) } } diff --git a/Projects/Core/DesignSystem/Sources/SelectionControls/SMSSelectionControls.swift b/Projects/Core/DesignSystem/Sources/SelectionControls/SMSSelectionControls.swift new file mode 100644 index 00000000..be8c8005 --- /dev/null +++ b/Projects/Core/DesignSystem/Sources/SelectionControls/SMSSelectionControls.swift @@ -0,0 +1,42 @@ +import SwiftUI + +public struct SMSSelectionControls: View { + @Binding var isSeleted: Bool + + public init(isSeleted: Binding) { + _isSeleted = isSeleted + } + public var body: some View { + Button { + self.isSeleted.toggle() + } label: { + ZStack { + Circle() + .stroke(isSeleted ? Color.sms(.primary(.p2)) : Color.sms(.neutral(.n20)), lineWidth: 2) + .frame(width: 20, height: 20) + Circle() + .fill(isSeleted ? Color.sms(.primary(.p2)) : .clear) + .frame(width: 12, height: 12) + } + } + .buttonStyle(PressedSelectionButtonStyle(isSeleted: isSeleted)) + } +} + +private struct PressedSelectionButtonStyle: ButtonStyle { + var isSeleted: Bool + + init(isSeleted: Bool) { + self.isSeleted = isSeleted + } + + @ViewBuilder + func makeBody(configuration: Configuration) -> some View { + Circle() + .fill(self.isSeleted && configuration.isPressed ? Color.sms(.neutral(.n20)) : Color.clear) + .overlay { + configuration.label + } + .frame(width: 32, height: 32) + } +}