Skip to content

Commit

Permalink
Add availability attributes to ColorWellStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbaird committed Nov 18, 2023
1 parent 3e732f7 commit ba91d80
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Sources/ColorWellKit/Views/SwiftUI/ColorWellStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
// MARK: - ColorWellStyleConfiguration

/// Values that configure a color well's style.
@available(macOS 10.15, *)
public struct _ColorWellStyleConfiguration {
/// The underlying style of the color well.
let style: ColorWell.Style
}

@available(macOS 10.15, *)
extension _ColorWellStyleConfiguration {
static var `default`: _ColorWellStyleConfiguration {
_ColorWellStyleConfiguration(style: ColorWell.BackingStorage.defaultStyle)
}
}

@available(macOS 10.15, *)
extension _ColorWellStyleConfiguration: CustomStringConvertible {
public var description: String {
String(describing: style)
Expand All @@ -28,6 +31,7 @@ extension _ColorWellStyleConfiguration: CustomStringConvertible {
// MARK: - ColorWellStyle

/// A type that specifies the appearance and behavior of a color well.
@available(macOS 10.15, *)
public protocol ColorWellStyle {
/// Values that configure the color well's style.
var _configuration: _ColorWellStyleConfiguration { get }
Expand All @@ -39,13 +43,15 @@ public protocol ColorWellStyle {
/// rectangular control, and toggles the system color panel when clicked.
///
/// You can also use ``default`` to construct this style.
@available(macOS 10.15, *)
public struct DefaultColorWellStyle: ColorWellStyle {
public let _configuration = _ColorWellStyleConfiguration(style: .default)

/// Creates an instance of the default color well style.
public init() { }
}

@available(macOS 10.15, *)
extension ColorWellStyle where Self == DefaultColorWellStyle {
/// A color well style that displays the color well's color inside of a
/// rectangular control, and toggles the system color panel when clicked.
Expand All @@ -61,13 +67,15 @@ extension ColorWellStyle where Self == DefaultColorWellStyle {
/// swatch colors when clicked.
///
/// You can also use ``minimal`` to construct this style.
@available(macOS 10.15, *)
public struct MinimalColorWellStyle: ColorWellStyle {
public let _configuration = _ColorWellStyleConfiguration(style: .minimal)

/// Creates an instance of the minimal color well style.
public init() { }
}

@available(macOS 10.15, *)
extension ColorWellStyle where Self == MinimalColorWellStyle {
/// A color well style that displays the color well's color inside of a
/// rectangular control, and shows a popover containing the color well's
Expand All @@ -86,13 +94,15 @@ extension ColorWellStyle where Self == MinimalColorWellStyle {
/// color well's swatch colors.
///
/// You can also use ``expanded`` to construct this style.
@available(macOS 10.15, *)
public struct ExpandedColorWellStyle: ColorWellStyle {
public let _configuration = _ColorWellStyleConfiguration(style: .expanded)

/// Creates an instance of the expanded color well style.
public init() { }
}

@available(macOS 10.15, *)
extension ColorWellStyle where Self == ExpandedColorWellStyle {
/// A color well style that displays the color well's color alongside
/// a dedicated button that toggles the system color panel.
Expand All @@ -112,6 +122,7 @@ extension ColorWellStyle where Self == ExpandedColorWellStyle {
/// rectangular control, and toggles the system color panel when clicked.
///
/// You can also use ``standard`` to construct this style.
@available(macOS 10.15, *)
@available(*, deprecated, renamed: "DefaultColorWellStyle")
public struct StandardColorWellStyle: ColorWellStyle {
public let _configuration = _ColorWellStyleConfiguration(style: .standard)
Expand All @@ -120,6 +131,7 @@ public struct StandardColorWellStyle: ColorWellStyle {
public init() { }
}

@available(macOS 10.15, *)
@available(*, deprecated)
extension ColorWellStyle where Self == StandardColorWellStyle {
/// A color well style that displays the color well's color inside of a
Expand All @@ -137,6 +149,7 @@ extension ColorWellStyle where Self == StandardColorWellStyle {
/// swatch colors when clicked.
///
/// You can also use ``swatches`` to construct this style.
@available(macOS 10.15, *)
@available(*, deprecated, renamed: "MinimalColorWellStyle")
public struct SwatchesColorWellStyle: ColorWellStyle {
public let _configuration = _ColorWellStyleConfiguration(style: .swatches)
Expand All @@ -145,6 +158,7 @@ public struct SwatchesColorWellStyle: ColorWellStyle {
public init() { }
}

@available(macOS 10.15, *)
@available(*, deprecated)
extension ColorWellStyle where Self == SwatchesColorWellStyle {
/// A color well style that displays the color well's color inside of a
Expand Down

0 comments on commit ba91d80

Please sign in to comment.