Skip to content

Commit e716102

Browse files
authored
Merge pull request #11 from LiveUI/5.2
FontAwesome 5.2
2 parents 88fb689 + 6d98020 commit e716102

File tree

8 files changed

+460
-103
lines changed

8 files changed

+460
-103
lines changed

Assets/fa-brands-400.ttf

1.43 KB
Binary file not shown.

Assets/fa-regular-400.ttf

-100 Bytes
Binary file not shown.

Assets/fa-solid-900.ttf

7.45 KB
Binary file not shown.

Classes/Enums/Awesome.swift

Lines changed: 41 additions & 7 deletions
Large diffs are not rendered by default.

Classes/Enums/AwesomePro.swift

Lines changed: 337 additions & 13 deletions
Large diffs are not rendered by default.

Generator/Sources/Generator/EnumBuilder.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import Foundation
22

33
func buildEnum (_ name: String, from styles: [String: [Icon]]) -> String {
4-
let formatter = DateFormatter()
5-
formatter.dateFormat = "dd/MM/yyyy HH:mm"
6-
4+
let formatter = DateFormatter()
5+
formatter.dateFormat = "dd/MM/yyyy HH:mm"
6+
77
var content = ""
88
content += "//\n// \(name).swift\n// AwesomeEnum\n//\n// Originally created by Ondrej Rafaj on 13/10/2017.\n"
99
content += "// Copyright © 2017 manGoweb UK. All rights reserved.\n//\n"
10-
content += "// This file has been auto-generated on \(formatter.string(from: Date())).\n\nimport Foundation\n\npublic struct \(name) {\n"
10+
content += "// This file has been auto-generated on \(formatter.string(from: Date())).\n\nimport Foundation\n\npublic struct \(name) {\n"
1111

1212
for (var style, list) in styles {
13-
if style == "brands" { style = "brand" }
14-
13+
if style == "brands" { style = "brand" }
14+
1515
content += "\n public enum \(style): String, Amazing {\n"
1616
var names = [String]()
1717
for icon in list {
@@ -20,12 +20,12 @@ func buildEnum (_ name: String, from styles: [String: [Icon]]) -> String {
2020
if Int(name.prefix(1)) != nil { name = "fa\(name)" }
2121
names.append(name)
2222

23-
content += " case \(name.isKeyword ? "`\(name)`" : name) = \"\\u{\(icon.unicode)}\"\n"
23+
content += " case \(name.isKeyword ? "`\(name)`" : name) = \"\\u{\(icon.unicode)}\"\n"
2424
}
2525

2626
content += "\n public static var all: [\(style)] {\n return [ \(names.map {"\(style).\($0)"}.joined(separator: ", ")) ]\n }\n"
27-
content += "\n public static var keys: [String] {\n return [ \(list.map {"\"\($0.name)\""}.joined(separator: ", ")) ]\n }\n"
28-
content += "\n public static var labels: [String] {\n return [ \(list.map {"\"\($0.name.split(separator: "-").map { $0.firstUppercased() }.joined(separator: " "))\""}.joined(separator: ", ")) ]\n }\n"
27+
content += "\n public static var keys: [String] {\n return [ \(list.map {"\"\($0.name)\""}.joined(separator: ", ")) ]\n }\n"
28+
content += "\n public static var labels: [String] {\n return [ \(list.map {"\"\($0.name.split(separator: "-").map { $0.firstUppercased() }.joined(separator: " "))\""}.joined(separator: ", ")) ]\n }\n"
2929
content += "\n public var code: String {\n return rawValue\n }\n"
3030
content += "\n public var fontType: AwesomeFont {\n return \(name).Font.\(style)\n }\n"
3131

Lines changed: 71 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,78 @@
11
import Foundation
22

33
extension Substring {
4-
func firstUppercased() -> Substring {
5-
return prefix(1).uppercased() + dropFirst()
6-
}
4+
func firstUppercased() -> Substring {
5+
return prefix(1).uppercased() + dropFirst()
6+
}
77
}
88

