1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
// Copyright (C) 2024 Rubén Beltrán del Río
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see https://map.tranquil.systems.
import SwiftUI
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:
return Stage(
i: String(localized: "stage_type.general.stage_i"),
ii: String(localized: "stage_type.general.stage_ii"),
iii: String(localized: "stage_type.general.stage_iii"),
iv: String(localized: "stage_type.general.stage_iv"))
case .practice:
return Stage(
i: String(localized: "stage_type.practice.stage_i"),
ii: String(localized: "stage_type.practice.stage_ii"),
iii: String(localized: "stage_type.practice.stage_iii"),
iv: String(localized: "stage_type.practice.stage_iv"))
case .data:
return Stage(
i: String(localized: "stage_type.data.stage_i"),
ii: String(localized: "stage_type.data.stage_ii"),
iii: String(localized: "stage_type.data.stage_iii"),
iv: String(localized: "stage_type.data.stage_iv"))
case .knowledge:
return Stage(
i: String(localized: "stage_type.knowledge.stage_i"),
ii: String(localized: "stage_type.knowledge.stage_ii"),
iii: String(localized: "stage_type.knowledge.stage_iii"),
iv: String(localized: "stage_type.knowledge.stage_iv"))
case .ubiquity:
return Stage(
i: String(localized: "stage_type.ubiquity.stage_i"),
ii: String(localized: "stage_type.ubiquity.stage_ii"),
iii: String(localized: "stage_type.ubiquity.stage_iii"),
iv: String(localized: "stage_type.ubiquity.stage_iv"))
case .certainty:
return Stage(
i: String(localized: "stage_type.certainty.stage_i"),
ii: String(localized: "stage_type.certainty.stage_ii"),
iii: String(localized: "stage_type.certainty.stage_iii"),
iv: String(localized: "stage_type.certainty.stage_iv"))
case .publicationTypes:
return Stage(
i:
String(localized: "stage_type.publication_types.stage_i"),
ii:
String(localized: "stage_type.publication_types.stage_ii"),
iii:
String(localized: "stage_type.publication_types.stage_iii"),
iv: String(localized: "stage_type.publication_types.stage_iv"))
case .market:
return Stage(
i: String(localized: "stage_type.market.stage_i"),
ii: String(localized: "stage_type.market.stage_ii"),
iii: String(localized: "stage_type.market.stage_iii"),
iv: String(localized: "stage_type.market.stage_iv"))
case .knowledgeManagement:
return Stage(
i: String(localized: "stage_type.knowledge_management.stage_i"),
ii: String(localized: "stage_type.knowledge_management.stage_ii"),
iii: String(localized: "stage_type.knowledge_management.stage_iii"),
iv: String(localized: "stage_type.knowledge_management.stage_iv"))
case .marketPerception:
return Stage(
i: String(localized: "stage_type.market_perception.stage_i"),
ii: String(localized: "stage_type.market_perception.stage_ii"),
iii: String(localized: "stage_type.market_perception.stage_iii"),
iv: String(localized: "stage_type.market_perception.stage_iv"))
case .userPerception:
return Stage(
i: String(localized: "stage_type.user_perception.stage_i"),
ii: String(localized: "stage_type.user_perception.stage_ii"),
iii: String(localized: "stage_type.user_perception.stage_iii"),
iv: String(localized: "stage_type.user_perception.stage_iv"))
case .perceptionInIndustry:
return Stage(
i: String(localized: "stage_type.perception_in_industry.stage_i"),
ii: String(localized: "stage_type.perception_in_industry.stage_ii"),
iii: String(localized: "stage_type.perception_in_industry.stage_iii"),
iv: String(localized: "stage_type.perception_in_industry.stage_iv"))
case .focusOfValue:
return Stage(
i: String(localized: "stage_type.focus_of_value.stage_i"),
ii: String(localized: "stage_type.focus_of_value.stage_ii"),
iii:
String(localized: "stage_type.focus_of_value.stage_iii"),
iv:
String(localized: "stage_type.focus_of_value.stage_iv")
)
case .understanding:
return Stage(
i: String(localized: "stage_type.understanding.stage_i"),
ii: String(localized: "stage_type.understanding.stage_ii"),
iii: String(localized: "stage_type.understanding.stage_iii"),
iv: String(localized: "stage_type.understanding.stage_iv"))
case .comparison:
return Stage(
i: String(localized: "stage_type.comparison.stage_i"),
ii: String(localized: "stage_type.comparison.stage_ii"),
iii: String(localized: "stage_type.comparison.stage_iii"),
iv: String(localized: "stage_type.comparison.stage_iv"))
case .failure:
return Stage(
i: String(localized: "stage_type.failure.stage_i"),
ii: String(localized: "stage_type.failure.stage_ii"),
iii:
String(localized: "stage_type.failure.stage_iii"),
iv: String(localized: "stage_type.failure.stage_iv"))
case .marketAction:
return Stage(
i: String(localized: "stage_type.market_action.stage_i"),
ii: String(localized: "stage_type.market_action.stage_ii"),
iii: String(localized: "stage_type.market_action.stage_iii"),
iv: String(localized: "stage_type.market_action.stage_iv"))
case .efficiency:
return Stage(
i: String(localized: "stage_type.efficiency.stage_i"),
ii: String(localized: "stage_type.efficiency.stage_ii"),
iii: String(localized: "stage_type.efficiency.stage_iii"),
iv: String(localized: "stage_type.efficiency.stage_iv"))
case .decisionDrivers:
return Stage(
i: String(localized: "stage_type.decision_drivers.stage_i"),
ii: String(localized: "stage_type.decision_drivers.stage_ii"),
iii: String(localized: "stage_type.decision_drivers.stage_iii"),
iv: String(localized: "stage_type.decision_drivers.stage_iv"))
case .behavior:
return Stage(
i: String(localized: "stage_type.behavior.stage_i"),
ii: String(localized: "stage_type.behavior.stage_ii"),
iii: String(localized: "stage_type.behavior.stage_iii"),
iv: String(localized: "stage_type.behavior.stage_iv"))
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) -> String {
switch type {
case .general:
return String(localized: "stage_type.general")
case .practice:
return String(localized: "stage_type.practice")
case .data:
return String(localized: "stage_type.data")
case .knowledge:
return String(localized: "stage_type.knowledge")
case .ubiquity:
return String(localized: "stage_type.ubiquity")
case .certainty:
return String(localized: "stage_type.certainty")
case .publicationTypes:
return String(localized: "stage_type.publication_types")
case .market:
return String(localized: "stage_type.market")
case .knowledgeManagement:
return String(localized: "stage_type.knowledge_management")
case .marketPerception:
return String(localized: "stage_type.market_perception")
case .userPerception:
return String(localized: "stage_type.user_perception")
case .perceptionInIndustry:
return String(localized: "stage_type.perception_in_industry")
case .focusOfValue:
return String(localized: "stage_type.focus_of_value")
case .understanding:
return String(localized: "stage_type.understanding")
case .comparison:
return String(localized: "stage_type.comparison")
case .failure:
return String(localized: "stage_type.failure")
case .marketAction:
return String(localized: "stage_type.market_action")
case .efficiency:
return String(localized: "stage_type.efficiency")
case .decisionDrivers:
return String(localized: "stage_type.decision_drivers")
case .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: Identifiable, Equatable {
case general
case practice
case data
case knowledge
case ubiquity
case certainty
case publicationTypes
case market
case knowledgeManagement
case marketPerception
case userPerception
case perceptionInIndustry
case focusOfValue
case understanding
case comparison
case failure
case marketAction
case efficiency
case decisionDrivers
case behavior
case custom(UUID)
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]
static let properties: [StageType] = [
.market, .knowledgeManagement, .marketPerception, .userPerception,
.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)
{
return customStagesList.map { .custom($0.id) }
}
return []
}
}
|