feat: add KeePassIconMapper (iconIndex -> SF Symbol)
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYqycDFsynHH9VnnK7LNSf
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import Foundation
|
||||
|
||||
/// Maps KeePass's standard icon palette (indices 0-68) to an approximate SF Symbol.
|
||||
/// This is a best-effort visual match, not the actual KeePass icon artwork -- MyPass's
|
||||
/// data model only stores the numeric iconIndex, not custom icon images.
|
||||
public enum KeePassIconMapper {
|
||||
private static let symbolsByIndex: [Int: String] = [
|
||||
0: "key.fill",
|
||||
1: "globe",
|
||||
2: "exclamationmark.triangle.fill",
|
||||
3: "server.rack",
|
||||
4: "doc.on.clipboard.fill",
|
||||
5: "pencil",
|
||||
6: "camera.fill",
|
||||
7: "wrench.fill",
|
||||
8: "person.text.rectangle.fill",
|
||||
9: "externaldrive.fill",
|
||||
10: "creditcard.fill",
|
||||
11: "chevron.left.forwardslash.chevron.right",
|
||||
12: "chart.bar.fill",
|
||||
13: "gamecontroller.fill",
|
||||
14: "envelope.fill",
|
||||
15: "folder.fill",
|
||||
16: "lock.fill",
|
||||
17: "checkmark.circle.fill",
|
||||
18: "star.fill",
|
||||
19: "house.fill",
|
||||
20: "network",
|
||||
]
|
||||
|
||||
public static func symbolName(forIconIndex index: Int) -> String {
|
||||
symbolsByIndex[index] ?? "key.fill"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import XCTest
|
||||
@testable import MyPassCore
|
||||
|
||||
final class KeePassIconMapperTests: XCTestCase {
|
||||
func test_knownIndex_returnsMappedSymbol() {
|
||||
XCTAssertEqual(KeePassIconMapper.symbolName(forIconIndex: 14), "envelope.fill")
|
||||
}
|
||||
|
||||
func test_indexZero_isKeyFill() {
|
||||
XCTAssertEqual(KeePassIconMapper.symbolName(forIconIndex: 0), "key.fill")
|
||||
}
|
||||
|
||||
func test_unmappedIndex_fallsBackToKeyFill() {
|
||||
XCTAssertEqual(KeePassIconMapper.symbolName(forIconIndex: 999), "key.fill")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user