diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift new file mode 100644 index 00000000..4898b797 --- /dev/null +++ b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift @@ -0,0 +1,36 @@ +import SwiftUI + +public struct DMSRadioButton: View { + @Binding var isOn: Bool + @Environment(\.isEnabled) private var isEnabled: Bool + + public init( + isOn: Binding = .constant(false) + ) { + self._isOn = isOn + } + + public var body: some View { + Button { + self.isOn.toggle() + } label: { + ZStack { + Circle() + .fill(Color.PrimaryVariant.primary) + .frame(width: 20, height: 20) + Circle() + .fill(Color.white) + .frame(width: 15, height: 15) + Circle() + .fill(Color.PrimaryVariant.primary) + .frame(width: 10, height: 10) + } + } + } +} + +struct DMSRadioButton_Previews: PreviewProvider { + static var previews: some View { + DMSRadioButton(isOn: .constant(true)) + } +} diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/View+if.swift b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/View+if.swift new file mode 100644 index 00000000..1eea9676 --- /dev/null +++ b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/View+if.swift @@ -0,0 +1,22 @@ +import SwiftUI + +public extension View { + func `if`( + _ condition: Bool, + transform: (Self) -> T + ) -> some View { + Group { + if condition { transform(self) } else { self } + } + } + + func `if`( + _ condition: Bool, + true trueTransform: (Self) -> T, + false falseTransform: (Self) -> T + ) -> some View { + Group { + if condition { trueTransform(self) } else { falseTransform(self) } + } + } +}