Skip to content

Commit dc155d1

Browse files
Polish a bit
1 parent 1884f21 commit dc155d1

File tree

8 files changed

+80
-31
lines changed

8 files changed

+80
-31
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0x00",
9+
"green" : "0x00",
10+
"red" : "0x00"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "light"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "srgb",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0x52",
27+
"green" : "0x24",
28+
"red" : "0xFF"
29+
}
30+
},
31+
"idiom" : "universal"
32+
},
33+
{
34+
"appearances" : [
35+
{
36+
"appearance" : "luminosity",
37+
"value" : "dark"
38+
}
39+
],
40+
"color" : {
41+
"color-space" : "srgb",
42+
"components" : {
43+
"alpha" : "1.000",
44+
"blue" : "0x23",
45+
"green" : "0xFF",
46+
"red" : "0x15"
47+
}
48+
},
49+
"idiom" : "universal"
50+
}
51+
],
52+
"info" : {
53+
"author" : "xcode",
54+
"version" : 1
55+
}
56+
}

Sources/RichTextKit/Actions/RichTextAction+Button.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ public extension RichTextAction {
1717
use and configure it as a normal button.
1818
*/
1919
struct Button: View {
20-
21-
#if macOS
22-
private let systemSpecificTextColor: Color? = Color(NSColor.textColor)
23-
#else
24-
private let systemSpecificTextColor: Color? = nil
25-
#endif
26-
2720
/**
2821
Create a rich text action button.
2922

@@ -54,7 +47,7 @@ public extension RichTextAction {
5447
.labelStyle(.iconOnly)
5548
.frame(maxHeight: fillVertically ? .infinity : nil)
5649
.contentShape(Rectangle())
57-
.foregroundColor(systemSpecificTextColor)
50+
.foregroundColor(.systemSpecificTextColor)
5851
}
5952
.keyboardShortcut(for: action)
6053
.disabled(!context.canHandle(action))

Sources/RichTextKit/Alignment/RichTextAlignment+Picker.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public extension RichTextAlignment {
2020
@Environment(\.colorScheme) var colorScheme
2121
/**
2222
Create a rich text alignment picker.
23-
23+
2424
- Parameters:
2525
- selection: The binding to update with the picker.
2626
- values: The pickable alignments, by default `.allCases`.
@@ -34,17 +34,16 @@ public extension RichTextAlignment {
3434
}
3535

3636
let values: [RichTextAlignment]
37-
37+
3838
@Binding
3939
private var selection: RichTextAlignment
40-
40+
4141
public var body: some View {
4242
SwiftUI.Picker("", selection: $selection) {
4343
ForEach(RichTextAlignment.allCases) { value in
4444
value.label
4545
.labelStyle(.iconOnly)
4646
}
47-
4847
}
4948
.labelsHidden()
5049
.accessibilityLabel(RTKL10n.textAlignment.text)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// Color+SystemSpecificTextColor.swift
3+
//
4+
//
5+
// Created by Dominik Bucher on 22.01.2024.
6+
//
7+
8+
import SwiftUI
9+
10+
extension Color {
11+
#if macOS
12+
// on macOS
13+
static let systemSpecificTextColor: Color? = Color(NSColor.textColor)
14+
#else
15+
static let systemSpecificTextColor: Color? = nil
16+
#endif
17+
}

Sources/RichTextKit/Component/RichTextViewComponent+Attributes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public extension RichTextViewComponent {
1919
#if macOS
2020
let range = NSRange(location: selectedRange.location - 1, length: 1)
2121
let safeRange = safeRange(for: range)
22-
return richTextAttributes(at: safeRange )
22+
return richTextAttributes(at: safeRange)
2323
#else
2424
return typingAttributes
2525
#endif

Sources/RichTextKit/Coordinator/RichTextCoordinator+Subscriptions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ internal extension RichTextCoordinator {
360360
}
361361
}
362362

363-
private extension ColorRepresentable {
363+
extension ColorRepresentable {
364364

365365
#if iOS || os(tvOS) || os(visionOS)
366366
static var textColor: ColorRepresentable { .label }

Sources/RichTextKit/Styles/RichTextStyleButton.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public struct RichTextStyleButton: View {
7878
.foregroundColor(tintColor)
7979
.contentShape(Rectangle())
8080
}
81-
.tint(tintColor)
8281
.keyboardShortcut(for: style)
8382
.accessibilityLabel(style.title)
8483
}
@@ -90,12 +89,6 @@ public extension RichTextStyleButton {
9089
This style can be used to style a ``RichTextStyleButton``.
9190
*/
9291
struct Style {
93-
94-
#if macOS
95-
private let systemSpecificTextColor: Color? = Color(NSColor.textColor)
96-
#else
97-
private let systemSpecificTextColor: Color? = nil
98-
#endif
9992
/**
10093
Create a rich text style button style.
10194

@@ -107,7 +100,7 @@ public extension RichTextStyleButton {
107100
inactiveColor: Color? = nil,
108101
activeColor: Color = .blue
109102
) {
110-
self.inactiveColor = inactiveColor ?? systemSpecificTextColor
103+
self.inactiveColor = inactiveColor ?? Color.systemSpecificTextColor
111104
self.activeColor = activeColor
112105
}
113106

Sources/RichTextKit/_Deprecated/RichTextAlignment+Deprecated.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,3 @@ import SwiftUI
22

33
@available(*, deprecated, renamed: "RichTextAlignment.Picker")
44
public typealias RichTextAlignmentPicker = RichTextAlignment.Picker
5-
6-
public extension RichTextAlignment.Picker.Style {
7-
8-
@available(*, deprecated, renamed: "init(lightIconColor:darkIconColor:)")
9-
init(iconColor: Color = .primary) {
10-
self.lightIconColor = iconColor
11-
self.darkIconColor = iconColor
12-
}
13-
}

0 commit comments

Comments
 (0)