Skip to content

Commit 0e7d0a9

Browse files
Merge pull request #1229 from wordpress-mobile/issue/make_Pre_Quote_colors_optional
Make pre and quote background colors optional
2 parents 6a39bfc + e490a22 commit 0e7d0a9

3 files changed

Lines changed: 22 additions & 13 deletions

File tree

Aztec/Classes/TextKit/LayoutManager.swift

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ class LayoutManager: NSLayoutManager {
99

1010
/// Blockquote's Left Border Color
1111
///
12-
var blockquoteBorderColor = UIColor(red: 0.52, green: 0.65, blue: 0.73, alpha: 1.0)
12+
var blockquoteBorderColor: UIColor? = UIColor(red: 0.52, green: 0.65, blue: 0.73, alpha: 1.0)
1313

1414
/// Blockquote's Background Color
1515
///
16-
var blockquoteBackgroundColor = UIColor(red: 0.91, green: 0.94, blue: 0.95, alpha: 1.0)
16+
var blockquoteBackgroundColor: UIColor? = UIColor(red: 0.91, green: 0.94, blue: 0.95, alpha: 1.0)
1717

1818
/// HTML Pre Background Color
1919
///
20-
var preBackgroundColor = UIColor(red: 243.0/255.0, green: 246.0/255.0, blue: 248.0/255.0, alpha: 1.0)
20+
var preBackgroundColor: UIColor? = UIColor(red: 243.0/255.0, green: 246.0/255.0, blue: 248.0/255.0, alpha: 1.0)
2121

2222
/// Closure that is expected to return the TypingAttributes associated to the Extra Line Fragment
2323
///
@@ -126,12 +126,17 @@ private extension LayoutManager {
126126
/// Draws a single Blockquote Line Fragment, in the specified Rectangle, using a given Graphics Context.
127127
///
128128
private func drawBlockquote(in rect: CGRect, with context: CGContext) {
129-
blockquoteBackgroundColor.setFill()
130-
context.fill(rect)
129+
if let blockquoteBackgroundColor = blockquoteBackgroundColor {
130+
blockquoteBackgroundColor.setFill()
131+
context.fill(rect)
132+
133+
}
131134

132-
let borderRect = CGRect(origin: rect.origin, size: CGSize(width: blockquoteBorderWidth, height: rect.height))
133-
blockquoteBorderColor.setFill()
134-
context.fill(borderRect)
135+
if let blockquoteBorderColor = blockquoteBorderColor {
136+
let borderRect = CGRect(origin: rect.origin, size: CGSize(width: blockquoteBorderWidth, height: rect.height))
137+
blockquoteBorderColor.setFill()
138+
context.fill(borderRect)
139+
}
135140
}
136141
}
137142

@@ -172,6 +177,9 @@ private extension LayoutManager {
172177
/// Draws a single HTML Pre Line Fragment, in the specified Rectangle, using a given Graphics Context.
173178
///
174179
private func drawHTMLPre(in rect: CGRect, with context: CGContext) {
180+
guard let preBackgroundColor = preBackgroundColor else {
181+
return
182+
}
175183
preBackgroundColor.setFill()
176184
context.fill(rect)
177185
}

Aztec/Classes/TextKit/TextView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ open class TextView: UITextView {
275275

276276
/// Blockquote Blocks Border Color.
277277
///
278-
@objc dynamic public var blockquoteBorderColor: UIColor {
278+
@objc dynamic public var blockquoteBorderColor: UIColor? {
279279
get {
280280
return layout.blockquoteBorderColor
281281
}
@@ -286,7 +286,7 @@ open class TextView: UITextView {
286286

287287
/// Blockquote Blocks Background Color.
288288
///
289-
@objc dynamic public var blockquoteBackgroundColor: UIColor {
289+
@objc dynamic public var blockquoteBackgroundColor: UIColor? {
290290
get {
291291
return layout.blockquoteBackgroundColor
292292
}
@@ -309,7 +309,7 @@ open class TextView: UITextView {
309309

310310
/// Pre Blocks Background Color.
311311
///
312-
@objc dynamic public var preBackgroundColor: UIColor {
312+
@objc dynamic public var preBackgroundColor: UIColor? {
313313
get {
314314
return layout.preBackgroundColor
315315
}

Example/Example/EditorDemoController.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ class EditorDemoController: UIViewController {
177177
titleTextView.textColor = UIColor.label
178178
editorView.htmlTextView.textColor = UIColor.label
179179
editorView.richTextView.textColor = UIColor.label
180-
editorView.richTextView.blockquoteBackgroundColor = UIColor.tertiarySystemBackground
181-
editorView.richTextView.preBackgroundColor = UIColor.tertiarySystemBackground
180+
editorView.richTextView.blockquoteBackgroundColor = UIColor.secondarySystemBackground
181+
editorView.richTextView.preBackgroundColor = UIColor.secondarySystemBackground
182+
editorView.richTextView.blockquoteBorderColor = UIColor.secondarySystemFill
182183
var attributes = editorView.richTextView.linkTextAttributes
183184
attributes?[.foregroundColor] = UIColor.link
184185
} else {

0 commit comments

Comments
 (0)