From c4aca8a86595b50f42df01f6c82d5141bc7e483a Mon Sep 17 00:00:00 2001 From: Everton Cunha Date: Tue, 14 Jun 2022 15:35:07 -0400 Subject: [PATCH] Pbselect (#2) * revert deprecated * pbselect * gitignore * xcode file --- .gitignore | 3 ++ .../contents.xcworkspacedata | 7 +++ Sources/Playbook/PBSelect.swift | 52 +++++++++++++++++++ .../Playbook/Typography/Font+Playbook.swift | 2 +- Sources/Playbook/Typography/Typography.swift | 2 +- 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata create mode 100644 Sources/Playbook/PBSelect.swift diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..2124feca9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.swiftpm/xcode/package.xcworkspace/xcuserdata +.swiftpm/xcode/xcuserdata +Package.resolved diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Sources/Playbook/PBSelect.swift b/Sources/Playbook/PBSelect.swift new file mode 100644 index 000000000..c984b7af9 --- /dev/null +++ b/Sources/Playbook/PBSelect.swift @@ -0,0 +1,52 @@ +// +// PBSelect.swift +// +// +// Created by Everton Cunha on 14/06/22. +// + +import SwiftUI + +public struct PBSelect: ButtonStyle { + + let title: String + + let style: PBCardStyle + + public init(_ title: String, style: PBCardStyle) { + self.title = title + self.style = style + } + + public func makeBody(configuration: Configuration) -> some View { + VStack(alignment: .leading, spacing: 4) { + if let title = title { + Text(title) + .pbFont(.caption, color: .pbTextLight) + } + PBCard(padding: 0, style: style) { + HStack { + configuration.label + .frame(height: 44) + .pbFont(.body) + Spacer() + PBIcon.fontAwesome(.chevronDown) + } + .padding(.horizontal, .pbSmall) + } + } + } +} + +struct PBSelect_Previews: PreviewProvider { + static var previews: some View { + registerFonts() + return Group { + Button("Burguers") { + + } + .buttonStyle(PBSelect("FAVORITE FOOD", style: .default)) + .preferredColorScheme(.light) + } + } +} diff --git a/Sources/Playbook/Typography/Font+Playbook.swift b/Sources/Playbook/Typography/Font+Playbook.swift index 9ed4670cf..04f52b7b0 100644 --- a/Sources/Playbook/Typography/Font+Playbook.swift +++ b/Sources/Playbook/Typography/Font+Playbook.swift @@ -41,7 +41,7 @@ public enum PBTextStyle { } extension Font { - @available(*, deprecated, message: "use .font(.pbBody)") + public static func pb(_ style: PBTextStyle) -> Font { return style.font } diff --git a/Sources/Playbook/Typography/Typography.swift b/Sources/Playbook/Typography/Typography.swift index 9e975b795..70bc9e542 100644 --- a/Sources/Playbook/Typography/Typography.swift +++ b/Sources/Playbook/Typography/Typography.swift @@ -72,7 +72,7 @@ public extension Typography { } public extension View { - @available(*, deprecated, message: "use .font(.pbBody)") + func pbFont(_ style: PBTextStyle, variant: Typography.Variant = .none, color: Color = .pbTextDefault) -> some View {