Skip to content
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d22a59e
Update editor's tint colour to always be WP Blue
SiobhyB Jul 25, 2022
0948e1e
Update tintColor to match correct shade of blue
SiobhyB Jul 25, 2022
b68465a
Merge branch 'trunk' into gutenberg/incorporate-consistent-tint-color
SiobhyB Jul 25, 2022
5ee8d0c
Update RELEASE-NOTES
SiobhyB Jul 25, 2022
38aac84
Set tintColor for *entire* editor window
SiobhyB Jul 26, 2022
feb03ea
Clarify purpose of code in comment
SiobhyB Jul 26, 2022
c85beaf
Tidy up code for clarity and conciseness
SiobhyB Jul 26, 2022
b4efa6a
Merge branch 'trunk' into gutenberg/incorporate-consistent-tint-color
SiobhyB Jul 26, 2022
256a4d2
Revert previous changes
SiobhyB Jul 27, 2022
9e64f2b
Set tintColor for modals
SiobhyB Jul 27, 2022
77e8e32
Merge branch 'trunk' into gutenberg/incorporate-consistent-tint-color
SiobhyB Jul 27, 2022
4fa4d0c
Set tintColor to Post Settings screen
SiobhyB Jul 27, 2022
a1cce52
Set tintColor for last Post Setting UI elements
SiobhyB Jul 28, 2022
324fe7b
Add editorPrimary var for clarity and reusability
SiobhyB Jul 28, 2022
f4eb426
Address mistake in previous commit
SiobhyB Jul 28, 2022
b6b76c5
Set tintColor on Post Settings' date picker
SiobhyB Jul 28, 2022
4763d9c
Small tweaks to code positioning, for readability
SiobhyB Jul 28, 2022
57d86ea
Set tintColor for switches in modals
SiobhyB Jul 28, 2022
7728b5a
Set tintColor for actionSheet in preseented modal
SiobhyB Jul 28, 2022
a4080b1
Replace Post Settings' tintColor calls
SiobhyB Aug 2, 2022
15effd5
Scope tintColor changes to editor
SiobhyB Aug 2, 2022
7fe6267
Small tweak: Remove unecessary reference
SiobhyB Aug 2, 2022
a8fb6ab
Refactor references to Post Settings UI
SiobhyB Aug 2, 2022
8544685
Remove accidental whitespace
SiobhyB Aug 2, 2022
67ceaa0
Set action sheet tintColor when editor appears
SiobhyB Aug 2, 2022
d5a655b
Update tintColor in Post Setting category screen
SiobhyB Aug 2, 2022
0e3821d
Update tintColor used in Post Settings media pick
SiobhyB Aug 2, 2022
ab3539c
Refine specificity of Post Settings tintColor call
SiobhyB Aug 2, 2022
233825f
Add clarifying comments
SiobhyB Aug 2, 2022
fe50487
Apply tintColor to Post Settings tag selection
SiobhyB Aug 2, 2022
10ed59f
Add clarifying comments to code
SiobhyB Aug 2, 2022
43b9994
Merge branch 'trunk' into gutenberg/incorporate-consistent-tint-color
SiobhyB Aug 2, 2022
1d5ba16
Revert accidental commit to previewController
SiobhyB Aug 2, 2022
e034bc6
Tweaks to comment spacing/wording for clarity
SiobhyB Aug 2, 2022
1eeb3ef
Add clarifying comment
SiobhyB Aug 3, 2022
6b2d0d9
Add clarifying comment
SiobhyB Aug 3, 2022
8868974
Refine/improve calls to Post Settings screen
SiobhyB Aug 4, 2022
9f4c72a
Merge branch 'trunk' into gutenberg/incorporate-consistent-tint-color
SiobhyB Aug 4, 2022
a67b94b
Remove calls to change editor action sheets
SiobhyB Aug 4, 2022
56dab96
[Code quality] Refine calls to UI elements
SiobhyB Aug 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
20.5
-----
* [*] [Jetpack-only] Block Editor: Makes some small changes to the editor's accent colours for consistency. [#19113]
* [*] Use larger thumbnail previews for recommended themes during site creation [https://github.com/wordpress-mobile/WordPress-iOS/pull/18972]

20.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct MurielColor {
static let textSubtle = AppStyleGuide.textSubtle
static let warning = AppStyleGuide.warning
static let jetpackGreen = AppStyleGuide.jetpackGreen
static let editorPrimary = AppStyleGuide.editorPrimary

/// The full name of the color, with required shade value
func assetName() -> String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ extension UIColor {
return muriel(color: .primary, shade)
}

/// Muriel editor primary color
static var editorPrimary = muriel(color: .editorPrimary)
class func editorPrimary(_ shade: MurielColorShade) -> UIColor {
return muriel(color: .editorPrimary, shade)
}

/// Muriel success color
static var success = muriel(color: .success)
class func success(_ shade: MurielColorShade) -> UIColor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
return .primaryDark
}

@available(swift, obsoleted: 1.0)
static func murielEditorPrimary() -> UIColor {
return .editorPrimary
}

@available(swift, obsoleted: 1.0)
static func murielNeutral() -> UIColor {
return .neutral
Expand Down
31 changes: 31 additions & 0 deletions WordPress/Classes/System/WordPressAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,37 @@ extension WordPressAppDelegate {
UIButton.appearance(whenContainedInInstancesOf: [WPActionBar.self]).tintColor = .primary
WPActionBar.appearance().barBackgroundColor = .basicBackground
WPActionBar.appearance().lineColor = .basicBackground

// Post Settings styles

/// Post Settings: Main and subscreens
UITableView.appearance(whenContainedInInstancesOf: [PostSettingsViewController.self]).tintColor = .editorPrimary
UITableView.appearance(whenContainedInInstancesOf: [AztecNavigationController.self]).tintColor = .editorPrimary
UISwitch.appearance(whenContainedInInstancesOf: [PostSettingsViewController.self]).onTintColor = .editorPrimary

/// Post Settings: Date picker
if #available(iOS 14.0, *) {
let editorSettingsDatePicker = UIView.appearance(whenContainedInInstancesOf: [SchedulingDatePickerViewController.self])
editorSettingsDatePicker.tintColor = .editorPrimary
}

/// Post Settings: Tag selection
UIView.appearance(whenContainedInInstancesOf: [PostTagPickerViewController.self]).tintColor = .editorPrimary

/// Post Settings: Categories selection
UIView.appearance(whenContainedInInstancesOf: [WPAddPostCategoryViewController.self]).tintColor = .editorPrimary
UIView.appearance(whenContainedInInstancesOf: [PostCategoriesViewController.self]).tintColor = .editorPrimary

/// It's necessary to target PostCategoriesViewController a second time to 'reset'
/// the UI element's `tintColor` for use in the app's Site Settings screen.
UIView.appearance(whenContainedInInstancesOf: [PostCategoriesViewController.self, WPSplitViewController.self]).tintColor = .primary

/// Post Settings: Featured Image Search
UIView.appearance(whenContainedInInstancesOf: [WPMediaPickerViewController.self]).tintColor = .editorPrimary

/// It's necessary to target WPMediaPickerViewController a second time to 'reset'
/// the UI element's `tintColor` for use app's main Media screen.
UIView.appearance(whenContainedInInstancesOf: [WPMediaPickerViewController.self, WPSplitViewController.self]).tintColor = .primary
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extension AppStyleGuide {
static let textSubtle = MurielColor(name: .gray, shade: .shade50)
static let warning = MurielColor(name: .yellow)
static let jetpackGreen = MurielColor(name: .jetpackGreen)
static let editorPrimary = MurielColor(name: .blue)
}

// MARK: - Images
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelega
super.viewWillAppear(animated)
verificationPromptHelper?.updateVerificationStatus()
ghostView.startAnimation()
// `.editorPrimary` should be the tintColor that's used for action sheets when the editor appears.
UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = .editorPrimary
}

override func viewDidAppear(_ animated: Bool) {
Expand All @@ -385,6 +387,8 @@ class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelega

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Resets the action sheet's tintColor to `.primary` to prevent `.editorPrimary` being set as the tintColor for UI elements outside of the editor.
UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = .primary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The need to mutate and reset this change is unfortunate and obscure. I am curious if more experience iOS developers have idea for an alternative approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can avoid this by targeting AztecNavigationController. [more context]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@twstokes, thank you for taking a look at this!

I tried UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self, AztecNavigationController.self]).tintColor = .primary, but it doesn't work locally for me.

