From 6514797141032059adf394dd7e8870cb73197b4f Mon Sep 17 00:00:00 2001 From: Matthias Klosek Date: Wed, 13 Jul 2022 13:13:09 +0200 Subject: [PATCH 1/2] Update Awesome/AwesomePro, make enums CaseIterable and add withKey function --- Classes/Enums/Awesome.swift | 18 ++++++++++++++--- Classes/Enums/AwesomePro.swift | 35 ++++++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/Classes/Enums/Awesome.swift b/Classes/Enums/Awesome.swift index 27246fd..520752b 100644 --- a/Classes/Enums/Awesome.swift +++ b/Classes/Enums/Awesome.swift @@ -11,7 +11,7 @@ import Foundation public struct Awesome { - public enum Brand: String, Amazing { + public enum Brand: String, Amazing, CaseIterable { case fa500px = "\u{f26e}" case accessibleIcon = "\u{f368}" case accusoft = "\u{f369}" @@ -469,12 +469,16 @@ public struct Awesome { case youtubeSquare = "\u{f431}" case zhihu = "\u{f63f}" + static func withKey(_ label: String) -> Brand? { + return self.allCases.first { label == "\($0)" } + } + public var fontType: AwesomeFont { return Awesome.Font.brand } } - public enum Solid: String, Amazing { + public enum Solid: String, Amazing, CaseIterable { case ad = "\u{f641}" case addressBook = "\u{f2b9}" case addressCard = "\u{f2bb}" @@ -1477,12 +1481,16 @@ public struct Awesome { case yenSign = "\u{f157}" case yinYang = "\u{f6ad}" + static func withKey(_ label: String) -> Solid? { + return self.allCases.first { label == "\($0)" } + } + public var fontType: AwesomeFont { return Awesome.Font.solid } } - public enum Regular: String, Amazing { + public enum Regular: String, Amazing, CaseIterable { case addressBook = "\u{f2b9}" case addressCard = "\u{f2bb}" case angry = "\u{f556}" @@ -1635,6 +1643,10 @@ public struct Awesome { case windowMinimize = "\u{f2d1}" case windowRestore = "\u{f2d2}" + static func withKey(_ label: String) -> Regular? { + return self.allCases.first { label == "\($0)" } + } + public var fontType: AwesomeFont { return Awesome.Font.regular } diff --git a/Classes/Enums/AwesomePro.swift b/Classes/Enums/AwesomePro.swift index f8882b7..ca7881d 100644 --- a/Classes/Enums/AwesomePro.swift +++ b/Classes/Enums/AwesomePro.swift @@ -10,8 +10,8 @@ import Foundation public struct AwesomePro { - - public enum Regular: String, Amazing { + + public enum Regular: String, Amazing, CaseIterable { case abacus = "\u{f640}" case acorn = "\u{f6ae}" case ad = "\u{f641}" @@ -1865,12 +1865,16 @@ public struct AwesomePro { case yenSign = "\u{f157}" case yinYang = "\u{f6ad}" + static func withKey(_ label: String) -> Regular? { + return self.allCases.first { label == "\($0)" } + } + public var fontType: AwesomeFont { return AwesomePro.Font.regular } } - public enum Brand: String, Amazing { + public enum Brand: String, Amazing, CaseIterable { case fa500px = "\u{f26e}" case accessibleIcon = "\u{f368}" case accusoft = "\u{f369}" @@ -2328,12 +2332,16 @@ public struct AwesomePro { case youtubeSquare = "\u{f431}" case zhihu = "\u{f63f}" + static func withKey(_ label: String) -> Brand? { + return self.allCases.first { label == "\($0)" } + } + public var fontType: AwesomeFont { return AwesomePro.Font.brand } } - public enum Solid: String, Amazing { + public enum Solid: String, Amazing, CaseIterable { case abacus = "\u{f640}" case acorn = "\u{f6ae}" case ad = "\u{f641}" @@ -4187,12 +4195,16 @@ public struct AwesomePro { case yenSign = "\u{f157}" case yinYang = "\u{f6ad}" + static func withKey(_ label: String) -> Solid? { + return self.allCases.first { label == "\($0)" } + } + public var fontType: AwesomeFont { return AwesomePro.Font.solid } } - public enum Light: String, Amazing { + public enum Light: String, Amazing, CaseIterable { case abacus = "\u{f640}" case acorn = "\u{f6ae}" case ad = "\u{f641}" @@ -6046,12 +6058,16 @@ public struct AwesomePro { case yenSign = "\u{f157}" case yinYang = "\u{f6ad}" + static func withKey(_ label: String) -> Light? { + return self.allCases.first { label == "\($0)" } + } + public var fontType: AwesomeFont { return AwesomePro.Font.light } } - public enum Duotone: String, Amazing { + public enum Duotone: String, Amazing, CaseIterable { case abacus = "\u{f640}" case acorn = "\u{f6ae}" case ad = "\u{f641}" @@ -7905,9 +7921,12 @@ public struct AwesomePro { case yenSign = "\u{f157}" case yinYang = "\u{f6ad}" + static func withKey(_ label: String) -> Duotone? { + return self.allCases.first { label == "\($0)" } + } + public var fontType: AwesomeFont { return AwesomePro.Font.duotone } } - -} +} \ No newline at end of file From d1a79a60e683246b402a7d816a695b6b771d9fbc Mon Sep 17 00:00:00 2001 From: Matthias Klosek Date: Wed, 13 Jul 2022 13:58:27 +0200 Subject: [PATCH 2/2] Make static func of Awesome/AwesomePro Enums public --- Classes/Enums/Awesome.swift | 6 +++--- Classes/Enums/AwesomePro.swift | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Classes/Enums/Awesome.swift b/Classes/Enums/Awesome.swift index 520752b..222833c 100644 --- a/Classes/Enums/Awesome.swift +++ b/Classes/Enums/Awesome.swift @@ -469,7 +469,7 @@ public struct Awesome { case youtubeSquare = "\u{f431}" case zhihu = "\u{f63f}" - static func withKey(_ label: String) -> Brand? { + public static func withKey(_ label: String) -> Brand? { return self.allCases.first { label == "\($0)" } } @@ -1481,7 +1481,7 @@ public struct Awesome { case yenSign = "\u{f157}" case yinYang = "\u{f6ad}" - static func withKey(_ label: String) -> Solid? { + public static func withKey(_ label: String) -> Solid? { return self.allCases.first { label == "\($0)" } } @@ -1643,7 +1643,7 @@ public struct Awesome { case windowMinimize = "\u{f2d1}" case windowRestore = "\u{f2d2}" - static func withKey(_ label: String) -> Regular? { + public static func withKey(_ label: String) -> Regular? { return self.allCases.first { label == "\($0)" } } diff --git a/Classes/Enums/AwesomePro.swift b/Classes/Enums/AwesomePro.swift index ca7881d..8f63543 100644 --- a/Classes/Enums/AwesomePro.swift +++ b/Classes/Enums/AwesomePro.swift @@ -10,7 +10,7 @@ import Foundation public struct AwesomePro { - + public enum Regular: String, Amazing, CaseIterable { case abacus = "\u{f640}" case acorn = "\u{f6ae}" @@ -1865,7 +1865,7 @@ public struct AwesomePro { case yenSign = "\u{f157}" case yinYang = "\u{f6ad}" - static func withKey(_ label: String) -> Regular? { + public static func withKey(_ label: String) -> Regular? { return self.allCases.first { label == "\($0)" } } @@ -2332,7 +2332,7 @@ public struct AwesomePro { case youtubeSquare = "\u{f431}" case zhihu = "\u{f63f}" - static func withKey(_ label: String) -> Brand? { + public static func withKey(_ label: String) -> Brand? { return self.allCases.first { label == "\($0)" } } @@ -4195,7 +4195,7 @@ public struct AwesomePro { case yenSign = "\u{f157}" case yinYang = "\u{f6ad}" - static func withKey(_ label: String) -> Solid? { + public static func withKey(_ label: String) -> Solid? { return self.allCases.first { label == "\($0)" } } @@ -6058,7 +6058,7 @@ public struct AwesomePro { case yenSign = "\u{f157}" case yinYang = "\u{f6ad}" - static func withKey(_ label: String) -> Light? { + public static func withKey(_ label: String) -> Light? { return self.allCases.first { label == "\($0)" } } @@ -7921,7 +7921,7 @@ public struct AwesomePro { case yenSign = "\u{f157}" case yinYang = "\u{f6ad}" - static func withKey(_ label: String) -> Duotone? { + public static func withKey(_ label: String) -> Duotone? { return self.allCases.first { label == "\($0)" } }