Skip to content

Commit

Permalink
Add navigation split view settings window design option
Browse files Browse the repository at this point in the history
  • Loading branch information
david-swift committed Sep 17, 2023
1 parent ea2047b commit 0a6d4d8
Show file tree
Hide file tree
Showing 28 changed files with 1,047 additions and 115 deletions.
4 changes: 2 additions & 2 deletions Documentation/Reference/SettingsKit/enums/TabType.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ public enum TabType
The type of a settings tab or subtab.

## Cases
### `new(label:)`
### `new(title:icon:)`

```swift
case new(label: Label<Text, Image>)
case new(title: String, icon: SFSymbol)
```

A new settings tab or subtab with a label.
Expand Down
3 changes: 2 additions & 1 deletion Documentation/Reference/SettingsKit/extensions/Scene.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ extension Scene
```

## Methods
### `settings(symbolVariant:_:)`
### `settings(design:symbolVariant:_:)`

```swift
public func settings(
design: SettingsWindowDesign = .default,
symbolVariant: SymbolVariants = .none,
@ArrayBuilder<SettingsTab> _ settings: () -> [SettingsTab]
) -> some Scene
Expand Down
32 changes: 32 additions & 0 deletions Documentation/Reference/SettingsKit/structs/SettingsKitScene.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,42 @@ var symbolVariant: SymbolVariants

Modify the way symbols are displayed.

### `design`

```swift
var design: SettingsWindowDesign
```

The design of the settings window.

### `search`

```swift
@State private var search = ""
```

The filter in the sidebar design.

### `body`

```swift
var body: some Scene
```

The scene.

### `navigationView`

```swift
private var navigationView: some View
```

The view with the sidebar design.

### `tabView`

```swift
private var tabView: some View
```

The view with the tab design.
44 changes: 21 additions & 23 deletions Documentation/Reference/SettingsKit/structs/SettingsSubtab.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ public var content: any View

The tab's view.

### `color`

```swift
public var color: Color
```

The tab's color.

### `standard`

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

The label of a custom tab, or else nil.

## Methods
### `init(_:id:content:)`
### `sidebarLabel`

```swift
public init(_ type: TabType, id: String, @ViewBuilder content: () -> any View)
@ViewBuilder public var sidebarLabel: some View
```

The initializer.
- Parameters:
- type: The tab type of the settings subtab.
- id: The identifier.
- content: The content of the settings subtab.
The label for the sidebar style.

#### Parameters

| Name | Description |
| ---- | ----------- |
| type | The tab type of the settings subtab. |
| id | The identifier. |
| content | The content of the settings subtab. |

### `init(_:id:content:)`
## Methods
### `init(_:id:color:content:)`

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

An initializer for a custom settings subtab.
The initializer.
- Parameters:
- label: The label of the custom settings subtab.
- type: The tab type of the settings subtab.
- id: The identifier.
- content: The content of the custom settings subtab.
- color: The tab's color in the sidebar style.
- content: The content of the settings subtab.

#### Parameters

| Name | Description |
| ---- | ----------- |
| label | The label of the custom settings subtab. |
| type | The tab type of the settings subtab. |
| id | The identifier. |
| content | The content of the custom settings subtab. |
| color | The tab’s color in the sidebar style. |
| content | The content of the settings subtab. |
61 changes: 36 additions & 25 deletions Documentation/Reference/SettingsKit/structs/SettingsTab.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ public var type: TabType

The tab's type.

### `color`

```swift
public var color: Color
```

The tab's color in the sidebar design.

### `content`

