Skip to content

Commit 8863e36

Browse files
committed
Add docs
1 parent 38aa445 commit 8863e36

6 files changed

Lines changed: 66 additions & 20 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,14 @@ func accessoryBar(@ViewBuilder content: () -> some View) -> some View
212212
/// Control the visibility of the list reorder controls. Untested.
213213
func listReorderControlVisibility(_ visibility: ListAccessoryVisibility) -> some View
214214
```
215+
216+
#### Form initializers
217+
218+
```swift
219+
public extension Form {
220+
/// Add a footer to a form.
221+
static func withFooter<C: View, F: View>(@ViewBuilder content: () -> C, @ViewBuilder footer: () -> F) -> some View {
222+
Form<FormFooterContent<C, F>>(content: content, footer: footer)
223+
}
224+
}
225+
```

Sources/SwiftUIHidden/App+open.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import SwiftUI
99

1010
public enum AppActions {
11+
/// Open SwiftUI Settings.
1112
public static func openSettings() {
1213
if #available(macOS 14.0, *) {
1314
EnvironmentValues().openSettings()
@@ -18,30 +19,36 @@ public enum AppActions {
1819
}
1920
}
2021

22+
/// Open a SwiftUI Window.
2123
@available(macOS 13.0, *)
2224
public static func openWindow(id: String) {
2325
EnvironmentValues().openWindow(id: id)
2426
}
2527

28+
/// Open a SwiftUI Window.
2629
@available(macOS 13.0, *)
2730
public static func openWindow<Value: Codable & Hashable>(id: String, value: Value) {
2831
EnvironmentValues().openWindow(id: id, value: value)
2932
}
3033

34+
/// Open a SwiftUI Window.
3135
@available(macOS 13.0, *)
3236
public static func openWindow<Value: Codable & Hashable>(value: Value) {
3337
EnvironmentValues().openWindow(value: value)
3438
}
3539

40+
/// Open a SwiftUI Document.
3641
@available(macOS 13.0, *)
3742
public static func openDocument(at url: URL) async throws {
3843
try await EnvironmentValues().openDocument(at: url)
3944
}
4045

46+
/// Open an URL.
4147
public static func openURL(_ url: URL) {
4248
EnvironmentValues().openURL(url)
4349
}
4450

51+
/// Open an URL.
4552
public static func openURL(_ url: URL) async -> Bool {
4653
await withCheckedContinuation {
4754
EnvironmentValues().openURL(url, completion: $0.resume(returning:))

Sources/SwiftUIHidden/Environment+extensions.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public struct WithCurrentWindowAction {
2424
public struct HiddenEnvironmentValues {
2525
let environment: EnvironmentValues
2626

27+
/// Open SwiftUI Settings.
2728
public var openSettings: () -> Void {
2829
if #available(macOS 14.0, *) {
2930
environment.openSettings.callAsFunction
@@ -38,6 +39,7 @@ public struct HiddenEnvironmentValues {
3839
}
3940
}
4041

42+
/// Access the current window.
4143
public var withCurrentWindow: WithCurrentWindowAction {
4244
.init(action: environment.withCurrentWindow)
4345
}

Sources/SwiftUIHidden/Form+init.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import SwiftUI
99

1010
public extension Form {
11+
/// Add a footer to a form.
1112
static func withFooter<C: View, F: View>(@ViewBuilder content: () -> C, @ViewBuilder footer: () -> F) -> some View {
1213
Form<FormFooterContent<C, F>>(content: content, footer: footer)
1314
}

Sources/SwiftUIHidden/Scene+extensions.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ public extension Scene {
1616
public struct HiddenSceneModifier<S: Scene> {
1717
let content: S
1818

19+
/// Customize the window background. Use `.clear` for a transparent window, use `.*Material` for a blurred background
1920
public func windowBackground(_ shape: some ShapeStyle) -> some Scene {
2021
content.windowBackground(shape)
2122
}
2223

24+
/// Disable automatic window opening behavior..
25+
/// For example, when set to `.hidden`, launching the app or clicking the app icon won't create a new window of that scene.
26+
/// Note that previously created windows may reappear.
2327
public func defaultVisibility(_ visibility: Visibility) -> some Scene {
2428
content.defaultVisibility(visibility)
2529
}
2630

31+
/// Determine if a window should be closed when the user tries to close the window.
32+
/// Returning `true` will close the window, `false` will keep the window open.
2733
public func windowShouldClose(_ perform: @escaping () -> Bool) -> some Scene {
2834
content.windowShouldClose(perform)
2935
}

Sources/SwiftUIHidden/View+extensions.swift

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,66 +42,81 @@ public enum ListAccessoryVisibility {
4242
public struct HiddenViewModifier<Content: View> {
4343
let content: Content
4444

45+
/// Apply a variable blur overlay to a view.
46+
public func variableBlur(maxRadius: CGFloat, mask: Image, opaque: Bool) -> some View {
47+
content.variableBlur(maxRadius: maxRadius, mask: mask, opaque: opaque)
48+
}
49+
50+
/// Change the toolbar behavior when the window is fullscreen.
51+
/// `.showsWithWindow` is the default behavior. `.showsWithMenuBar` will hide the toolbar when fullscreen.
4552
public func fullScreenToolbarBehavior(_ behavior: FullScreenToolbarBehavior) -> some View {
4653
content.fullScreenToolbarBehavior(behavior.toOriginal)
4754
}
4855

56+
/// Get a trigger when a row has been selected by the user, and gets clicked again.
57+
/// This differs from a TapGesture, as there is no time limit between the clicks.
58+
public func onReselect(enabled: Bool, perform: (() -> ())?) -> some View {
59+
content.onReselect(isEnabled: enabled, perform: perform)
60+
}
61+
62+
/// Adjust the padding around a Form with FormStyle `.grouped`
4963
public func formInsets(_ edges: Edge.Set, _ value: CGFloat) -> some View {
5064
content.formInsets(edges, value)
5165
}
5266

67+
/// Adjust the padding around a Form with FormStyle `.grouped`
5368
public func formInsets(_ edges: Edge.Set, _ value: EdgeInsets) -> some View {
5469
content.formInsets(edges, value)
5570
}
5671

57-
public func onReselect(enabled: Bool, perform: (() -> ())?) -> some View {
58-
content.onReselect(isEnabled: enabled, perform: perform)
72+
/// Adjust the inset of an individual row in a Form with FormStyle `.grouped`
73+
public func formRowInsets(_ insets: EdgeInsets?) -> some View {
74+
content.formRowInsets(insets)
5975
}
6076

61-
public func variableBlur(maxRadius: CGFloat, mask: Image, opaque: Bool) -> some View {
62-
content.variableBlur(maxRadius: maxRadius, mask: mask, opaque: opaque)
77+
/// Set the indentation level of a Form row.
78+
public func formRowIndentationLevel(_ level: Int?) -> some View {
79+
content.formRowIndentationLevel(level)
6380
}
6481

82+
/// Change the background color of a Form.
6583
public func formBackground<S: ShapeStyle>(_ shape: S?) -> some View {
6684
content.formBackground(shape)
6785
}
6886

87+
/// Change the background color of an individual row in a Form.
6988
public func formRowBackground<S: ShapeStyle>(_ shape: S?) -> some View {
7089
content.formRowBackground(shape)
7190
}
7291

73-
public func formInfoAction(action: @escaping () -> Void) -> some View {
74-
content.formInfoAction(action: action)
75-
}
76-
92+
/// Change the background color of a section.
7793
public func sectionBackground(_ visibility: Visibility) -> some View {
7894
content.sectionBackground(visibility)
7995
}
8096

81-
public func formRowInfoVisibility(_ visibility: Visibility) -> some View {
82-
content.formRowInfoVisibility(visibility)
97+
/// Add a trailing info icon to a Form row.
98+
/// As an example, see system bluetooth settings.
99+
public func formInfoAction(action: @escaping () -> Void) -> some View {
100+
content.formInfoAction(action: action)
83101
}
84102

85-
public func formRowIndentationLevel(_ level: Int?) -> some View {
86-
content.formRowIndentationLevel(level)
103+
/// Change the visibility of the trailing info icon in a Form row.
104+
public func formRowInfoVisibility(_ visibility: Visibility) -> some View {
105+
content.formRowInfoVisibility(visibility)
87106
}
88107

108+
/// Add a trailing Form row view, which becomes visible when hovered over the row.
109+
/// As an example, see system wifi settings.
89110
public func formAccessory(@ViewBuilder accessories: () -> some View) -> some View {
90111
content.formAccessory(accessories: accessories)
91112
}
92113

93-
public func formRowInsets(_ insets: EdgeInsets?) -> some View {
94-
content.formRowInsets(insets)
95-
}
96-
114+
/// Change the visibility of the trailing Form row view.
97115
public func formAccessoryVisibility(_ visibility: Visibility) -> some View {
98116
content.formAccessoryVisibility(visibility)
99117
}
100118

101-
public func listReorderControlVisibility(_ visibility: ListAccessoryVisibility) -> some View {
102-
content.listReorderControlVisibility(visibility.toOriginal)
103-
}
104-
119+
/// Add a bottom row to a Form.
105120
public func bottomBar(@ViewBuilder content: () -> some View) -> some View {
106121
self.content.bottomBar(content: content)
107122
}
@@ -111,4 +126,8 @@ public struct HiddenViewModifier<Content: View> {
111126
self.content.accessoryBar(content: content)
112127
}
113128

129+
/// Control the visibility of the list reorder controls. Untested.
130+
public func listReorderControlVisibility(_ visibility: ListAccessoryVisibility) -> some View {
131+
content.listReorderControlVisibility(visibility.toOriginal)
132+
}
114133
}

0 commit comments

Comments
 (0)