Skip to content

Commit 2172d01

Browse files
committed
Clean.
1 parent 1c52d93 commit 2172d01

4 files changed

Lines changed: 74 additions & 18 deletions

File tree

README.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
Generate settings icons by Apple's SF Symbols.
44

5-
```swift
6-
let image = UIImage.generateSettingsIcon("bell.fill", backgroundColor: .systemBlue)
7-
```
8-
95
<p float="left">
106
<img src="https://cdn.ivanvorobei.by/github/sppermissions/permissions/notifications.png" width="38">
117
<img src="https://cdn.ivanvorobei.by/github/sppermissions/permissions/location.png" width="38">
@@ -20,6 +16,15 @@ let image = UIImage.generateSettingsIcon("bell.fill", backgroundColor: .systemBl
2016

2117
For safe using SFSymbols see [SPSafeSymbols](https://github.com/sparrowcode/SPSafeSymbols) library.
2218

19+
- [Installation](#installation)
20+
- [Swift Package Manager](#swift-package-manager)
21+
- [CocoaPods](#cocoapods)
22+
- [Manually](#manually)
23+
- [Usage](#usage)
24+
- [UIKit](#uikit)
25+
- [SwiftUI](#swiftui)
26+
- [AppKit](#appkit)
27+
2328
## Installation
2429

2530
Ready for use on iOS 13+.
@@ -47,3 +52,23 @@ pod 'SPSettingsIcons'
4752
### Manually
4853

4954
If you prefer not to use any of dependency managers, you can integrate manually. Put `Sources/SPSettingsIcons` folder in your Xcode project. Make sure to enable `Copy items if needed` and `Create groups`.
55+
56+
## Usage
57+
58+
### UIKit
59+
60+
```swift
61+
let image = UIImage.generateSettingsIcon("bell.fill", backgroundColor: .systemBlue)
62+
```
63+
64+
### SwiftUI
65+
66+
```swift
67+
68+
```
69+
70+
### AppKit
71+
72+
```swift
73+
74+
```

Sources/SPSettingsIcons/Image+Extension.swift renamed to Sources/SPSettingsIcons/ImageExtension.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
// SOFTWARE.
2121

22+
#if canImport(SwiftUI)
2223
import SwiftUI
2324

2425
extension Image {
25-
26+
2627
/// Apply settings style for Image
2728
///
2829
/// Example:
@@ -35,19 +36,22 @@ extension Image {
3536
.modifier(SettingsImageModifier())
3637
.foregroundColor(color)
3738
}
38-
3939
}
4040

4141
struct SettingsImageModifier: ViewModifier {
42-
42+
43+
private static var iconFontSize: CGFloat = 16
44+
private static var backgroundFontSize: CGFloat = 32
45+
private static var backgroundSystemName: String = "app.fill"
46+
4347
func body(content: Content) -> some View {
4448
ZStack {
45-
Image(systemName: "app.fill")
46-
.font(.system(size: 32))
49+
Image(systemName: SettingsImageModifier.backgroundSystemName)
50+
.font(.system(size: SettingsImageModifier.backgroundFontSize))
4751
content
48-
.font(.system(size: 16))
52+
.font(.system(size: SettingsImageModifier.iconFontSize))
4953
.foregroundColor(.white)
5054
}
5155
}
52-
5356
}
57+
#endif

Sources/SPSettingsIcons/SPSettingsIcons.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
// SOFTWARE.
2121

22+
#if canImport(UIKit)
2223
import UIKit
2324

2425
class SPSettingsIconImage {
@@ -55,10 +56,4 @@ class SPSettingsIconImage {
5556
return settingsImage
5657
}
5758
}
58-
59-
extension UIImage {
60-
61-
public static func generateSettingsIcon(_ systemName: String, backgroundColor: UIColor) -> UIImage? {
62-
return SPSettingsIconImage.generate(systemName: systemName, backgroundColor: backgroundColor)
63-
}
64-
}
59+
#endif
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// The MIT License (MIT)
2+
// Copyright © 2022 Ivan Vorobei (hello@ivanvorobei.by)
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in all
12+
// copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
// SOFTWARE.
21+
22+
#if canImport(UIKit)
23+
import UIKit
24+
25+
extension UIImage {
26+
27+
public static func generateSettingsIcon(_ systemName: String, backgroundColor: UIColor) -> UIImage? {
28+
return SPSettingsIconImage.generate(systemName: systemName, backgroundColor: backgroundColor)
29+
}
30+
}
31+
#endif
32+

0 commit comments

Comments
 (0)