Skip to content

Commit

Permalink
Added mac os.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvorobei committed Jan 25, 2022
1 parent dc97372 commit 7d88744
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ let package = Package(
name: "SFSymbols",
defaultLocalization: "en",
platforms: [
.iOS(.v13), .watchOS(.v6), .tvOS(.v13)
.iOS(.v13),
.watchOS(.v6),
.tvOS(.v13),
.macOS(.v11)
],
products: [
.library(
Expand Down
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,24 @@ If you prefer not to use any of dependency managers, you can integrate manually.

## Usage

To create image:
### SwiftUI

To create an image:

```swift
Image(.trash.circle)
```

With a font:

```swift
Image(.plus)
.font(.body)
```

### UIKit

To create an image:

```swift
let image = UIImage(.trash.circle)
Expand All @@ -36,6 +53,20 @@ If need with specific font, use this:
let image = UIImage(.plus, font: UIFont.preferredFont(forTextStyle: .body))
```

### AppKit

To create an image:

```swift
let image = NSImage(.trash.circle)
```

If need with specific font, use this:

```swift
let image = NSImage(.plus, font: UIFont.preferredFont(forTextStyle: .body))
```

## Russian Community

Я веду [телеграм-канал](https://sparrowcode.io/telegram), там публикую новости и туториалы.<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,44 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.


#if canImport(SwiftUI)
import SwiftUI

extension Image {

/**
SFSymbols: Create `SFSymbols` image by symbol.

- parameter symbol: Symbol.
*/
public init(_ symbol: SFSymbol) {
self.init(systemName: symbol.name)
}
}
#endif

#if canImport(AppKit)
import AppKit

extension NSImage {

#if targetEnvironment(macCatalyst)

#else
/**
SFSymbols: Create `SFSymbols` image by symbol.

- parameter symbol: Symbol.
*/
public convenience init(_ symbol: SFSymbol) {
self.init(systemSymbolName: symbol.name, accessibilityDescription: nil)!
}
#endif
}
#endif

#if canImport(UIKit)
import UIKit

extension UIImage {
Expand All @@ -32,7 +70,7 @@ extension UIImage {
public convenience init(_ symbol: SFSymbol) {
self.init(systemName: symbol.name)!
}

/**
SFSymbols: Create `SFSymbols` image by symbol with specific configuration.

Expand All @@ -45,9 +83,9 @@ extension UIImage {
let configuration = UIImage.SymbolConfiguration(pointSize: pointSize, weight: weight)
self.init(systemName: symbol.name, withConfiguration: configuration)!
}

/**
SparrowKit: Create `SFSymbols` image by symbol with specific configuration.
SFSymbols: Create `SFSymbols` image by symbol with specific configuration.

- parameter symbol: Symbol.
- parameter font: Font of image.
Expand All @@ -58,3 +96,4 @@ extension UIImage {
self.init(systemName: symbol.name, withConfiguration: configuration)!
}
}
#endif
2 changes: 0 additions & 2 deletions Sources/SFSymbols/SFSymbol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import UIKit

open class SFSymbol {

public let name: String
Expand Down

0 comments on commit 7d88744

Please sign in to comment.