forked from LoopKit/LoopKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSectionHeader.swift
More file actions
50 lines (41 loc) · 1.14 KB
/
SectionHeader.swift
File metadata and controls
50 lines (41 loc) · 1.14 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
//
// SectionHeader.swift
// LoopKitUI
//
// Created by Nathaniel Hamming on 2020-02-20.
// Copyright © 2020 LoopKit Authors. All rights reserved.
//
import SwiftUI
public struct SectionHeader: View {
var label: String
var style: Style
public enum Style {
case regular
case tight
}
public init(label: String, style: Style = .default) {
self.label = label
self.style = style
}
public var body: some View {
// iOS 14 puts section headers in all-caps by default. This un-does that.
content.textCase(nil)
}
@ViewBuilder private var content: some View {
Text(label)
.font(.headline)
.foregroundColor(.primary)
.padding(.leading, style == .tight ? -10 : 0)
}
}
fileprivate struct HorizontalSizeClassOverrideHelper: HorizontalSizeClassOverride {}
public extension SectionHeader.Style {
static let `default`: SectionHeader.Style = {
return .regular
}()
}
struct SectionHeader_Previews: PreviewProvider {
static var previews: some View {
SectionHeader(label: "Header Label")
}
}