From a1937ad3343a7fa9c64d44c4196a1d2fdd0650a0 Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Tue, 26 Apr 2022 16:53:57 -0400 Subject: [PATCH 01/16] Remove preview mode selector from the nav bar. --- ...esignContentCollectionViewController.swift | 50 ------------------- 1 file changed, 50 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift index 6838c8b0e5c2..b64c5931b620 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift @@ -49,7 +49,6 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl tableView.reloadData() } } - var previewDeviceButtonItem: UIBarButtonItem? var selectedDesign: RemoteSiteDesign? { guard let sectionIndex = selectedItem?.section, let position = selectedItem?.item else { return nil } @@ -79,7 +78,6 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl fetchSiteDesigns() configureCloseButton() configureSkipButton() - configurePreviewDeviceButton() SiteCreationAnalyticsHelper.trackSiteDesignViewed(previewMode: selectedPreviewDevice) } @@ -106,12 +104,6 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl navigationItem.rightBarButtonItem = skip } - private func configurePreviewDeviceButton() { - let button = UIBarButtonItem(image: UIImage(named: "icon-devices"), style: .plain, target: self, action: #selector(previewDeviceButtonTapped)) - previewDeviceButtonItem = button - navigationItem.rightBarButtonItems?.append(button) - } - private func configureCloseButton() { guard navigationController?.viewControllers.first == self else { return @@ -126,21 +118,6 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl completion(nil) } - @objc private func previewDeviceButtonTapped() { - SiteCreationAnalyticsHelper.trackSiteDesignThumbnailModeButtonTapped(selectedPreviewDevice) - let popoverContentController = PreviewDeviceSelectionViewController() - popoverContentController.selectedOption = selectedPreviewDevice - popoverContentController.onDeviceChange = { [weak self] device in - guard let self = self else { return } - SiteCreationAnalyticsHelper.trackSiteDesignPreviewModeChanged(device) - self.selectedPreviewDevice = device - } - - popoverContentController.modalPresentationStyle = .popover - popoverContentController.popoverPresentationController?.delegate = self - self.present(popoverContentController, animated: true, completion: nil) - } - override func primaryActionSelected(_ sender: Any) { guard let design = selectedDesign else { completion(nil) @@ -189,30 +166,3 @@ extension SiteDesignContentCollectionViewController: NoResultsViewControllerDele fetchSiteDesigns() } } - -// MARK: UIPopoverPresentationDelegate -extension SiteDesignContentCollectionViewController { - func prepareForPopoverPresentation(_ popoverPresentationController: UIPopoverPresentationController) { - guard popoverPresentationController.presentedViewController is PreviewDeviceSelectionViewController else { - return - } - - popoverPresentationController.permittedArrowDirections = .up - popoverPresentationController.barButtonItem = previewDeviceButtonItem - } - - func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle { - return .none - } - - override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { - super.traitCollectionDidChange(previousTraitCollection) - - // Reset our source rect and view for a transition to a new size - guard let popoverPresentationController = presentedViewController?.presentationController as? UIPopoverPresentationController else { - return - } - - prepareForPopoverPresentation(popoverPresentationController) - } -} From 02f519e119d20980606dcd6bced07287227a19ca Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Tue, 26 Apr 2022 16:55:16 -0400 Subject: [PATCH 02/16] Remove Tracks helper function for the thumbnail preview mode. --- .../Site Creation/Shared/SiteCreationAnalyticsHelper.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Shared/SiteCreationAnalyticsHelper.swift b/WordPress/Classes/ViewRelated/Site Creation/Shared/SiteCreationAnalyticsHelper.swift index 26404df39ae8..a1ca2cdc74b1 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Shared/SiteCreationAnalyticsHelper.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Shared/SiteCreationAnalyticsHelper.swift @@ -77,10 +77,6 @@ class SiteCreationAnalyticsHelper { WPAnalytics.track(.enhancedSiteCreationSiteDesignViewed, withProperties: commonProperties(previewMode)) } - static func trackSiteDesignThumbnailModeButtonTapped(_ previewMode: PreviewDevice) { - WPAnalytics.track(.enhancedSiteCreationSiteDesignThumbnailModeButtonTapped, withProperties: commonProperties(previewMode)) - } - static func trackSiteDesignSkipped() { WPAnalytics.track(.enhancedSiteCreationSiteDesignSkipped) } From d920a0c60629ec5aebcc460e2f6ad52430de36c9 Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Tue, 26 Apr 2022 16:56:20 -0400 Subject: [PATCH 03/16] Point to WordPressShared pod branch. --- Podfile | 4 ++-- Podfile.lock | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Podfile b/Podfile index 3ff3bc552f79..025401b4f56f 100644 --- a/Podfile +++ b/Podfile @@ -20,9 +20,9 @@ workspace 'WordPress.xcworkspace' ## =================================== ## def wordpress_shared - pod 'WordPressShared', '~> 1.17.1' + #pod 'WordPressShared', '~> 1.17.1' #pod 'WordPressShared', :git => 'https://github.com/wordpress-mobile/WordPress-iOS-Shared.git', :tag => '' - #pod 'WordPressShared', :git => 'https://github.com/wordpress-mobile/WordPress-iOS-Shared.git', :branch => '' + pod 'WordPressShared', :git => 'https://github.com/wordpress-mobile/WordPress-iOS-Shared.git', :branch => 'task/remove-design-thumbnail-button-tapped' #pod 'WordPressShared', :git => 'https://github.com/wordpress-mobile/WordPress-iOS-Shared.git', :commit => '' #pod 'WordPressShared', :path => '../WordPress-iOS-Shared' end diff --git a/Podfile.lock b/Podfile.lock index fc76335b6191..86b96813e557 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -593,7 +593,7 @@ DEPENDENCIES: - WordPressAuthenticator (~> 2.0.0) - WordPressKit (~> 4.50.0) - WordPressMocks (~> 0.0.15) - - WordPressShared (~> 1.17.1) + - WordPressShared (from `https://github.com/wordpress-mobile/WordPress-iOS-Shared.git`, branch `task/remove-design-thumbnail-button-tapped`) - WordPressUI (~> 1.12.5) - WPMediaPicker (~> 1.8.3) - Yoga (from `https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.74.0/third-party-podspecs/Yoga.podspec.json`) @@ -642,7 +642,6 @@ SPEC REPOS: - WordPress-Editor-iOS - WordPressKit - WordPressMocks - - WordPressShared - WordPressUI - WPMediaPicker - wpxmlrpc @@ -753,6 +752,9 @@ EXTERNAL SOURCES: :git: https://github.com/wordpress-mobile/gutenberg-mobile.git :submodules: true :tag: v1.74.0 + WordPressShared: + :branch: task/remove-design-thumbnail-button-tapped + :git: https://github.com/wordpress-mobile/WordPress-iOS-Shared.git Yoga: :podspec: https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.74.0/third-party-podspecs/Yoga.podspec.json @@ -768,6 +770,9 @@ CHECKOUT OPTIONS: :git: https://github.com/wordpress-mobile/gutenberg-mobile.git :submodules: true :tag: v1.74.0 + WordPressShared: + :commit: e3ca2763fd28b7f1d326653b58a2ceb111491a10 + :git: https://github.com/wordpress-mobile/WordPress-iOS-Shared.git SPEC CHECKSUMS: Alamofire: 3ec537f71edc9804815215393ae2b1a8ea33a844 @@ -869,6 +874,6 @@ SPEC CHECKSUMS: ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba ZIPFoundation: ae5b4b813d216d3bf0a148773267fff14bd51d37 -PODFILE CHECKSUM: 4ec8f8e1fe1324b2079ae08999bcc274e8232655 +PODFILE CHECKSUM: 0c76b3628a2a62ca073f6c1e4ce934689c2184c3 COCOAPODS: 1.11.2 From 9e3248f9f216d12cacbf4a9494c322792f59414c Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Wed, 27 Apr 2022 15:20:18 -0400 Subject: [PATCH 04/16] Remove Tracks event. --- .../Utility/Analytics/WPAnalyticsTrackerAutomatticTracks.m | 3 --- 1 file changed, 3 deletions(-) diff --git a/WordPress/Classes/Utility/Analytics/WPAnalyticsTrackerAutomatticTracks.m b/WordPress/Classes/Utility/Analytics/WPAnalyticsTrackerAutomatticTracks.m index 311d27a56a79..025c64008c57 100644 --- a/WordPress/Classes/Utility/Analytics/WPAnalyticsTrackerAutomatticTracks.m +++ b/WordPress/Classes/Utility/Analytics/WPAnalyticsTrackerAutomatticTracks.m @@ -702,9 +702,6 @@ + (TracksEventPair *)eventPairForStat:(WPAnalyticsStat)stat case WPAnalyticsStatEnhancedSiteCreationSiteDesignPreviewLoaded: eventName = @"enhanced_site_creation_site_design_preview_loaded"; break; - case WPAnalyticsStatEnhancedSiteCreationSiteDesignThumbnailModeButtonTapped: - eventName = @"enhanced_site_creation_site_design_thumbnail_mode_button_tapped"; - break; case WPAnalyticsStatEnhancedSiteCreationSiteDesignPreviewModeButtonTapped: eventName = @"enhanced_site_creation_site_design_preview_mode_button_tapped"; break; From 1e02f9b24ad79f647e817fcd60580442eae2eae0 Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Wed, 27 Apr 2022 15:21:07 -0400 Subject: [PATCH 05/16] Enforce mobile thumbnails and prevent changing them with the device mode picker for previews. --- .../SiteDesignContentCollectionViewController.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift index b64c5931b620..ec22ed1f9646 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift @@ -35,6 +35,7 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl var selectedIndexPath: IndexPath? = nil private var sections: [SiteDesignSection] = [] internal override var categorySections: [CategorySection] { get { sections }} + var siteDesigns = RemoteSiteDesigns() { didSet { if oldValue.categories.count == 0 { @@ -66,6 +67,9 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl primaryActionTitle: createsSite ? TextContent.createSiteButton : TextContent.chooseButton, secondaryActionTitle: TextContent.previewButton ) + + // show mobile thumbnails for all devices + selectedPreviewDevice = .mobile } required init?(coder: NSCoder) { @@ -130,9 +134,7 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl override func secondaryActionSelected(_ sender: Any) { guard let design = selectedDesign else { return } - let previewVC = SiteDesignPreviewViewController(siteDesign: design, selectedPreviewDevice: selectedPreviewDevice, createsSite: createsSite, onDismissWithDeviceSelected: { [weak self] device in - self?.selectedPreviewDevice = device - }, completion: completion) + let previewVC = SiteDesignPreviewViewController(siteDesign: design, selectedPreviewDevice: PreviewDevice.default, createsSite: createsSite, onDismissWithDeviceSelected: nil, completion: completion) let navController = GutenbergLightNavigationController(rootViewController: previewVC) navController.modalPresentationStyle = .pageSheet From af51a87532b5056ab67a26051b11056d87983cbc Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Wed, 27 Apr 2022 15:47:40 -0400 Subject: [PATCH 06/16] Override the getter and setter for the superclass property. --- .../SiteDesignContentCollectionViewController.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift index ec22ed1f9646..6491db1e6d28 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift @@ -36,6 +36,11 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl private var sections: [SiteDesignSection] = [] internal override var categorySections: [CategorySection] { get { sections }} + override var selectedPreviewDevice: PreviewDevice { + get { .mobile } + set { /* no op */ } + } + var siteDesigns = RemoteSiteDesigns() { didSet { if oldValue.categories.count == 0 { @@ -67,9 +72,6 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl primaryActionTitle: createsSite ? TextContent.createSiteButton : TextContent.chooseButton, secondaryActionTitle: TextContent.previewButton ) - - // show mobile thumbnails for all devices - selectedPreviewDevice = .mobile } required init?(coder: NSCoder) { From 2db87b620d43c95dd3b9737d0a24bbf16f822aed Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Wed, 27 Apr 2022 17:10:04 -0400 Subject: [PATCH 07/16] Test that the preview device can't be changed on design screen. --- .../SiteCreation/SiteDesignTests.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/WordPress/WordPressTest/SiteCreation/SiteDesignTests.swift b/WordPress/WordPressTest/SiteCreation/SiteDesignTests.swift index a30cc8f72c01..b6024a2eaceb 100644 --- a/WordPress/WordPressTest/SiteCreation/SiteDesignTests.swift +++ b/WordPress/WordPressTest/SiteCreation/SiteDesignTests.swift @@ -73,4 +73,19 @@ class SiteDesignTests: XCTestCase { let currentTitle = siteDesignPreviewVC.primaryActionButton.currentTitle XCTAssertEqual(expectedPrimaryTitle, currentTitle) } + + /// Tests that the selected preview device cannot be changed from mobile + func testSiteDesignPreviewDeviceIsAlwaysMobile() throws { + + // given + let siteDesignVC = SiteDesignContentCollectionViewController(createsSite: false) { _ in } + let expectedDevice = PreviewDeviceSelectionViewController.PreviewDevice.mobile + XCTAssertEqual(siteDesignVC.selectedPreviewDevice, expectedDevice) + + // when + siteDesignVC.selectedPreviewDevice = PreviewDeviceSelectionViewController.PreviewDevice.tablet + + // then + XCTAssertEqual(siteDesignVC.selectedPreviewDevice, expectedDevice) + } } From a68c8c4073eecb770d20bcc3a3a5a07ef6a2be05 Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Wed, 27 Apr 2022 17:41:01 -0400 Subject: [PATCH 08/16] Add test for preview view. --- .../SiteCreation/SiteDesignTests.swift | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/WordPress/WordPressTest/SiteCreation/SiteDesignTests.swift b/WordPress/WordPressTest/SiteCreation/SiteDesignTests.swift index b6024a2eaceb..3d8a0e115eae 100644 --- a/WordPress/WordPressTest/SiteCreation/SiteDesignTests.swift +++ b/WordPress/WordPressTest/SiteCreation/SiteDesignTests.swift @@ -74,18 +74,41 @@ class SiteDesignTests: XCTestCase { XCTAssertEqual(expectedPrimaryTitle, currentTitle) } - /// Tests that the selected preview device cannot be changed from mobile + /// Tests that the preview device on the Design view cannot be changed func testSiteDesignPreviewDeviceIsAlwaysMobile() throws { // given let siteDesignVC = SiteDesignContentCollectionViewController(createsSite: false) { _ in } let expectedDevice = PreviewDeviceSelectionViewController.PreviewDevice.mobile - XCTAssertEqual(siteDesignVC.selectedPreviewDevice, expectedDevice) // when + XCTAssertEqual(siteDesignVC.selectedPreviewDevice, expectedDevice) siteDesignVC.selectedPreviewDevice = PreviewDeviceSelectionViewController.PreviewDevice.tablet // then XCTAssertEqual(siteDesignVC.selectedPreviewDevice, expectedDevice) } + + /// Tests that the preview device on the Preview view can be changed + func testSiteDesignPreviewPreviewDeviceCanBeChanged() throws { + + // given + let siteDesignPreviewVC = SiteDesignPreviewViewController( + siteDesign: remoteDesign, + selectedPreviewDevice: PreviewDeviceSelectionViewController.PreviewDevice.mobile, + createsSite: true, + onDismissWithDeviceSelected: nil, + completion: {design in } + ) + let expectedDevice = PreviewDeviceSelectionViewController.PreviewDevice.tablet + + // when + siteDesignPreviewVC.loadViewIfNeeded() + siteDesignPreviewVC.viewDidLoad() + XCTAssertEqual(siteDesignPreviewVC.selectedPreviewDevice, PreviewDeviceSelectionViewController.PreviewDevice.mobile) + siteDesignPreviewVC.selectedPreviewDevice = PreviewDeviceSelectionViewController.PreviewDevice.tablet + + // then + XCTAssertEqual(siteDesignPreviewVC.selectedPreviewDevice, expectedDevice) + } } From c7f1cbaa9c5529ee23f05766fc6a06960c1a721d Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Thu, 28 Apr 2022 08:37:46 -0400 Subject: [PATCH 09/16] Point to feature branch for iOS Shared pod. --- Podfile | 2 +- Podfile.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Podfile b/Podfile index 025401b4f56f..b4839673dd8a 100644 --- a/Podfile +++ b/Podfile @@ -22,7 +22,7 @@ workspace 'WordPress.xcworkspace' def wordpress_shared #pod 'WordPressShared', '~> 1.17.1' #pod 'WordPressShared', :git => 'https://github.com/wordpress-mobile/WordPress-iOS-Shared.git', :tag => '' - pod 'WordPressShared', :git => 'https://github.com/wordpress-mobile/WordPress-iOS-Shared.git', :branch => 'task/remove-design-thumbnail-button-tapped' + pod 'WordPressShared', :git => 'https://github.com/wordpress-mobile/WordPress-iOS-Shared.git', :branch => 'feature/site-design-revamp' #pod 'WordPressShared', :git => 'https://github.com/wordpress-mobile/WordPress-iOS-Shared.git', :commit => '' #pod 'WordPressShared', :path => '../WordPress-iOS-Shared' end diff --git a/Podfile.lock b/Podfile.lock index 86b96813e557..d7f5861963a9 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -593,7 +593,7 @@ DEPENDENCIES: - WordPressAuthenticator (~> 2.0.0) - WordPressKit (~> 4.50.0) - WordPressMocks (~> 0.0.15) - - WordPressShared (from `https://github.com/wordpress-mobile/WordPress-iOS-Shared.git`, branch `task/remove-design-thumbnail-button-tapped`) + - WordPressShared (from `https://github.com/wordpress-mobile/WordPress-iOS-Shared.git`, branch `feature/site-design-revamp`) - WordPressUI (~> 1.12.5) - WPMediaPicker (~> 1.8.3) - Yoga (from `https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.74.0/third-party-podspecs/Yoga.podspec.json`) @@ -753,7 +753,7 @@ EXTERNAL SOURCES: :submodules: true :tag: v1.74.0 WordPressShared: - :branch: task/remove-design-thumbnail-button-tapped + :branch: feature/site-design-revamp :git: https://github.com/wordpress-mobile/WordPress-iOS-Shared.git Yoga: :podspec: https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.74.0/third-party-podspecs/Yoga.podspec.json @@ -771,7 +771,7 @@ CHECKOUT OPTIONS: :submodules: true :tag: v1.74.0 WordPressShared: - :commit: e3ca2763fd28b7f1d326653b58a2ceb111491a10 + :commit: cd17c7c81d2ad7005a724b580f99e42a50a06bdb :git: https://github.com/wordpress-mobile/WordPress-iOS-Shared.git SPEC CHECKSUMS: @@ -874,6 +874,6 @@ SPEC CHECKSUMS: ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba ZIPFoundation: ae5b4b813d216d3bf0a148773267fff14bd51d37 -PODFILE CHECKSUM: 0c76b3628a2a62ca073f6c1e4ce934689c2184c3 +PODFILE CHECKSUM: b8a2c329dc0c5787b885a9311d168d112338a918 COCOAPODS: 1.11.2 From baae1a1dfc189738099e353fafee04c125b4a14e Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Thu, 28 Apr 2022 09:55:50 -0400 Subject: [PATCH 10/16] Store the selected preview device for the Preview view. --- .../SiteDesignContentCollectionViewController.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift index 6491db1e6d28..3ba8071db383 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift @@ -41,6 +41,8 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl set { /* no op */ } } + lazy var previewViewSelectedPreviewDevice = selectedPreviewDevice + var siteDesigns = RemoteSiteDesigns() { didSet { if oldValue.categories.count == 0 { @@ -136,7 +138,15 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl override func secondaryActionSelected(_ sender: Any) { guard let design = selectedDesign else { return } - let previewVC = SiteDesignPreviewViewController(siteDesign: design, selectedPreviewDevice: PreviewDevice.default, createsSite: createsSite, onDismissWithDeviceSelected: nil, completion: completion) + let previewVC = SiteDesignPreviewViewController( + siteDesign: design, + selectedPreviewDevice: previewViewSelectedPreviewDevice, + createsSite: createsSite, + onDismissWithDeviceSelected: { [weak self] device in + self?.previewViewSelectedPreviewDevice = device + }, + completion: completion + ) let navController = GutenbergLightNavigationController(rootViewController: previewVC) navController.modalPresentationStyle = .pageSheet From 19b1dcc1fc68e4a065fe91cf1a561d465072ab1e Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Thu, 28 Apr 2022 09:56:16 -0400 Subject: [PATCH 11/16] Remove test for Preview view. --- .../SiteCreation/SiteDesignTests.swift | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/WordPress/WordPressTest/SiteCreation/SiteDesignTests.swift b/WordPress/WordPressTest/SiteCreation/SiteDesignTests.swift index 3d8a0e115eae..2b0bbd2396a5 100644 --- a/WordPress/WordPressTest/SiteCreation/SiteDesignTests.swift +++ b/WordPress/WordPressTest/SiteCreation/SiteDesignTests.swift @@ -88,27 +88,4 @@ class SiteDesignTests: XCTestCase { // then XCTAssertEqual(siteDesignVC.selectedPreviewDevice, expectedDevice) } - - /// Tests that the preview device on the Preview view can be changed - func testSiteDesignPreviewPreviewDeviceCanBeChanged() throws { - - // given - let siteDesignPreviewVC = SiteDesignPreviewViewController( - siteDesign: remoteDesign, - selectedPreviewDevice: PreviewDeviceSelectionViewController.PreviewDevice.mobile, - createsSite: true, - onDismissWithDeviceSelected: nil, - completion: {design in } - ) - let expectedDevice = PreviewDeviceSelectionViewController.PreviewDevice.tablet - - // when - siteDesignPreviewVC.loadViewIfNeeded() - siteDesignPreviewVC.viewDidLoad() - XCTAssertEqual(siteDesignPreviewVC.selectedPreviewDevice, PreviewDeviceSelectionViewController.PreviewDevice.mobile) - siteDesignPreviewVC.selectedPreviewDevice = PreviewDeviceSelectionViewController.PreviewDevice.tablet - - // then - XCTAssertEqual(siteDesignPreviewVC.selectedPreviewDevice, expectedDevice) - } } From 07e45e5d3b6a0552c0820f04c3b707a5b4a4f83c Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Thu, 28 Apr 2022 10:06:48 -0400 Subject: [PATCH 12/16] Tweak access control for Preview view device. --- .../SiteDesignContentCollectionViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift index 3ba8071db383..97e9608248ad 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift @@ -41,7 +41,7 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl set { /* no op */ } } - lazy var previewViewSelectedPreviewDevice = selectedPreviewDevice + private lazy var previewViewSelectedPreviewDevice = selectedPreviewDevice var siteDesigns = RemoteSiteDesigns() { didSet { From 0620afb063a2a7838b31b537002a099be49e933d Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Thu, 28 Apr 2022 10:21:43 -0400 Subject: [PATCH 13/16] Use device default for initial Preview device size. --- .../SiteDesignContentCollectionViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift index 97e9608248ad..01eece17634c 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift @@ -41,7 +41,7 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl set { /* no op */ } } - private lazy var previewViewSelectedPreviewDevice = selectedPreviewDevice + private lazy var previewViewSelectedPreviewDevice = PreviewDevice.default var siteDesigns = RemoteSiteDesigns() { didSet { From 52752f98e3c754d4cc00ff1d7af92fd787c36c50 Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Thu, 28 Apr 2022 13:21:27 -0400 Subject: [PATCH 14/16] Reword title. --- .../SiteDesignContentCollectionViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift index 01eece17634c..f3202f31cf70 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift @@ -161,7 +161,7 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl } private enum TextContent { - static let mainTitle = NSLocalizedString("Choose a design", comment: "Title for the screen to pick a design and homepage for a site.") + static let mainTitle = NSLocalizedString("Choose a theme", comment: "Title for the screen to pick a theme and homepage for a site.") static let subtitle = 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.") static let createSiteButton = NSLocalizedString("Create Site", comment: "Title for the button to progress with creating the site with the selected design.") static let chooseButton = NSLocalizedString("Choose", comment: "Title for the button to progress with the selected site homepage design.") From a3dc8f7f343914c3388032a6f20df545c8a2fc45 Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Thu, 28 Apr 2022 15:22:09 -0400 Subject: [PATCH 15/16] Hide prompt view and remove text. --- .../SiteDesignContentCollectionViewController.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift index f3202f31cf70..36c090b81327 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift @@ -70,7 +70,7 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl super.init( analyticsLocation: "site_creation", mainTitle: TextContent.mainTitle, - prompt: TextContent.subtitle, + prompt: "", primaryActionTitle: createsSite ? TextContent.createSiteButton : TextContent.chooseButton, secondaryActionTitle: TextContent.previewButton ) @@ -82,6 +82,7 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl override func viewDidLoad() { super.viewDidLoad() + promptView.isHidden = true navigationItem.backButtonTitle = TextContent.backButtonTitle fetchSiteDesigns() configureCloseButton() @@ -162,7 +163,6 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl private enum TextContent { static let mainTitle = NSLocalizedString("Choose a theme", comment: "Title for the screen to pick a theme and homepage for a site.") - static let subtitle = 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.") static let createSiteButton = NSLocalizedString("Create Site", comment: "Title for the button to progress with creating the site with the selected design.") static let chooseButton = NSLocalizedString("Choose", comment: "Title for the button to progress with the selected site homepage design.") static let previewButton = NSLocalizedString("Preview", comment: "Title for button to preview a selected homepage design.") From 3e9f2d54f0ba7b9481f76e2a7a57397f747428e5 Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Thu, 28 Apr 2022 15:38:18 -0400 Subject: [PATCH 16/16] Make the prompt text optional and hide the view when it's nil. --- .../Collapsable Header/CollapsableHeaderViewController.swift | 5 +++-- .../Layout Picker/FilterableCategoriesViewController.swift | 2 +- .../SiteDesignContentCollectionViewController.swift | 2 -- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Gutenberg/Collapsable Header/CollapsableHeaderViewController.swift b/WordPress/Classes/ViewRelated/Gutenberg/Collapsable Header/CollapsableHeaderViewController.swift index 787ca2ba9359..92d22f95fdac 100644 --- a/WordPress/Classes/ViewRelated/Gutenberg/Collapsable Header/CollapsableHeaderViewController.swift +++ b/WordPress/Classes/ViewRelated/Gutenberg/Collapsable Header/CollapsableHeaderViewController.swift @@ -12,7 +12,7 @@ class CollapsableHeaderViewController: UIViewController, NoResultsViewHost { let accessoryView: UIView? let mainTitle: String let navigationBarTitle: String? - let prompt: String + let prompt: String? let primaryActionTitle: String let secondaryActionTitle: String? let defaultActionTitle: String? @@ -189,7 +189,7 @@ class CollapsableHeaderViewController: UIViewController, NoResultsViewHost { mainTitle: String, navigationBarTitle: String? = nil, headerImage: UIImage? = nil, - prompt: String, + prompt: String? = nil, primaryActionTitle: String, secondaryActionTitle: String? = nil, defaultActionTitle: String? = nil, @@ -323,6 +323,7 @@ class CollapsableHeaderViewController: UIViewController, NoResultsViewHost { titleView.text = navigationBarTitle ?? mainTitle titleView.sizeToFit() largeTitleView.text = mainTitle + promptView.isHidden = prompt == nil promptView.text = prompt primaryActionButton.setTitle(primaryActionTitle, for: .normal) diff --git a/WordPress/Classes/ViewRelated/Gutenberg/Layout Picker/FilterableCategoriesViewController.swift b/WordPress/Classes/ViewRelated/Gutenberg/Layout Picker/FilterableCategoriesViewController.swift index 445bb820e749..2128ae5c2cdf 100644 --- a/WordPress/Classes/ViewRelated/Gutenberg/Layout Picker/FilterableCategoriesViewController.swift +++ b/WordPress/Classes/ViewRelated/Gutenberg/Layout Picker/FilterableCategoriesViewController.swift @@ -54,7 +54,7 @@ class FilterableCategoriesViewController: CollapsableHeaderViewController { init( analyticsLocation: String, mainTitle: String, - prompt: String, + prompt: String? = nil, primaryActionTitle: String, secondaryActionTitle: String? = nil, defaultActionTitle: String? = nil diff --git a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift index 36c090b81327..44636bed9c9a 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Design Selection/SiteDesignContentCollectionViewController.swift @@ -70,7 +70,6 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl super.init( analyticsLocation: "site_creation", mainTitle: TextContent.mainTitle, - prompt: "", primaryActionTitle: createsSite ? TextContent.createSiteButton : TextContent.chooseButton, secondaryActionTitle: TextContent.previewButton ) @@ -82,7 +81,6 @@ class SiteDesignContentCollectionViewController: FilterableCategoriesViewControl override func viewDidLoad() { super.viewDidLoad() - promptView.isHidden = true navigationItem.backButtonTitle = TextContent.backButtonTitle fetchSiteDesigns() configureCloseButton()