From 3220ba167114cf7ef87091b29f7b1cba0ddca10b Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Thu, 10 Oct 2019 09:39:13 +0100 Subject: [PATCH 01/10] Update colors for dark mode. --- Example/Example/EditorDemoController.swift | 34 +++++++++++++++++----- Example/Example/ViewController.swift | 17 +++-------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/Example/Example/EditorDemoController.swift b/Example/Example/EditorDemoController.swift index a1045394b..a66b79466 100644 --- a/Example/Example/EditorDemoController.swift +++ b/Example/Example/EditorDemoController.swift @@ -167,12 +167,23 @@ class EditorDemoController: UIViewController { edgesForExtendedLayout = UIRectEdge() navigationController?.navigationBar.isTranslucent = false - - view.backgroundColor = .white view.addSubview(editorView) view.addSubview(titleTextView) view.addSubview(titlePlaceholderLabel) view.addSubview(separatorView) + // color setup + if #available(iOS 13.0, *) { + view.backgroundColor = UIColor.systemBackground + titleTextView.textColor = UIColor.label + editorView.htmlTextView.textColor = UIColor.label + editorView.richTextView.textColor = UIColor.label + editorView.richTextView.blockquoteBackgroundColor = UIColor.tertiarySystemBackground + editorView.richTextView.preBackgroundColor = UIColor.tertiarySystemBackground + var attributes = editorView.richTextView.linkTextAttributes + attributes?[.foregroundColor] = UIColor.link + } else { + view.backgroundColor = UIColor.white + } //Don't allow scroll while the constraints are being setup and text set editorView.isScrollEnabled = false configureConstraints() @@ -940,11 +951,20 @@ extension EditorDemoController { let toolbar = Aztec.FormatBar() - toolbar.tintColor = .gray - toolbar.highlightedTintColor = .blue - toolbar.selectedTintColor = view.tintColor - toolbar.disabledTintColor = .lightGray - toolbar.dividerTintColor = .gray + if #available(iOS 13.0, *) { + toolbar.backgroundColor = UIColor.systemGroupedBackground + toolbar.tintColor = UIColor.secondaryLabel + toolbar.highlightedTintColor = UIColor.systemBlue + toolbar.selectedTintColor = UIColor.systemBlue + toolbar.disabledTintColor = .systemGray4 + toolbar.dividerTintColor = UIColor.separator + } else { + toolbar.tintColor = .gray + toolbar.highlightedTintColor = .blue + toolbar.selectedTintColor = view.tintColor + toolbar.disabledTintColor = .lightGray + toolbar.dividerTintColor = .gray + } toolbar.overflowToggleIcon = Gridicon.iconOfType(.ellipsis) toolbar.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: 44.0) diff --git a/Example/Example/ViewController.swift b/Example/Example/ViewController.swift index 4294e3892..c5951c73f 100644 --- a/Example/Example/ViewController.swift +++ b/Example/Example/ViewController.swift @@ -77,7 +77,7 @@ class ViewController: UITableViewController override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier)! cell.accessoryType = .disclosureIndicator - + //cell.backgroundColor = UIColor. let row = sections[indexPath.section].rows[indexPath.row] cell.textLabel?.text = row.title @@ -87,19 +87,10 @@ class ViewController: UITableViewController override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return 40 } - - override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { - let textView = UITextView() - - textView.font = UIFont.boldSystemFont(ofSize: 14) - textView.textAlignment = .center - textView.isEditable = false - textView.text = sections[section].title - textView.backgroundColor = UIColor.lightGray - - return textView - } + override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return sections[section].title + } override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) From 85ee96e70dfe31b9a938bc811665c4cd2e3e4a44 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Thu, 10 Oct 2019 09:39:21 +0100 Subject: [PATCH 02/10] Update storyboard for dark mode. --- Example/Example/Base.lproj/Main.storyboard | 38 +++++++++++++--------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/Example/Example/Base.lproj/Main.storyboard b/Example/Example/Base.lproj/Main.storyboard index d23bb2a67..7613ad57d 100644 --- a/Example/Example/Base.lproj/Main.storyboard +++ b/Example/Example/Base.lproj/Main.storyboard @@ -1,8 +1,9 @@ - + + - - + + @@ -11,16 +12,21 @@ - + - + + + + + - + - + + @@ -44,16 +50,16 @@ - + - + - + @@ -85,11 +91,11 @@ - + - + @@ -123,11 +129,11 @@ - + - + @@ -157,7 +163,7 @@ - + @@ -188,7 +194,7 @@ - + From 522acd7d0385be349a5a10496a96d2fd87045a2a Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Fri, 11 Oct 2019 15:30:36 +0100 Subject: [PATCH 03/10] Make sure HTML mode also has proper colors for dark mode. --- Example/Example/EditorDemoController.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Example/Example/EditorDemoController.swift b/Example/Example/EditorDemoController.swift index a66b79466..9de85fff2 100644 --- a/Example/Example/EditorDemoController.swift +++ b/Example/Example/EditorDemoController.swift @@ -328,7 +328,15 @@ class EditorDemoController: UIViewController { textView.accessibilityLabel = accessibilityLabel textView.font = Constants.defaultContentFont textView.keyboardDismissMode = .interactive - textView.textColor = UIColor(red: 0x1A/255.0, green: 0x1A/255.0, blue: 0x1A/255.0, alpha: 1) + if #available(iOS 13.0, *) { + textView.textColor = UIColor.label + if let htmlStorage = textView.textStorage as? HTMLStorage { + htmlStorage.textColor = UIColor.label + } + } else { + // Fallback on earlier versions + textView.textColor = UIColor(red: 0x1A/255.0, green: 0x1A/255.0, blue: 0x1A/255.0, alpha: 1) + } textView.linkTextAttributes = [.foregroundColor: UIColor(red: 0x01 / 255.0, green: 0x60 / 255.0, blue: 0x87 / 255.0, alpha: 1), NSAttributedString.Key.underlineStyle: NSNumber(value: NSUnderlineStyle.single.rawValue)] } From 8a6e96bacf7c90f33363053aeeb3374b6a3a28fe Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 15 Oct 2019 16:57:18 +0100 Subject: [PATCH 04/10] Fix options screen for dark mode --- .../OptionsTableViewController.swift | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/WordPressEditor/WordPressEditor/Classes/ViewControllers/OptionsTableViewController/OptionsTableViewController.swift b/WordPressEditor/WordPressEditor/Classes/ViewControllers/OptionsTableViewController/OptionsTableViewController.swift index 113ffe082..c1f451cc0 100644 --- a/WordPressEditor/WordPressEditor/Classes/ViewControllers/OptionsTableViewController/OptionsTableViewController.swift +++ b/WordPressEditor/WordPressEditor/Classes/ViewControllers/OptionsTableViewController/OptionsTableViewController.swift @@ -24,6 +24,25 @@ public struct OptionsTableViewOption: Equatable { } public class OptionsTableViewController: UITableViewController { + + enum Constants { + static var cellBackgroundColor: UIColor = { + if #available(iOS 13.0, *) { + return .systemBackground + } else { + return .white + } + }() + + static var cellSelectedBackgroundColor: UIColor = { + if #available(iOS 13.0, *) { + return .secondarySystemBackground + } else { + return .lightGray + } + }() + } + private static let rowHeight: CGFloat = 44.0 public typealias OnSelectHandler = (_ selected: Int) -> Void @@ -32,14 +51,14 @@ public class OptionsTableViewController: UITableViewController { public var onSelect: OnSelectHandler? - public var cellBackgroundColor: UIColor = .white { + public var cellBackgroundColor: UIColor = Constants.cellBackgroundColor { didSet { tableView.backgroundColor = cellBackgroundColor tableView?.reloadData() } } - public var cellSelectedBackgroundColor: UIColor = .lightGray + public var cellSelectedBackgroundColor: UIColor = Constants.cellSelectedBackgroundColor public var cellDeselectedTintColor: UIColor? { didSet { From 7c69fcc86c784a66841aa5862cb8e9c68cdf374a Mon Sep 17 00:00:00 2001 From: James Treanor Date: Thu, 17 Oct 2019 15:07:56 +0100 Subject: [PATCH 05/10] CircleCI: Bump Orbs to use any 1.0.x version --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bf7ef87f7..0c0a10cfd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ version: 2.1 orbs: - # This uses the iOS Orb located at https://github.com/wordpress-mobile/circleci-orbs - ios: wordpress-mobile/ios@0.0.36 + # Using 1.0 of our Orbs means it will use the latest 1.0.x version from https://github.com/wordpress-mobile/circleci-orbs + ios: wordpress-mobile/ios@1.0 workflows: test_and_validate: From bd0548894c9af281b3f250444f198641e9d86832 Mon Sep 17 00:00:00 2001 From: Matt Chowning Date: Mon, 21 Oct 2019 09:22:41 -0400 Subject: [PATCH 06/10] Recalculate typing attributes on alignment update --- Aztec/Classes/TextKit/TextView.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Aztec/Classes/TextKit/TextView.swift b/Aztec/Classes/TextKit/TextView.swift index e7d631a5a..d2c5b3948 100644 --- a/Aztec/Classes/TextKit/TextView.swift +++ b/Aztec/Classes/TextKit/TextView.swift @@ -339,6 +339,12 @@ open class TextView: UITextView { } } + override open var textAlignment: NSTextAlignment { + didSet { + recalculateTypingAttributes() + } + } + /// This property returns the Attributes associated to the Extra Line Fragment. /// From 1767c31e7e17abbbff7550c01e8f34af0e80957b Mon Sep 17 00:00:00 2001 From: Matt Chowning Date: Wed, 23 Oct 2019 12:42:47 -0400 Subject: [PATCH 07/10] Only recalulateTypingAttributes for alignment on change --- Aztec/Classes/TextKit/TextView.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Aztec/Classes/TextKit/TextView.swift b/Aztec/Classes/TextKit/TextView.swift index d2c5b3948..91cbcd72e 100644 --- a/Aztec/Classes/TextKit/TextView.swift +++ b/Aztec/Classes/TextKit/TextView.swift @@ -341,7 +341,9 @@ open class TextView: UITextView { override open var textAlignment: NSTextAlignment { didSet { - recalculateTypingAttributes() + if (textAlignment != oldValue) { + recalculateTypingAttributes() + } } } From 4c220f8d54d080f4a53f7e0a3fae89fb37d6d530 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Sun, 3 Nov 2019 23:14:07 +0000 Subject: [PATCH 08/10] Make colors for Quote and Pre elements optional. --- Aztec/Classes/TextKit/LayoutManager.swift | 24 +++++++++++++++-------- Aztec/Classes/TextKit/TextView.swift | 6 +++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Aztec/Classes/TextKit/LayoutManager.swift b/Aztec/Classes/TextKit/LayoutManager.swift index dbe233234..e9dac2c5e 100644 --- a/Aztec/Classes/TextKit/LayoutManager.swift +++ b/Aztec/Classes/TextKit/LayoutManager.swift @@ -9,15 +9,15 @@ class LayoutManager: NSLayoutManager { /// Blockquote's Left Border Color /// - var blockquoteBorderColor = UIColor(red: 0.52, green: 0.65, blue: 0.73, alpha: 1.0) + var blockquoteBorderColor: UIColor? = UIColor(red: 0.52, green: 0.65, blue: 0.73, alpha: 1.0) /// Blockquote's Background Color /// - var blockquoteBackgroundColor = UIColor(red: 0.91, green: 0.94, blue: 0.95, alpha: 1.0) + var blockquoteBackgroundColor: UIColor? = UIColor(red: 0.91, green: 0.94, blue: 0.95, alpha: 1.0) /// HTML Pre Background Color /// - var preBackgroundColor = UIColor(red: 243.0/255.0, green: 246.0/255.0, blue: 248.0/255.0, alpha: 1.0) + var preBackgroundColor: UIColor? = UIColor(red: 243.0/255.0, green: 246.0/255.0, blue: 248.0/255.0, alpha: 1.0) /// Closure that is expected to return the TypingAttributes associated to the Extra Line Fragment /// @@ -126,12 +126,17 @@ private extension LayoutManager { /// Draws a single Blockquote Line Fragment, in the specified Rectangle, using a given Graphics Context. /// private func drawBlockquote(in rect: CGRect, with context: CGContext) { - blockquoteBackgroundColor.setFill() - context.fill(rect) + if let blockquoteBackgroundColor = blockquoteBackgroundColor { + blockquoteBackgroundColor.setFill() + context.fill(rect) + + } - let borderRect = CGRect(origin: rect.origin, size: CGSize(width: blockquoteBorderWidth, height: rect.height)) - blockquoteBorderColor.setFill() - context.fill(borderRect) + if let blockquoteBorderColor = blockquoteBorderColor { + let borderRect = CGRect(origin: rect.origin, size: CGSize(width: blockquoteBorderWidth, height: rect.height)) + blockquoteBorderColor.setFill() + context.fill(borderRect) + } } } @@ -172,6 +177,9 @@ private extension LayoutManager { /// Draws a single HTML Pre Line Fragment, in the specified Rectangle, using a given Graphics Context. /// private func drawHTMLPre(in rect: CGRect, with context: CGContext) { + guard let preBackgroundColor = preBackgroundColor else { + return + } preBackgroundColor.setFill() context.fill(rect) } diff --git a/Aztec/Classes/TextKit/TextView.swift b/Aztec/Classes/TextKit/TextView.swift index 91cbcd72e..d4b3d3a92 100644 --- a/Aztec/Classes/TextKit/TextView.swift +++ b/Aztec/Classes/TextKit/TextView.swift @@ -275,7 +275,7 @@ open class TextView: UITextView { /// Blockquote Blocks Border Color. /// - @objc dynamic public var blockquoteBorderColor: UIColor { + @objc dynamic public var blockquoteBorderColor: UIColor? { get { return layout.blockquoteBorderColor } @@ -286,7 +286,7 @@ open class TextView: UITextView { /// Blockquote Blocks Background Color. /// - @objc dynamic public var blockquoteBackgroundColor: UIColor { + @objc dynamic public var blockquoteBackgroundColor: UIColor? { get { return layout.blockquoteBackgroundColor } @@ -309,7 +309,7 @@ open class TextView: UITextView { /// Pre Blocks Background Color. /// - @objc dynamic public var preBackgroundColor: UIColor { + @objc dynamic public var preBackgroundColor: UIColor? { get { return layout.preBackgroundColor } From e490a2251dfe53c3e4951caa2ed415efb709e04f Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Sun, 3 Nov 2019 23:21:30 +0000 Subject: [PATCH 09/10] Improve colors used in demo for pre and quote formats. --- Example/Example/EditorDemoController.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Example/Example/EditorDemoController.swift b/Example/Example/EditorDemoController.swift index 9de85fff2..f46617af7 100644 --- a/Example/Example/EditorDemoController.swift +++ b/Example/Example/EditorDemoController.swift @@ -177,8 +177,9 @@ class EditorDemoController: UIViewController { titleTextView.textColor = UIColor.label editorView.htmlTextView.textColor = UIColor.label editorView.richTextView.textColor = UIColor.label - editorView.richTextView.blockquoteBackgroundColor = UIColor.tertiarySystemBackground - editorView.richTextView.preBackgroundColor = UIColor.tertiarySystemBackground + editorView.richTextView.blockquoteBackgroundColor = UIColor.secondarySystemBackground + editorView.richTextView.preBackgroundColor = UIColor.secondarySystemBackground + editorView.richTextView.blockquoteBorderColor = UIColor.secondarySystemFill var attributes = editorView.richTextView.linkTextAttributes attributes?[.foregroundColor] = UIColor.link } else { From 2a9d0fc57ac86c7081e192c90fa602317674a93a Mon Sep 17 00:00:00 2001 From: Matt Chowning Date: Mon, 11 Nov 2019 06:13:39 -0500 Subject: [PATCH 10/10] Update podspec files for 1.12.0 release --- WordPress-Aztec-iOS.podspec | 2 +- WordPress-Editor-iOS.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress-Aztec-iOS.podspec b/WordPress-Aztec-iOS.podspec index 21b42d224..e2be4c6d7 100644 --- a/WordPress-Aztec-iOS.podspec +++ b/WordPress-Aztec-iOS.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'WordPress-Aztec-iOS' - s.version = '1.11.0' + s.version = '1.12.0' s.summary = 'The native HTML Editor.' # This description is used to generate tags and improve search results. diff --git a/WordPress-Editor-iOS.podspec b/WordPress-Editor-iOS.podspec index 35e7940a0..ef6ea79ae 100644 --- a/WordPress-Editor-iOS.podspec +++ b/WordPress-Editor-iOS.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'WordPress-Editor-iOS' - s.version = '1.11.0' + s.version = '1.12.0' s.summary = 'The WordPress HTML Editor.' # This description is used to generate tags and improve search results.