From 394bd5b76fdd4266d40c9ebaf5e1807e3cab321e Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Wed, 27 Apr 2022 05:19:56 +0200 Subject: [PATCH 01/19] Add: Media upload tour basic info Without steps --- .../Classes/ViewRelated/Blog/QuickStartTours.swift | 14 ++++++++++++++ .../Blog/QuickStartToursCollection.swift | 1 + 2 files changed, 15 insertions(+) diff --git a/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift b/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift index fca095961b4d..25718b763bac 100644 --- a/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift +++ b/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift @@ -386,6 +386,20 @@ struct QuickStartNotificationsTour: QuickStartTour { let accessibilityHintText = NSLocalizedString("Guides you through the process of checking your notifications.", comment: "This value is used to set the accessibility hint text for viewing the user's notifications.") } +struct QuickStartMediaUploadTour: QuickStartTour { + let key = "quick-start-media-upload-tour" + let analyticsKey = "media" + let title = NSLocalizedString("Upload photos or videos", comment: "Title of a Quick Start Tour") + let titleMarkedCompleted = NSLocalizedString("Completed: Upload photos or videos", comment: "The Quick Start Tour title after the user finished the step.") + let description = NSLocalizedString("Bring media straight from your device or camera to your site.", comment: "Description of a Quick Start Tour") + let icon = UIImage.gridicon(.addImage) + let suggestionNoText = Strings.notNow + let suggestionYesText = Strings.yesShowMe + let possibleEntryPoints: Set = [.blogDetails, .blogDashboard] + + let accessibilityHintText = NSLocalizedString("Guides you through the process of uploading new media.", comment: "This value is used to set the accessibility hint text for viewing the user's notifications.") +} + private let congratsTitle = NSLocalizedString("Congrats on finishing Quick Start 🎉", comment: "Title of a Quick Start Tour") private let congratsDescription = NSLocalizedString("doesn’t it feel good to cross things off a list?", comment: "subhead shown to users when they complete all Quick Start items") struct QuickStartCongratulationsTour: QuickStartTour { diff --git a/WordPress/Classes/ViewRelated/Blog/QuickStartToursCollection.swift b/WordPress/Classes/ViewRelated/Blog/QuickStartToursCollection.swift index 907f27b62584..9e36a52d2eb9 100644 --- a/WordPress/Classes/ViewRelated/Blog/QuickStartToursCollection.swift +++ b/WordPress/Classes/ViewRelated/Blog/QuickStartToursCollection.swift @@ -78,6 +78,7 @@ struct QuickStartGetToKnowAppCollection: QuickStartToursCollection { QuickStartCheckStatsTour(), QuickStartNotificationsTour(), QuickStartViewTour(blog: blog), + QuickStartMediaUploadTour(), QuickStartFollowTour() ] } From f1b5efce4917f98c573fea5400a40cf23e992b1d Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Wed, 27 Apr 2022 05:28:18 +0200 Subject: [PATCH 02/19] Add: first upload media step --- .../Blog/Blog Details/BlogDetailsViewController.h | 2 ++ WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.h b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.h index e928d5059e37..454b890d4db9 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.h +++ b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.h @@ -74,6 +74,8 @@ typedef NS_ENUM(NSInteger, QuickStartTourElement) { QuickStartTourElementNotifications = 23, QuickStartTourElementSetupQuickStart = 24, QuickStartTourElementRemoveQuickStart = 25, + QuickStartTourElementMediaScreen = 26, + QuickStartTourElementMediaAdd = 27, }; typedef NS_ENUM(NSUInteger, BlogDetailsNavigationSource) { diff --git a/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift b/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift index 25718b763bac..a5b59085843a 100644 --- a/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift +++ b/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift @@ -397,6 +397,13 @@ struct QuickStartMediaUploadTour: QuickStartTour { let suggestionYesText = Strings.yesShowMe let possibleEntryPoints: Set = [.blogDetails, .blogDashboard] + var waypoints: [WayPoint] = { + let step1DescriptionBase = NSLocalizedString("Select %@ to see your current library.", comment: "A step in a guided tour for quick start. %@ will be the name of the item to select.") + let step1DescriptionTarget = NSLocalizedString("Media", comment: "The menu item to select during a guided tour.") + let step1: WayPoint = (element: .mediaScreen, description: step1DescriptionBase.highlighting(phrase: step1DescriptionTarget, icon: .gridicon(.image))) + return [step1] + }() + let accessibilityHintText = NSLocalizedString("Guides you through the process of uploading new media.", comment: "This value is used to set the accessibility hint text for viewing the user's notifications.") } From 056f06aff8f580946191a6b60c003747951da580 Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Wed, 27 Apr 2022 05:33:38 +0200 Subject: [PATCH 03/19] Add: point to media button on the dashboard --- .../Blog Dashboard/BlogDashboardViewController.swift | 2 +- .../Quick Actions/DashboardQuickActionsCardCell.swift | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/BlogDashboardViewController.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/BlogDashboardViewController.swift index a972e3ad951e..88433bdd3259 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/BlogDashboardViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/BlogDashboardViewController.swift @@ -164,7 +164,7 @@ final class BlogDashboardViewController: UIViewController { switch element { case .setupQuickStart, .removeQuickStart: self.loadCardsFromCache() - case .stats: + case .stats, .mediaScreen: if self.embeddedInScrollView { self.mySiteScrollView?.scrollToTop(animated: true) } else { diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Actions/DashboardQuickActionsCardCell.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Actions/DashboardQuickActionsCardCell.swift index 1e2b57892b84..9b5bc85ddea8 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Actions/DashboardQuickActionsCardCell.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Actions/DashboardQuickActionsCardCell.swift @@ -147,6 +147,13 @@ extension DashboardQuickActionsCardCell { self?.statsButton.shouldShowSpotlight = true self?.autoScrollToStatsButton() + case .mediaScreen: + guard QuickStartTourGuide.shared.entryPointForCurrentTour == .blogDashboard else { + return + } + + self?.mediaButton.shouldShowSpotlight = true + self?.autoScrollToMediaButton() default: break } @@ -161,6 +168,10 @@ extension DashboardQuickActionsCardCell { private func autoScrollToStatsButton() { scrollView.scrollHorizontallyToView(statsButton, animated: true) } + + private func autoScrollToMediaButton() { + scrollView.scrollHorizontallyToView(mediaButton, animated: true) + } } extension DashboardQuickActionsCardCell { From 1182fdc125fd86457857a8e9e47024f728062a1d Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Wed, 27 Apr 2022 05:38:21 +0200 Subject: [PATCH 04/19] Add: point to menu button on site menu --- .../Blog Details/BlogDetailsViewController+FancyAlerts.swift | 2 +- .../ViewRelated/Blog/Blog Details/BlogDetailsViewController.m | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+FancyAlerts.swift b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+FancyAlerts.swift index 1da890ea213b..7b2674f7de8b 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+FancyAlerts.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+FancyAlerts.swift @@ -17,7 +17,7 @@ extension BlogDetailsViewController { if let info = notification.userInfo?[QuickStartTourGuide.notificationElementKey] as? QuickStartTourElement { switch info { - case .stats: + case .stats, .mediaScreen: guard QuickStartTourGuide.shared.entryPointForCurrentTour == .blogDetails else { return } diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m index d620a2007288..a0efc02f461b 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m +++ b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m @@ -909,6 +909,7 @@ - (BlogDetailsSection *)publishTypeSectionViewModel callback:^{ [weakSelf showMediaLibraryFromSource:BlogDetailsNavigationSourceRow]; }]; + mediaRow.quickStartIdentifier = QuickStartTourElementMediaScreen; [rows addObject:mediaRow]; BlogDetailsRow *pagesRow = [[BlogDetailsRow alloc] initWithTitle:NSLocalizedString(@"Pages", @"Noun. Title. Links to the blog's Pages screen.") From 9bd6a12900131cd18c5e80f3bd6a8044a55b9337 Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Wed, 27 Apr 2022 05:48:14 +0200 Subject: [PATCH 05/19] Add: mark first step as visited --- .../ViewRelated/Blog/Blog Details/BlogDetailsViewController.m | 2 +- .../Classes/ViewRelated/Media/MediaLibraryViewController.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m index a0efc02f461b..25aacf25664d 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m +++ b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m @@ -1448,7 +1448,7 @@ - (void)showMediaLibraryFromSource:(BlogDetailsNavigationSource)source controller.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever; [self showDetailViewController:controller sender:self]; - [[QuickStartTourGuide shared] visited:QuickStartTourElementBlogDetailNavigation]; + [[QuickStartTourGuide shared] visited:QuickStartTourElementMediaScreen]; } - (void)showPeople diff --git a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift index 326b35df8ba3..37ff6a22baa1 100644 --- a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift +++ b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift @@ -62,7 +62,7 @@ class MediaLibraryViewController: WPMediaPickerViewController { controller.navigationItem.largeTitleDisplayMode = .never sourceController.navigationController?.pushViewController(controller, animated: true) - QuickStartTourGuide.shared.visited(.blogDetailNavigation) + QuickStartTourGuide.shared.visited(.mediaScreen) } deinit { From 02dc7bf7f2250f006e0aa7b62a752463a1ec8a4e Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Wed, 27 Apr 2022 05:50:42 +0200 Subject: [PATCH 06/19] Refactor: always reevaluate if quick action spotlight should be shown --- .../Cards/Quick Actions/DashboardQuickActionsCardCell.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Actions/DashboardQuickActionsCardCell.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Actions/DashboardQuickActionsCardCell.swift index 9b5bc85ddea8..6ad2306ac711 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Actions/DashboardQuickActionsCardCell.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Actions/DashboardQuickActionsCardCell.swift @@ -138,25 +138,23 @@ extension DashboardQuickActionsCardCell { let element = info[QuickStartTourGuide.notificationElementKey] as? QuickStartTourElement { switch element { - case .noSuchElement: - self?.statsButton.shouldShowSpotlight = false case .stats: guard QuickStartTourGuide.shared.entryPointForCurrentTour == .blogDashboard else { return } - self?.statsButton.shouldShowSpotlight = true self?.autoScrollToStatsButton() case .mediaScreen: guard QuickStartTourGuide.shared.entryPointForCurrentTour == .blogDashboard else { return } - self?.mediaButton.shouldShowSpotlight = true self?.autoScrollToMediaButton() default: break } + self?.statsButton.shouldShowSpotlight = element == .stats + self?.mediaButton.shouldShowSpotlight = element == .mediaScreen } } } From 6f18cfc3c7fa8961035bcbffb7921cbdd7900f76 Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Wed, 27 Apr 2022 06:01:07 +0200 Subject: [PATCH 07/19] Add: add media step --- WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift b/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift index a5b59085843a..db5c3d9997dd 100644 --- a/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift +++ b/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift @@ -401,7 +401,12 @@ struct QuickStartMediaUploadTour: QuickStartTour { let step1DescriptionBase = NSLocalizedString("Select %@ to see your current library.", comment: "A step in a guided tour for quick start. %@ will be the name of the item to select.") let step1DescriptionTarget = NSLocalizedString("Media", comment: "The menu item to select during a guided tour.") let step1: WayPoint = (element: .mediaScreen, description: step1DescriptionBase.highlighting(phrase: step1DescriptionTarget, icon: .gridicon(.image))) - return [step1] + + let step2DescriptionBase = NSLocalizedString("Select %@to upload media. You can add it to your posts / pages from any device.", comment: "A step in a guided tour for quick start. %@ will be a plus icon.") + let step2DescriptionTarget = "" + let step2: WayPoint = (element: .mediaAdd, description: step2DescriptionBase.highlighting(phrase: step2DescriptionTarget, icon: .gridicon(.plus))) + + return [step1, step2] }() let accessibilityHintText = NSLocalizedString("Guides you through the process of uploading new media.", comment: "This value is used to set the accessibility hint text for viewing the user's notifications.") From 31d47b64282cb41fe0cca11fdfca6a2f3f24702d Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Wed, 27 Apr 2022 06:04:29 +0200 Subject: [PATCH 08/19] Add: mark the second step as visited --- .../Classes/ViewRelated/Media/MediaLibraryViewController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift index 37ff6a22baa1..b40c0e1f5d8c 100644 --- a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift +++ b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift @@ -255,6 +255,7 @@ class MediaLibraryViewController: WPMediaPickerViewController { // MARK: - Actions @objc fileprivate func addTapped() { + QuickStartTourGuide.shared.visited(.mediaAdd) showOptionsMenu() } From abf84b93cc4f4b0615ee81f66c808770815811ee Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Thu, 28 Apr 2022 05:21:39 +0200 Subject: [PATCH 09/19] Add: spotlight view to add button --- .../Media/MediaLibraryViewController.swift | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift index b40c0e1f5d8c..a4c77461e97f 100644 --- a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift +++ b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift @@ -16,6 +16,7 @@ class MediaLibraryViewController: WPMediaPickerViewController { fileprivate var isLoading: Bool = false fileprivate let noResultsView = NoResultsViewController.controller() + fileprivate let addButton: SpotlightableButton = SpotlightableButton(type: .custom) fileprivate var selectedAsset: Media? = nil @@ -120,6 +121,11 @@ class MediaLibraryViewController: WPMediaPickerViewController { } } + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + addButton.shouldShowSpotlight = QuickStartTourGuide.shared.isCurrentElement(.mediaAdd) + } + // MARK: - Update view state fileprivate func updateViewState(for assetCount: Int) { @@ -143,11 +149,17 @@ class MediaLibraryViewController: WPMediaPickerViewController { var barButtonItems = [UIBarButtonItem]() if blog.userCanUploadMedia && assetCount > 0 { - let addButton = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addTapped)) + addButton.spotlightOffset = Constants.addButtonSpotlightOffset + let config = UIImage.SymbolConfiguration(textStyle: .body, scale: .large) + let image = UIImage(systemName: "plus", withConfiguration: config) ?? .gridicon(.plus) + addButton.setImage(image, for: .normal) + addButton.contentEdgeInsets = Constants.addButtonContentInset + addButton.addTarget(self, action: #selector(addTapped), for: .touchUpInside) addButton.accessibilityLabel = NSLocalizedString("Add", comment: "Accessibility label for add button to add items to the user's media library") addButton.accessibilityHint = NSLocalizedString("Add new media", comment: "Accessibility hint for add button to add items to the user's media library") - barButtonItems.append(addButton) + let addBarButton = UIBarButtonItem(customView: addButton) + barButtonItems.append(addBarButton) } if blog.supports(.mediaDeletion) && assetCount > 0 { @@ -157,10 +169,8 @@ class MediaLibraryViewController: WPMediaPickerViewController { barButtonItems.append(editButton) - navigationItem.setRightBarButtonItems(barButtonItems, animated: false) - } else { - navigationItem.setRightBarButtonItems(barButtonItems, animated: false) } + navigationItem.setRightBarButtonItems(barButtonItems, animated: false) } } @@ -256,6 +266,7 @@ class MediaLibraryViewController: WPMediaPickerViewController { @objc fileprivate func addTapped() { QuickStartTourGuide.shared.visited(.mediaAdd) + addButton.shouldShowSpotlight = QuickStartTourGuide.shared.isCurrentElement(.mediaAdd) showOptionsMenu() } @@ -743,3 +754,12 @@ extension MediaLibraryViewController: TenorPickerDelegate { } } } + +// MARK: Constants + +extension MediaLibraryViewController { + private enum Constants { + static let addButtonSpotlightOffset = UIOffset(horizontal: 20, vertical: -10) + static let addButtonContentInset = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0) + } +} From fdd5c029c9c6ef754d8199b9d93cb374f9e613ff Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Thu, 28 Apr 2022 05:22:45 +0200 Subject: [PATCH 10/19] Fix: spotlight view being clipped --- .../Media/MediaLibraryViewController.swift | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift index a4c77461e97f..d4909edb523d 100644 --- a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift +++ b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift @@ -18,6 +18,8 @@ class MediaLibraryViewController: WPMediaPickerViewController { fileprivate let noResultsView = NoResultsViewController.controller() fileprivate let addButton: SpotlightableButton = SpotlightableButton(type: .custom) + fileprivate var kvoTokens: [NSKeyValueObservation]? + fileprivate var selectedAsset: Media? = nil fileprivate var capturePresenter: WPMediaCapturePresenter? @@ -69,6 +71,7 @@ class MediaLibraryViewController: WPMediaPickerViewController { deinit { unregisterChangeObserver() unregisterUploadCoordinatorObserver() + stopObservingNavigationBarClipsToBounds() } private class func pickerOptions() -> WPMediaPickerOptions { @@ -105,6 +108,9 @@ class MediaLibraryViewController: WPMediaPickerViewController { if let collectionView = collectionView { WPStyleGuide.configureColors(view: view, collectionView: collectionView) } + + navigationController?.navigationBar.subviews.forEach ({ $0.clipsToBounds = false }) + startObservingNavigationBarClipsToBounds() } override func viewDidAppear(_ animated: Bool) { @@ -439,6 +445,21 @@ class MediaLibraryViewController: WPMediaPickerViewController { MediaCoordinator.shared.removeObserver(withUUID: uuid) } } + + // MARK: ClipsToBounds KVO Observer + + private func startObservingNavigationBarClipsToBounds() { + kvoTokens = navigationController?.navigationBar.subviews.map({ subview in + return subview.observe(\.clipsToBounds, options: .new, changeHandler: { view, change in + guard let newValue = change.newValue, newValue else { return } + view.clipsToBounds = false + }) + }) + } + + private func stopObservingNavigationBarClipsToBounds() { + kvoTokens?.forEach({ $0.invalidate() }) + } } // MARK: - UIDocumentPickerDelegate From 27b9a6910ff72caa9971f4f8d596081a0315dc1d Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Thu, 28 Apr 2022 15:52:10 +0200 Subject: [PATCH 11/19] Change: always show add button, even if there's no media --- .../Classes/ViewRelated/Media/MediaLibraryViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift index d4909edb523d..33379dfc4cc1 100644 --- a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift +++ b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift @@ -154,7 +154,7 @@ class MediaLibraryViewController: WPMediaPickerViewController { var barButtonItems = [UIBarButtonItem]() - if blog.userCanUploadMedia && assetCount > 0 { + if blog.userCanUploadMedia { addButton.spotlightOffset = Constants.addButtonSpotlightOffset let config = UIImage.SymbolConfiguration(textStyle: .body, scale: .large) let image = UIImage(systemName: "plus", withConfiguration: config) ?? .gridicon(.plus) From 0b812f029bdf35aa6bac47b13fd9cf2ae1c49607 Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Thu, 28 Apr 2022 15:54:48 +0200 Subject: [PATCH 12/19] Change: use in-progress MediaPicker beta --- Podfile | 4 ++-- Podfile.lock | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Podfile b/Podfile index 3ff3bc552f79..2330abd9f0ee 100644 --- a/Podfile +++ b/Podfile @@ -210,10 +210,10 @@ abstract_target 'Apps' do pod 'NSURL+IDN', '~> 0.4' - pod 'WPMediaPicker', '~> 1.8.3' + # pod 'WPMediaPicker', '~> 1.8.3' # pod 'WPMediaPicker', :git => 'https://github.com/wordpress-mobile/MediaPicker-iOS.git', :tag => '1.7.0' ## while PR is in review: - # pod 'WPMediaPicker', :git => 'https://github.com/wordpress-mobile/MediaPicker-iOS.git', :branch => '' + pod 'WPMediaPicker', :git => 'https://github.com/wordpress-mobile/MediaPicker-iOS.git', :branch => 'issue/386-empty-view-placement' # pod 'WPMediaPicker', :path => '../MediaPicker-iOS' pod 'Gridicons', '~> 1.1.0' diff --git a/Podfile.lock b/Podfile.lock index fc76335b6191..75b51046ebc9 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -499,7 +499,7 @@ PODS: - CocoaLumberjack (~> 3.4) - FormatterKit/TimeIntervalFormatter (~> 1.8) - WordPressUI (1.12.5) - - WPMediaPicker (1.8.3) + - WPMediaPicker (1.8.3-beta.1) - wpxmlrpc (0.9.0) - Yoga (1.14.0) - ZendeskCommonUISDK (6.1.2) @@ -595,7 +595,7 @@ DEPENDENCIES: - WordPressMocks (~> 0.0.15) - WordPressShared (~> 1.17.1) - WordPressUI (~> 1.12.5) - - WPMediaPicker (~> 1.8.3) + - WPMediaPicker (from `https://github.com/wordpress-mobile/MediaPicker-iOS.git`, branch `issue/386-empty-view-placement`) - Yoga (from `https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.74.0/third-party-podspecs/Yoga.podspec.json`) - ZendeskSupportSDK (= 5.3.0) - ZIPFoundation (~> 0.9.8) @@ -644,7 +644,6 @@ SPEC REPOS: - WordPressMocks - WordPressShared - WordPressUI - - WPMediaPicker - wpxmlrpc - ZendeskCommonUISDK - ZendeskCoreSDK @@ -753,6 +752,9 @@ EXTERNAL SOURCES: :git: https://github.com/wordpress-mobile/gutenberg-mobile.git :submodules: true :tag: v1.74.0 + WPMediaPicker: + :branch: issue/386-empty-view-placement + :git: https://github.com/wordpress-mobile/MediaPicker-iOS.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 + WPMediaPicker: + :commit: 0c09a04d38553c440e396a59b490f0406729fd5d + :git: https://github.com/wordpress-mobile/MediaPicker-iOS.git SPEC CHECKSUMS: Alamofire: 3ec537f71edc9804815215393ae2b1a8ea33a844 @@ -857,7 +862,7 @@ SPEC CHECKSUMS: WordPressMocks: 6b52b0764d9939408151367dd9c6e8a910877f4d WordPressShared: 0c4bc5e25765732fcf5d07f28c81970ab28493fb WordPressUI: c5be816f6c7b3392224ac21de9e521e89fa108ac - WPMediaPicker: 0f4f20c7f661b46d33283f1ac2adceb98718fffa + WPMediaPicker: 0bcc78d3f1f2e14a369f318bbe930b8ea1d65ae5 wpxmlrpc: bf55a43a7e710bd2a4fb8c02dfe83b1246f14f13 Yoga: 2ca978c40e0fd6d7f54bcb1602bc0cbbc79454a7 ZendeskCommonUISDK: 5f0a83f412e07ae23701f18c412fe783b3249ef5 @@ -869,6 +874,6 @@ SPEC CHECKSUMS: ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba ZIPFoundation: ae5b4b813d216d3bf0a148773267fff14bd51d37 -PODFILE CHECKSUM: 4ec8f8e1fe1324b2079ae08999bcc274e8232655 +PODFILE CHECKSUM: 4a6b2e4e9e08956fd4025238314208173585b4ca COCOAPODS: 1.11.2 From f0900942e9ff79a5d6b0aa40a7b120cddff10693 Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Thu, 28 Apr 2022 16:04:47 +0200 Subject: [PATCH 13/19] Add: documentation for kvo usage --- .../ViewRelated/Media/MediaLibraryViewController.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift index 33379dfc4cc1..e7b7962d28e5 100644 --- a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift +++ b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift @@ -448,6 +448,10 @@ class MediaLibraryViewController: WPMediaPickerViewController { // MARK: ClipsToBounds KVO Observer + /// The content view of the navigation bar causes the spotlight view on the add button to be clipped. + /// This ensures that `clipsToBounds` of the content view is always `false`. + /// Without this, `clipsToBounds` reverts to `true` at some point during the view lifecycle. This happens asynchronously, + /// so we can't confidently reset it. Hence the need for KVO. private func startObservingNavigationBarClipsToBounds() { kvoTokens = navigationController?.navigationBar.subviews.map({ subview in return subview.observe(\.clipsToBounds, options: .new, changeHandler: { view, change in From 7c979fc08da2e61be6e70ae828b055638503d80b Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Mon, 9 May 2022 03:09:33 +0200 Subject: [PATCH 14/19] Revert "Change: use in-progress MediaPicker beta" This reverts commit 0b812f029bdf35aa6bac47b13fd9cf2ae1c49607. --- Podfile | 4 ++-- Podfile.lock | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Podfile b/Podfile index 2330abd9f0ee..3ff3bc552f79 100644 --- a/Podfile +++ b/Podfile @@ -210,10 +210,10 @@ abstract_target 'Apps' do pod 'NSURL+IDN', '~> 0.4' - # pod 'WPMediaPicker', '~> 1.8.3' + pod 'WPMediaPicker', '~> 1.8.3' # pod 'WPMediaPicker', :git => 'https://github.com/wordpress-mobile/MediaPicker-iOS.git', :tag => '1.7.0' ## while PR is in review: - pod 'WPMediaPicker', :git => 'https://github.com/wordpress-mobile/MediaPicker-iOS.git', :branch => 'issue/386-empty-view-placement' + # pod 'WPMediaPicker', :git => 'https://github.com/wordpress-mobile/MediaPicker-iOS.git', :branch => '' # pod 'WPMediaPicker', :path => '../MediaPicker-iOS' pod 'Gridicons', '~> 1.1.0' diff --git a/Podfile.lock b/Podfile.lock index 75b51046ebc9..fc76335b6191 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -499,7 +499,7 @@ PODS: - CocoaLumberjack (~> 3.4) - FormatterKit/TimeIntervalFormatter (~> 1.8) - WordPressUI (1.12.5) - - WPMediaPicker (1.8.3-beta.1) + - WPMediaPicker (1.8.3) - wpxmlrpc (0.9.0) - Yoga (1.14.0) - ZendeskCommonUISDK (6.1.2) @@ -595,7 +595,7 @@ DEPENDENCIES: - WordPressMocks (~> 0.0.15) - WordPressShared (~> 1.17.1) - WordPressUI (~> 1.12.5) - - WPMediaPicker (from `https://github.com/wordpress-mobile/MediaPicker-iOS.git`, branch `issue/386-empty-view-placement`) + - WPMediaPicker (~> 1.8.3) - Yoga (from `https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.74.0/third-party-podspecs/Yoga.podspec.json`) - ZendeskSupportSDK (= 5.3.0) - ZIPFoundation (~> 0.9.8) @@ -644,6 +644,7 @@ SPEC REPOS: - WordPressMocks - WordPressShared - WordPressUI + - WPMediaPicker - wpxmlrpc - ZendeskCommonUISDK - ZendeskCoreSDK @@ -752,9 +753,6 @@ EXTERNAL SOURCES: :git: https://github.com/wordpress-mobile/gutenberg-mobile.git :submodules: true :tag: v1.74.0 - WPMediaPicker: - :branch: issue/386-empty-view-placement - :git: https://github.com/wordpress-mobile/MediaPicker-iOS.git Yoga: :podspec: https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.74.0/third-party-podspecs/Yoga.podspec.json @@ -770,9 +768,6 @@ CHECKOUT OPTIONS: :git: https://github.com/wordpress-mobile/gutenberg-mobile.git :submodules: true :tag: v1.74.0 - WPMediaPicker: - :commit: 0c09a04d38553c440e396a59b490f0406729fd5d - :git: https://github.com/wordpress-mobile/MediaPicker-iOS.git SPEC CHECKSUMS: Alamofire: 3ec537f71edc9804815215393ae2b1a8ea33a844 @@ -862,7 +857,7 @@ SPEC CHECKSUMS: WordPressMocks: 6b52b0764d9939408151367dd9c6e8a910877f4d WordPressShared: 0c4bc5e25765732fcf5d07f28c81970ab28493fb WordPressUI: c5be816f6c7b3392224ac21de9e521e89fa108ac - WPMediaPicker: 0bcc78d3f1f2e14a369f318bbe930b8ea1d65ae5 + WPMediaPicker: 0f4f20c7f661b46d33283f1ac2adceb98718fffa wpxmlrpc: bf55a43a7e710bd2a4fb8c02dfe83b1246f14f13 Yoga: 2ca978c40e0fd6d7f54bcb1602bc0cbbc79454a7 ZendeskCommonUISDK: 5f0a83f412e07ae23701f18c412fe783b3249ef5 @@ -874,6 +869,6 @@ SPEC CHECKSUMS: ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba ZIPFoundation: ae5b4b813d216d3bf0a148773267fff14bd51d37 -PODFILE CHECKSUM: 4a6b2e4e9e08956fd4025238314208173585b4ca +PODFILE CHECKSUM: 4ec8f8e1fe1324b2079ae08999bcc274e8232655 COCOAPODS: 1.11.2 From a91b3b59b2708c93274135773c019254fd2d9dc2 Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Mon, 9 May 2022 03:32:20 +0200 Subject: [PATCH 15/19] Change: use WPMediaPicker 1.8.3-beta.1 --- Podfile | 2 +- Podfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Podfile b/Podfile index 4ef1ceec6df8..aff44e1511fe 100644 --- a/Podfile +++ b/Podfile @@ -210,7 +210,7 @@ abstract_target 'Apps' do pod 'NSURL+IDN', '~> 0.4' - pod 'WPMediaPicker', '~> 1.8.3' + pod 'WPMediaPicker', '~> 1.8.3-beta.1' # pod 'WPMediaPicker', :git => 'https://github.com/wordpress-mobile/MediaPicker-iOS.git', :tag => '1.7.0' ## while PR is in review: # pod 'WPMediaPicker', :git => 'https://github.com/wordpress-mobile/MediaPicker-iOS.git', :branch => '' diff --git a/Podfile.lock b/Podfile.lock index 9605309addd7..cbf1d920009c 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -595,7 +595,7 @@ DEPENDENCIES: - WordPressMocks (~> 0.0.15) - WordPressShared (~> 1.17.1) - WordPressUI (~> 1.12.5) - - WPMediaPicker (~> 1.8.3) + - WPMediaPicker (~> 1.8.3-beta.1) - Yoga (from `https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.75.0/third-party-podspecs/Yoga.podspec.json`) - ZendeskSupportSDK (= 5.3.0) - ZIPFoundation (~> 0.9.8) @@ -869,6 +869,6 @@ SPEC CHECKSUMS: ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba ZIPFoundation: ae5b4b813d216d3bf0a148773267fff14bd51d37 -PODFILE CHECKSUM: a9583cec2bc246d23cf0045230cd179dc03c5adb +PODFILE CHECKSUM: 5a95da7aea712ea40c414022082be3d6dbe39b4b COCOAPODS: 1.11.2 From 913e67bf821e7a060da1662222d823d53bbd3e5f Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Mon, 9 May 2022 03:36:05 +0200 Subject: [PATCH 16/19] Fix: failing unit tests --- WordPress/WordPressTest/QuickStartFactoryTests.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/WordPressTest/QuickStartFactoryTests.swift b/WordPress/WordPressTest/QuickStartFactoryTests.swift index 69996533c936..0ad107d0dddb 100644 --- a/WordPress/WordPressTest/QuickStartFactoryTests.swift +++ b/WordPress/WordPressTest/QuickStartFactoryTests.swift @@ -83,11 +83,12 @@ class QuickStartFactoryTests: XCTestCase { let tours = QuickStartFactory.allTours(for: blog) // Then - XCTAssertEqual(tours.count, 4) + XCTAssertEqual(tours.count, 5) XCTAssertTrue(tours[0] is QuickStartCheckStatsTour) XCTAssertTrue(tours[1] is QuickStartNotificationsTour) XCTAssertTrue(tours[2] is QuickStartViewTour) - XCTAssertTrue(tours[3] is QuickStartFollowTour) + XCTAssertTrue(tours[3] is QuickStartMediaUploadTour) + XCTAssertTrue(tours[4] is QuickStartFollowTour) } func testToursForNewSite() { From 724a60ded182b0b18ee6a76b41d839b6ae7a77b2 Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Mon, 9 May 2022 03:38:42 +0200 Subject: [PATCH 17/19] Refactor: rename QuickStartTourElement media enum case --- .../Blog/Blog Details/BlogDetailsViewController.h | 2 +- WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift | 2 +- .../ViewRelated/Media/MediaLibraryViewController.swift | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.h b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.h index 8a8b83e6a5e4..1e68653c3e6a 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.h +++ b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.h @@ -74,7 +74,7 @@ typedef NS_ENUM(NSInteger, QuickStartTourElement) { QuickStartTourElementSetupQuickStart = 23, QuickStartTourElementRemoveQuickStart = 24, QuickStartTourElementMediaScreen = 25, - QuickStartTourElementMediaAdd = 26, + QuickStartTourElementMediaUpload = 26, }; typedef NS_ENUM(NSUInteger, BlogDetailsNavigationSource) { diff --git a/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift b/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift index 5c6c373b4dcc..ac84e802169c 100644 --- a/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift +++ b/WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift @@ -389,7 +389,7 @@ struct QuickStartMediaUploadTour: QuickStartTour { let step2DescriptionBase = NSLocalizedString("Select %@to upload media. You can add it to your posts / pages from any device.", comment: "A step in a guided tour for quick start. %@ will be a plus icon.") let step2DescriptionTarget = "" - let step2: WayPoint = (element: .mediaAdd, description: step2DescriptionBase.highlighting(phrase: step2DescriptionTarget, icon: .gridicon(.plus))) + let step2: WayPoint = (element: .mediaUpload, description: step2DescriptionBase.highlighting(phrase: step2DescriptionTarget, icon: .gridicon(.plus))) return [step1, step2] }() diff --git a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift index e7b7962d28e5..f5ff0e2dea60 100644 --- a/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift +++ b/WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift @@ -129,7 +129,7 @@ class MediaLibraryViewController: WPMediaPickerViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - addButton.shouldShowSpotlight = QuickStartTourGuide.shared.isCurrentElement(.mediaAdd) + addButton.shouldShowSpotlight = QuickStartTourGuide.shared.isCurrentElement(.mediaUpload) } // MARK: - Update view state @@ -271,8 +271,8 @@ class MediaLibraryViewController: WPMediaPickerViewController { // MARK: - Actions @objc fileprivate func addTapped() { - QuickStartTourGuide.shared.visited(.mediaAdd) - addButton.shouldShowSpotlight = QuickStartTourGuide.shared.isCurrentElement(.mediaAdd) + QuickStartTourGuide.shared.visited(.mediaUpload) + addButton.shouldShowSpotlight = QuickStartTourGuide.shared.isCurrentElement(.mediaUpload) showOptionsMenu() } From 3ee251c08e06202db6b7378a099c41b3893589ca Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Tue, 10 May 2022 05:36:12 +0200 Subject: [PATCH 18/19] Add: release note --- RELEASE-NOTES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index d80798ef0115..c16e0c5e245c 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,6 +1,6 @@ 19.9 ----- - +* [*] Media Picker: Fixed an issue where the empty state view was being displayed incorrectly. [#18471] 19.8 ----- From aa5d8053e15fc8dd2683b2b06822f097eea275af Mon Sep 17 00:00:00 2001 From: Hassaan El-Garem Date: Tue, 10 May 2022 13:43:06 +0200 Subject: [PATCH 19/19] Change: use WPMediaPicker 1.8.4-beta.1 --- Podfile | 2 +- Podfile.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Podfile b/Podfile index aff44e1511fe..a85a914c2ef5 100644 --- a/Podfile +++ b/Podfile @@ -210,7 +210,7 @@ abstract_target 'Apps' do pod 'NSURL+IDN', '~> 0.4' - pod 'WPMediaPicker', '~> 1.8.3-beta.1' + pod 'WPMediaPicker', '~> 1.8.4-beta.1' # pod 'WPMediaPicker', :git => 'https://github.com/wordpress-mobile/MediaPicker-iOS.git', :tag => '1.7.0' ## while PR is in review: # pod 'WPMediaPicker', :git => 'https://github.com/wordpress-mobile/MediaPicker-iOS.git', :branch => '' diff --git a/Podfile.lock b/Podfile.lock index cbf1d920009c..e83923bbf6e1 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -499,7 +499,7 @@ PODS: - CocoaLumberjack (~> 3.4) - FormatterKit/TimeIntervalFormatter (~> 1.8) - WordPressUI (1.12.5) - - WPMediaPicker (1.8.3) + - WPMediaPicker (1.8.4-beta.1) - wpxmlrpc (0.9.0) - Yoga (1.14.0) - ZendeskCommonUISDK (6.1.2) @@ -595,7 +595,7 @@ DEPENDENCIES: - WordPressMocks (~> 0.0.15) - WordPressShared (~> 1.17.1) - WordPressUI (~> 1.12.5) - - WPMediaPicker (~> 1.8.3-beta.1) + - WPMediaPicker (~> 1.8.4-beta.1) - Yoga (from `https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.75.0/third-party-podspecs/Yoga.podspec.json`) - ZendeskSupportSDK (= 5.3.0) - ZIPFoundation (~> 0.9.8) @@ -857,7 +857,7 @@ SPEC CHECKSUMS: WordPressMocks: 6b52b0764d9939408151367dd9c6e8a910877f4d WordPressShared: 0c4bc5e25765732fcf5d07f28c81970ab28493fb WordPressUI: c5be816f6c7b3392224ac21de9e521e89fa108ac - WPMediaPicker: 0f4f20c7f661b46d33283f1ac2adceb98718fffa + WPMediaPicker: 547b19abb9361a0a70ac7df4399502b3d59f1f3b wpxmlrpc: bf55a43a7e710bd2a4fb8c02dfe83b1246f14f13 Yoga: 2ca978c40e0fd6d7f54bcb1602bc0cbbc79454a7 ZendeskCommonUISDK: 5f0a83f412e07ae23701f18c412fe783b3249ef5 @@ -869,6 +869,6 @@ SPEC CHECKSUMS: ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba ZIPFoundation: ae5b4b813d216d3bf0a148773267fff14bd51d37 -PODFILE CHECKSUM: 5a95da7aea712ea40c414022082be3d6dbe39b4b +PODFILE CHECKSUM: f6bd23447af8d4f331d87b63590f4bf520730633 COCOAPODS: 1.11.2