```swift
Expand Down Expand Up @@ -97,6 +105,14 @@ private var sidebarList: some View

The list in the tab's sidebar.

### `sidebarBody`

```swift
@ViewBuilder var sidebarBody: some View
```

The body if the sidebar layout is active.

### `contentView`

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

The selected subtab's content.

## Methods
### `init(_:id:content:)`
### `label`

```swift
public init(
_ type: TabType,
id: String,
@ArrayBuilder<SettingsSubtab> content: () -> [SettingsSubtab]
)
public var label: Label<Text, Image>?
```

The initializer.
- Parameters:
- type: The tab type of the settings tab.
- id: The identifier.
- content: The content of the settings tab.
The label of a custom tab, or else nil.

#### Parameters
### `sidebarLabel`

| Name | Description |
| ---- | ----------- |
| type | The tab type of the settings tab. |
| id | The identifier. |
| content | The content of the settings tab. |
```swift
@ViewBuilder public var sidebarLabel: some View
```

The label in the sidebar.

### `init(_:id:content:)`
## Methods
### `init(_:id:color:content:)`

```swift
public init(
_ label: Label<Text, Image>,
_ type: TabType,
id: String,
color: Color = .blue,
@ArrayBuilder<SettingsSubtab> content: () -> [SettingsSubtab]
)
```

An initializer for a custom settings tav.
The initializer.
- Parameters:
- label: The label of the custom settings tab.
- type: The tab type of the settings tab.
- id: The identifier.
- content: The content of the custom settings tab.
- color: The tab's color in the settings window with the sidebar design.
- content: The content of the settings tab.

#### Parameters

| Name | Description |
| ---- | ----------- |
| label | The label of the custom settings tab. |
| type | The tab type of the settings tab. |
| id | The identifier. |
| content | The content of the custom settings tab. |
| color | The tab’s color in the settings window with the sidebar design. |
| content | The content of the settings tab. |

### `listContent(subtab:)`

Expand Down
Binary file modified Icons/GitHubBanner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Icons/GitHubBanner.pxd
Binary file not shown.
47 changes: 26 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ _SettingsKit_ makes it easier to add a settings window to a SwiftUI app for macO

## Usage

An example app project is available [here.][5]

You can add settings to any SwiftUI scene, for example to a `Window` or `WindowGroup` in a standard SwiftUI app.

The following example creates a simple settings window:
Expand Down Expand Up @@ -110,35 +112,38 @@ struct SuperCoolApp: App {
- `1.2` - Create a new settings subtab with the initializer for `SettingsSubtab` inside a `SettingsTab` initializer.
- `1.3` - Extend an existing tab by using `.extend(id:)` and providing the ID of the settings tab to extend.
- `1.4` - Create a new settings subtab by using `.noSelection` that is displayed if there is not a selected subtab.
- `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:)`.
- `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:)`.

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.

## Thanks

### Dependencies
- [SFSafeSymbols][5] licensed under the [MIT license][6]
- [SwiftLintPlugin][7] licensed under the [MIT license][8]
- [ColibriComponents][9] licensed under the [MIT license][10]
- [SFSafeSymbols][6] licensed under the [MIT license][7]
- [SwiftLintPlugin][8] licensed under the [MIT license][9]
- [ColibriComponents][10] licensed under the [MIT license][11]

### Other Thanks
- The [contributors][11]
- [SourceDocs][12] used for generating the [docs][13]
- [SwiftLint][14] for checking whether code style conventions are violated
- The programming language [Swift][15]
- The [contributors][12]
- [SourceDocs][13] used for generating the [docs][14]
- [SwiftLint][15] for checking whether code style conventions are violated
- The programming language [Swift][16]

[1]: #Elements
[2]: #Installation
[3]: #Usage
[4]: #Thanks
[5]: https://github.com/SFSafeSymbols/SFSafeSymbols
[6]: https://github.com/SFSafeSymbols/SFSafeSymbols/blob/stable/LICENSE
[7]: https://github.com/lukepistrol/SwiftLintPlugin
[8]: https://github.com/lukepistrol/SwiftLintPlugin/blob/main/LICENSE
[9]: https://github.com/david-swift/ColibriComponents-macOS
[10]: https://github.com/david-swift/ColibriComponents-macOS/blob/main/LICENSE.md
[11]: Contributors.md
[12]: https://github.com/SourceDocs/SourceDocs
[13]: Documentation/Reference/SettingsKit-macOS/README.md
[14]: https://github.com/realm/SwiftLint
[15]: https://github.com/apple/swift

[image-1]: Icons/GitHubBanner.png
[5]: /Tests/Examples/
[6]: https://github.com/SFSafeSymbols/SFSafeSymbols
[7]: https://github.com/SFSafeSymbols/SFSafeSymbols/blob/stable/LICENSE
[8]: https://github.com/lukepistrol/SwiftLintPlugin
[9]: https://github.com/lukepistrol/SwiftLintPlugin/blob/main/LICENSE
[10]: https://github.com/david-swift/ColibriComponents-macOS
[11]: https://github.com/david-swift/ColibriComponents-macOS/blob/main/LICENSE.md
[12]: Contributors.md
[13]: https://github.com/SourceDocs/SourceDocs
[14]: Documentation/Reference/SettingsKit-macOS/README.md
[15]: https://github.com/realm/SwiftLint
[16]: https://github.com/apple/swift

[image-1]: Icons/GitHubBanner.png
Loading

0 comments on commit 0a6d4d8

Please sign in to comment.