Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jan 23, 2023
1 parent 9b4d3a7 commit 0034213
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.6
// swift-tools-version:5.7
import PackageDescription

let package = Package(
Expand Down
10 changes: 5 additions & 5 deletions Sources/Preferences/Section.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ extension Settings {
- label: A view describing the setting handled by this section.
- content: A content view.
*/
public init<Label: View, Content: View>(
public init(
bottomDivider: Bool = false,
verticalAlignment: VerticalAlignment = .firstTextBaseline,
label: @escaping () -> Label,
@ViewBuilder content: @escaping () -> Content
label: @escaping () -> some View,
@ViewBuilder content: @escaping () -> some View
) {
self.label = label()
.overlay(LabelOverlay())
Expand All @@ -88,11 +88,11 @@ extension Settings {
- verticalAlignement: The vertical alignment of the section content.
- content: A content view.
*/
public init<Content: View>(
public init(
title: String,
bottomDivider: Bool = false,
verticalAlignment: VerticalAlignment = .firstTextBaseline,
@ViewBuilder content: @escaping () -> Content
@ViewBuilder content: @escaping () -> some View
) {
let textLabel = {
Text(title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ final class SegmentedControlStyleViewController: NSViewController, SettingsStyle
// context menu that pops up at the right edge of the window.
let toolbarItemGroup = NSToolbarItemGroup(itemIdentifier: toolbarItemIdentifier)
toolbarItemGroup.view = segmentedControl
toolbarItemGroup.subitems = panes.enumerated().map { index, settingsPane -> NSToolbarItem in
toolbarItemGroup.subitems = panes.enumerated().map { index, settingsPane in
let item = NSToolbarItem(itemIdentifier: .init("segment-\(settingsPane.preferencePaneTitle)"))
item.label = settingsPane.preferencePaneTitle

Expand Down
6 changes: 3 additions & 3 deletions Sources/Preferences/SettingsTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class SettingsTabViewController: NSViewController, SettingsStyleController
var isAnimated = true

var activeViewController: NSViewController? {
guard let activeTab = activeTab else {
guard let activeTab else {
return nil
}

Expand Down Expand Up @@ -119,7 +119,7 @@ final class SettingsTabViewController: NSViewController, SettingsStyleController
}

private func animateTabTransition(index: Int, animated: Bool) {
guard let activeTab = activeTab else {
guard let activeTab else {
assertionFailure("animateTabTransition called before a tab was displayed; transition only works from one tab to another")
immediatelyDisplayTab(index: index)
return
Expand Down Expand Up @@ -189,7 +189,7 @@ final class SettingsTabViewController: NSViewController, SettingsStyleController
}

private func setWindowFrame(for viewController: NSViewController, animated: Bool = false) {
guard let window = window else {
guard let window else {
preconditionFailure()
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Preferences/SettingsWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public final class SettingsWindowController: NSWindowController {
- See `showWindow(_:)` to show the window without the convenience of activating the app.
*/
public func show(preferencePane paneIdentifier: Settings.PaneIdentifier? = nil) {
if let paneIdentifier = paneIdentifier {
if let paneIdentifier {
tabViewController.activateTab(paneIdentifier: paneIdentifier, animated: false)
} else {
tabViewController.restoreInitialTab()
Expand All @@ -102,7 +102,7 @@ public final class SettingsWindowController: NSWindowController {

private func restoreWindowPosition() {
guard
let window = window,
let window,
let screenContainingWindow = window.screen
else {
return
Expand Down
2 changes: 1 addition & 1 deletion Sources/Preferences/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extension NSImage {
extension NSView {
@discardableResult
func constrainToSuperviewBounds() -> [NSLayoutConstraint] {
guard let superview = superview else {
guard let superview else {
preconditionFailure("superview has to be set first")
}

Expand Down

0 comments on commit 0034213

Please sign in to comment.