From db555640eb03e002e21921cc3f3a7581b766744c Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Thu, 2 Jun 2022 10:55:59 +0800 Subject: [PATCH] PreferencesExtension // Clang-Format. --- .../SindreSorhus/Preferences/Container.swift | 22 ++++----- .../Preferences/Localization.swift | 8 ++-- .../SindreSorhus/Preferences/Pane.swift | 18 +++---- .../PreferencesWindowController.swift | 18 +++---- .../SindreSorhus/Preferences/Section.swift | 48 +++++++++---------- .../SindreSorhus/Preferences/Utilities.swift | 4 +- 6 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Source/3rdParty/SindreSorhus/Preferences/Container.swift b/Source/3rdParty/SindreSorhus/Preferences/Container.swift index 115f7e58..ff7993d9 100755 --- a/Source/3rdParty/SindreSorhus/Preferences/Container.swift +++ b/Source/3rdParty/SindreSorhus/Preferences/Container.swift @@ -23,8 +23,8 @@ import SwiftUI @available(macOS 10.15, *) extension Preferences { /** - Function builder for `Preferences` components used in order to restrict types of child views to be of type `Section`. - */ + Function builder for `Preferences` components used in order to restrict types of child views to be of type `Section`. + */ @resultBuilder public enum SectionBuilder { public static func buildBlock(_ sections: Section...) -> [Section] { @@ -33,8 +33,8 @@ extension Preferences { } /** - A view which holds `Preferences.Section` views and does all the alignment magic similar to `NSGridView` from AppKit. - */ + A view which holds `Preferences.Section` views and does all the alignment magic similar to `NSGridView` from AppKit. + */ public struct Container: View { private let sectionBuilder: () -> [Section] private let contentWidth: Double @@ -42,15 +42,15 @@ extension Preferences { @State private var maximumLabelWidth = 0.0 /** - Creates an instance of container component, which handles layout of stacked `Preferences.Section` views. + Creates an instance of container component, which handles layout of stacked `Preferences.Section` views. - Custom alignment requires content width to be specified beforehand. + Custom alignment requires content width to be specified beforehand. - - Parameters: - - contentWidth: A fixed width of the container's content (excluding paddings). - - minimumLabelWidth: A minimum width for labels within this container. By default, it will fit to the largest label. - - builder: A view builder that creates `Preferences.Section`'s of this container. - */ + - Parameters: + - contentWidth: A fixed width of the container's content (excluding paddings). + - minimumLabelWidth: A minimum width for labels within this container. By default, it will fit to the largest label. + - builder: A view builder that creates `Preferences.Section`'s of this container. + */ public init( contentWidth: Double, minimumLabelWidth: Double = 0, diff --git a/Source/3rdParty/SindreSorhus/Preferences/Localization.swift b/Source/3rdParty/SindreSorhus/Preferences/Localization.swift index de0c60cc..4f0808dd 100755 --- a/Source/3rdParty/SindreSorhus/Preferences/Localization.swift +++ b/Source/3rdParty/SindreSorhus/Preferences/Localization.swift @@ -112,12 +112,12 @@ struct Localization { ] /** - Returns the localized version of the given string. + Returns the localized version of the given string. - - Parameter identifier: Identifier of the string to localize. + - Parameter identifier: Identifier of the string to localize. - - Note: If the system's locale can't be determined, the English localization of the string will be returned. - */ + - Note: If the system's locale can't be determined, the English localization of the string will be returned. + */ static subscript(identifier: Identifier) -> String { // Force-unwrapped since all of the involved code is under our control. let localizedDict = Localization.localizedStrings[identifier]! diff --git a/Source/3rdParty/SindreSorhus/Preferences/Pane.swift b/Source/3rdParty/SindreSorhus/Preferences/Pane.swift index 21b83af3..02262cee 100755 --- a/Source/3rdParty/SindreSorhus/Preferences/Pane.swift +++ b/Source/3rdParty/SindreSorhus/Preferences/Pane.swift @@ -25,18 +25,18 @@ import SwiftUI /// Acts as type-eraser for `Preferences.Pane`. public protocol PreferencePaneConvertible { /** - Convert `self` to equivalent `PreferencePane`. - */ + Convert `self` to equivalent `PreferencePane`. + */ func asPreferencePane() -> PreferencePane } @available(macOS 10.15, *) extension Preferences { /** - Create a SwiftUI-based preference pane. + Create a SwiftUI-based preference pane. - SwiftUI equivalent of the `PreferencePane` protocol. - */ + SwiftUI equivalent of the `PreferencePane` protocol. + */ public struct Pane: View, PreferencePaneConvertible { let identifier: PaneIdentifier let title: String @@ -63,8 +63,8 @@ extension Preferences { } /** - Hosting controller enabling `Preferences.Pane` to be used alongside AppKit `NSViewController`'s. - */ + Hosting controller enabling `Preferences.Pane` to be used alongside AppKit `NSViewController`'s. + */ public final class PaneHostingController: NSHostingController, PreferencePane { public let preferencePaneIdentifier: PaneIdentifier public let preferencePaneTitle: String @@ -102,8 +102,8 @@ extension Preferences { @available(macOS 10.15, *) extension View { /** - Applies font and color for a label used for describing a preference. - */ + Applies font and color for a label used for describing a preference. + */ public func preferenceDescription() -> some View { font(.system(size: 11.0)) // TODO: Use `.foregroundStyle` when targeting macOS 12. diff --git a/Source/3rdParty/SindreSorhus/Preferences/PreferencesWindowController.swift b/Source/3rdParty/SindreSorhus/Preferences/PreferencesWindowController.swift index 0480271c..71fdfb32 100755 --- a/Source/3rdParty/SindreSorhus/Preferences/PreferencesWindowController.swift +++ b/Source/3rdParty/SindreSorhus/Preferences/PreferencesWindowController.swift @@ -97,17 +97,17 @@ public final class PreferencesWindowController: NSWindowController { } /** - Show the preferences window and brings it to front. + Show the preferences window and brings it to front. - If you pass a `Preferences.PaneIdentifier`, the window will activate the corresponding tab. + If you pass a `Preferences.PaneIdentifier`, the window will activate the corresponding tab. - - Parameter preferencePane: Identifier of the preference pane to display, or `nil` to show the tab that was open when the user last closed the window. + - Parameter preferencePane: Identifier of the preference pane to display, or `nil` to show the tab that was open when the user last closed the window. - - Note: Unless you need to open a specific pane, prefer not to pass a parameter at all or `nil`. + - Note: Unless you need to open a specific pane, prefer not to pass a parameter at all or `nil`. - - See `close()` to close the window again. - - See `showWindow(_:)` to show the window without the convenience of activating the app. - */ + - See `close()` to close the window again. + - See `showWindow(_:)` to show the window without the convenience of activating the app. + */ public func show(preferencePane preferenceIdentifier: Preferences.PaneIdentifier? = nil) { if let preferenceIdentifier = preferenceIdentifier { tabViewController.activateTab(preferenceIdentifier: preferenceIdentifier, animated: false) @@ -168,8 +168,8 @@ extension PreferencesWindowController { @available(macOS 10.15, *) extension PreferencesWindowController { /** - Create a preferences window from only SwiftUI-based preference panes. - */ + Create a preferences window from only SwiftUI-based preference panes. + */ public convenience init( panes: [PreferencePaneConvertible], style: Preferences.Style = .toolbarItems, diff --git a/Source/3rdParty/SindreSorhus/Preferences/Section.swift b/Source/3rdParty/SindreSorhus/Preferences/Section.swift index 86c7a637..2279bfe9 100755 --- a/Source/3rdParty/SindreSorhus/Preferences/Section.swift +++ b/Source/3rdParty/SindreSorhus/Preferences/Section.swift @@ -23,13 +23,13 @@ import SwiftUI @available(macOS 10.15, *) extension Preferences { /** - Represents a section with right-aligned title and optional bottom divider. - */ + Represents a section with right-aligned title and optional bottom divider. + */ @available(macOS 10.15, *) public struct Section: View { /** - Preference key holding max width of section labels. - */ + Preference key holding max width of section labels. + */ private struct LabelWidthPreferenceKey: PreferenceKey { typealias Value = Double @@ -42,8 +42,8 @@ extension Preferences { } /** - Convenience overlay for finding a label's dimensions using `GeometryReader`. - */ + Convenience overlay for finding a label's dimensions using `GeometryReader`. + */ private struct LabelOverlay: View { var body: some View { GeometryReader { geometry in @@ -54,8 +54,8 @@ extension Preferences { } /** - Convenience modifier for applying `LabelWidthPreferenceKey`. - */ + Convenience modifier for applying `LabelWidthPreferenceKey`. + */ struct LabelWidthModifier: ViewModifier { @Binding var maximumWidth: Double @@ -73,15 +73,15 @@ extension Preferences { public let verticalAlignment: VerticalAlignment /** - A section is responsible for controlling a single preference. + A section is responsible for controlling a single preference. - - Parameters: - - bottomDivider: Whether to place a `Divider` after the section content. Default is `false`. - - verticalAlignement: The vertical alignment of the section content. - - verticalAlignment: - - label: A view describing preference handled by this section. - - content: A content view. - */ + - Parameters: + - bottomDivider: Whether to place a `Divider` after the section content. Default is `false`. + - verticalAlignement: The vertical alignment of the section content. + - verticalAlignment: + - label: A view describing preference handled by this section. + - content: A content view. + */ public init( bottomDivider: Bool = false, verticalAlignment: VerticalAlignment = .firstTextBaseline, @@ -98,15 +98,15 @@ extension Preferences { } /** - Creates instance of section, responsible for controling single preference with `Text` as a `Label`. + Creates instance of section, responsible for controling single preference with `Text` as a `Label`. - - Parameters: - - title: A string describing preference handled by this section. - - bottomDivider: Whether to place a `Divider` after the section content. Default is `false`. - - verticalAlignement: The vertical alignment of the section content. - - verticalAlignment: - - content: A content view. - */ + - Parameters: + - title: A string describing preference handled by this section. + - bottomDivider: Whether to place a `Divider` after the section content. Default is `false`. + - verticalAlignement: The vertical alignment of the section content. + - verticalAlignment: + - content: A content view. + */ public init( title: String, bottomDivider: Bool = false, diff --git a/Source/3rdParty/SindreSorhus/Preferences/Utilities.swift b/Source/3rdParty/SindreSorhus/Preferences/Utilities.swift index f2c27a15..865d6670 100755 --- a/Source/3rdParty/SindreSorhus/Preferences/Utilities.swift +++ b/Source/3rdParty/SindreSorhus/Preferences/Utilities.swift @@ -130,8 +130,8 @@ class UserInteractionPausableWindow: NSWindow { @available(macOS 10.15, *) extension View { /** - Equivalent to `.eraseToAnyPublisher()` from the Combine framework. - */ + Equivalent to `.eraseToAnyPublisher()` from the Combine framework. + */ func eraseToAnyView() -> AnyView { AnyView(self) }