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 configureAccessibility() { | |
isAccessibilityElement = true | |
let deleteAction = UIAccessibilityCustomAction( | |
name: "delete", | |
target: self, | |
selector: #selector(didTouchDeleteListAction) | |
) | |
let selectAction = UIAccessibilityCustomAction( | |
name: "select", | |
target: self, |
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
final class IconsDataTests: XCTestCase { | |
func test_icons_shouldHaveExpectedHash() { | |
guard recordMode == false else { | |
recordReferenceHashes() | |
return | |
} | |
let storedObjects = storage.toredIconsHashes() // [IconData] | |
Icon.allCases.forEach { icon in | |
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 record(file: [IconData]) throws { | |
// Create the JSON | |
let data = try JSONEncoder().encode(file) | |
let json = try convertToFormattedJSON(data: data) | |
// Get the file path | |
let referenceFileURL = try getReferenceFilePath() | |
// Write file | |
try json.write(to: referenceFileURL, atomically: false, encoding: .utf8) |
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
private func getReferenceFilePath() throws -> URL { | |
let fileURL = URL(fileURLWithPath: #file, isDirectory: false) | |
let referenceFileDirectotyURL = fileURL | |
.deletingLastPathComponent().deletingLastPathComponent() | |
.appendingPathComponent("ReferenceFolder") | |
let referenceFileURL = referenceFileDirectotyURL | |
.appendingPathComponent("referenceFile") | |
.appendingPathExtension("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
struct ItemData: Codable { | |
let name: String | |
let hash: String | |
} |
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 createHash(from image: UIImage) -> String { | |
let data = image.pngData() | |
let hash = SHA256.createHashString(data: data) | |
return hash | |
} |
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 |
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
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
class IconView: UIView { | |
private func setupAccessibility() { | |
label.isAccessibilityElement = false | |
isAccessibilityElement = false | |
shouldGroupAccessibilityChildren = true | |
} | |
} |