99
extension String {
10-
11-
func firstUppercased() -> String {
12-
return prefix(1).uppercased() + dropFirst()
13-
}
14-
15-
var isKeyword: Bool {
16-
switch self {
17-
case
18-
"associativity",
19-
"break",
20-
"case",
21-
"catch",
22-
"class",
23-
"continue",
24-
"convenience",
25-
"default",
26-
"deinit",
27-
"didSet",
28-
"do",
29-
"else",
30-
"enum",
31-
"extension",
32-
"fallthrough",
33-
"false",
34-
"final",
35-
"for",
36-
"func",
37-
"get",
38-
"guard",
39-
"if",
40-
"in",
41-
"infix",
42-
"init",
43-
"inout",
44-
"internal",
45-
"lazy",
46-
"let",
47-
"mutating",
48-
"nil",
49-
"operator",
50-
"override",
51-
"postfix",
52-
"precedence",
53-
"prefix",
54-
"private",
55-
"public",
56-
"repeat",
57-
"required",
58-
"return",
59-
"self",
60-
"set",
61-
"static",
62-
"struct",
63-
"subscript",
64-
"super",
65-
"switch",
66-
"throws",
67-
"true",
68-
"try",
69-
"var",
70-
"weak",
71-
"where",
72-
"while",
73-
"willSet":
74-
return true
75-
default:
76-
return false
77-
}
78-
}
10+
func firstUppercased() -> String {
11+
return prefix(1).uppercased() + dropFirst()
12+
}
13+
14+
var isKeyword: Bool {
15+
switch self {
16+
case
17+
"associativity",
18+
"break",
19+
"case",
20+
"catch",
21+
"class",
22+
"continue",
23+
"convenience",
24+
"default",
25+
"deinit",
26+
"didSet",
27+
"do",
28+
"else",
29+
"enum",
30+
"extension",
31+
"fallthrough",
32+
"false",
33+
"final",
34+
"for",
35+
"func",
36+
"get",
37+
"guard",
38+
"if",
39+
"in",
40+
"infix",
41+
"init",
42+
"inout",
43+
"internal",
44+
"lazy",
45+
"let",
46+
"mutating",
47+
"nil",
48+
"operator",
49+
"override",
50+
"postfix",
51+
"precedence",
52+
"prefix",
53+
"private",
54+
"public",
55+
"repeat",
56+
"required",
57+
"return",
58+
"self",
59+
"set",
60+
"static",
61+
"struct",
62+
"subscript",
63+
"super",
64+
"switch",
65+
"throws",
66+
"true",
67+
"try",
68+
"var",
69+
"weak",
70+
"where",
71+
"while",
72+
"willSet":
73+
return true
74+
default:
75+
return false
76+
}
77+
}
7978
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Awesome
22

3-
[![Font Awesome](https://img.shields.io/badge/Font%20Awesome-5.1.0-brightgreen.svg)](https://fontawesome.com/v5.1.0/icons)
3+
[![Font Awesome](https://img.shields.io/badge/Font%20Awesome-5.2.0-brightgreen.svg)](https://fontawesome.com/v5.2.0/icons)
44
[![Slack](https://img.shields.io/badge/join-slack-745EAF.svg?style=flat)](http://bit.ly/2B0dEyt)
55
[![Version](https://img.shields.io/cocoapods/v/AwesomeEnum.svg?style=flat)](http://cocoapods.org/pods/AwesomeEnum)
66
[![License](https://img.shields.io/cocoapods/l/AwesomeEnum.svg?style=flat)](http://cocoapods.org/pods/AwesomeEnum)
@@ -57,7 +57,7 @@ let attributedText = Awesome.regular.envelopeOpen.asAttributedText(fontSize: 17,
5757
The Font Awesome Free files are included and loaded for you out of the box. Font Awesome Pro licensing terms don't allow to publish the font files however, so we can't add those for you. As such you will need to manually add the fonts to your project and register them before using them:
5858

5959
```swift
60-
// AppDelegate application(:didFinishLaunchingWithOptions:)
60+
// AppDelegate application(_:didFinishLaunchingWithOptions:)
6161

6262
// Load all fonts
6363
AwesomePro.loadFonts(from: Bundle.main)

0 commit comments

Comments
 (0)