Skip to content

Commit 0a6d4d8

Browse files
committed
Add navigation split view settings window design option
1 parent ea2047b commit 0a6d4d8

File tree

28 files changed

+1047
-115
lines changed

28 files changed

+1047
-115
lines changed

Documentation/Reference/SettingsKit/enums/TabType.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ public enum TabType
99
The type of a settings tab or subtab.
1010

1111
## Cases
12-
### `new(label:)`
12+
### `new(title:icon:)`
1313

1414
```swift
15-
case new(label: Label<Text, Image>)
15+
case new(title: String, icon: SFSymbol)
1616
```
1717

1818
A new settings tab or subtab with a label.

Documentation/Reference/SettingsKit/extensions/Scene.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ extension Scene
66
```
77

88
## Methods
9-
### `settings(symbolVariant:_:)`
9+
### `settings(design:symbolVariant:_:)`
1010

1111
```swift
1212
public func settings(
13+
design: SettingsWindowDesign = .default,
1314
symbolVariant: SymbolVariants = .none,
1415
@ArrayBuilder<SettingsTab> _ settings: () -> [SettingsTab]
1516
) -> some Scene

Documentation/Reference/SettingsKit/structs/SettingsKitScene.md

+32
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,42 @@ var symbolVariant: SymbolVariants
4949

5050
Modify the way symbols are displayed.
5151

52+
### `design`
53+
54+
```swift
55+
var design: SettingsWindowDesign
56+
```
57+
58+
The design of the settings window.
59+
60+
### `search`
61+
62+
```swift
63+
@State private var search = ""
64+
```
65+
66+
The filter in the sidebar design.
67+
5268
### `body`
5369

5470
```swift
5571
var body: some Scene
5672
```
5773

5874
The scene.
75+
76+
### `navigationView`
77+
78+
```swift
79+
private var navigationView: some View
80+
```
81+
82+
The view with the sidebar design.
83+
84+
### `tabView`
85+
86+
```swift
87+
private var tabView: some View
88+
```
89+
90+
The view with the tab design.

Documentation/Reference/SettingsKit/structs/SettingsSubtab.md

+21-23
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ public var content: any View
3333

3434
The tab's view.
3535

36+
### `color`
37+
38+
```swift
39+
public var color: Color
40+
```
41+
42+
The tab's color.
43+
3644
### `standard`
3745

3846
```swift
@@ -58,43 +66,33 @@ public var label: Label<Text, Image>?
5866

5967
The label of a custom tab, or else nil.
6068

61-
## Methods
62-
### `init(_:id:content:)`
69+
### `sidebarLabel`
6370

6471
```swift
65-
public init(_ type: TabType, id: String, @ViewBuilder content: () -> any View)
72+
@ViewBuilder public var sidebarLabel: some View
6673
```
6774

68-
The initializer.
69-
- Parameters:
70-
- type: The tab type of the settings subtab.
71-
- id: The identifier.
72-
- content: The content of the settings subtab.
75+
The label for the sidebar style.
7376

74-
#### Parameters
75-
76-
| Name | Description |
77-
| ---- | ----------- |
78-
| type | The tab type of the settings subtab. |
79-
| id | The identifier. |
80-
| content | The content of the settings subtab. |
81-
82-
### `init(_:id:content:)`
77+
## Methods
78+
### `init(_:id:color:content:)`
8379

8480
```swift
85-
public init(_ label: Label<Text, Image>, id: String, @ViewBuilder content: () -> any View)
81+
public init(_ type: TabType, id: String, color: Color = .blue, @ViewBuilder content: () -> any View)
8682
```
8783

88-
An initializer for a custom settings subtab.
84+
The initializer.
8985
- Parameters:
90-
- label: The label of the custom settings subtab.
86+
- type: The tab type of the settings subtab.
9187
- id: The identifier.
92-
- content: The content of the custom settings subtab.
88+
- color: The tab's color in the sidebar style.
89+
- content: The content of the settings subtab.
9390

9491
#### Parameters
9592

9693
| Name | Description |
9794
| ---- | ----------- |
98-
| label | The label of the custom settings subtab. |
95+
| type | The tab type of the settings subtab. |
9996
| id | The identifier. |
100-
| content | The content of the custom settings subtab. |
97+
| color | The tab’s color in the sidebar style. |
98+
| content | The content of the settings subtab. |

Documentation/Reference/SettingsKit/structs/SettingsTab.md

+36-25
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ public var type: TabType
3333

3434
The tab's type.
3535

36+
### `color`
37+
38+
```swift
39+
public var color: Color
40+
```
41+
42+
The tab's color in the sidebar design.
43+
3644
### `content`
3745

3846
```swift
@@ -97,6 +105,14 @@ private var sidebarList: some View
97105

