LegacyWatchCompatibility.swift
1.23 KB
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
import Foundation
import SwiftUI
enum HRVStatus: String, Codable {
case fullOfEnergy = "活力满满"
case normal = "状态正常"
case overpressure = "压力过载"
}
struct HRVData: Codable {
var value: Double?
var hrvBaseline: Double?
var date: Date?
var status: HRVStatus? {
guard let value else { return nil }
guard let hrvBaseline, hrvBaseline > 0 else { return .normal }
let ratio = value / hrvBaseline
if ratio >= 1.05 { return .fullOfEnergy }
if ratio < 0.9 { return .overpressure }
return .normal
}
}
struct UserInfo: Codable {
var id: Int?
var pairId: Int?
var isPaired: Bool {
pairId != nil
}
}
extension WatchThemeModel {
var isDefaultTheme: Bool? {
isOfficial.map { $0 == 1 }
}
func hrvStatusThumnailImageURL(hrvStatus: HRVStatus) -> String? {
switch hrvStatus {
case .fullOfEnergy:
return energeticImageURL
case .normal:
return normalImageURL
case .overpressure:
return stressfulImageURL
}
}
}
extension Text {
func wenyiheiFont(size: CGFloat) -> Text {
font(.custom("WenYue-XinQingNianTi-NC-W8", size: size))
}
}