aboutsummaryrefslogtreecommitdiff
path: root/Map/Business/Stage.swift
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-07-06 12:45:37 +0200
committerRuben Beltran del Rio <git@r.bdr.sh>2025-07-06 12:45:37 +0200
commit54f89bcd1a7fb0b92b65d8c0ea3847d635e11133 (patch)
treeda6c1e3f015c4b21a2e32854cadb09e71f9079e7 /Map/Business/Stage.swift
parent3cd8f1f7200109d505b5e105d5ebe53f0c93d337 (diff)
Allow adding and removing templates
Diffstat (limited to 'Map/Business/Stage.swift')
-rw-r--r--Map/Business/Stage.swift26
1 files changed, 14 insertions, 12 deletions
diff --git a/Map/Business/Stage.swift b/Map/Business/Stage.swift
index fcbdb62..4b98ecc 100644
--- a/Map/Business/Stage.swift
+++ b/Map/Business/Stage.swift
@@ -20,7 +20,6 @@ struct Stage: Codable {
var iii: String
var iv: String
-
static func stages(_ type: StageType) -> Stage {
switch type {
case .general:
@@ -127,15 +126,15 @@ struct Stage: Codable {
iv: "Known / common usage")
case .custom(let uuid):
if let customStagesData = UserDefaults.standard.data(forKey: "customStages"),
- let customStagesList = try? JSONDecoder().decode([CustomStage].self, from: customStagesData),
- let customStage = customStagesList.first(where: { $0.id == uuid }) {
+ let customStagesList = try? JSONDecoder().decode(
+ [CustomStage].self, from: customStagesData),
+ let customStage = customStagesList.first(where: { $0.id == uuid })
+ {
return customStage.stage
}
- return stages(.behavior) // fallback
+ return stages(.behavior) // fallback
}
}
-
-
static func title(_ type: StageType) -> String {
switch type {
@@ -181,11 +180,13 @@ struct Stage: Codable {
return String(localized: "stage_type.behavior")
case .custom(let uuid):
if let customStagesData = UserDefaults.standard.data(forKey: "customStages"),
- let customStagesList = try? JSONDecoder().decode([CustomStage].self, from: customStagesData),
- let customStage = customStagesList.first(where: { $0.id == uuid }) {
+ let customStagesList = try? JSONDecoder().decode(
+ [CustomStage].self, from: customStagesData),
+ let customStage = customStagesList.first(where: { $0.id == uuid })
+ {
return customStage.name
}
- return String(localized: "stage_type.behavior") // fallback
+ return String(localized: "stage_type.behavior") // fallback
}
}
}
@@ -216,7 +217,7 @@ enum StageType: Identifiable, Equatable {
case behavior
case custom(UUID)
- var id: String {
+ var id: String {
switch self {
case .general: return "general"
case .practice: return "practice"
@@ -249,10 +250,11 @@ enum StageType: Identifiable, Equatable {
.perceptionInIndustry, .focusOfValue, .understanding, .comparison, .failure,
.marketAction, .efficiency, .decisionDrivers,
]
-
+
static var customStages: [StageType] {
if let customStagesData = UserDefaults.standard.data(forKey: "customStages"),
- let customStagesList = try? JSONDecoder().decode([CustomStage].self, from: customStagesData) {
+ let customStagesList = try? JSONDecoder().decode([CustomStage].self, from: customStagesData)
+ {
return customStagesList.map { .custom($0.id) }
}
return []