DFSingleStressHomeView.swift 1.48 KB
//
//  File.swift
//  iwatch
//
//  Created by 权海 on 2026/6/15.
//

import SwiftUI

struct DFSingleStressHomeView: View {
    var kind: DFWatchStressKind = .overloaded
    var value: String? = "38ms"
    var sampleTime: String = "16:06"
    
    private var valueDesc: String{
        if let value{
            return kind.title + "·" + value
        }
        return "等待数据"
    }

    var body: some View {
            ZStack(alignment: .top) {
                LinearGradient(
                    colors: [kind.color.opacity(0.3), kind.color.opacity(0)],
                    startPoint: .top,
                    endPoint: .bottom
                )
                .frame(width: .infinity, height: .infinity)
                VStack(spacing: 8){
                    DFWatchFigmaHeader(subtitle: "HRV")
                        .padding(.top, 16)
                    HStack{}
                        .frame(width: 78, height: 78)
                        .background(Color(hex: "#FF0000"))
                    Text(valueDesc)
                        .font(.system(size: 16, weight: .semibold))
                        .foregroundStyle(value == nil ? Color(hex: "#B0B0B6") : kind.color)
                    DFWatchFigmaSegmentBar(selected: kind)
                        .frame(height: 14)
                    Text(sampleTime)
                        .font(.system(size: 12))
                        .foregroundStyle(.white)
                }.padding(.horizontal, value == nil ? 30 : 22)
            }
    }
}