This repository was archived by the owner on Feb 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
[Woo Brand Update] Add more customization options to the prologue #867
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6271de6
Remove outdated logic of setting the blur
hichamboushaba 09d51bf
Set the background color always regardless of whether an image is add…
hichamboushaba fa79610
Use an image view to set the view background to allow setting both co…
hichamboushaba 592fa49
Add ability to personalize the site creation button style
hichamboushaba 9c70a8c
Make sure we don't keep the empty stackview shown in the buttons cont…
hichamboushaba 74b8c9f
Add changelog entries
hichamboushaba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,11 +13,6 @@ class LoginPrologueViewController: LoginViewController { | |
| var showCancel = false | ||
|
|
||
| @IBOutlet private weak var buttonContainerView: UIView! | ||
| /// Blur effect on button container view | ||
| /// | ||
| private var blurEffect: UIBlurEffect.Style { | ||
| return .systemChromeMaterial | ||
| } | ||
|
|
||
| /// Constraints on the button view container. | ||
| /// Used to adjust the button width in unified views. | ||
|
|
@@ -66,12 +61,10 @@ class LoginPrologueViewController: LoginViewController { | |
| topContainerView.pinSubviewToAllEdges(topContainerChildViewController.view) | ||
| } | ||
|
|
||
| setupViewBackground() | ||
| createButtonViewController() | ||
|
|
||
| defaultButtonViewMargin = buttonViewLeadingConstraint?.constant ?? 0 | ||
| if let backgroundImage = WordPressAuthenticator.shared.unifiedStyle?.prologueBackgroundImage { | ||
| view.layer.contents = backgroundImage.cgImage | ||
| } | ||
| } | ||
|
|
||
| override func styleBackground() { | ||
|
|
@@ -266,6 +259,7 @@ class LoginPrologueViewController: LoginViewController { | |
|
|
||
| let primaryButtonStyle = WordPressAuthenticator.shared.style.prologuePrimaryButtonStyle | ||
| let secondaryButtonStyle = WordPressAuthenticator.shared.style.prologueSecondaryButtonStyle | ||
| let tertiaryButtonStyle = WordPressAuthenticator.shared.style.prologueTertiaryButtonStyle ?? NUXButtonStyle.linkButtonStyle | ||
|
|
||
| setButtonViewMargins(forWidth: view.frame.width) | ||
| let displayStrings = WordPressAuthenticator.shared.displayStrings | ||
|
|
@@ -324,7 +318,7 @@ class LoginPrologueViewController: LoginViewController { | |
| isPrimary: false, | ||
| configureBodyFontForTitle: true, | ||
| accessibilityIdentifier: "Prologue Site Creation Guide button", | ||
| style: NUXButtonStyle.linkButtonStyle, | ||
| style: tertiaryButtonStyle, | ||
| onTap: siteCreationGuideCallback()) | ||
| }() | ||
|
|
||
|
|
@@ -386,26 +380,27 @@ class LoginPrologueViewController: LoginViewController { | |
| } | ||
| } | ||
|
|
||
| private func setupViewBackground() { | ||
| if let prologueViewBackgroundColor = WordPressAuthenticator.shared.unifiedStyle?.prologueViewBackgroundColor { | ||
| view.backgroundColor = prologueViewBackgroundColor | ||
| } | ||
|
|
||
| if let backgroundImage = WordPressAuthenticator.shared.unifiedStyle?.prologueBackgroundImage { | ||
| let backgroundImageView = UIImageView(image: backgroundImage) | ||
| backgroundImageView.contentMode = WordPressAuthenticator.shared.unifiedStyle?.prologueBackgroundScaleMode ?? .scaleAspectFill | ||
| backgroundImageView.translatesAutoresizingMaskIntoConstraints = false | ||
| view.insertSubview(backgroundImageView, at: 0) | ||
| view.pinSubviewToAllEdges(backgroundImageView) | ||
| } | ||
| } | ||
|
|
||
| private func setButtonViewControllerBackground() { | ||
| // Fallback to setting the button background color to clear so the blur effect blurs the Prologue background color. | ||
| let buttonsBackgroundColor = WordPressAuthenticator.shared.unifiedStyle?.prologueButtonsBackgroundColor ?? .clear | ||
| buttonViewController?.backgroundColor = buttonsBackgroundColor | ||
| buttonBackgroundView?.backgroundColor = buttonsBackgroundColor | ||
| stackedButtonsViewController?.backgroundColor = buttonsBackgroundColor | ||
|
|
||
| /// If host apps provide a background color for the prologue buttons: | ||
| /// 1. Hide the blur effect | ||
| /// 2. Set the background color of the view controller to prologueViewBackgroundColor | ||
| let prologueViewBackgroundColor = WordPressAuthenticator.shared.unifiedStyle?.prologueViewBackgroundColor ?? .clear | ||
|
|
||
| guard prologueViewBackgroundColor.cgColor == buttonsBackgroundColor.cgColor else { | ||
| buttonBlurEffectView.effect = UIBlurEffect(style: blurEffect) | ||
| return | ||
| } | ||
|
Comment on lines
-401
to
-404
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic is old, we had it when we didn't allow client apps to control the blur effect, later, this ability was added. Also, this old logic was causing me an issue, since with the new design, we need to have the buttons background as |
||
| // do not set background color if we've set a background image earlier | ||
| if WordPressAuthenticator.shared.unifiedStyle?.prologueBackgroundImage == nil { | ||
| view.backgroundColor = prologueViewBackgroundColor | ||
| } | ||
| // if a blur effect for the buttons was passed, use it; otherwise hide the view. | ||
| guard let blurEffect = WordPressAuthenticator.shared.unifiedStyle?.prologueButtonsBlurEffect else { | ||
| buttonBlurEffectView.isHidden = true | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this, both stack views were shown even when they are empty, and for some reason this causes the button section to take more space than needed when the top layout doesn't dictate a specific sizing.
I'm not entirely sure about the cause here, but my basic understanding is that when the stackview is empty and shown, it doesn't report an intrinsic size, so AutoLayout doesn't know how much space to give it when the top view doesn't report a size either.
Anyway, regardless of the explanation, I think hiding the empty view is what we should do, and given this fixes the issue, it's just better.
(I tried setting a higher priority for the content hugging constraint for the button container, but it didn't have an effect).