-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathAdaptiveHelpLink.swift
More file actions
29 lines (26 loc) · 973 Bytes
/
AdaptiveHelpLink.swift
File metadata and controls
29 lines (26 loc) · 973 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
import SwiftUI
/// A small adaptive help link button that uses the native `HelpLink` on macOS 14+
/// and falls back to a styled question-mark button on earlier versions.
public struct AdaptiveHelpLink: View {
let action: () -> Void
var controlSize: ControlSize = .small
public init(controlSize: ControlSize = .small, action: @escaping () -> Void) {
self.controlSize = controlSize
self.action = action
}
public var body: some View {
Group {
if #available(macOS 14.0, *) {
HelpLink(action: action)
} else {
Button(action: action) {
Image(systemName: "questionmark")
}
.clipShape(Circle())
.shadow(color: .black.opacity(0.05), radius: 0, x: 0, y: 0)
.shadow(color: .black.opacity(0.3), radius: 1.25, x: 0, y: 0.5)
}
}
.controlSize(controlSize)
}
}