I checked the hierarchy and I believe that AztecNavigationController is a 'sibling' view to UIAlertController, rather than a parent view:

Screenshot 2022-08-04 at 09 48 39

Is there perhaps another way to target the UIAlertController that I'm missing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the hierarchy and I believe that AztecNavigationController is a 'sibling' view to UIAlertController, rather than a parent view

Good catch! When I did my smoke test this code was still active so I thought the appearance proxy umbrella covered it. 👍

Is there perhaps another way to target the UIAlertController that I'm missing?

I'll look into this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 @SiobhyB - This doesn't solve all the UIAlertController cases, but what do you think about adding alert.view.tintColor = .editorPrimary here to explicitly set the "More Sheet" tint color?

let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
if mode == .richText, let contentInfo = contentInfo {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For UIAlertControllers created on the RN side (e.g. Image block -> Add Image -> Choose image), is there a reason why we're not trying to enforce the tint from there (if that's possible)? Or perhaps RN has no concept of the branding colors?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this can't be controlled / set from the RN side, I currently can't think of a better solution than what you have @SiobhyB. It's fascinating to me that the bottom sheet being presented by the editor isn't a descendant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For UIAlertControllers created on the RN side (e.g. Image block -> Add Image -> Choose image), is there a reason why we're not trying to enforce the tint from there (if that's possible)? Or perhaps RN has no concept of the branding colors?

