Skip to content

Commit 48fdc91

Browse files
committed
Update documentation and deprecate no longer needed types
1 parent 04bb83d commit 48fdc91

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+292
-695
lines changed

RELEASE_NOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ These release notes cover the current major version. See older versions for olde
1111

1212

1313

14+
## 6.1
15+
16+
This version bumps the package to 6.1 and deprecates some list views.
17+
18+
19+
1420
## 6.0
1521

1622
This version removes all deprecations, which means that many parts of the library are no longer available.

Sources/SwiftUIKit/Collections/Array+Range.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import Foundation
1010

1111
public extension Array where Element: Comparable & Strideable {
1212

13-
/// Create an array with values from a `range`, stepping
14-
/// `stepSize` between each value.
13+
/// Create an array from a `range` with `stepSize` between each value.
1514
init(
1615
_ range: ClosedRange<Element>,
1716
stepSize: Element.Stride

Sources/SwiftUIKit/Collections/Sequence+Group.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ public extension Sequence {
1212

1313
/// Group the sequence into a dictionary.
1414
///
15-
/// The operation can use any property from the items as
16-
/// the dictionary key.
15+
/// The operation can use any element property as dictionary key.
1716
func grouped<T>(by grouper: (Element) -> T) -> [T: [Element]] {
1817
Dictionary(grouping: self, by: grouper)
1918
}

Sources/SwiftUIKit/Colors/Color+Codable.swift

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ import AppKit
2222
#endif
2323

2424
/// This extension makes `Color` implement `Codable`.
25-
extension Color: Codable {
26-
25+
extension Color: @retroactive Decodable {}
26+
extension Color: @retroactive Encodable {}
27+
28+
public extension Color {
29+
2730
enum CodingKeys: String, CodingKey {
2831
case red, green, blue, alpha
2932
}
3033

3134
/// Initialize a color value from a decoder.
32-
public init(from decoder: Decoder) throws {
35+
init(from decoder: Decoder) throws {
3336
let container = try decoder.container(keyedBy: CodingKeys.self)
3437
let r = try container.decode(Double.self, forKey: .red)
3538
let g = try container.decode(Double.self, forKey: .green)
@@ -40,10 +43,9 @@ extension Color: Codable {
4043

4144
/// Encode the color, using an encoder.
4245
///
43-
/// Note that encoding colors that support features like
44-
/// dark mode, high contrast etc. will cause the encoded
45-
/// colors to only contain the current color information.
46-
public func encode(to encoder: Encoder) throws {
46+
/// > Important: Encoding colors that support system features like dark mode,
47+
/// high contrast etc. will cause the encoded colors to be non-dynamic.
48+
func encode(to encoder: Encoder) throws {
4749
guard let colorComponents = self.colorComponents else { return }
4850
var container = encoder.container(keyedBy: CodingKeys.self)
4951
try container.encode(colorComponents.red, forKey: .red)
@@ -69,13 +71,8 @@ private extension Color {
6971

7072
#if os(macOS)
7173
SystemColor(self).getRed(&r, green: &g, blue: &b, alpha: &a)
72-
// Note that non RGB color will raise an exception, that I don't now how to catch because it is an Objc exception.
7374
#else
74-
guard SystemColor(self).getRed(&r, green: &g, blue: &b, alpha: &a) else {
75-
// Pay attention that the color should be convertible into RGB format
76-
// Colors using hue, saturation and brightness won't work
77-
return nil
78-
}
75+
guard SystemColor(self).getRed(&r, green: &g, blue: &b, alpha: &a) else { return nil }
7976
#endif
8077

8178
return (r, g, b, a)

Sources/SwiftUIKit/Colors/Color+Hex.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public extension Color {
2222

2323
/// Create a color with a string hex, e.g. `#abcdef`,
2424
///
25-
/// This supports multiple string formats, like `abcdef`,
26-
/// `#abcdef`, `0xabcdef`, and `#abcdef`.
25+
/// This supports `abcdef`, `#abcdef`, `0xabcdef`, and `#abcdef`.
2726
///
2827
/// - Parameters:
2928
/// - hex: The hex string to parse.
@@ -44,8 +43,7 @@ public extension Color {
4443

4544
/// Create a color with a string hex, e.g. `#abcdef`,
4645
///
47-
/// This supports multiple string formats, like `abcdef`,
48-
/// `#abcdef`, `0xabcdef`, and `#abcdef`.
46+
/// This supports `abcdef`, `#abcdef`, `0xabcdef`, and `#abcdef`.
4947
///
5048
/// - Parameters:
5149
/// - hex: The hex string to parse.
@@ -80,8 +78,7 @@ public extension Color {
8078
return Preview()
8179
}
8280

83-
/// This extension extends `ColorRepresentable` with ways to
84-
/// be created with hex strings and int values.
81+
/// This extension extends `ColorRepresentable` with hex-based initializers.
8582
public extension ColorRepresentable {
8683

8784
/// Initialize a color with a hex value, e.g. `0xabcdef`.
@@ -98,8 +95,7 @@ public extension ColorRepresentable {
9895

9996
/// Initialize a color with a hex string, e.g. `#abcdef`.
10097
///
101-
/// This supports multiple string formats, like `abcdef`,
102-
/// `#abcdef`, `0xabcdef`, and `#abcdef`.
98+
/// This supports `abcdef`, `#abcdef`, `0xabcdef`, and `#abcdef`.
10399
///
104100
/// - Parameters:
105101
/// - hex: The hex string to parse.

Sources/SwiftUIKit/Colors/Color+Random.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public extension Color {
1515
///
1616
/// - Parameters:
1717
/// - range: The random color range, by default `0...1`.
18-
/// - randomOpacity: Whether or not to randomize opacity as well, by default `false`.
18+
/// - randomOpacity: Whether to randomize opacity, by default `false`.
1919
static func random(
2020
in range: ClosedRange<Double> = 0...1,
2121
randomOpacity: Bool = false

Sources/SwiftUIKit/Data/Collection+Codable.swift

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
import Foundation
1212
import SwiftUI
1313

14-
/// This extension makes `Array` able to store Codable types,
15-
/// by serializing the collection to JSON.
14+
/// This extension makes `Array` able to store `Codable` types.
1615
///
17-
/// > Important: JSON encoding may cause important type data
18-
/// to disappear. For instance, JSON encoding a `Color` will
19-
/// not include any information about alternate color values
20-
/// for light and dark mode, high constrasts, etc.
16+
/// > Important: Values will be encoded and decoded with JSON. This may cause
17+
/// loss of important data. For instance, a JSON encoded `Color` will not include
18+
/// any dynamic color information, like dark mode and high contrast variants.
2119
extension Array: @retroactive RawRepresentable where Element: Codable {
2220

2321
public init?(rawValue: String) {
@@ -37,13 +35,11 @@ extension Array: @retroactive RawRepresentable where Element: Codable {
3735
}
3836
}
3937

40-
/// This extension makes `Dictionary` able to store `Codable`
41-
/// types, by serializing the collection to JSON.
38+
/// This extension makes `Dictionary` able to store `Codable` types.
4239
///
43-
/// > Important: JSON encoding may cause important type data
44-
/// to disappear. For instance, JSON encoding a `Color` will
45-
/// not include any information about alternate color values
46-
/// for light and dark mode, high constrasts, etc.
40+
/// > Important: Values will be encoded and decoded with JSON. This may cause
41+
/// loss of important data. For instance, a JSON encoded `Color` will not include
42+
/// any dynamic color information, like dark mode and high contrast variants.
4743
extension Dictionary: @retroactive RawRepresentable where Key: Codable, Value: Codable {
4844

4945
public init?(rawValue: String) {

Sources/SwiftUIKit/Data/CsvParser.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88

99
import Foundation
1010

11-
/**
12-
This type can parse comma-separated value files and strings.
13-
14-
When parsing a CSV file or string, every line will be split
15-
up into components, using the provided `componentSeparator`.
16-
*/
11+
/// This type can parse comma-separated value files and strings.
12+
///
13+
/// When parsing a CSV file or string, each line will be split up into components by
14+
/// splitting the string with the provided `componentSeparator`.
1715
public class CsvParser {
1816

1917
/// Create a CSV parser.

Sources/SwiftUIKit/Data/MimeType.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ import Foundation
1010
import UniformTypeIdentifiers
1111

1212
/// This enum defines different MIME and file types.
13-
///
14-
/// Note that some types are expected to be a different type,
15-
/// but instead use `application`. For instance, `json` is a
16-
/// text format, but the mime type is `application/json`.
1713
public enum MimeType: Identifiable {
1814

1915
case

Sources/SwiftUIKit/Data/StorageValue.swift

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@
1111
import Foundation
1212
import SwiftUI
1313

14-
/// This type can wrap any `Codable` type to make it able to
15-
/// store the value in `AppStorage` and `SceneStorage`.
14+
/// This type can be used to wrap any `Codable` type, to let us store that value
15+
/// as JSON in `AppStorage` and `SceneStorage`.
1616
///
17-
/// This type uses `JSONEncoder` and `JSONDecoder` to encode
18-
/// the value to data then decode it back to the source type.
19-
///
20-
/// > Important: JSON encoding may cause important type data
21-
/// to disappear. For instance, JSON encoding a `Color` will
22-
/// not include any information about alternate color values
23-
/// for light and dark mode, high constrasts, etc.
17+
/// > Important: Values will be encoded and decoded with JSON. This may cause
18+
/// loss of important data. For instance, a JSON encoded `Color` will not include
19+
/// any dynamic color information, like dark mode and high contrast variants.
2420
public struct StorageValue<Value: Codable>: RawRepresentable {
2521

2622
/// Create a storage value.

0 commit comments

Comments
 (0)