forked from LoopKit/LoopKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLabeledValueView.swift
More file actions
39 lines (33 loc) · 1008 Bytes
/
LabeledValueView.swift
File metadata and controls
39 lines (33 loc) · 1008 Bytes
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
//
// LabeledValueView.swift
// LoopKitUI
//
// Created by Nathaniel Hamming on 2020-02-20.
// Copyright © 2020 LoopKit Authors. All rights reserved.
//
import SwiftUI
public struct LabeledValueView: View {
public static let NoValueString: String = "–"
var label: String
var value: String?
var highlightValue: Bool
public init(label: String, value: String?, highlightValue: Bool = false) {
self.label = label
self.value = value
self.highlightValue = highlightValue
}
public var body: some View {
HStack {
Text(label)
.foregroundColor(.primary)
Spacer()
Text(value ?? LabeledValueView.NoValueString)
.foregroundColor(highlightValue ? .accentColor : .secondary)
}
}
}
struct LabeledValueView_Previews: PreviewProvider {
static var previews: some View {
LabeledValueView(label: "Glucose", value: "80 mg/dL", highlightValue: true)
}
}