Skip to content

Commit

Permalink
[Home Page Picker] Bug fixes (#15360)
Browse files Browse the repository at this point in the history
* Prevent swipe to dismiss on site creation flow

* Fix layout constraint collisions

* Resolve issue where the header will sometimes jump around

* Correct issue where it's possible to scroll too far offscreen

* Bump gutenberg version

* Updated the site design prompt wording

* Add the WP custom user agent to site creation webviews (#15376)

* Add Template to Preview analytics (#15365)

* Resolves issue where the selection remains but the results update
  • Loading branch information
Chip authored Nov 24, 2020
1 parent a278374 commit 546c978
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 106 deletions.
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ target 'WordPress' do
## Gutenberg (React Native)
## =====================
##
gutenberg :tag => 'v1.42.0-alpha2'
gutenberg :tag => 'v1.42.0-alpha3'

## Third party libraries
## =====================
Expand Down
166 changes: 83 additions & 83 deletions Podfile.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -571,18 +571,24 @@ extension CollapsableHeaderViewController: UIScrollViewDelegate {
}
}

func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
/// Clear the stashed offset because the user has initiated a change
stashedOffset = nil
/// Restores the stashed content offset if it appears as if it's been reset.
private func restoreContentOffsetIfNeeded(_ scrollView: UIScrollView) {
guard var stashedOffset = stashedOffset else { return }
stashedOffset = resolveContentOffsetCollisions(scrollView, cachedOffset: stashedOffset)
scrollView.contentOffset = stashedOffset
}

/// Restores the stashed content offset if it appears as if it's been reset.
private func restorContentOffsetIfNeeded(_ scrollView: UIScrollView) {
guard let stashedOffset = stashedOffset else { return }
if scrollView.contentOffset.y == 0 { // Offset has probably been reset
scrollView.contentOffset = stashedOffset
private func resolveContentOffsetCollisions(_ scrollView: UIScrollView, cachedOffset: CGPoint) -> CGPoint {
var adjustedOffset = cachedOffset

/// If the content size has changed enough to where the cached offset would scroll beyond the allowable bounds then we reset to the minum scroll height to
/// maintain the header's size.
if scrollView.contentSize.height - cachedOffset.y < scrollView.frame.height {
adjustedOffset.y = maxHeaderHeight - headerHeightConstraint.constant
stashedOffset = adjustedOffset
}
self.stashedOffset = nil

return adjustedOffset
}

private func resizeHeaderIfNeeded(_ scrollView: UIScrollView) {
Expand All @@ -596,13 +602,21 @@ extension CollapsableHeaderViewController: UIScrollViewDelegate {
}
}

fileprivate func updateTitleViewVisibility(_ animated: Bool = true) {
private func updateTitleViewVisibility(_ animated: Bool = true) {
let shouldHide = (headerHeightConstraint.constant > midHeaderHeight) && !shouldUseCompactLayout
titleView.animatableSetIsHidden(shouldHide, animated: animated)
}

func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
/// Clear the stashed offset because the user has initiated a change
stashedOffset = nil
}

func scrollViewDidScroll(_ scrollView: UIScrollView) {
restorContentOffsetIfNeeded(scrollView)
guard stashedOffset == nil else {
restoreContentOffsetIfNeeded(scrollView)
return
}

guard !shouldUseCompactLayout,
!isShowingNoResults else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class SiteDesignPreviewViewController: UIViewController, NoResultsViewHost {
private func configureWebView() {
guard let demoURL = URL(string: siteDesign.demoURL) else { return }
let request = URLRequest(url: demoURL)
webView.customUserAgent = WPUserAgent.wordPress()
webView.load(request)
}

Expand Down Expand Up @@ -107,7 +108,7 @@ class SiteDesignPreviewViewController: UIViewController, NoResultsViewHost {
extension SiteDesignPreviewViewController: WKNavigationDelegate {

func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
SiteCreationAnalyticsHelper.trackSiteDesignPreviewLoading()
SiteCreationAnalyticsHelper.trackSiteDesignPreviewLoading(siteDesign)
}

func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
Expand All @@ -119,7 +120,7 @@ extension SiteDesignPreviewViewController: WKNavigationDelegate {
}

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
SiteCreationAnalyticsHelper.trackSiteDesignPreviewLoaded()
SiteCreationAnalyticsHelper.trackSiteDesignPreviewLoaded(siteDesign)
progressBar.animatableSetIsHidden(true)
removeProgressObserver()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SiteDesignContentCollectionViewController: CollapsableHeaderViewController

super.init(scrollableView: collectionView,
mainTitle: NSLocalizedString("Choose a design", comment: "Title for the screen to pick a design and homepage for a site."),
prompt: NSLocalizedString("Pick your favorite homepage layout. You can customize or change it later.", comment: "Prompt for the screen to pick a design and homepage for a site."),
prompt: NSLocalizedString("Pick your favorite homepage layout. You can edit and customize it later.", comment: "Prompt for the screen to pick a design and homepage for a site."),
primaryActionTitle: NSLocalizedString("Choose", comment: "Title for the button to progress with the selected site homepage design"),
secondaryActionTitle: NSLocalizedString("Preview", comment: "Title for button to preview a selected homepage design"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ final class AssembledSiteView: UIView {
self.initialSiteRequest = siteRequest

generator.prepare()

webView.customUserAgent = WPUserAgent.wordPress()
webView.load(siteRequest)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ class SiteCreationAnalyticsHelper {
}

static func trackSiteDesignSelected(_ siteDesign: RemoteSiteDesign) {
WPAnalytics.track(.enhancedSiteCreationSiteDesignSelected, withProperties: [siteDesignKey: siteDesign.slug])
WPAnalytics.track(.enhancedSiteCreationSiteDesignSelected, withProperties: commonProperties(siteDesign))
}

// MARK: - Site Design Preview
static func trackSiteDesignPreviewViewed(_ siteDesign: RemoteSiteDesign) {
WPAnalytics.track(.enhancedSiteCreationSiteDesignPreviewViewed, withProperties: [siteDesignKey: siteDesign.slug])
WPAnalytics.track(.enhancedSiteCreationSiteDesignPreviewViewed, withProperties: commonProperties(siteDesign))
}

static func trackSiteDesignPreviewLoading() {
WPAnalytics.track(.enhancedSiteCreationSiteDesignPreviewLoading)
static func trackSiteDesignPreviewLoading(_ siteDesign: RemoteSiteDesign) {
WPAnalytics.track(.enhancedSiteCreationSiteDesignPreviewLoading, withProperties: commonProperties(siteDesign))
}

static func trackSiteDesignPreviewLoaded() {
WPAnalytics.track(.enhancedSiteCreationSiteDesignPreviewLoaded)
static func trackSiteDesignPreviewLoaded(_ siteDesign: RemoteSiteDesign) {
WPAnalytics.track(.enhancedSiteCreationSiteDesignPreviewLoaded, withProperties: commonProperties(siteDesign))
}

// MARK: - Error
Expand All @@ -38,4 +38,9 @@ class SiteCreationAnalyticsHelper {

WPAnalytics.track(.enhancedSiteCreationErrorShown, withProperties: errorProperties)
}

// MARK: - Common
private static func commonProperties(_ siteDesign: RemoteSiteDesign) -> [AnyHashable: Any] {
return [siteDesignKey: siteDesign.slug]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<constraints>
<constraint firstItem="hQm-TV-IDW" firstAttribute="leading" secondItem="njF-e1-oar" secondAttribute="leading" constant="16" id="QB9-fd-Zsn"/>
<constraint firstItem="hQm-TV-IDW" firstAttribute="centerY" secondItem="njF-e1-oar" secondAttribute="centerY" id="eud-Yr-hp5"/>
<constraint firstItem="njF-e1-oar" firstAttribute="trailing" secondItem="hQm-TV-IDW" secondAttribute="trailing" constant="55" id="pJe-WK-HF0"/>
</constraints>
<connections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ final class WebAddressWizardContent: CollapsableHeaderViewController {
}

private func handleData(_ data: [DomainSuggestion]) {
let resultsHavePreviousSelection = data.contains { (suggestion) -> Bool in self.selectedDomain?.domainName == suggestion.domainName }
if !resultsHavePreviousSelection {
clearSelectionAndCreateSiteButton()
}

self.data = data
if data.isEmpty {
noResultsLabel.isHidden = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ final class SiteCreationWizardLauncher {
if FeatureFlag.siteCreationHomePagePicker.enabled {
if #available(iOS 13.0, *) {
wizardContent.modalPresentationStyle = .pageSheet
wizardContent.isModalInPresentation = true
} else {
// Specifically using fullScreen instead of pageSheet to get the desired behavior on Max devices running iOS 12 and below.
wizardContent.modalPresentationStyle = UIDevice.current.userInterfaceIdiom == .pad ? .pageSheet : .fullScreen
}
} else {
wizardContent.modalPresentationStyle = .fullScreen
}

return wizardContent
}()
}

0 comments on commit 546c978

Please sign in to comment.