Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

11.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]

11.4
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ final class EmptyStoresTableViewCell: UITableViewCell {

@IBOutlet private weak var stackView: UIStackView!
@IBOutlet private weak var emptyStoresImageView: UIImageView!
@IBOutlet private weak var removeAppleIDAccessButton: UIButton!
@IBOutlet private weak var closeAccountButton: UIButton!

override func awakeFromNib() {
super.awakeFromNib()

configureStackView()
configureImageView()
configureRemoveAppleIDAccessButton()
updateRemoveAppleIDAccessButtonVisibility(isVisible: false)
configureCloseAccountButton()
updateCloseAccountButtonVisibility(isVisible: false)
}

func updateRemoveAppleIDAccessButtonVisibility(isVisible: Bool) {
removeAppleIDAccessButton.isHidden = !isVisible
func updateCloseAccountButtonVisibility(isVisible: Bool) {
closeAccountButton.isHidden = !isVisible
}
}

Expand All @@ -57,10 +57,10 @@ private extension EmptyStoresTableViewCell {
emptyStoresImageView.image = .emptyStorePickerImage
}

func configureRemoveAppleIDAccessButton() {
removeAppleIDAccessButton.applyLinkButtonStyle()
removeAppleIDAccessButton.setTitle(Localization.closeAccountTitle, for: .normal)
removeAppleIDAccessButton.on(.touchUpInside) { [weak self] _ in
func configureCloseAccountButton() {
closeAccountButton.applyLinkButtonStyle()
closeAccountButton.setTitle(Localization.closeAccountTitle, for: .normal)
closeAccountButton.on(.touchUpInside) { [weak self] _ in
self?.onCloseAccountButtonTapped?()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<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">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -57,9 +55,9 @@
</tableViewCellContentView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="closeAccountButton" destination="XF9-r3-Vq9" id="sLP-Jl-0hK"/>
<outlet property="emptyStoresImageView" destination="uuh-xp-DA5" id="4yf-Rz-3c2"/>
<outlet property="legendLabel" destination="bPV-bJ-GBz" id="sQX-ir-ghQ"/>
<outlet property="removeAppleIDAccessButton" destination="XF9-r3-Vq9" id="sLP-Jl-0hK"/>
<outlet property="stackView" destination="pky-np-rBc" id="vRx-dY-Ma9"/>
<outlet property="subtitleLabel" destination="Oil-C8-RKM" id="9VO-5Z-BNb"/>
</connections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ final class StorePickerViewController: UIViewController {
}
}

private lazy var removeAppleIDAccessCoordinator: RemoveAppleIDAccessCoordinator =
RemoveAppleIDAccessCoordinator(sourceViewController: self) { [weak self] in
guard let self = self else { throw RemoveAppleIDAccessError.presenterDeallocated }
return try await self.removeAppleIDAccess()
private lazy var closeAccountCoordinator: CloseAccountCoordinator =
CloseAccountCoordinator(sourceViewController: self) { [weak self] in
guard let self = self else { throw CloseAccountError.presenterDeallocated }
return try await self.closeAccount()
} onRemoveSuccess: { [weak self] in
self?.restartAuthentication()
}
Expand Down Expand Up @@ -698,13 +698,15 @@ extension StorePickerViewController: UITableViewDataSource {
guard let site = viewModel.site(at: indexPath) else {
hideActionButton()
let cell = tableView.dequeueReusableCell(EmptyStoresTableViewCell.self, for: indexPath)
let isRemoveAppleIDAccessButtonVisible = appleIDCredentialChecker.hasAppleUserID()
cell.updateRemoveAppleIDAccessButtonVisibility(isVisible: isRemoveAppleIDAccessButtonVisible)
if isRemoveAppleIDAccessButtonVisible {
let isCloseAccountButtonVisible = appleIDCredentialChecker.hasAppleUserID()
|| featureFlagService.isFeatureFlagEnabled(.storeCreationMVP)
|| featureFlagService.isFeatureFlagEnabled(.storeCreationM2)
cell.updateCloseAccountButtonVisibility(isVisible: isCloseAccountButtonVisible)
if isCloseAccountButtonVisible {
cell.onCloseAccountButtonTapped = { [weak self] in
guard let self = self else { return }
ServiceLocator.analytics.track(event: .closeAccountTapped(source: .emptyStores))
self.removeAppleIDAccessCoordinator.start()
self.closeAccountCoordinator.start()
}
}
return cell
Expand Down Expand Up @@ -777,7 +779,7 @@ extension StorePickerViewController: UITableViewDelegate {
}

private extension StorePickerViewController {
func removeAppleIDAccess() async throws {
func closeAccount() async throws {
try await withCheckedThrowingContinuation { [weak self] continuation in
guard let self = self else { return }
let action = AccountAction.closeAccount { result in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import UIKit
import protocol Yosemite.StoresManager

/// Coordinates navigation for removing Apple ID access from various entry points (settings and empty stores screens).
@MainActor final class RemoveAppleIDAccessCoordinator {
/// Coordinates navigation for closing a WPCOM account from various entry points (settings and empty stores screens).
@MainActor final class CloseAccountCoordinator {
private let sourceViewController: UIViewController
private let removeAction: () async throws -> Void
private let onRemoveSuccess: () -> Void
Expand Down Expand Up @@ -30,7 +30,7 @@ import protocol Yosemite.StoresManager
}
}

private extension RemoveAppleIDAccessCoordinator {
private extension CloseAccountCoordinator {
func presentConfirmationAlert() {
// TODO: 7068 - analytics

Expand Down Expand Up @@ -86,7 +86,7 @@ private extension RemoveAppleIDAccessCoordinator {
}

func presentInProgressUI() {
let viewProperties = InProgressViewProperties(title: Localization.RemoveAppleIDAccessInProgressView.title, message: "")
let viewProperties = InProgressViewProperties(title: Localization.InProgressView.title, message: "")
let inProgressViewController = InProgressViewController(viewProperties: viewProperties)
inProgressViewController.modalPresentationStyle = .overFullScreen
sourceViewController.present(inProgressViewController, animated: true)
Expand Down Expand Up @@ -140,9 +140,9 @@ private extension RemoveAppleIDAccessCoordinator {
}
}

private extension RemoveAppleIDAccessCoordinator {
private extension CloseAccountCoordinator {
enum Localization {
enum RemoveAppleIDAccessInProgressView {
enum InProgressView {
static let title = NSLocalizedString(
"Closing account...",
comment: "Title of the Close Account in-progress view."
Expand Down Expand Up @@ -186,12 +186,12 @@ private extension RemoveAppleIDAccessCoordinator {
}
}

private extension RemoveAppleIDAccessCoordinator {
private extension CloseAccountCoordinator {
enum Constants {
static let dotcomAPIErrorCodeKey = "WordPressComRestApiErrorCodeKey"
}
}

enum RemoveAppleIDAccessError: Error {
enum CloseAccountError: Error {
case presenterDeallocated
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ final class SettingsViewController: UIViewController {
///
private var storePickerCoordinator: StorePickerCoordinator?

private lazy var removeAppleIDAccessCoordinator: RemoveAppleIDAccessCoordinator =
RemoveAppleIDAccessCoordinator(sourceViewController: self) { [weak self] in
guard let self = self else { throw RemoveAppleIDAccessError.presenterDeallocated }
try await self.removeAppleIDAccess()
private lazy var closeAccountCoordinator: CloseAccountCoordinator =
CloseAccountCoordinator(sourceViewController: self) { [weak self] in
guard let self = self else { throw CloseAccountError.presenterDeallocated }
try await self.closeAccount()
} onRemoveSuccess: { [weak self] in
self?.logOutUser()
}
Expand Down Expand Up @@ -154,8 +154,8 @@ private extension SettingsViewController {
configureAppSettings(cell: cell)
case let cell as BasicTableViewCell where row == .wormholy:
configureWormholy(cell: cell)
case let cell as BasicTableViewCell where row == .removeAppleIDAccess:
configureRemoveAppleIDAccess(cell: cell)
case let cell as BasicTableViewCell where row == .closeAccount:
configureCloseAccount(cell: cell)
case let cell as BasicTableViewCell where row == .logout:
configureLogout(cell: cell)
default:
Expand Down Expand Up @@ -249,7 +249,7 @@ private extension SettingsViewController {
cell.textLabel?.text = Localization.whatsNew
}

func configureRemoveAppleIDAccess(cell: BasicTableViewCell) {
func configureCloseAccount(cell: BasicTableViewCell) {
cell.selectionStyle = .default
cell.textLabel?.textAlignment = .center
cell.textLabel?.textColor = .error
Expand Down Expand Up @@ -279,12 +279,12 @@ private extension SettingsViewController {
// MARK: - Actions
//
private extension SettingsViewController {
func removeAppleIDAccessWasPressed() {
func closeAccountWasPressed() {
ServiceLocator.analytics.track(event: .closeAccountTapped(source: .settings))
removeAppleIDAccessCoordinator.start()
closeAccountCoordinator.start()
}

func removeAppleIDAccess() async throws {
func closeAccount() async throws {
try await withCheckedThrowingContinuation { [weak self] continuation in
guard let self = self else { return }
let action = AccountAction.closeAccount { result in
Expand Down Expand Up @@ -542,8 +542,8 @@ extension SettingsViewController: UITableViewDelegate {
wormholyWasPressed()
case .whatsNew:
whatsNewWasPressed()
case .removeAppleIDAccess:
removeAppleIDAccessWasPressed()
case .closeAccount:
closeAccountWasPressed()
case .logout:
logoutWasPressed()
default:
Expand Down Expand Up @@ -621,7 +621,7 @@ extension SettingsViewController {
case wormholy

// Account deletion
case removeAppleIDAccess
case closeAccount

// Logout
case logout
Expand Down Expand Up @@ -651,7 +651,7 @@ extension SettingsViewController {
return HostingTableViewCell<FeatureAnnouncementCardView>.self
case .installJetpack:
return BasicTableViewCell.self
case .logout, .removeAppleIDAccess:
case .logout, .closeAccount:
return BasicTableViewCell.self
case .privacy:
return BasicTableViewCell.self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,15 @@ private extension SettingsViewModel {
footerHeight: CGFloat.leastNonzeroMagnitude)
}()

// Remove Apple ID Access
let removeAppleIDAccessSection: Section? = {
guard appleIDCredentialChecker.hasAppleUserID() else {
// Close account
let closeAccountSection: Section? = {
guard appleIDCredentialChecker.hasAppleUserID()
|| featureFlagService.isFeatureFlagEnabled(.storeCreationMVP)
|| featureFlagService.isFeatureFlagEnabled(.storeCreationM2) else {
return nil
}
return Section(title: nil,
rows: [.removeAppleIDAccess],
rows: [.closeAccount],
footerHeight: CGFloat.leastNonzeroMagnitude)
}()

Expand All @@ -308,7 +310,7 @@ private extension SettingsViewModel {
appSettingsSection,
aboutTheAppSection,
otherSection,
removeAppleIDAccessSection,
closeAccountSection,
logoutSection
]
.compactMap { $0 }
Expand Down
Loading