Skip to content

Commit 9a53aad

Browse files
authored
Merge pull request #8272 from woocommerce/feat/8178-move-close-account-action
Account deletion: move the CTA from empty stores cell to ellipsis menu action sheet
2 parents bb936fb + 6db8030 commit 9a53aad

File tree

4 files changed

+38
-48
lines changed

4 files changed

+38
-48
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
11.5
44
-----
5-
- [*] Account deletion is now supported for all users in settings or in the empty stores screen. [https://github.com/woocommerce/woocommerce-ios/pull/8179]
5+
- [*] Account deletion is now supported for all users in settings or in the empty stores screen (in the ellipsis menu). [https://github.com/woocommerce/woocommerce-ios/pull/8179, https://github.com/woocommerce/woocommerce-ios/pull/8272]
66
- [*] In-Person Payments: We removed any references to Simple Payments from Orders, and the red badge from the Menu tab and Menu Payments icon announcing the new Payments section. [https://github.com/woocommerce/woocommerce-ios/pull/8183]
77
- [internal] Store creation flow was improved with native implementation. It is available from the login prologue (`Get Started` CTA), login email error screen, and store picker (`Add a store` CTA from the empty stores screen or at the bottom of the store list). [Example testing steps in https://github.com/woocommerce/woocommerce-ios/pull/8251]
88

WooCommerce/Classes/Authentication/Epilogue/EmptyStoresTableViewCell.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import UIKit
66
///
77
final class EmptyStoresTableViewCell: UITableViewCell {
88

9-
var onCloseAccountButtonTapped: (() -> Void)?
10-
119
/// LegendLabel: To be displayed below the ImageView.
1210
///
1311
@IBOutlet private var legendLabel: UILabel! {
@@ -28,19 +26,12 @@ final class EmptyStoresTableViewCell: UITableViewCell {
2826

2927
@IBOutlet private weak var stackView: UIStackView!
3028
@IBOutlet private weak var emptyStoresImageView: UIImageView!
31-
@IBOutlet private weak var closeAccountButton: UIButton!
3229

3330
override func awakeFromNib() {
3431
super.awakeFromNib()
3532

3633
configureStackView()
3734
configureImageView()
38-
configureCloseAccountButton()
39-
updateCloseAccountButtonVisibility(isVisible: false)
40-
}
41-
42-
func updateCloseAccountButtonVisibility(isVisible: Bool) {
43-
closeAccountButton.isHidden = !isVisible
4435
}
4536
}
4637

@@ -56,22 +47,10 @@ private extension EmptyStoresTableViewCell {
5647
emptyStoresImageView.contentMode = .scaleAspectFit
5748
emptyStoresImageView.image = .emptyStorePickerImage
5849
}
59-
60-
func configureCloseAccountButton() {
61-
closeAccountButton.applyLinkButtonStyle()
62-
closeAccountButton.setTitle(Localization.closeAccountTitle, for: .normal)
63-
closeAccountButton.on(.touchUpInside) { [weak self] _ in
64-
self?.onCloseAccountButtonTapped?()
65-
}
66-
}
6750
}
6851

6952
private extension EmptyStoresTableViewCell {
7053
enum Localization {
71-
static let closeAccountTitle = NSLocalizedString(
72-
"Close Account",
73-
comment: "Link on the store picker for users who signed in with Apple to close their WordPress.com account."
74-
)
7554
static let legend =
7655
NSLocalizedString("Add your first store",
7756
comment: "Displayed during the Login flow, whenever the user has no woo stores associated.")

WooCommerce/Classes/Authentication/Epilogue/EmptyStoresTableViewCell.xib

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3+
<device id="retina6_12" orientation="portrait" appearance="light"/>
34
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
57
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
68
</dependencies>
79
<objects>
@@ -18,30 +20,25 @@
1820
<rect key="frame" x="16" y="0.0" width="343" height="222"/>
1921
<subviews>
2022
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="woo-no-store" translatesAutoresizingMaskIntoConstraints="NO" id="uuh-xp-DA5">
21-
<rect key="frame" x="0.0" y="0.0" width="343" height="138.5"/>
23+
<rect key="frame" x="0.0" y="0.0" width="343" height="173.33333333333334"/>
2224
</imageView>
2325
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="JZd-ud-Vc8">
24-
<rect key="frame" x="0.0" y="138.5" width="343" height="49"/>
26+
<rect key="frame" x="0.0" y="173.33333333333334" width="343" height="48.666666666666657"/>
2527
<subviews>
2628
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" verticalCompressionResistancePriority="751" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bPV-bJ-GBz">
27-
<rect key="frame" x="0.0" y="0.0" width="343" height="20.5"/>
29+
<rect key="frame" x="0.0" y="0.0" width="343" height="20.333333333333332"/>
2830
<fontDescription key="fontDescription" type="system" pointSize="17"/>
2931
<nil key="textColor"/>
3032
<nil key="highlightedColor"/>
3133
</label>
3234
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" verticalCompressionResistancePriority="751" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Oil-C8-RKM">
33-
<rect key="frame" x="0.0" y="28.5" width="343" height="20.5"/>
35+
<rect key="frame" x="0.0" y="28.333333333333314" width="343" height="20.333333333333329"/>
3436
<fontDescription key="fontDescription" type="system" pointSize="17"/>
3537
<nil key="textColor"/>
3638
<nil key="highlightedColor"/>
3739
</label>
3840
</subviews>
3941
</stackView>
40-
<button opaque="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="751" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XF9-r3-Vq9" userLabel="Remove Apple ID Access Button">
41-
<rect key="frame" x="0.0" y="187.5" width="343" height="34.5"/>
42-
<state key="normal" title="Button"/>
43-
<buttonConfiguration key="configuration" style="plain" title="Button"/>
44-
</button>
4542
</subviews>
4643
</stackView>
4744
</subviews>
@@ -55,7 +52,6 @@
5552
</tableViewCellContentView>
5653
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
5754
<connections>
58-
<outlet property="closeAccountButton" destination="XF9-r3-Vq9" id="sLP-Jl-0hK"/>
5955
<outlet property="emptyStoresImageView" destination="uuh-xp-DA5" id="4yf-Rz-3c2"/>
6056
<outlet property="legendLabel" destination="bPV-bJ-GBz" id="sQX-ir-ghQ"/>
6157
<outlet property="stackView" destination="pky-np-rBc" id="vRx-dY-Ma9"/>

WooCommerce/Classes/Authentication/Epilogue/StorePickerViewController.swift

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -318,18 +318,40 @@ private extension StorePickerViewController {
318318
func presentActionMenu(from sourceView: UIView) {
319319
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
320320
actionSheet.view.tintColor = .text
321+
321322
let logOutAction = UIAlertAction(title: Localization.ActionMenu.logOut, style: .default) { [weak self] _ in
322323
self?.restartAuthentication()
323324
}
325+
actionSheet.addAction(logOutAction)
326+
324327
let helpAction = UIAlertAction(title: Localization.ActionMenu.help, style: .default) { [weak self] _ in
325328
guard let self else { return }
326329
ServiceLocator.analytics.track(.sitePickerHelpButtonTapped)
327330
self.presentHelp()
328331
}
329-
let cancelAction = UIAlertAction(title: Localization.cancel, style: .cancel)
330-
331-
actionSheet.addAction(logOutAction)
332332
actionSheet.addAction(helpAction)
333+
334+
let isCloseAccountButtonVisible: Bool = {
335+
let hasEmptyStores: Bool = {
336+
if case .empty = viewModel.state {
337+
return true
338+
}
339+
return false
340+
}()
341+
return (appleIDCredentialChecker.hasAppleUserID()
342+
|| featureFlagService.isFeatureFlagEnabled(.storeCreationMVP)
343+
|| featureFlagService.isFeatureFlagEnabled(.storeCreationM2)) && hasEmptyStores
344+
}()
345+
if isCloseAccountButtonVisible {
346+
let closeAccountAction = UIAlertAction(title: Localization.ActionMenu.closeAccount, style: .destructive) { [weak self] _ in
347+
guard let self else { return }
348+
ServiceLocator.analytics.track(event: .closeAccountTapped(source: .emptyStores))
349+
self.closeAccountCoordinator.start()
350+
}
351+
actionSheet.addAction(closeAccountAction)
352+
}
353+
354+
let cancelAction = UIAlertAction(title: Localization.cancel, style: .cancel)
333355
actionSheet.addAction(cancelAction)
334356

335357
if let popoverController = actionSheet.popoverPresentationController {
@@ -700,17 +722,6 @@ extension StorePickerViewController: UITableViewDataSource {
700722
guard let site = viewModel.site(at: indexPath) else {
701723
hideActionButton()
702724
let cell = tableView.dequeueReusableCell(EmptyStoresTableViewCell.self, for: indexPath)
703-
let isCloseAccountButtonVisible = appleIDCredentialChecker.hasAppleUserID()
704-
|| featureFlagService.isFeatureFlagEnabled(.storeCreationMVP)
705-
|| featureFlagService.isFeatureFlagEnabled(.storeCreationM2)
706-
cell.updateCloseAccountButtonVisibility(isVisible: isCloseAccountButtonVisible)
707-
if isCloseAccountButtonVisible {
708-
cell.onCloseAccountButtonTapped = { [weak self] in
709-
guard let self = self else { return }
710-
ServiceLocator.analytics.track(event: .closeAccountTapped(source: .emptyStores))
711-
self.closeAccountCoordinator.start()
712-
}
713-
}
714725
return cell
715726
}
716727
let cell = tableView.dequeueReusableCell(StoreTableViewCell.self, for: indexPath)
@@ -864,6 +875,10 @@ private extension StorePickerViewController {
864875
comment: "Button to log out from the current account from the store picker")
865876
static let help = NSLocalizedString("Help",
866877
comment: "Button to get help from the store picker")
878+
static let closeAccount = NSLocalizedString(
879+
"Close account",
880+
comment: "Button to close the WordPress.com account on the store picker."
881+
)
867882
}
868883
}
869884
}

0 commit comments

Comments
 (0)