Skip to content

Commit

Permalink
Remove undefined color enum case
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsaidi committed Feb 14, 2024
1 parent 2ced875 commit 012803a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 17 deletions.
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/RichTextKit/Colors/ColorRepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Sources/RichTextKit/Colors/RichTextColor+Picker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Color>,
quickColors: [Color] = []
Expand Down
13 changes: 1 addition & 12 deletions Sources/RichTextKit/Colors/RichTextColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,21 +29,13 @@ public enum RichTextColor: String, CaseIterable, Codable, Equatable, Identifiabl

/// Underline color.
case underline

/// An undefined color type.
case undefined
}

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 {
Expand All @@ -52,7 +44,6 @@ public extension RichTextColor {
case .strikethrough: .strikethroughColor
case .stroke: .strokeColor
case .underline: .underlineColor
case .undefined: nil
}
}

Expand All @@ -64,7 +55,6 @@ public extension RichTextColor {
case .strikethrough: .richTextColorStrikethrough
case .stroke: .richTextColorStroke
case .underline: .richTextColorUnderline
case .undefined: .richTextColorUndefined
}
}

Expand All @@ -76,7 +66,6 @@ public extension RichTextColor {
case .strikethrough: .strikethroughColor
case .stroke: .strokeColor
case .underline: .underlineColor
case .undefined: .strokeColor
}
}

Expand Down
2 changes: 0 additions & 2 deletions Sources/RichTextKit/Context/RichTextContext+Colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public extension RichTextContext {
case .strikethrough: strikethroughColor
case .stroke: strokeColor
case .underline: underlineColor
case .undefined: nil
}
}

Expand All @@ -44,7 +43,6 @@ public extension RichTextContext {
case .strikethrough: strikethroughColor = val
case .stroke: strokeColor = val
case .underline: underlineColor = val
case .undefined: return
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public extension RichTextColor.Picker {
quickColors: [Color] = []
) {
self.init(
type: .foreground,
icon: showIcon ? color.icon : nil,
value: value,
quickColors: quickColors
Expand Down

0 comments on commit 012803a

Please sign in to comment.