Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced the APIs' rawValues with proper names. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ For macOS, you only need to declare fonts path, copy below to `Info.plist`
To find which icon name is for which style, consult [fontawesome.com website](https://fontawesome.com/icons?s=brands)

```swift
Text(AwesomeIcon.aws.rawValue)
Text(AwesomeIcon.aws.icon)
.font(.awesome(style: .brand, size: 20))
.foregroundColor(.white)
```
Expand Down
4 changes: 2 additions & 2 deletions Sources/FontAwesomeSwiftUI/FontAwesome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ public struct FontAwesome {
public static func register() {
let register = FontRegister()
FontStyle.allCases.forEach {
register.register(fontName: $0.rawValue)
register.register(fontName: $0.name)
}
}
}

@available(iOS 13.0, OSX 10.15, *)
public extension SwiftUI.Font {
static func awesome(style: FontStyle, size: CGFloat) -> SwiftUI.Font {
return SwiftUI.Font.custom(style.rawValue, size: size)
return SwiftUI.Font.custom(style.name, size: size)
}
}
4 changes: 4 additions & 0 deletions Sources/FontAwesomeSwiftUI/FontStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public enum FontStyle: String, CaseIterable {
case regular = "FontAwesome5Free-Regular"
case solid = "FontAwesome5Free-Solid"

public var name: String {
return self.rawValue
}

public var familyName: String {
switch self {
case .brand:
Expand Down
6 changes: 6 additions & 0 deletions Sources/FontAwesomeSwiftUI/Icon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1412,3 +1412,9 @@ public enum AwesomeIcon: String, CaseIterable {
case youtubeSquare = "youtube-square"
case zhihu = "zhihu"
}

extension AwesomeIcon {
public var icon: String {
return self.rawValue
}
}