some fixes
This commit is contained in:
76
Cable/LoadConfigurationStatus.swift
Normal file
76
Cable/LoadConfigurationStatus.swift
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
enum LoadConfigurationStatus: Identifiable, Equatable {
|
||||||
|
case missingDetails(count: Int)
|
||||||
|
|
||||||
|
var id: String {
|
||||||
|
switch self {
|
||||||
|
case .missingDetails(let count):
|
||||||
|
return "missing-details-\(count)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var symbol: String {
|
||||||
|
switch self {
|
||||||
|
case .missingDetails:
|
||||||
|
return "exclamationmark.triangle.fill"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var tint: Color {
|
||||||
|
switch self {
|
||||||
|
case .missingDetails:
|
||||||
|
return .orange
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var bannerText: String {
|
||||||
|
switch self {
|
||||||
|
case .missingDetails:
|
||||||
|
return NSLocalizedString(
|
||||||
|
"loads.overview.status.missing_details.banner",
|
||||||
|
bundle: .main,
|
||||||
|
value: "Finish configuring your loads",
|
||||||
|
comment: "Short banner text describing loads that need additional details"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func detailInfo() -> LoadStatusDetail {
|
||||||
|
switch self {
|
||||||
|
case .missingDetails(let count):
|
||||||
|
let title = NSLocalizedString(
|
||||||
|
"loads.overview.status.missing_details.title",
|
||||||
|
bundle: .main,
|
||||||
|
value: "Missing load details",
|
||||||
|
comment: "Alert title when loads are missing required details"
|
||||||
|
)
|
||||||
|
let format = NSLocalizedString(
|
||||||
|
"loads.overview.status.missing_details.message",
|
||||||
|
bundle: .main,
|
||||||
|
value: "Enter cable length and wire size for %d %@ to see accurate recommendations.",
|
||||||
|
comment: "Alert message when loads are missing required details"
|
||||||
|
)
|
||||||
|
let loadWord = count == 1
|
||||||
|
? NSLocalizedString(
|
||||||
|
"loads.overview.status.missing_details.singular",
|
||||||
|
bundle: .main,
|
||||||
|
value: "load",
|
||||||
|
comment: "Singular noun for load"
|
||||||
|
)
|
||||||
|
: NSLocalizedString(
|
||||||
|
"loads.overview.status.missing_details.plural",
|
||||||
|
bundle: .main,
|
||||||
|
value: "loads",
|
||||||
|
comment: "Plural noun for loads"
|
||||||
|
)
|
||||||
|
let message = String(format: format, count, loadWord)
|
||||||
|
return LoadStatusDetail(title: title, message: message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct LoadStatusDetail {
|
||||||
|
let title: String
|
||||||
|
let message: String
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user