aboutsummaryrefslogtreecommitdiff
path: root/Map/Business/Stage.swift
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-07-05 11:29:17 +0200
committerRuben Beltran del Rio <git@r.bdr.sh>2025-07-05 11:29:17 +0200
commitcb4a713afc81326485becba4fa3a635f112114d4 (patch)
treee3efea48ccb7be53ed681eb9ed333af39d93ce67 /Map/Business/Stage.swift
parente21ead77ffdff206d1ae17e5ce93ea34c4227414 (diff)
Add custom stages
Diffstat (limited to 'Map/Business/Stage.swift')
-rw-r--r--Map/Business/Stage.swift107
1 files changed, 78 insertions, 29 deletions
diff --git a/Map/Business/Stage.swift b/Map/Business/Stage.swift
index 4a1b834..fcbdb62 100644
--- a/Map/Business/Stage.swift
+++ b/Map/Business/Stage.swift
@@ -14,12 +14,13 @@
// along with this program. If not, see https://map.tranquil.systems.
import SwiftUI
-struct Stage {
- let i: String
- let ii: String
- let iii: String
- let iv: String
+struct Stage: Codable {
+ var i: String
+ var ii: String
+ var iii: String
+ var iv: String
+
static func stages(_ type: StageType) -> Stage {
switch type {
case .general:
@@ -124,56 +125,72 @@ struct Stage {
return Stage(
i: "Uncertain when to use", ii: "Learning when to use", iii: "Learning through use",
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 }) {
+ return customStage.stage
+ }
+ return stages(.behavior) // fallback
}
}
+
- static func title(_ type: StageType) -> LocalizedStringKey {
+
+ static func title(_ type: StageType) -> String {
switch type {
case .general:
- return "Activities"
+ return String(localized: "stage_type.general")
case .practice:
- return "Practice"
+ return String(localized: "stage_type.practice")
case .data:
- return "Data"
+ return String(localized: "stage_type.data")
case .knowledge:
- return "Knowledge"
+ return String(localized: "stage_type.knowledge")
case .ubiquity:
- return "Ubiquity"
+ return String(localized: "stage_type.ubiquity")
case .certainty:
- return "Certainty"
+ return String(localized: "stage_type.certainty")
case .publicationTypes:
- return "Publication Types"
+ return String(localized: "stage_type.publication_types")
case .market:
- return "Market"
+ return String(localized: "stage_type.market")
case .knowledgeManagement:
- return "Knowledge Management"
+ return String(localized: "stage_type.knowledge_management")
case .marketPerception:
- return "Market Perception"
+ return String(localized: "stage_type.market_perception")
case .userPerception:
- return "User Perception"
+ return String(localized: "stage_type.user_perception")
case .perceptionInIndustry:
- return "Perception In Industry"
+ return String(localized: "stage_type.perception_in_industry")
case .focusOfValue:
- return "Focus Of Value"
+ return String(localized: "stage_type.focus_of_value")
case .understanding:
- return "Understanding"
+ return String(localized: "stage_type.understanding")
case .comparison:
- return "Comparison"
+ return String(localized: "stage_type.comparison")
case .failure:
- return "Failure"
+ return String(localized: "stage_type.failure")
case .marketAction:
- return "Market Action"
+ return String(localized: "stage_type.market_action")
case .efficiency:
- return "Efficiency"
+ return String(localized: "stage_type.efficiency")
case .decisionDrivers:
- return "Decision Drivers"
+ return String(localized: "stage_type.decision_drivers")
case .behavior:
- return "Behavior"
+ 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 }) {
+ return customStage.name
+ }
+ return String(localized: "stage_type.behavior") // fallback
}
}
}
-enum StageType: String, CaseIterable, Identifiable {
+enum StageType: Identifiable, Equatable {
case general
case practice
case data
@@ -197,8 +214,33 @@ enum StageType: String, CaseIterable, Identifiable {
case decisionDrivers
case behavior
+ case custom(UUID)
- var id: String { self.rawValue }
+ var id: String {
+ switch self {
+ case .general: return "general"
+ case .practice: return "practice"
+ case .data: return "data"
+ case .knowledge: return "knowledge"
+ case .ubiquity: return "ubiquity"
+ case .certainty: return "certainty"
+ case .publicationTypes: return "publicationTypes"
+ case .market: return "market"
+ case .knowledgeManagement: return "knowledgeManagement"
+ case .marketPerception: return "marketPerception"
+ case .userPerception: return "userPerception"
+ case .perceptionInIndustry: return "perceptionInIndustry"
+ case .focusOfValue: return "focusOfValue"
+ case .understanding: return "understanding"
+ case .comparison: return "comparison"
+ case .failure: return "failure"
+ case .marketAction: return "marketAction"
+ case .efficiency: return "efficiency"
+ case .decisionDrivers: return "decisionDrivers"
+ case .behavior: return "behavior"
+ case .custom(let uuid): return uuid.uuidString.lowercased()
+ }
+ }
static let types: [StageType] = [.general, .practice, .data, .knowledge]
static let characteristics: [StageType] = [.ubiquity, .certainty, .publicationTypes]
@@ -207,5 +249,12 @@ enum StageType: String, CaseIterable, Identifiable {
.perceptionInIndustry, .focusOfValue, .understanding, .comparison, .failure,
.marketAction, .efficiency, .decisionDrivers,
]
- static let custom: [StageType] = [.behavior]
+
+ static var customStages: [StageType] {
+ if let customStagesData = UserDefaults.standard.data(forKey: "customStages"),
+ let customStagesList = try? JSONDecoder().decode([CustomStage].self, from: customStagesData) {
+ return customStagesList.map { .custom($0.id) }
+ }
+ return []
+ }
}