Skip to content

Commit

Permalink
Merge pull request #11 from LiveUI/5.2
Browse files Browse the repository at this point in the history
FontAwesome 5.2
  • Loading branch information
rafiki270 authored Jul 25, 2018
2 parents 88fb689 + 6d98020 commit e716102
Show file tree
Hide file tree
Showing 8 changed files with 460 additions and 103 deletions.
Binary file modified Assets/fa-brands-400.ttf
Binary file not shown.
Binary file modified Assets/fa-regular-400.ttf
Binary file not shown.
Binary file modified Assets/fa-solid-900.ttf
Binary file not shown.
48 changes: 41 additions & 7 deletions Classes/Enums/Awesome.swift

Large diffs are not rendered by default.

350 changes: 337 additions & 13 deletions Classes/Enums/AwesomePro.swift

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Generator/Sources/Generator/EnumBuilder.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import Foundation

func buildEnum (_ name: String, from styles: [String: [Icon]]) -> String {
let formatter = DateFormatter()
formatter.dateFormat = "dd/MM/yyyy HH:mm"
let formatter = DateFormatter()
formatter.dateFormat = "dd/MM/yyyy HH:mm"

var content = ""
content += "//\n// \(name).swift\n// AwesomeEnum\n//\n// Originally created by Ondrej Rafaj on 13/10/2017.\n"
content += "// Copyright © 2017 manGoweb UK. All rights reserved.\n//\n"
content += "// This file has been auto-generated on \(formatter.string(from: Date())).\n\nimport Foundation\n\npublic struct \(name) {\n"
content += "// This file has been auto-generated on \(formatter.string(from: Date())).\n\nimport Foundation\n\npublic struct \(name) {\n"

for (var style, list) in styles {
if style == "brands" { style = "brand" }
if style == "brands" { style = "brand" }

content += "\n public enum \(style): String, Amazing {\n"
var names = [String]()
for icon in list {
Expand All @@ -20,12 +20,12 @@ func buildEnum (_ name: String, from styles: [String: [Icon]]) -> String {
if Int(name.prefix(1)) != nil { name = "fa\(name)" }
names.append(name)

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

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

Expand Down
143 changes: 71 additions & 72 deletions Generator/Sources/Generator/StringExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,79 +1,78 @@
import Foundation

extension Substring {
func firstUppercased() -> Substring {
return prefix(1).uppercased() + dropFirst()
}
func firstUppercased() -> Substring {
return prefix(1).uppercased() + dropFirst()
}
}

extension String {

func firstUppercased() -> String {
return prefix(1).uppercased() + dropFirst()
}

var isKeyword: Bool {
switch self {
case
"associativity",
"break",
"case",
"catch",
"class",
"continue",
"convenience",
"default",
"deinit",
"didSet",
"do",
"else",
"enum",
"extension",
"fallthrough",
"false",
"final",
"for",
"func",
"get",
"guard",
"if",
"in",
"infix",
"init",
"inout",
"internal",
"lazy",
"let",
"mutating",
"nil",
"operator",
"override",
"postfix",
"precedence",
"prefix",
"private",
"public",
"repeat",
"required",
"return",
"self",
"set",
"static",
"struct",
"subscript",
"super",
"switch",
"throws",
"true",
"try",
"var",
"weak",
"where",
"while",
"willSet":
return true
default:
return false
}
}
func firstUppercased() -> String {
return prefix(1).uppercased() + dropFirst()
}

var isKeyword: Bool {
switch self {
case
"associativity",
"break",
"case",
"catch",
"class",
"continue",
"convenience",
"default",
"deinit",
"didSet",
"do",
"else",
"enum",
"extension",
"fallthrough",
"false",
"final",
"for",
"func",
"get",
"guard",
"if",
"in",
"infix",
"init",
"inout",
"internal",
"lazy",
"let",
"mutating",
"nil",
"operator",
"override",
"postfix",
"precedence",
"prefix",
"private",
"public",
"repeat",
"required",
"return",
"self",
"set",
"static",
"struct",
"subscript",
"super",
"switch",
"throws",
"true",
"try",
"var",
"weak",
"where",
"while",
"willSet":
return true
default:
return false
}
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Awesome

[![Font Awesome](https://img.shields.io/badge/Font%20Awesome-5.1.0-brightgreen.svg)](https://fontawesome.com/v5.1.0/icons)
[![Font Awesome](https://img.shields.io/badge/Font%20Awesome-5.2.0-brightgreen.svg)](https://fontawesome.com/v5.2.0/icons)
[![Slack](https://img.shields.io/badge/join-slack-745EAF.svg?style=flat)](http://bit.ly/2B0dEyt)
[![Version](https://img.shields.io/cocoapods/v/AwesomeEnum.svg?style=flat)](http://cocoapods.org/pods/AwesomeEnum)
[![License](https://img.shields.io/cocoapods/l/AwesomeEnum.svg?style=flat)](http://cocoapods.org/pods/AwesomeEnum)
Expand Down Expand Up @@ -57,7 +57,7 @@ let attributedText = Awesome.regular.envelopeOpen.asAttributedText(fontSize: 17,
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:

```swift
// AppDelegate application(:didFinishLaunchingWithOptions:)
// AppDelegate application(_:didFinishLaunchingWithOptions:)

// Load all fonts
AwesomePro.loadFonts(from: Bundle.main)
Expand Down

0 comments on commit e716102

Please sign in to comment.