This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Icon: String, CaseIterable { | |
case bag = "\u{e807}" | |
case bank = "\u{e808}" | |
case batteryout = "\u{e809}" | |
case battery = "\u{e80a}" | |
case bike = "\u{e80b}" | |
case bulb = "\u{e80c}" | |
case calendar = "\u{e80d}" | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IconView: UIView { | |
var icon: Icon | |
var color: UIColor | |
private let label: UILabel = { | |
let font = UIFont.iconFont(ofSize: 500) | |
let label = UILabel() | |
label.font = font | |
label.adjustsFontSizeToFitWidth = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Icon { | |
func callAsFunction(color: UIColor = .black) -> IconView { | |
IconView(icon: self, color: color) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IconView: UIView { | |
/// Change the icon being displayed | |
var icon: Icon { | |
didSet { | |
label.text = icon.rawValue | |
} | |
} | |
/// Change the color of the icon being displayed | |
var color: UIColor { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
"name": "alert", | |
"char": "🔔" | |
}, | |
{ | |
"name": "car", | |
"char": "🚘" | |
}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Icon { | |
case alert | |
case car | |
case person | |
... | |
} | |
extension Icon { | |
var stringValue: String? { | |
let items = JSONDecoder().decode([IconDescription], from: json) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IconView: UIView { | |
private func setupAccessibility() { | |
label.isAccessibilityElement = false | |
isAccessibilityElement = false | |
shouldGroupAccessibilityChildren = true | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guard let jsonString = UserDefaults.shared.string(forKey: .splashAnimation), | |
let data = jsonString.data(using: .utf8), | |
let animation = try? JSONDecoder().decode(Animation.self, from: data) else { return } | |
animationView = AnimationView(animation: animation) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
"startDate": "YYYY-MM-dd", | |
"endDate": "YYYY-MM-dd", | |
"animation": { ... } | |
}, | |
{ | |
"startDate": "YYYY-MM-dd", | |
"endDate": "YYYY-MM-dd", | |
"animation": { ... } | |
}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func createSnapshot(from icon: Icon) -> UIImage { | |
// Create view and add as subview on the window | |
let window: UIWindow = UIApplication.shared.keyWindow ?? UIWindow() | |
let iconView = IconView(icon: icon) | |
window.addSubview(iconView) | |
// Set a default size for all the snapshots | |
iconView.frame = CGRect(origin: .zero, size: dataImageStorageSize) | |
// Take a snapshot |