From 6b10f441bdf44b906d50192405c59b9938e98523 Mon Sep 17 00:00:00 2001 From: baegteun Date: Wed, 10 May 2023 00:01:09 +0900 Subject: [PATCH 1/3] :sparkles: :: SMSChip --- .../DesignSystem/Sources/Chip/SMSChip.swift | 37 +++++++++++++++++++ .../Sources/Chip/SMSChipButtonStyle.swift | 12 ++++++ 2 files changed, 49 insertions(+) create mode 100644 Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift create mode 100644 Projects/Core/DesignSystem/Sources/Chip/SMSChipButtonStyle.swift diff --git a/Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift b/Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift new file mode 100644 index 00000000..da8978a7 --- /dev/null +++ b/Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift @@ -0,0 +1,37 @@ +import SwiftUI + +public struct SMSChip: View { + var iconView: Content + var text: String + var action: () -> Void + + public init( + text: String, + iconView: @escaping () -> Content = { + SMSIcon(.plus, renderingMode: .template, width: 12, height: 12) + }, + action: @escaping () -> Void = {} + ) { + self.iconView = iconView() + self.text = text + self.action = action + } + + public var body: some View { + Button(action: action) { + HStack(spacing: 4) { + iconView + + Text(text) + } + .smsFont(.body1, color: .neutral(.n30)) + } + .buttonStyle(SMSChipButtonStyle()) + } +} + +struct SMSChip_Previews: PreviewProvider { + static var previews: some View { + SMSChip(text: "Text") + } +} diff --git a/Projects/Core/DesignSystem/Sources/Chip/SMSChipButtonStyle.swift b/Projects/Core/DesignSystem/Sources/Chip/SMSChipButtonStyle.swift new file mode 100644 index 00000000..39ec58b0 --- /dev/null +++ b/Projects/Core/DesignSystem/Sources/Chip/SMSChipButtonStyle.swift @@ -0,0 +1,12 @@ +import SwiftUI + +struct SMSChipButtonStyle: ButtonStyle { + func makeBody(configuration: Configuration) -> some View { + configuration.label + .padding(8) + .background { + configuration.isPressed ? Color.sms(.neutral(.n10)) : .sms(.system(.white)) + } + .cornerRadius(8) + } +} From 2c65214f0ed0800bfadc3b0cb2c7ab243261d658 Mon Sep 17 00:00:00 2001 From: baegteun Date: Wed, 10 May 2023 00:03:45 +0900 Subject: [PATCH 2/3] :truck: :: iconView -> iconLabel --- .../Core/DesignSystem/Sources/Chip/SMSChip.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift b/Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift index da8978a7..e6bd7f36 100644 --- a/Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift +++ b/Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift @@ -1,26 +1,26 @@ import SwiftUI public struct SMSChip: View { - var iconView: Content + var iconLabel: Content var text: String var action: () -> Void public init( text: String, - iconView: @escaping () -> Content = { + action: @escaping () -> Void = {}, + iconLabel: @escaping () -> Content = { SMSIcon(.plus, renderingMode: .template, width: 12, height: 12) - }, - action: @escaping () -> Void = {} + } ) { - self.iconView = iconView() self.text = text + self.iconLabel = iconLabel() self.action = action } public var body: some View { Button(action: action) { HStack(spacing: 4) { - iconView + iconLabel Text(text) } From 1b9fe4517b6d346fd6ed982ac80d1e884efd1eca Mon Sep 17 00:00:00 2001 From: baegteun Date: Wed, 10 May 2023 00:08:50 +0900 Subject: [PATCH 3/3] =?UTF-8?q?:pencil2:=20::=20=ED=8C=8C=EB=9D=BC?= =?UTF-8?q?=EB=AF=B8=ED=84=B0=EB=AA=85=20placeholder=EB=A1=9C=20=EB=B0=9B?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift b/Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift index e6bd7f36..ab7d7e13 100644 --- a/Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift +++ b/Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift @@ -6,7 +6,7 @@ public struct SMSChip: View { var action: () -> Void public init( - text: String, + _ text: String, action: @escaping () -> Void = {}, iconLabel: @escaping () -> Content = { SMSIcon(.plus, renderingMode: .template, width: 12, height: 12) @@ -32,6 +32,6 @@ public struct SMSChip: View { struct SMSChip_Previews: PreviewProvider { static var previews: some View { - SMSChip(text: "Text") + SMSChip("Text") } }