forked from github/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingsLink.swift
More file actions
64 lines (59 loc) · 1.42 KB
/
SettingsLink.swift
File metadata and controls
64 lines (59 loc) · 1.42 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
import SwiftUI
struct SettingsLink: View {
let url: URL
let title: String
let subtitle: String?
let badge: BadgeItem?
init(
_ url: URL,
title: String,
subtitle: String? = nil,
badge: BadgeItem? = nil
) {
self.url = url
self.title = title
self.subtitle = subtitle
self.badge = badge
}
init(
url: String,
title: String,
subtitle: String? = nil,
badge: BadgeItem? = nil
) {
self.init(
URL(string: url)!,
title: title,
subtitle: subtitle,
badge: badge
)
}
var body: some View {
Link(destination: url) {
VStack(alignment: .leading) {
HStack{
Text(title).font(.body)
if let badge = self.badge {
Badge(badgeItem: badge)
}
}
if let subtitle = subtitle {
Text(subtitle)
.font(.footnote)
}
}
Spacer()
Image(systemName: "chevron.right")
}
.foregroundStyle(.primary)
.padding(10)
}
}
#Preview {
SettingsLink(
url: "https://example.com",
title: "Example",
subtitle: "This is an example",
badge: .init(text: "Not Granted", level: .danger)
)
}