File tree Expand file tree Collapse file tree 7 files changed +98
-72
lines changed Expand file tree Collapse file tree 7 files changed +98
-72
lines changed Original file line number Diff line number Diff line change @@ -104,17 +104,7 @@ struct CardData: View {
104
104
}
105
105
106
106
private func rebootContent( value: Int ) -> some View {
107
- var formattedLastRestart : String {
108
- if value >= 1440 { // 1440 minutes in a day
109
- let days = value / 1440
110
- return " \( days) \( Constants . General. daysAgo) "
111
- } else if value >= 60 { // More than an hour
112
- let hours = value / 60
113
- return " \( hours) \( Constants . General. hours) "
114
- } else { // Less than an hour
115
- return " \( value) \( Constants . General. minutes) "
116
- }
117
- }
107
+ let formattedLastRestart = formattedRebootContent ( value: value)
118
108
return Text ( formattedLastRestart)
119
109
. foregroundColor ( colorForLastRestart ( value: value) )
120
110
. font ( . system( size: fontSize ?? 14 ) )
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ enum Constants {
36
36
37
37
enum General {
38
38
static let days = String ( localized: " General.Days " , defaultValue: " Days " , comment: " Number of days " )
39
+ static let dayAgo = String ( localized: " General.DayAgo " , defaultValue: " Day Ago " , comment: " Number of day ago " )
39
40
static let daysAgo = String ( localized: " General.DaysAgo " , defaultValue: " Days Ago " , comment: " Number of days ago " )
40
41
static let hours = String ( localized: " General.Hours " , defaultValue: " Hours " , comment: " Number of hours " )
41
42
static let hour = String ( localized: " General.Hour " , defaultValue: " Hour " , comment: " Number of hour " )
Original file line number Diff line number Diff line change @@ -198,6 +198,30 @@ class IPAddressMonitor {
198
198
}
199
199
}
200
200
201
+ func formattedRebootContent( value: Int ) -> String {
202
+ var formattedLastRestart : String {
203
+ if value >= 1440 { // 1440 minutes in a day
204
+ let days = value / 1440
205
+ if days == 1 {
206
+ return " \( days) \( Constants . General. dayAgo) "
207
+ }
208
+ return " \( days) \( Constants . General. daysAgo) "
209
+ } else if value >= 60 { // More than an hour
210
+ let hours = value / 60
211
+ if hours == 1 {
212
+ return " \( hours) \( Constants . General. hour) "
213
+ }
214
+ return " \( hours) \( Constants . General. hours) "
215
+ } else { // Less than an hour
216
+ if value == 1 {
217
+ return " \( value) \( Constants . General. minute) "
218
+ }
219
+ return " \( value) \( Constants . General. minutes) "
220
+ }
221
+ }
222
+ return formattedLastRestart
223
+ }
224
+
201
225
class LastRebootMonitor {
202
226
static let shared = LastRebootMonitor ( )
203
227
private var updateHandler : ( ( Int ) -> Void ) ?
Original file line number Diff line number Diff line change 2040
2040
}
2041
2041
}
2042
2042
},
2043
+ "General.DayAgo" : {
2044
+ "comment" : "Number of day ago",
2045
+ "extractionState" : "extracted_with_value",
2046
+ "localizations" : {
2047
+ "de" : {
2048
+ "stringUnit" : {
2049
+ "state" : "translated",
2050
+ "value" : "tag zuvor"
2051
+ }
2052
+ },
2053
+ "en" : {
2054
+ "stringUnit" : {
2055
+ "state" : "new",
2056
+ "value" : "Day Ago"
2057
+ }
2058
+ },
2059
+ "fr" : {
2060
+ "stringUnit" : {
2061
+ "state" : "translated",
2062
+ "value" : "jour avant"
2063
+ }
2064
+ },
2065
+ "ja" : {
2066
+ "stringUnit" : {
2067
+ "state" : "translated",
2068
+ "value" : "日前"
2069
+ }
2070
+ },
2071
+ "nb" : {
2072
+ "stringUnit" : {
2073
+ "state" : "translated",
2074
+ "value" : "dag siden"
2075
+ }
2076
+ },
2077
+ "sv" : {
2078
+ "stringUnit" : {
2079
+ "state" : "translated",
2080
+ "value" : "dag sedan"
2081
+ }
2082
+ }
2083
+ }
2084
+ },
2043
2085
"General.Days" : {
2044
2086
"comment" : "Number of days",
2045
2087
"extractionState" : "manual",
2046
2088
"localizations" : {
2047
2089
"de" : {
2048
2090
"stringUnit" : {
2049
2091
"state" : "translated",
2050
- "value" : "Tage "
2092
+ "value" : "tage "
2051
2093
}
2052
2094
},
2053
2095
"en" : {
2059
2101
"fr" : {
2060
2102
"stringUnit" : {
2061
2103
"state" : "translated",
2062
- "value" : "Jours "
2104
+ "value" : "jours "
2063
2105
}
2064
2106
},
2065
2107
"ja" : {
2071
2113
"nb" : {
2072
2114
"stringUnit" : {
2073
2115
"state" : "translated",
2074
- "value" : "Dager "
2116
+ "value" : "dager "
2075
2117
}
2076
2118
},
2077
2119
"sv" : {
2089
2131
"de" : {
2090
2132
"stringUnit" : {
2091
2133
"state" : "translated",
2092
- "value" : "Vor Tagen "
2134
+ "value" : "vor tagen "
2093
2135
}
2094
2136
},
2095
2137
"en" : {
2101
2143
"fr" : {
2102
2144
"stringUnit" : {
2103
2145
"state" : "translated",
2104
- "value" : "Jours avant"
2146
+ "value" : "jours avant"
2105
2147
}
2106
2148
},
2107
2149
"ja" : {
2173
2215
"de" : {
2174
2216
"stringUnit" : {
2175
2217
"state" : "translated",
2176
- "value" : "Stunde "
2218
+ "value" : "stunde "
2177
2219
}
2178
2220
},
2179
2221
"en" : {
2185
2227
"fr" : {
2186
2228
"stringUnit" : {
2187
2229
"state" : "translated",
2188
- "value" : "Heure "
2230
+ "value" : "heure "
2189
2231
}
2190
2232
},
2191
2233
"ja" : {
2197
2239
"nb" : {
2198
2240
"stringUnit" : {
2199
2241
"state" : "translated",
2200
- "value" : "Time "
2242
+ "value" : "time "
2201
2243
}
2202
2244
},
2203
2245
"sv" : {
2204
2246
"stringUnit" : {
2205
2247
"state" : "translated",
2206
- "value" : "Timme "
2248
+ "value" : "timme "
2207
2249
}
2208
2250
}
2209
2251
}
2215
2257
"de" : {
2216
2258
"stringUnit" : {
2217
2259
"state" : "translated",
2218
- "value" : "Stunden "
2260
+ "value" : "stunden "
2219
2261
}
2220
2262
},
2221
2263
"en" : {
2227
2269
"fr" : {
2228
2270
"stringUnit" : {
2229
2271
"state" : "translated",
2230
- "value" : "Heures "
2272
+ "value" : "heures "
2231
2273
}
2232
2274
},
2233
2275
"ja" : {
2239
2281
"nb" : {
2240
2282
"stringUnit" : {
2241
2283
"state" : "translated",
2242
- "value" : "Timer "
2284
+ "value" : "timer "
2243
2285
}
2244
2286
},
2245
2287
"sv" : {
2246
2288
"stringUnit" : {
2247
2289
"state" : "translated",
2248
- "value" : "Timmar "
2290
+ "value" : "timmar "
2249
2291
}
2250
2292
}
2251
2293
}
2299
2341
"de" : {
2300
2342
"stringUnit" : {
2301
2343
"state" : "translated",
2302
- "value" : "Minuten "
2344
+ "value" : "minuten "
2303
2345
}
2304
2346
},
2305
2347
"en" : {
2317
2359
"nb" : {
2318
2360
"stringUnit" : {
2319
2361
"state" : "translated",
2320
- "value" : "Minutt "
2362
+ "value" : "minutt "
2321
2363
}
2322
2364
},
2323
2365
"sv" : {
2324
2366
"stringUnit" : {
2325
2367
"state" : "translated",
2326
- "value" : "Minut "
2368
+ "value" : "minut "
2327
2369
}
2328
2370
}
2329
2371
}
2335
2377
"de" : {
2336
2378
"stringUnit" : {
2337
2379
"state" : "translated",
2338
- "value" : "Minuten "
2380
+ "value" : "minuten "
2339
2381
}
2340
2382
},
2341
2383
"en" : {
2353
2395
"nb" : {
2354
2396
"stringUnit" : {
2355
2397
"state" : "translated",
2356
- "value" : "Minutter "
2398
+ "value" : "minutter "
2357
2399
}
2358
2400
},
2359
2401
"sv" : {
2371
2413
"de" : {
2372
2414
"stringUnit" : {
2373
2415
"state" : "translated",
2374
- "value" : "Sekunde "
2416
+ "value" : "sekunde "
2375
2417
}
2376
2418
},
2377
2419
"en" : {
2383
2425
"fr" : {
2384
2426
"stringUnit" : {
2385
2427
"state" : "translated",
2386
- "value" : "Seconde "
2428
+ "value" : "seconde "
2387
2429
}
2388
2430
},
2389
2431
"ja" : {
2395
2437
"nb" : {
2396
2438
"stringUnit" : {
2397
2439
"state" : "translated",
2398
- "value" : "Sekund "
2440
+ "value" : "sekund "
2399
2441
}
2400
2442
},
2401
2443
"sv" : {
2402
2444
"stringUnit" : {
2403
2445
"state" : "translated",
2404
- "value" : "Sekund "
2446
+ "value" : "sekund "
2405
2447
}
2406
2448
}
2407
2449
}
2413
2455
"de" : {
2414
2456
"stringUnit" : {
2415
2457
"state" : "translated",
2416
- "value" : "Sekunden "
2458
+ "value" : "sekunden "
2417
2459
}
2418
2460
},
2419
2461
"en" : {
2425
2467
"fr" : {
2426
2468
"stringUnit" : {
2427
2469
"state" : "translated",
2428
- "value" : "Secondes "
2470
+ "value" : "secondes "
2429
2471
}
2430
2472
},
2431
2473
"ja" : {
2437
2479
"nb" : {
2438
2480
"stringUnit" : {
2439
2481
"state" : "translated",
2440
- "value" : "Sekunder "
2482
+ "value" : "sekunder "
2441
2483
}
2442
2484
},
2443
2485
"sv" : {
2444
2486
"stringUnit" : {
2445
2487
"state" : "translated",
2446
- "value" : "Sekunder "
2488
+ "value" : "sekunder "
2447
2489
}
2448
2490
}
2449
2491
}
Original file line number Diff line number Diff line change @@ -149,19 +149,8 @@ struct LastRestartRow: View {
149
149
let value : Int // Days since last restart
150
150
let colorScheme : ColorScheme
151
151
152
- private var formattedLastRestart : String {
153
- if value >= 1440 { // 1440 minutes in a day
154
- let days = value / 1440
155
- return " \( days) \( Constants . General. daysAgo) "
156
- } else if value >= 60 { // More than an hour
157
- let hours = value / 60
158
- return " \( hours) \( Constants . General. hours) "
159
- } else { // Less than an hour
160
- return " \( value) \( Constants . General. minutes) "
161
- }
162
- }
163
-
164
152
var body : some View {
153
+ let formattedLastRestart = formattedRebootContent ( value: value)
165
154
let color = colorForLastRestart ( value: value)
166
155
167
156
HStack {
Original file line number Diff line number Diff line change @@ -351,19 +351,9 @@ struct LastRestartRowTransparent: View {
351
351
let value : Int // Days since last restart
352
352
let fontSize : CGFloat
353
353
354
- private var formattedLastRestart : String {
355
- if value >= 1440 { // 1440 minutes in a day
356
- let days = value / 1440
357
- return " \( days) \( Constants . General. daysAgo) "
358
- } else if value >= 60 { // More than an hour
359
- let hours = value / 60
360
- return " \( hours) \( Constants . General. hours) "
361
- } else { // Less than an hour
362
- return " \( value) \( Constants . General. minutes) "
363
- }
364
- }
365
-
366
354
var body : some View {
355
+ let formattedLastRestart = formattedRebootContent ( value: value)
356
+
367
357
HStack {
368
358
Text ( label)
369
359
. font ( . system( size: fontSize) )
Original file line number Diff line number Diff line change @@ -139,18 +139,8 @@ struct SupportCompanionCLI {
139
139
let lastReboot = getLastRestartMinutes ( ) ?? 0
140
140
let osVersion = getOSVersion ( )
141
141
let osBuild = getOSBuild ( )
142
+ let formattedLastRestart = formattedRebootContent ( value: lastReboot)
142
143
143
- var formattedLastRestart : String {
144
- if lastReboot >= 1440 { // 1440 minutes in a day
145
- let days = lastReboot / 1440
146
- return " \( days) \( Constants . General. daysAgo) "
147
- } else if lastReboot >= 60 { // More than an hour
148
- let hours = lastReboot / 60
149
- return " \( hours) \( Constants . General. hours) "
150
- } else { // Less than an hour
151
- return " \( lastReboot) \( Constants . General. minutes) "
152
- }
153
- }
154
144
155
145
print ( """
156
146
💻 Device Information
You can’t perform that action at this time.
0 commit comments