Refine trends and debug harness; clean up warnings
This commit is contained in:
+22
-3
@@ -9,6 +9,9 @@
|
||||
|
||||
import Foundation
|
||||
import Security
|
||||
#if canImport(AppIntents)
|
||||
import AppIntents
|
||||
#endif
|
||||
import SwiftUI
|
||||
|
||||
// MARK: - Fuel types
|
||||
@@ -59,6 +62,18 @@ enum RAGRating: Int, Codable {
|
||||
}
|
||||
|
||||
enum FuelType: String, Codable, CaseIterable, Identifiable {
|
||||
#if canImport(AppIntents)
|
||||
typealias DisplayRepresentation = AppIntents.DisplayRepresentation
|
||||
typealias TypeDisplayRepresentation = AppIntents.TypeDisplayRepresentation
|
||||
|
||||
static var typeDisplayRepresentation: TypeDisplayRepresentation = "Fuel"
|
||||
|
||||
static var caseDisplayRepresentations: [FuelType: DisplayRepresentation] = [
|
||||
.e10: "Unleaded",
|
||||
.e5: "Premium",
|
||||
.diesel: "Diesel",
|
||||
]
|
||||
#endif
|
||||
case e10 // Unleaded (E10)
|
||||
case e5 // Premium (E5)
|
||||
case diesel // B7 diesel
|
||||
@@ -74,6 +89,10 @@ enum FuelType: String, Codable, CaseIterable, Identifiable {
|
||||
}
|
||||
}
|
||||
|
||||
#if canImport(AppIntents)
|
||||
extension FuelType: AppEnum {}
|
||||
#endif
|
||||
|
||||
/// Display unit for all distances in the app + widget. Internally distances
|
||||
/// are always stored/computed in km; conversion happens at the display and
|
||||
/// filter boundary so nothing else needs to know the unit.
|
||||
@@ -516,7 +535,7 @@ struct FuelStore {
|
||||
let whole = tenths / 1000
|
||||
let major = (tenths % 1000) / 10
|
||||
let minor = tenths % 10
|
||||
let main = Text(String(format: "£%d.%02d", whole, major))
|
||||
let amount = Text(String(format: "£%d.%02d", whole, major))
|
||||
.font(base)
|
||||
.foregroundColor(color)
|
||||
let sup = Text(String(superscriptDigits[minor]))
|
||||
@@ -526,7 +545,7 @@ struct FuelStore {
|
||||
let perL = Text("/L")
|
||||
.font(.system(size: size * 0.5, weight: .regular).monospaced())
|
||||
.foregroundColor(color.opacity(0.55))
|
||||
return main + sup + perL
|
||||
return Text("\(amount)\(sup)\(perL)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -825,7 +844,7 @@ struct FuelStore {
|
||||
// MARK: Low-level keychain helpers
|
||||
|
||||
private static func keychainData(service: String) -> Data? {
|
||||
var query: [String: Any] = [
|
||||
let query: [String: Any] = [
|
||||
kSecClass as String: kSecClassGenericPassword,
|
||||
kSecAttrService as String: service,
|
||||
kSecReturnData as String: true,
|
||||
|
||||
Reference in New Issue
Block a user