From 995bec6cb2a31cc9f5193f13a9656294a8e6f01e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 28 Feb 2024 15:32:00 -0600 Subject: [PATCH] refactored out mapped and inserted within the only function that calls it. Signed-off-by: Matt Bruce --- .../Atomic/Extensions/VDS-TextStyle.swift | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/Atomic/Extensions/VDS-TextStyle.swift b/MVMCoreUI/Atomic/Extensions/VDS-TextStyle.swift index 6da79f1f..f7e5917e 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-TextStyle.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-TextStyle.swift @@ -12,7 +12,25 @@ import VDS extension Styler.Font { //Converts Legacy Font to a VDS.TextStyle public func vdsTextStyle() -> VDS.TextStyle? { - let updatedRaw = mapped().rawValue.replacingOccurrences(of: "Regular", with: "") + + //ensure that the current Styler.Font isn't Legacy Version + //if it is, here is the conversion to the updated version + var actualFont: Styler.Font = self + switch self { + case .Title2XLarge: actualFont = .RegularTitle2XLarge + case .TitleXLarge: actualFont = .RegularTitleXLarge + case .H1: actualFont = .RegularTitle2XLarge + case .H32: actualFont = .RegularTitleXLarge + case .H2: actualFont = .RegularTitleLarge + case .B20: actualFont = .RegularBodyLarge + case .H3: actualFont = .BoldTitleMedium + case .B1: actualFont = .BoldBodySmall + case .B2: actualFont = .RegularBodySmall + case .B3: actualFont = .RegularMicro + default: break + } + + let updatedRaw = actualFont.rawValue.replacingOccurrences(of: "Regular", with: "") let newRaw = updatedRaw.prefix(1).lowercased() + updatedRaw.dropFirst() guard let style = VDS.TextStyle(rawValue: newRaw) else { return nil } return style @@ -29,24 +47,6 @@ extension Styler.Font { } return standardStyle } - - private func mapped() -> Styler.Font { - var mapped: Styler.Font = self - switch self { - case .Title2XLarge: mapped = .RegularTitle2XLarge - case .TitleXLarge: mapped = .RegularTitleXLarge - case .H1: mapped = .RegularTitle2XLarge - case .H32: mapped = .RegularTitleXLarge - case .H2: mapped = .RegularTitleLarge - case .B20: mapped = .RegularBodyLarge - case .H3: mapped = .BoldTitleMedium - case .B1: mapped = .BoldBodySmall - case .B2: mapped = .RegularBodySmall - case .B3: mapped = .RegularMicro - default: break - } - return mapped - } } extension VDS.Font {