From 6a6696ff0d162bad3c749c8b222870fb37db6a97 Mon Sep 17 00:00:00 2001 From: sian7563 Date: Wed, 28 Sep 2022 22:37:36 +0900 Subject: [PATCH 1/9] =?UTF-8?q?feat=20::=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EC=8B=9C=EC=8A=A4=ED=85=9C=20RadioButton?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/RadioButton/DMSRadioButton.swift | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift new file mode 100644 index 00000000..4625f7e5 --- /dev/null +++ b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift @@ -0,0 +1,55 @@ +import SwiftUI + +public struct DMSRadioButton: View { + + @Binding var isOn: Bool + @Binding var isDisabeld: Bool + + let id: String + let size: CGFloat + let callback: (String) -> Void + + public init( + isOn: Binding = .constant(false), + isDisabled: Binding = .constant(false), + id: String, + size: CGFloat = 20, + callback: @escaping (String) -> Void + ) { + self._isOn = isOn + self._isDisabeld = isDisabled + self.id = id + self.size = size + self.callback = callback + } + + public var body: some View { + Button { + self.isOn.toggle() + self.callback(self.id) + } label: { + HStack(alignment: .center) { + if self.isDisabeld { + Image(systemName: self.isOn ? "largecircle.fill.circle" : "circle") + .clipShape(Circle()) + .foregroundColor(self.isOn ? Color.PrimaryVariant.lighten1 : Color.GrayScale.gray3) + .disabled(isDisabeld) + } else { + Image(systemName: self.isOn ? "largecircle.fill.circle" : "circle") + .clipShape(Circle()) + .foregroundColor(self.isOn ? Color.PrimaryVariant.primary : Color.GrayScale.gray5) + .disabled(isDisabeld) + } + } + } + } +} + +struct DMSRadioButton_Previews: PreviewProvider { + static var previews: some View { + DMSRadioButton( + id: "asdf", + callback: { _ in } + ) + } +} From ff9434f450e53870a941cb38e428d9c3e2e3c69c Mon Sep 17 00:00:00 2001 From: sian7563 Date: Thu, 29 Sep 2022 17:15:43 +0900 Subject: [PATCH 2/9] =?UTF-8?q?feat=20::=20RadioButton=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DesignSystem/Sources/RadioButton/DMSRadioButton.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift index 4625f7e5..edc1aa86 100644 --- a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift +++ b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift @@ -33,15 +33,13 @@ public struct DMSRadioButton: View { Image(systemName: self.isOn ? "largecircle.fill.circle" : "circle") .clipShape(Circle()) .foregroundColor(self.isOn ? Color.PrimaryVariant.lighten1 : Color.GrayScale.gray3) - .disabled(isDisabeld) } else { Image(systemName: self.isOn ? "largecircle.fill.circle" : "circle") .clipShape(Circle()) .foregroundColor(self.isOn ? Color.PrimaryVariant.primary : Color.GrayScale.gray5) - .disabled(isDisabeld) } } - } + }.disabled(isDisabeld) } } From 4dc636afaad6bad2e6314fc186942acafb2255a3 Mon Sep 17 00:00:00 2001 From: sian7563 Date: Thu, 29 Sep 2022 17:18:43 +0900 Subject: [PATCH 3/9] =?UTF-8?q?feat=20::=20RadioButton=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/RadioButton/DMSRadioButton.swift | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift index edc1aa86..a011e393 100644 --- a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift +++ b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift @@ -5,28 +5,17 @@ public struct DMSRadioButton: View { @Binding var isOn: Bool @Binding var isDisabeld: Bool - let id: String - let size: CGFloat - let callback: (String) -> Void - public init( isOn: Binding = .constant(false), - isDisabled: Binding = .constant(false), - id: String, - size: CGFloat = 20, - callback: @escaping (String) -> Void + isDisabled: Binding = .constant(false) ) { self._isOn = isOn self._isDisabeld = isDisabled - self.id = id - self.size = size - self.callback = callback } public var body: some View { Button { self.isOn.toggle() - self.callback(self.id) } label: { HStack(alignment: .center) { if self.isDisabeld { @@ -45,9 +34,6 @@ public struct DMSRadioButton: View { struct DMSRadioButton_Previews: PreviewProvider { static var previews: some View { - DMSRadioButton( - id: "asdf", - callback: { _ in } - ) + DMSRadioButton() } } From 34a60325f5567c1879b6ffd187141500a5d6c247 Mon Sep 17 00:00:00 2001 From: sian7563 Date: Thu, 6 Oct 2022 11:37:40 +0900 Subject: [PATCH 4/9] =?UTF-8?q?feat=20::=20DMSRadioButton=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/RadioButton/DMSRadioButton.swift | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift index a011e393..bdf5eef0 100644 --- a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift +++ b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift @@ -34,6 +34,30 @@ public struct DMSRadioButton: View { struct DMSRadioButton_Previews: PreviewProvider { static var previews: some View { - DMSRadioButton() + DMSRadioButton(isOn: .constant(true)) + .if(true) { + $0.foregroundColor(Color.PrimaryVariant.primary) + } + } +} + +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) } + } } } From b890306ea3738a272122997bac635de163baaf0e Mon Sep 17 00:00:00 2001 From: sian7563 Date: Thu, 6 Oct 2022 12:24:43 +0900 Subject: [PATCH 5/9] =?UTF-8?q?feat=20::=20RadioButtonExtension=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RadioButton+RadioButtonState.swift | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/RadioButton+RadioButtonState.swift diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/RadioButton+RadioButtonState.swift b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/RadioButton+RadioButtonState.swift new file mode 100644 index 00000000..1eea9676 --- /dev/null +++ b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/RadioButton+RadioButtonState.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) } + } + } +} From dfad4eac7d4917ce5104f09ed0d675e13a299ef8 Mon Sep 17 00:00:00 2001 From: sian7563 Date: Thu, 6 Oct 2022 19:24:36 +0900 Subject: [PATCH 6/9] =?UTF-8?q?feat=20::=20DMSRadioButton=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/RadioButton/DMSRadioButton.swift | 40 ++++--------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift index bdf5eef0..a05a15cc 100644 --- a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift +++ b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift @@ -18,15 +18,13 @@ public struct DMSRadioButton: View { self.isOn.toggle() } label: { HStack(alignment: .center) { - if self.isDisabeld { - Image(systemName: self.isOn ? "largecircle.fill.circle" : "circle") - .clipShape(Circle()) - .foregroundColor(self.isOn ? Color.PrimaryVariant.lighten1 : Color.GrayScale.gray3) - } else { - Image(systemName: self.isOn ? "largecircle.fill.circle" : "circle") - .clipShape(Circle()) - .foregroundColor(self.isOn ? Color.PrimaryVariant.primary : Color.GrayScale.gray5) - } + Image(systemName: self.isOn ? "largecircle.fill.circle" : "circle") + .clipShape(Circle()) + .if(isDisabeld) { + $0.foregroundColor(self.isOn ? Color.PrimaryVariant.lighten1 : Color.GrayScale.gray3) + } false: { + $0.foregroundColor(self.isOn ? Color.PrimaryVariant.primary : Color.GrayScale.gray5) + } } }.disabled(isDisabeld) } @@ -35,29 +33,5 @@ public struct DMSRadioButton: View { struct DMSRadioButton_Previews: PreviewProvider { static var previews: some View { DMSRadioButton(isOn: .constant(true)) - .if(true) { - $0.foregroundColor(Color.PrimaryVariant.primary) - } - } -} - -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) } - } } } From 2efadd06badfe25a9ad3e16b387ccb6d26beafc9 Mon Sep 17 00:00:00 2001 From: sian7563 Date: Thu, 6 Oct 2022 23:24:14 +0900 Subject: [PATCH 7/9] =?UTF-8?q?feat=20::=20extension=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{RadioButton+RadioButtonState.swift => View+if.swift} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/{RadioButton+RadioButtonState.swift => View+if.swift} (100%) diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/RadioButton+RadioButtonState.swift b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/View+if.swift similarity index 100% rename from Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/RadioButton+RadioButtonState.swift rename to Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/View+if.swift From e7d98f92b54ed981bf47e7703748d5f692277ee4 Mon Sep 17 00:00:00 2001 From: sian7563 Date: Sun, 9 Oct 2022 21:35:50 +0900 Subject: [PATCH 8/9] =?UTF-8?q?feat=20::=20DMSRadioButton=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/RadioButton/DMSRadioButton.swift | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift index a05a15cc..cea3e886 100644 --- a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift +++ b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift @@ -1,32 +1,32 @@ import SwiftUI public struct DMSRadioButton: View { - @Binding var isOn: Bool - @Binding var isDisabeld: Bool + @Environment(\.isEnabled) private var isEnabled: Bool public init( - isOn: Binding = .constant(false), - isDisabled: Binding = .constant(false) + isOn: Binding = .constant(false) ) { self._isOn = isOn - self._isDisabeld = isDisabled } public var body: some View { Button { self.isOn.toggle() } label: { - HStack(alignment: .center) { - Image(systemName: self.isOn ? "largecircle.fill.circle" : "circle") + ZStack { + Circle() + .fill(Color.PrimaryVariant.primary) + .frame(width: 20, height: 20) .clipShape(Circle()) - .if(isDisabeld) { - $0.foregroundColor(self.isOn ? Color.PrimaryVariant.lighten1 : Color.GrayScale.gray3) - } false: { - $0.foregroundColor(self.isOn ? Color.PrimaryVariant.primary : Color.GrayScale.gray5) - } - } - }.disabled(isDisabeld) + Circle() + .fill(Color.white) + .frame(width: 15, height: 15) + Circle() + .fill(Color.PrimaryVariant.primary) + .frame(width: 10, height: 10) + }.disabled(isEnabled) + } } } From f6e1abbc9ee70f9d6f82faea8540449a16f5bc4e Mon Sep 17 00:00:00 2001 From: sian7563 Date: Sun, 9 Oct 2022 21:41:22 +0900 Subject: [PATCH 9/9] =?UTF-8?q?feat=20::=20DMSRadioButton=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DesignSystem/Sources/RadioButton/DMSRadioButton.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift index cea3e886..4898b797 100644 --- a/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift +++ b/Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.swift @@ -18,14 +18,13 @@ public struct DMSRadioButton: View { Circle() .fill(Color.PrimaryVariant.primary) .frame(width: 20, height: 20) - .clipShape(Circle()) Circle() .fill(Color.white) .frame(width: 15, height: 15) Circle() .fill(Color.PrimaryVariant.primary) .frame(width: 10, height: 10) - }.disabled(isEnabled) + } } } }