From 012803a4233fa036a4a6c3390418523eaff26e9a Mon Sep 17 00:00:00 2001 From: Daniel Saidi Date: Wed, 14 Feb 2024 17:25:30 +0100 Subject: [PATCH] Remove undefined color enum case --- RELEASE_NOTES.md | 4 ++++ Sources/RichTextKit/Colors/ColorRepresentable.swift | 2 +- .../RichTextKit/Colors/RichTextColor+Picker.swift | 4 ++-- Sources/RichTextKit/Colors/RichTextColor.swift | 13 +------------ .../Context/RichTextContext+Colors.swift | 2 -- .../RichTextColorPicker+Deprecated.swift | 1 + 6 files changed, 9 insertions(+), 17 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 1df360a04..35e7eaa7f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -46,6 +46,10 @@ By deprecating these functions, we can simplify the library in 1.0, and focus mo * `RichTextCoordinator` functions that simply triggered `handle(_:)` have been deprecated. * `RTKL10n.bundle` has been deprecated, since we can just use the `.module` bundle from now. +### 💥 Breaking Changes + +* `RichTextColor.undefined` was no longer used and has been removed. + ## 0.9.8 diff --git a/Sources/RichTextKit/Colors/ColorRepresentable.swift b/Sources/RichTextKit/Colors/ColorRepresentable.swift index 5a0d9678c..a654a663f 100644 --- a/Sources/RichTextKit/Colors/ColorRepresentable.swift +++ b/Sources/RichTextKit/Colors/ColorRepresentable.swift @@ -3,7 +3,7 @@ // RichTextKit // // Created by Daniel Saidi on 2022-05-28. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. // #if macOS diff --git a/Sources/RichTextKit/Colors/RichTextColor+Picker.swift b/Sources/RichTextKit/Colors/RichTextColor+Picker.swift index fc53b5197..6507a0eb7 100644 --- a/Sources/RichTextKit/Colors/RichTextColor+Picker.swift +++ b/Sources/RichTextKit/Colors/RichTextColor+Picker.swift @@ -25,13 +25,13 @@ public extension RichTextColor { Create a rich text color picker that binds to a color. - Parameters: - - type: The type of color to pick, by default `.undefined`. + - type: The type of color to pick. - icon: The icon to show, if any, by default the `type` icon. - value: The value to bind to. - quickColors: Colors to show in the trailing list, by default no colors. */ public init( - type: RichTextColor = .undefined, + type: RichTextColor, icon: Image? = nil, value: Binding, quickColors: [Color] = [] diff --git a/Sources/RichTextKit/Colors/RichTextColor.swift b/Sources/RichTextKit/Colors/RichTextColor.swift index 370ef9b2a..f25259da7 100644 --- a/Sources/RichTextKit/Colors/RichTextColor.swift +++ b/Sources/RichTextKit/Colors/RichTextColor.swift @@ -3,7 +3,7 @@ // RichTextKit // // Created by Daniel Saidi on 2022-05-28. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. // import SwiftUI @@ -29,9 +29,6 @@ public enum RichTextColor: String, CaseIterable, Codable, Equatable, Identifiabl /// Underline color. case underline - - /// An undefined color type. - case undefined } public extension RichTextColor { @@ -39,11 +36,6 @@ public extension RichTextColor { /// The unique color ID. var id: String { rawValue } - /// All relevant cases. - static var allCases: [RichTextColor] { - [.foreground, .background, .strikethrough, .stroke, .underline] - } - /// The corresponding rich text attribute, if any. var attribute: NSAttributedString.Key? { switch self { @@ -52,7 +44,6 @@ public extension RichTextColor { case .strikethrough: .strikethroughColor case .stroke: .strokeColor case .underline: .underlineColor - case .undefined: nil } } @@ -64,7 +55,6 @@ public extension RichTextColor { case .strikethrough: .richTextColorStrikethrough case .stroke: .richTextColorStroke case .underline: .richTextColorUnderline - case .undefined: .richTextColorUndefined } } @@ -76,7 +66,6 @@ public extension RichTextColor { case .strikethrough: .strikethroughColor case .stroke: .strokeColor case .underline: .underlineColor - case .undefined: .strokeColor } } diff --git a/Sources/RichTextKit/Context/RichTextContext+Colors.swift b/Sources/RichTextKit/Context/RichTextContext+Colors.swift index 2f0d48c54..ee7edf6ea 100644 --- a/Sources/RichTextKit/Context/RichTextContext+Colors.swift +++ b/Sources/RichTextKit/Context/RichTextContext+Colors.swift @@ -26,7 +26,6 @@ public extension RichTextContext { case .strikethrough: strikethroughColor case .stroke: strokeColor case .underline: underlineColor - case .undefined: nil } } @@ -44,7 +43,6 @@ public extension RichTextContext { case .strikethrough: strikethroughColor = val case .stroke: strokeColor = val case .underline: underlineColor = val - case .undefined: return } } } diff --git a/Sources/RichTextKit/_Deprecated/RichTextColorPicker+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextColorPicker+Deprecated.swift index f951c8dce..034d3a58a 100644 --- a/Sources/RichTextKit/_Deprecated/RichTextColorPicker+Deprecated.swift +++ b/Sources/RichTextKit/_Deprecated/RichTextColorPicker+Deprecated.swift @@ -14,6 +14,7 @@ public extension RichTextColor.Picker { quickColors: [Color] = [] ) { self.init( + type: .foreground, icon: showIcon ? color.icon : nil, value: value, quickColors: quickColors