Woah, yes, I just tested this quickly and it seems possible! It seems such an obvious solution, not sure why I went down such a complicated road with it now. 🤦‍♀️ Thanks so much @twstokes, I'll work on a Gutenberg PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone ahead to create that PR at WordPress/gutenberg#42996 and have removed the (now redundant) calls within iOS in a67b94b.

}

override func viewLayoutMarginsDidChange() {
Expand All @@ -408,6 +412,13 @@ class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelega
}
}

override func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) {
super.present(viewControllerToPresent, animated: flag, completion: completion)

let presentedView = presentedViewController?.view
presentedView?.tintColor = .editorPrimary
}

// MARK: - Functions

private var keyboardShowObserver: Any?
Expand Down Expand Up @@ -554,12 +565,15 @@ class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelega
extension GutenbergViewController {
private func setupGutenbergView() {
view.backgroundColor = .white
view.tintColor = .editorPrimary
gutenberg.rootView.translatesAutoresizingMaskIntoConstraints = false
gutenberg.rootView.backgroundColor = .basicBackground
view.addSubview(gutenberg.rootView)

view.pinSubviewToAllEdges(gutenberg.rootView)
gutenberg.rootView.pinSubviewToAllEdges(ghostView)

UISwitch.appearance(whenContainedInInstancesOf: [RCTModalHostViewController.self]).onTintColor = .editorPrimary
}
}

Expand Down
1 change: 1 addition & 0 deletions WordPress/Jetpack/AppStyleGuide.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extension AppStyleGuide {
static let textSubtle = MurielColor(name: .gray, shade: .shade50)
static let warning = MurielColor(name: .yellow)
static let jetpackGreen = MurielColor(name: .jetpackGreen)
static let editorPrimary = MurielColor(name: .blue)
}

// MARK: - Images
Expand Down