Skip to content

Commit

Permalink
Merge pull request #17948 from wordpress-mobile/feature/enable-jetpac…
Browse files Browse the repository at this point in the history
…k-app-features

Disables the Jetpack No Sites error for logins and signups
  • Loading branch information
Emily Laguna authored Feb 14, 2022
2 parents 57adae5 + 960c538 commit 053f9a3
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 9 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* [*] Site previews: Reduced visual flickering when previewing sites and templates. [#17861]
* [*] Stats: fix navigation between Stats tab. [#17894]
* [*] Add "Copy Link" functionality to Posts List and Pages List [#17911]
* [*] [Jetpack-only] Enables the ability to use and create WordPress.com sites, and enables the Reader tab. [#17914, #17948]

19.2
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@ import WordPressAuthenticator
protocol AuthenticationHandler {
func shouldPresentUsernamePasswordController(for siteInfo: WordPressComSiteInfo?, onCompletion: @escaping (WordPressAuthenticatorResult) -> Void)

/// Whether or not the AuthenticationHandler will override or handle the `presentLoginEpilogue` method.
/// If this returns true, the `AuthenticationHandler.presentLoginEpilogue` method is called
/// If not, then the default implementation will be called instead
/// - Returns: Bool, true if we should override the functionality, false if we should not
func willHandlePresentLoginEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials) -> Bool

func presentLoginEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, windowManager: WindowManager, onDismiss: @escaping () -> Void) -> Bool

/// Whether or not the AuthenticationHandler will override or handle the `presentSignupEpilogue` method.
/// If this returns true, the `AuthenticationHandler.presentSignupEpilogue` method is called
/// If not, then the default implementation will be called instead
/// - Returns: Bool, true if we should override the functionality, false if we should not
func willHandlePresentSignupEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, service: SocialService?) -> Bool

func presentSignupEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, service: SocialService?)

// WPAuthenticator style overrides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class PostSignUpInterstitialViewController: UIViewController {
@IBOutlet weak var createSiteButton: UIButton!
@IBOutlet weak var addSelfHostedButton: UIButton!
@IBOutlet weak var cancelButton: UIButton!
@IBOutlet weak var imageView: UIImageView!

enum DismissAction {
case none
Expand All @@ -66,6 +67,11 @@ class PostSignUpInterstitialViewController: UIViewController {

view.backgroundColor = .listBackground

// Update the banner image for Jetpack
if AppConfiguration.isJetpack, let image = UIImage(named: "wp-illustration-construct-site-jetpack") {
imageView.image = image
}

configureI18N()

WPAnalytics.track(.welcomeNoSitesInterstitialShown)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19455" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina5_5" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19454"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -13,6 +13,7 @@
<outlet property="addSelfHostedButton" destination="JzC-d5-c3A" id="32W-0f-Xl2"/>
<outlet property="cancelButton" destination="kkA-2A-oQc" id="8c3-7h-dBg"/>
<outlet property="createSiteButton" destination="r6K-uZ-29W" id="7AY-Mm-WeY"/>
<outlet property="imageView" destination="eYR-bH-2jT" id="1KO-P6-LzI"/>
<outlet property="subTitleLabel" destination="qaw-pG-rKU" id="JPQ-AV-SRz"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
<outlet property="welcomeLabel" destination="4Zg-pY-BXB" id="Cjg-0o-iCM"/>
Expand All @@ -29,7 +30,7 @@
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="aWd-hf-9Yb">
<rect key="frame" x="0.0" y="280" width="327" height="164"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="r6K-uZ-29W" customClass="NUXButton" customModule="WordPressAuthenticator">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="r6K-uZ-29W" customClass="NUXButton" customModule="WordPressAuthenticator">
<rect key="frame" x="0.0" y="0.0" width="327" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="umu-lG-4yV"/>
Expand All @@ -40,7 +41,7 @@
<action selector="createSite:" destination="-1" eventType="touchUpInside" id="PvC-HP-RQK"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JzC-d5-c3A" customClass="NUXButton" customModule="WordPressAuthenticator">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JzC-d5-c3A" customClass="NUXButton" customModule="WordPressAuthenticator">
<rect key="frame" x="0.0" y="60" width="327" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="xFj-m5-SMx"/>
Expand All @@ -51,7 +52,7 @@
<action selector="addSelfHosted:" destination="-1" eventType="touchUpInside" id="igX-Gf-1No"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kkA-2A-oQc">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kkA-2A-oQc">
<rect key="frame" x="0.0" y="120" width="327" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="Q2e-2m-ELz"/>
Expand Down Expand Up @@ -98,14 +99,14 @@
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Vgl-ir-q3p" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="4cW-ud-JFW"/>
<constraint firstAttribute="trailing" secondItem="Vgl-ir-q3p" secondAttribute="trailing" priority="999" constant="24" id="6j2-qD-fQR"/>
<constraint firstItem="Vgl-ir-q3p" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" priority="999" constant="24" id="GMi-uW-igj"/>
<constraint firstItem="Vgl-ir-q3p" firstAttribute="centerY" secondItem="i5M-Pr-FkT" secondAttribute="centerY" id="k5v-HX-Ggv"/>
</constraints>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
<point key="canvasLocation" x="-2445" y="-60"/>
</view>
</objects>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ extension WordPressAuthenticationManager: WordPressAuthenticatorDelegate {
///
func presentLoginEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, onDismiss: @escaping () -> Void) {
if let authenticationHandler = authenticationHandler,
authenticationHandler.willHandlePresentLoginEpilogue(in: navigationController, for: credentials),
authenticationHandler.presentLoginEpilogue(in: navigationController, for: credentials, windowManager: windowManager, onDismiss: onDismiss) {
return
}
Expand Down Expand Up @@ -395,7 +396,8 @@ extension WordPressAuthenticationManager: WordPressAuthenticatorDelegate {
/// Presents the Signup Epilogue, in the specified NavigationController.
///
func presentSignupEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, service: SocialService?) {
if let authenticationHandler = authenticationHandler {
if let authenticationHandler = authenticationHandler,
authenticationHandler.willHandlePresentSignupEpilogue(in: navigationController, for: credentials, service: service) {
authenticationHandler.presentSignupEpilogue(in: navigationController, for: credentials, service: service)
return
}
Expand Down
3 changes: 1 addition & 2 deletions WordPress/Jetpack/AppConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ import WordPressKit
// MARK: - Tab bar order
@objc enum WPTab: Int {
case mySites
case notifications
// Reader on Jetpack is not displayed, but we keep it here to avoid adding conditionals on existing code
case reader
case notifications
}

// MARK: - Localized Strings
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"images" : [
{
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
],
"filename" : "jetpack-empty-state-light.pdf",
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "jetpack-empty-state-dark.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "original"
}
}
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions WordPress/Jetpack/Classes/JetpackAuthenticationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ struct JetpackAuthenticationManager: AuthenticationHandler {
onCompletion(authenticationResult)
}

func willHandlePresentLoginEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials) -> Bool {
// Don't display the "no sites" epilogue if we allow site creation
return !AppConfiguration.allowSiteCreation
}

func presentLoginEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, windowManager: WindowManager, onDismiss: @escaping () -> Void) -> Bool {
if AccountHelper.hasBlogs {
return false
Expand All @@ -65,6 +70,11 @@ struct JetpackAuthenticationManager: AuthenticationHandler {
return true
}

func willHandlePresentSignupEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, service: SocialService?) -> Bool {
// Don't display the "no sites" epilogue if we allow site creation
return !AppConfiguration.allowSiteCreation
}

// If the user signs up using the Jetpack app (through SIWA, for example)
// We show right away the screen explaining that they do not have Jetpack sites
func presentSignupEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, service: SocialService?) {
Expand Down

0 comments on commit 053f9a3

Please sign in to comment.