Files
iOS/Sources/Shared/Common/Extensions/INImage+MaterialDesignIcons.swift
Zac West 640cca884b Add SwiftFormat to project (#1463)
Adds new fastlane lanes:
- `fastlane lint` which checks the linters
- `fastlane autocorrect` which applies the linters which can autocorrect (Rubocop, SwiftFormat)

Adds a build step to the Codegen abstract target which runs SwiftFormat in lint mode, pointing out what it's going to change when run.

Applies SwiftFormat to nearly all code -- exempts a few externally-sourced files and generated code.
2021-02-05 22:06:25 -08:00

30 lines
706 B
Swift

import Foundation
import Intents
public extension INImage {
#if os(iOS)
convenience init(
icon: MaterialDesignIcons,
foreground: UIColor,
background: UIColor
) {
MaterialDesignIcons.register()
let iconRect = CGRect(x: 0, y: 0, width: 64, height: 64)
let iconData = UIKit.UIGraphicsImageRenderer(size: iconRect.size).pngData { _ in
let imageRect = iconRect.insetBy(dx: 8, dy: 8)
background.set()
UIRectFill(iconRect)
icon
.image(ofSize: imageRect.size, color: foreground)
.draw(in: imageRect)
}
self.init(imageData: iconData)
}
#endif
}