98106
The list in the tab's sidebar.
99107

108+
### `sidebarBody`
109+
110+
```swift
111+
@ViewBuilder var sidebarBody: some View
112+
```
113+
114+
The body if the sidebar layout is active.
115+
100116
### `contentView`
101117

102118
```swift
@@ -105,54 +121,49 @@ private var contentView: some View
105121

106122
The selected subtab's content.
107123

108-
## Methods
109-
### `init(_:id:content:)`
124+
### `label`
110125

111126
```swift
112-
public init(
113-
_ type: TabType,
114-
id: String,
115-
@ArrayBuilder<SettingsSubtab> content: () -> [SettingsSubtab]
116-
)
127+
public var label: Label<Text, Image>?
117128
```
118129

119-
The initializer.
120-
- Parameters:
121-
- type: The tab type of the settings tab.
122-
- id: The identifier.
123-
- content: The content of the settings tab.
130+
The label of a custom tab, or else nil.
124131

125-
#### Parameters
132+
### `sidebarLabel`
126133

127-
| Name | Description |
128-
| ---- | ----------- |
129-
| type | The tab type of the settings tab. |
130-
| id | The identifier. |
131-
| content | The content of the settings tab. |
134+
```swift
135+
@ViewBuilder public var sidebarLabel: some View
136+
```
137+
138+
The label in the sidebar.
132139

133-
### `init(_:id:content:)`
140+
## Methods
141+
### `init(_:id:color:content:)`
134142

135143
```swift
136144
public init(
137-
_ label: Label<Text, Image>,
145+
_ type: TabType,
138146
id: String,
147+
color: Color = .blue,
139148
@ArrayBuilder<SettingsSubtab> content: () -> [SettingsSubtab]
140149
)
141150
```
142151

143-
An initializer for a custom settings tav.
152+
The initializer.
144153
- Parameters:
145-
- label: The label of the custom settings tab.
154+
- type: The tab type of the settings tab.
146155
- id: The identifier.
147-
- content: The content of the custom settings tab.
156+
- color: The tab's color in the settings window with the sidebar design.
157+
- content: The content of the settings tab.
148158

149159
#### Parameters
150160

151161
| Name | Description |
152162
| ---- | ----------- |
153-
| label | The label of the custom settings tab. |
163+
| type | The tab type of the settings tab. |
154164
| id | The identifier. |
155-
| content | The content of the custom settings tab. |
165+
| color | The tab’s color in the settings window with the sidebar design. |
166+
| content | The content of the settings tab. |
156167

157168
### `listContent(subtab:)`
158169

Icons/GitHubBanner.png

579 KB
Loading

Icons/GitHubBanner.pxd

100 KB
Binary file not shown.

README.md

+26-21
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ _SettingsKit_ makes it easier to add a settings window to a SwiftUI app for macO
5050

5151
## Usage
5252

53+
An example app project is available [here.][5]
54+
5355
You can add settings to any SwiftUI scene, for example to a `Window` or `WindowGroup` in a standard SwiftUI app.
5456

5557
The following example creates a simple settings window:
@@ -110,35 +112,38 @@ struct SuperCoolApp: App {
110112
- `1.2` - Create a new settings subtab with the initializer for `SettingsSubtab` inside a `SettingsTab` initializer.
111113
- `1.3` - Extend an existing tab by using `.extend(id:)` and providing the ID of the settings tab to extend.
112114
- `1.4` - Create a new settings subtab by using `.noSelection` that is displayed if there is not a selected subtab.
113-
- `2.1` - Use the `.standardActions(add:remove:options:)` modifier on a settings tab for adding a „+“, „-„ and optionally „⋯“ toolbar button to the sidebar. You can also add a custom toolbar with `.actions(content:)`.
115+
- `2.1` - Use the `.standardActions(add:remove:options:)` modifier on a settings tab for adding a „+“, „-“ and optionally „⋯“ toolbar button to the sidebar. You can also add a custom toolbar with `.actions(content:)`.
116+
117+
Replace the line `.settings {` with `.settings(design: .sidebar) {` in order to get a settings window with the split view style. It is best suited for apps with many settings tabs.
114118

115119
## Thanks
116120

117121
### Dependencies
118-
- [SFSafeSymbols][5] licensed under the [MIT license][6]
119-
- [SwiftLintPlugin][7] licensed under the [MIT license][8]
120-
- [ColibriComponents][9] licensed under the [MIT license][10]
122+
- [SFSafeSymbols][6] licensed under the [MIT license][7]
123+
- [SwiftLintPlugin][8] licensed under the [MIT license][9]
124+
- [ColibriComponents][10] licensed under the [MIT license][11]
121125

122126
### Other Thanks
123-
- The [contributors][11]
124-
- [SourceDocs][12] used for generating the [docs][13]
125-
- [SwiftLint][14] for checking whether code style conventions are violated
126-
- The programming language [Swift][15]
127+
- The [contributors][12]
128+
- [SourceDocs][13] used for generating the [docs][14]
129+
- [SwiftLint][15] for checking whether code style conventions are violated
130+
- The programming language [Swift][16]
127131

128132
[1]: #Elements
129133
[2]: #Installation
130134
[3]: #Usage
131135
[4]: #Thanks
132-
[5]: https://github.com/SFSafeSymbols/SFSafeSymbols
133-
[6]: https://github.com/SFSafeSymbols/SFSafeSymbols/blob/stable/LICENSE
134-
[7]: https://github.com/lukepistrol/SwiftLintPlugin
135-
[8]: https://github.com/lukepistrol/SwiftLintPlugin/blob/main/LICENSE
136-
[9]: https://github.com/david-swift/ColibriComponents-macOS
137-
[10]: https://github.com/david-swift/ColibriComponents-macOS/blob/main/LICENSE.md
138-
[11]: Contributors.md
139-
[12]: https://github.com/SourceDocs/SourceDocs
140-
[13]: Documentation/Reference/SettingsKit-macOS/README.md
141-
[14]: https://github.com/realm/SwiftLint
142-
[15]: https://github.com/apple/swift
143-
144-
[image-1]: Icons/GitHubBanner.png
136+
[5]: /Tests/Examples/
137+
[6]: https://github.com/SFSafeSymbols/SFSafeSymbols
138+
[7]: https://github.com/SFSafeSymbols/SFSafeSymbols/blob/stable/LICENSE
139+
[8]: https://github.com/lukepistrol/SwiftLintPlugin
140+
[9]: https://github.com/lukepistrol/SwiftLintPlugin/blob/main/LICENSE
141+
[10]: https://github.com/david-swift/ColibriComponents-macOS
142+
[11]: https://github.com/david-swift/ColibriComponents-macOS/blob/main/LICENSE.md
143+
[12]: Contributors.md
144+
[13]: https://github.com/SourceDocs/SourceDocs
145+
[14]: Documentation/Reference/SettingsKit-macOS/README.md
146+
[15]: https://github.com/realm/SwiftLint
147+
[16]: https://github.com/apple/swift
148+
149+
[image-1]: Icons/GitHubBanner.png

0 commit comments

Comments
 (0)