DFWatchFigmaHomeViews.swift
2.51 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import SwiftUI
struct DFDefaultWatchHomeView: View {
@State private var weekday: String = ""
@State private var day: String = ""
var hasData: Bool = false
var hrvValue: String = "38ms"
var hrvTime: String = "19:04"
var body: some View {
VStack{
HStack{
Spacer()
Text(weekday)
.font(.system(size: 16, weight: .medium))
.foregroundColor(DFWatchFigmaColor.purple)
Spacer().frame(width: 4)
Text(day)
.font(.system(size: 16, weight: .medium))
.foregroundColor(.white)
}
Text(.now, style: .time)
.font(.system(size: 52, weight: .medium))
.foregroundColor(.white)
.frame(height: 50)
HStack(alignment: .center){
HStack{}
.frame(width: 44, height: 44)
.background(Color(hex: "#FF0000"))
Spacer().frame(width: 14)
VStack(alignment: .leading, spacing: 0) {
Text(hasData ? "状态优秀" : "暂无数据")
.font(.system(size: 16, weight: .semibold))
.foregroundColor(hasData ? DFWatchFigmaColor.green : DFWatchFigmaColor.grayText)
Text(hasData ? "\(hrvValue)·\(hrvTime)" : "--ms·--:--")
.font(.system(size: 12, weight: .medium))
.foregroundColor(.white)
DFWatchFigmaSegmentBar(selected: nil)
.frame(height: 14)
}
}
HStack{
DFWatchHeartBeatCircle(progress: 0, value: nil)
.frame(width: 45, height: 44)
Spacer()
DFWatchCloseCircle(outerProgress: 0, middleProgress: 0, innerProgress: 0)
.frame(width: 44, height: 44)
Spacer()
DFWatchStepCountCircle(progress: 0, value: 0)
.frame(width: 44, height: 44)
}
}
.padding(.all, 15)
.onAppear {
updateDate()
}
}
private func updateDate(){
let calendar = Calendar.current
let component = calendar.component(.weekday, from: .now)
weekday = calendar.shortWeekdaySymbols[component].uppercased()
let formatter = DateFormatter()
formatter.dateFormat = "dd"
day = formatter.string(from: .now)
}
}