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: 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 e7d631a5a..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 } @@ -339,6 +339,14 @@ open class TextView: UITextView { } } + override open var textAlignment: NSTextAlignment { + didSet { + if (textAlignment != oldValue) { + recalculateTypingAttributes() + } + } + } + /// This property returns the Attributes associated to the Extra Line Fragment. /// 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 @@ - + diff --git a/Example/Example/EditorDemoController.swift b/Example/Example/EditorDemoController.swift index a1045394b..f46617af7 100644 --- a/Example/Example/EditorDemoController.swift +++ b/Example/Example/EditorDemoController.swift @@ -167,12 +167,24 @@ 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.secondarySystemBackground + editorView.richTextView.preBackgroundColor = UIColor.secondarySystemBackground + editorView.richTextView.blockquoteBorderColor = UIColor.secondarySystemFill + 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() @@ -317,7 +329,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)] } @@ -940,11 +960,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) 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. 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 {