From 648b6df912d70f8dbf906bc6de20af1ad452e364 Mon Sep 17 00:00:00 2001 From: Juan David Hurtado Date: Wed, 1 Jun 2022 12:13:18 -0500 Subject: [PATCH] feat: add fonts --- Sources/Purace/Styles/PuraceStyle.swift | 15 +++++++++++++++ .../Purace/Views/Basic/Text/PuraceTextView.swift | 11 +---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Sources/Purace/Styles/PuraceStyle.swift b/Sources/Purace/Styles/PuraceStyle.swift index 5046170..3622f2d 100644 --- a/Sources/Purace/Styles/PuraceStyle.swift +++ b/Sources/Purace/Styles/PuraceStyle.swift @@ -32,4 +32,19 @@ public struct PuraceStyle { public static let G7 = SwiftUI.Color(hex: "D7DCE1") ?? .gray public static let G8 = SwiftUI.Color(hex: "DFE4E8") ?? .gray } + + public struct Font { + public static func get(size: CGFloat, weight: PuraceTextWeight = .regular) -> SwiftUI.Font { + var fontName = "Poppins-" + switch weight { + case .regular: + fontName += "Regular" + case .medium: + fontName += "Medium" + case .semibold: + fontName += "SemiBold" + } + return .custom(fontName, size: size) + } + } } diff --git a/Sources/Purace/Views/Basic/Text/PuraceTextView.swift b/Sources/Purace/Views/Basic/Text/PuraceTextView.swift index 28c6faf..cd843db 100644 --- a/Sources/Purace/Views/Basic/Text/PuraceTextView.swift +++ b/Sources/Purace/Views/Basic/Text/PuraceTextView.swift @@ -21,16 +21,7 @@ public struct PuraceTextView: View { } private func getFont() -> Font { - var fontName = "Poppins-" - switch weight { - case .regular: - fontName += "Regular" - case .medium: - fontName += "Medium" - case .semibold: - fontName += "SemiBold" - } - return .custom(fontName, size: CGFloat(fontSize)) + PuraceStyle.Font.get(size: CGFloat(fontSize), weight: weight) } public var body: some View {