diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/SettingsPrivacyViewController.swift b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/SettingsPrivacyViewController.swift index 0594a1befc..738e7b2e5b 100644 --- a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/SettingsPrivacyViewController.swift +++ b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/SettingsPrivacyViewController.swift @@ -76,9 +76,7 @@ internal final class SettingsPrivacyViewController: UITableViewController { internal override func tableView(_: UITableView, willDisplay cell: UITableViewCell, forRowAt _: IndexPath) { if let followCell = cell as? SettingsFollowCell { followCell.delegate = self - } else if let requestDataCell = cell as? SettingsPrivacyRequestDataCell { - requestDataCell.delegate = self - } else if let deleteAccountCell = cell as? SettingsPrivacyDeleteAccountCell { + } else if let deleteAccountCell = cell as? SettingsPrivacyDeleteOrRequestCell { deleteAccountCell.delegate = self } else if let privacySwitchCell = cell as? SettingsPrivacySwitchCell { privacySwitchCell.delegate = self @@ -117,45 +115,9 @@ extension SettingsPrivacyViewController: SettingsFollowCellDelegate { } } -extension SettingsPrivacyViewController: SettingsRequestDataCellDelegate { - internal func settingsRequestDataCellDidPresentPrompt( - _: SettingsPrivacyRequestDataCell, - alertMessage: String - ) { - let exportDataSheet = UIAlertController( - title: nil, - message: alertMessage, - preferredStyle: .actionSheet - ) - - let startTheRequest = UIAlertAction( - title: Strings.Request_my_data(), - style: .default, - handler: { _ in - NotificationCenter.default.post(name: Notification.Name.ksr_dataRequested, object: nil, userInfo: nil) - } - ) - - let dismiss = UIAlertAction(title: Strings.Cancel(), style: .cancel, handler: nil) - - exportDataSheet.addAction(startTheRequest) - exportDataSheet.addAction(dismiss) - - self.present(exportDataSheet, animated: true, completion: nil) - } - - internal func settingsRequestDataCell( - _: SettingsPrivacyRequestDataCell, - requestedDataWith url: String - ) { - guard let fileUrl = URL(string: url) else { return } - UIApplication.shared.open(fileUrl) - } -} - -extension SettingsPrivacyViewController: SettingsPrivacyDeleteAccountCellDelegate { - internal func settingsPrivacyDeleteAccountCellTapped( - _: SettingsPrivacyDeleteAccountCell, +extension SettingsPrivacyViewController: SettingsPrivacyDeleteOrRequestCellDelegate { + internal func settingsPrivacyDeleteOrRequestCellTapped( + _: SettingsPrivacyDeleteOrRequestCell, with url: URL ) { self.goTo(url: url) diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/SettingsPrivacyViewControllerTests.swift b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/SettingsPrivacyViewControllerTests.swift index eb4c5828ae..4abeddb85f 100644 --- a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/SettingsPrivacyViewControllerTests.swift +++ b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/SettingsPrivacyViewControllerTests.swift @@ -18,13 +18,11 @@ internal final class SettingsPrivacyViewControllerTests: TestCase { super.tearDown() } - func testSocialOptedOut_And_DownloadDataCopy() { + func testSocialOptedOut() { let currentUser = User.template |> \.social .~ false - let exportData = ExportDataEnvelope.template let mockService = MockService( - fetchExportStateResponse: exportData, fetchUserSelfResponse: currentUser ) @@ -50,17 +48,11 @@ internal final class SettingsPrivacyViewControllerTests: TestCase { } } - func testSocialOptedIn_And_RequestDataCopy() { + func testSocialOptedIn() { let currentUser = User.template |> \.social .~ true - let exportData = .template - |> ExportDataEnvelope.lens.state .~ .expired - |> ExportDataEnvelope.lens.dataUrl .~ nil - |> ExportDataEnvelope.lens.expiresAt .~ nil - let mockService = MockService( - fetchExportStateResponse: exportData, fetchUserSelfResponse: currentUser ) diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_de_device_pad.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_de_device_pad.png similarity index 55% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_de_device_pad.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_de_device_pad.png index 8eeae502e0..1fc9dd07e0 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_de_device_pad.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_de_device_pad.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_de_device_phone4_7inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_de_device_phone4_7inch.png similarity index 81% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_de_device_phone4_7inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_de_device_phone4_7inch.png index a69fd8ff62..369874f025 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_de_device_phone4_7inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_de_device_phone4_7inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_de_device_phone5_8inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_de_device_phone5_8inch.png similarity index 64% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_de_device_phone5_8inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_de_device_phone5_8inch.png index 555613eb8c..2778879fd4 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_de_device_phone5_8inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_de_device_phone5_8inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_en_device_pad.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_en_device_pad.png similarity index 62% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_en_device_pad.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_en_device_pad.png index 31dbee79a1..15ea13ed53 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_en_device_pad.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_en_device_pad.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_en_device_phone4_7inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_en_device_phone4_7inch.png similarity index 57% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_en_device_phone4_7inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_en_device_phone4_7inch.png index 80b31691e8..274b015b85 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_en_device_phone4_7inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_en_device_phone4_7inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_en_device_phone5_8inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_en_device_phone5_8inch.png similarity index 70% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_en_device_phone5_8inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_en_device_phone5_8inch.png index 47ac6742db..3b407cea6f 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_en_device_phone5_8inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_en_device_phone5_8inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_es_device_pad.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_es_device_pad.png similarity index 63% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_es_device_pad.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_es_device_pad.png index 8ed2e30fc6..3b52a1b049 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_es_device_pad.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_es_device_pad.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_es_device_phone4_7inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_es_device_phone4_7inch.png similarity index 80% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_es_device_phone4_7inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_es_device_phone4_7inch.png index 68180ca456..33799c7429 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_es_device_phone4_7inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_es_device_phone4_7inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_es_device_phone5_8inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_es_device_phone5_8inch.png similarity index 64% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_es_device_phone5_8inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_es_device_phone5_8inch.png index 70b3409757..0fd2c6ea87 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_es_device_phone5_8inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_es_device_phone5_8inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_fr_device_pad.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_fr_device_pad.png similarity index 79% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_fr_device_pad.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_fr_device_pad.png index 5f00fb8af8..20d1f0b1f3 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_fr_device_pad.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_fr_device_pad.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_fr_device_phone4_7inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_fr_device_phone4_7inch.png similarity index 81% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_fr_device_phone4_7inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_fr_device_phone4_7inch.png index fdf8289d82..62df2c3137 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_fr_device_phone4_7inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_fr_device_phone4_7inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_fr_device_phone5_8inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_fr_device_phone5_8inch.png similarity index 84% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_fr_device_phone5_8inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_fr_device_phone5_8inch.png index 06c84415ce..8cb658bb44 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_fr_device_phone5_8inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_fr_device_phone5_8inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_ja_device_pad.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_ja_device_pad.png similarity index 63% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_ja_device_pad.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_ja_device_pad.png index 3a9bacd3ab..9500c6def2 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_ja_device_pad.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_ja_device_pad.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_ja_device_phone4_7inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_ja_device_phone4_7inch.png similarity index 91% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_ja_device_phone4_7inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_ja_device_phone4_7inch.png index a5184de788..a2b040658f 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_ja_device_phone4_7inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_ja_device_phone4_7inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_ja_device_phone5_8inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_ja_device_phone5_8inch.png similarity index 85% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_ja_device_phone5_8inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_ja_device_phone5_8inch.png index 9dca598d4f..fb233d71cc 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn_And_RequestDataCopy.lang_ja_device_phone5_8inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedIn.lang_ja_device_phone5_8inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_de_device_pad.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_de_device_pad.png similarity index 54% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_de_device_pad.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_de_device_pad.png index 971e0e1b9a..4357b2dd54 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_de_device_pad.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_de_device_pad.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_de_device_phone4_7inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_de_device_phone4_7inch.png similarity index 75% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_de_device_phone4_7inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_de_device_phone4_7inch.png index fbe5d1d77b..db0c7d7619 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_de_device_phone4_7inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_de_device_phone4_7inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_de_device_phone5_8inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_de_device_phone5_8inch.png similarity index 62% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_de_device_phone5_8inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_de_device_phone5_8inch.png index f17ef2abe7..2fdb9879bc 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_de_device_phone5_8inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_de_device_phone5_8inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_en_device_pad.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_en_device_pad.png new file mode 100644 index 0000000000..b23601d6e7 Binary files /dev/null and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_en_device_pad.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_en_device_phone4_7inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_en_device_phone4_7inch.png similarity index 54% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_en_device_phone4_7inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_en_device_phone4_7inch.png index 33d7a84029..a0e634c588 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_en_device_phone4_7inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_en_device_phone4_7inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_en_device_phone5_8inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_en_device_phone5_8inch.png similarity index 66% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_en_device_phone5_8inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_en_device_phone5_8inch.png index 4dd9799b5b..9cce33fb93 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_en_device_phone5_8inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_en_device_phone5_8inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_es_device_pad.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_es_device_pad.png similarity index 61% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_es_device_pad.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_es_device_pad.png index 57bb6c513e..bbc1fd4189 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_es_device_pad.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_es_device_pad.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_es_device_phone4_7inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_es_device_phone4_7inch.png similarity index 76% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_es_device_phone4_7inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_es_device_phone4_7inch.png index c09fd4f394..cbb01a5c54 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_es_device_phone4_7inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_es_device_phone4_7inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_es_device_phone5_8inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_es_device_phone5_8inch.png similarity index 61% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_es_device_phone5_8inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_es_device_phone5_8inch.png index f8d843a87c..ff4a6d97e8 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_es_device_phone5_8inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_es_device_phone5_8inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_fr_device_pad.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_fr_device_pad.png similarity index 59% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_fr_device_pad.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_fr_device_pad.png index fd09cf3ade..31ec750e1e 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_fr_device_pad.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_fr_device_pad.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_fr_device_phone4_7inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_fr_device_phone4_7inch.png similarity index 77% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_fr_device_phone4_7inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_fr_device_phone4_7inch.png index 53b2f72aeb..11af47457c 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_fr_device_phone4_7inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_fr_device_phone4_7inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_fr_device_phone5_8inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_fr_device_phone5_8inch.png similarity index 58% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_fr_device_phone5_8inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_fr_device_phone5_8inch.png index b726af5150..cb44cb3b41 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_fr_device_phone5_8inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_fr_device_phone5_8inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_ja_device_pad.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_ja_device_pad.png similarity index 62% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_ja_device_pad.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_ja_device_pad.png index 15b5cd3de7..4144038137 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_ja_device_pad.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_ja_device_pad.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_ja_device_phone4_7inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_ja_device_phone4_7inch.png similarity index 69% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_ja_device_phone4_7inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_ja_device_phone4_7inch.png index 7757abd625..7d4d8e87c9 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_ja_device_phone4_7inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_ja_device_phone4_7inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_ja_device_phone5_8inch.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_ja_device_phone5_8inch.png similarity index 78% rename from Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_ja_device_phone5_8inch.png rename to Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_ja_device_phone5_8inch.png index 74243147f2..bceba789f0 100644 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_ja_device_phone5_8inch.png and b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut.lang_ja_device_phone5_8inch.png differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_en_device_pad.png b/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_en_device_pad.png deleted file mode 100644 index e7d75d0851..0000000000 Binary files a/Kickstarter-iOS/Features/SettingsPrivacy/Controller/__Snapshots__/SettingsPrivacyViewControllerTests/testSocialOptedOut_And_DownloadDataCopy.lang_en_device_pad.png and /dev/null differ diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Datasource/SettingsPrivacyDataSource.swift b/Kickstarter-iOS/Features/SettingsPrivacy/Datasource/SettingsPrivacyDataSource.swift index a94f7042da..b631bfef09 100644 --- a/Kickstarter-iOS/Features/SettingsPrivacy/Datasource/SettingsPrivacyDataSource.swift +++ b/Kickstarter-iOS/Features/SettingsPrivacy/Datasource/SettingsPrivacyDataSource.swift @@ -64,14 +64,14 @@ internal final class SettingsPrivacyDataSource: ValueCellDataSource { } self.set( - values: [user], - cellClass: SettingsPrivacyRequestDataCell.self, + values: [(user: user, cellType: .request)], + cellClass: SettingsPrivacyDeleteOrRequestCell.self, inSection: Section.requestData.rawValue ) self.set( - values: [user], - cellClass: SettingsPrivacyDeleteAccountCell.self, + values: [(user: user, cellType: .delete)], + cellClass: SettingsPrivacyDeleteOrRequestCell.self, inSection: Section.deleteAccount.rawValue ) } @@ -82,9 +82,10 @@ internal final class SettingsPrivacyDataSource: ValueCellDataSource { cell.configureWith(value: value) case let (cell as SettingsPrivacyRecommendationCell, value as SettingsPrivacyStaticCellValue): cell.configureWith(value: value) - case let (cell as SettingsPrivacyRequestDataCell, value as User): - cell.configureWith(value: value) - case let (cell as SettingsPrivacyDeleteAccountCell, value as User): + case let ( + cell as SettingsPrivacyDeleteOrRequestCell, + value as (user: User, cellType: SettingsPrivacyDeleteOrRequestCell.CellType) + ): cell.configureWith(value: value) case let (cell as SettingsPrivacyStaticCell, value as String): cell.configureWith(value: value) diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Storyboard/SettingsPrivacy.storyboard b/Kickstarter-iOS/Features/SettingsPrivacy/Storyboard/SettingsPrivacy.storyboard index 5fddc74041..eda388fe5a 100644 --- a/Kickstarter-iOS/Features/SettingsPrivacy/Storyboard/SettingsPrivacy.storyboard +++ b/Kickstarter-iOS/Features/SettingsPrivacy/Storyboard/SettingsPrivacy.storyboard @@ -1,10 +1,9 @@ - + - - + @@ -18,7 +17,7 @@ - + @@ -92,7 +91,7 @@ - + @@ -128,7 +127,7 @@ - + @@ -199,159 +198,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -431,7 +279,4 @@ - - - diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Views/Cells/SettingsPrivacyDeleteAccountCell.swift b/Kickstarter-iOS/Features/SettingsPrivacy/Views/Cells/SettingsPrivacyDeleteOrRequestCell.swift similarity index 54% rename from Kickstarter-iOS/Features/SettingsPrivacy/Views/Cells/SettingsPrivacyDeleteAccountCell.swift rename to Kickstarter-iOS/Features/SettingsPrivacy/Views/Cells/SettingsPrivacyDeleteOrRequestCell.swift index 1857dc5c75..ea16e0a59f 100644 --- a/Kickstarter-iOS/Features/SettingsPrivacy/Views/Cells/SettingsPrivacyDeleteAccountCell.swift +++ b/Kickstarter-iOS/Features/SettingsPrivacy/Views/Cells/SettingsPrivacyDeleteOrRequestCell.swift @@ -5,13 +5,18 @@ import ReactiveExtensions import ReactiveSwift import UIKit -internal protocol SettingsPrivacyDeleteAccountCellDelegate: AnyObject { - func settingsPrivacyDeleteAccountCellTapped(_ cell: SettingsPrivacyDeleteAccountCell, with url: URL) +internal protocol SettingsPrivacyDeleteOrRequestCellDelegate: AnyObject { + func settingsPrivacyDeleteOrRequestCellTapped(_ cell: SettingsPrivacyDeleteOrRequestCell, with url: URL) } -internal final class SettingsPrivacyDeleteAccountCell: UITableViewCell, ValueCell { - fileprivate let viewModel: SettingsDeleteAccountCellViewModelType = SettingsDeleteAccountCellViewModel() - internal weak var delegate: SettingsPrivacyDeleteAccountCellDelegate? +internal final class SettingsPrivacyDeleteOrRequestCell: UITableViewCell, ValueCell { + fileprivate let viewModel: SettingsDeleteOrRequestCellViewModelType = SettingsDeleteOrRequestCellViewModel() + internal weak var delegate: SettingsPrivacyDeleteOrRequestCellDelegate? + + internal enum CellType { + case delete + case request + } @IBOutlet fileprivate var deleteAccountButton: UIButton! @IBOutlet fileprivate var deleteAccountLabel: UILabel! @@ -23,14 +28,22 @@ internal final class SettingsPrivacyDeleteAccountCell: UITableViewCell, ValueCel _ = self |> \.accessibilityElements .~ [self.deleteAccountButton].compact() - _ = self.deleteAccountButton - |> \.accessibilityLabel %~ { _ in Strings.Delete_my_Kickstarter_Account() } - self.deleteAccountButton.addTarget(self, action: #selector(self.deleteAccountTapped), for: .touchUpInside) } - internal func configureWith(value user: User) { - self.viewModel.inputs.configureWith(user: user) + internal func configureWith(value: (user: User, cellType: CellType)) { + self.viewModel.inputs.configureWith(user: value.user) + + switch value.cellType { + case .request: + self.deleteAccountLabel.textColor = .ksr_support_700 + self.deleteAccountLabel.text = Strings.Request_my_personal_data() + self.deleteAccountButton.accessibilityLabel = Strings.Request_my_personal_data() + case .delete: + self.deleteAccountLabel.textColor = .ksr_alert + self.deleteAccountLabel.text = Strings.Delete_my_Kickstarter_Account() + self.deleteAccountButton.accessibilityLabel = Strings.Delete_my_Kickstarter_Account() + } } internal override func bindStyles() { @@ -48,10 +61,8 @@ internal final class SettingsPrivacyDeleteAccountCell: UITableViewCell, ValueCel ||> settingsSeparatorStyle _ = self.deleteAccountLabel - |> UILabel.lens.textColor .~ .ksr_alert |> UILabel.lens.font .~ .ksr_body() |> UILabel.lens.numberOfLines .~ 2 - |> UILabel.lens.text %~ { _ in Strings.Delete_my_Kickstarter_Account() } } internal override func bindViewModel() { @@ -61,7 +72,7 @@ internal final class SettingsPrivacyDeleteAccountCell: UITableViewCell, ValueCel .observeForUI() .observeValues { [weak self] url in guard let _self = self else { return } - self?.delegate?.settingsPrivacyDeleteAccountCellTapped(_self, with: url) + self?.delegate?.settingsPrivacyDeleteOrRequestCellTapped(_self, with: url) } } diff --git a/Kickstarter-iOS/Features/SettingsPrivacy/Views/Cells/SettingsPrivacyRequestDataCell.swift b/Kickstarter-iOS/Features/SettingsPrivacy/Views/Cells/SettingsPrivacyRequestDataCell.swift deleted file mode 100644 index 9830f6d82e..0000000000 --- a/Kickstarter-iOS/Features/SettingsPrivacy/Views/Cells/SettingsPrivacyRequestDataCell.swift +++ /dev/null @@ -1,127 +0,0 @@ -import KsApi -import Library -import Prelude -import Prelude_UIKit -import ReactiveSwift -import UIKit - -internal protocol SettingsRequestDataCellDelegate: AnyObject { - func settingsRequestDataCellDidPresentPrompt(_ cell: SettingsPrivacyRequestDataCell, alertMessage: String) - func settingsRequestDataCell(_ cell: SettingsPrivacyRequestDataCell, requestedDataWith url: String) -} - -internal final class SettingsPrivacyRequestDataCell: UITableViewCell, ValueCell { - fileprivate let viewModel: SettingsRequestDataCellViewModelType = SettingsRequestDataCellViewModel() - internal weak var delegate: SettingsRequestDataCellDelegate? - - @IBOutlet fileprivate var containerView: UIView! - @IBOutlet fileprivate var chevron: UIImageView! - @IBOutlet fileprivate var preparingDataLabel: UILabel! - @IBOutlet fileprivate var checkBackLaterLabel: UILabel! - @IBOutlet fileprivate var requestDataActivityIndicator: UIActivityIndicatorView! - @IBOutlet fileprivate var requestDataButton: UIButton! - @IBOutlet fileprivate var requestDataLabel: UILabel! - @IBOutlet fileprivate var requestedDataStatusAndDateLabel: UILabel! - @IBOutlet fileprivate var separatorViews: [UIView]! - - private var requestDataObserver: Any? - - internal override func awakeFromNib() { - super.awakeFromNib() - - self.requestDataButton.addTarget(self, action: #selector(self.exportButtonTapped), for: .touchUpInside) - - self.requestDataObserver = NotificationCenter.default.addObserver( - forName: Notification.Name.ksr_dataRequested, - object: nil, queue: nil - ) { [weak self] _ in self?.viewModel.inputs.startRequestDataTapped() } - - self.viewModel.inputs.awakeFromNib() - } - - deinit { - self.requestDataObserver.doIfSome(NotificationCenter.default.removeObserver) - } - - internal func configureWith(value: User) { - self.viewModel.inputs.configureWith(user: value) - } - - internal override func bindStyles() { - super.bindStyles() - - _ = self - |> baseTableViewCellStyle() - |> UITableViewCell.lens.contentView.layoutMargins %~~ { _, cell in - cell.traitCollection.isRegularRegular - ? .init(topBottom: Styles.grid(2), leftRight: Styles.grid(20)) - : .init(topBottom: Styles.grid(1), leftRight: Styles.grid(2)) - } - - _ = self.contentView - |> \.backgroundColor .~ .ksr_support_100 - - _ = self.separatorViews - ||> settingsSeparatorStyle - - _ = self.requestDataButton - |> UIButton.lens.backgroundColor(for: .highlighted) .~ .ksr_support_400 - - _ = self.chevron - |> UIImageView.lens.tintColor .~ .ksr_support_400 - |> UIImageView.lens.contentMode .~ .scaleAspectFit - - _ = self.preparingDataLabel - |> settingsTitleLabelStyle - |> UILabel.lens.numberOfLines .~ 1 - |> UILabel.lens.text %~ { _ in Strings.Preparing_your_personal_data() } - - _ = self.checkBackLaterLabel - |> UILabel.lens.textColor .~ .ksr_support_400 - |> UILabel.lens.font .~ .ksr_body(size: 13) - |> UILabel.lens.text %~ { _ in Strings.Check_back_later_for_an_update_on_your_export() } - - _ = self.requestDataActivityIndicator - |> UIActivityIndicatorView.lens.hidesWhenStopped .~ true - - _ = self.requestDataLabel - |> settingsTitleLabelStyle - |> UILabel.lens.numberOfLines .~ 1 - - _ = self.requestedDataStatusAndDateLabel - |> UILabel.lens.textColor .~ .ksr_support_400 - |> UILabel.lens.font .~ .ksr_body(size: 13) - } - - internal override func bindViewModel() { - super.bindViewModel() - - self.viewModel.outputs.showRequestDataPrompt - .observeForUI() - .observeValues { [weak self] requestDataAlertText in - guard let _self = self else { return } - self?.delegate?.settingsRequestDataCellDidPresentPrompt(_self, alertMessage: requestDataAlertText) - } - - self.viewModel.outputs.goToSafari - .observeForUI() - .observeValues { [weak self] url in - guard let _self = self else { return } - self?.delegate?.settingsRequestDataCell(_self, requestedDataWith: url) - } - - self.requestDataButton.rac.enabled = self.viewModel.outputs.requestDataButtonEnabled - self.requestDataActivityIndicator.rac.animating = self.viewModel.outputs.requestDataLoadingIndicator - self.requestDataLabel.rac.text = self.viewModel.outputs.requestDataText - self.requestedDataStatusAndDateLabel.rac.text = self.viewModel.outputs.requestedDataExpirationDate - self.chevron.rac.hidden = self.viewModel.outputs.dataExpirationAndChevronHidden - self.requestDataLabel.rac.hidden = self.viewModel.outputs.requestDataTextHidden - self.preparingDataLabel.rac.hidden = self.viewModel.outputs.preparingDataAndCheckBackLaterTextHidden - self.checkBackLaterLabel.rac.hidden = self.viewModel.outputs.preparingDataAndCheckBackLaterTextHidden - self.requestedDataStatusAndDateLabel.rac.hidden = self.viewModel.outputs.dataExpirationAndChevronHidden - } - - @objc fileprivate func exportButtonTapped() { - self.viewModel.inputs.exportDataTapped() - } -} diff --git a/Kickstarter.xcodeproj/project.pbxproj b/Kickstarter.xcodeproj/project.pbxproj index e633c5f8e1..e86d30e2a0 100644 --- a/Kickstarter.xcodeproj/project.pbxproj +++ b/Kickstarter.xcodeproj/project.pbxproj @@ -344,7 +344,6 @@ 37FDAFAC2273BA4700662CC8 /* UIStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37FDAF702273B7FF00662CC8 /* UIStackView.swift */; }; 37FDAFAD2273BA4B00662CC8 /* UIStackView+Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37FDAFAA2273B86800662CC8 /* UIStackView+Tests.swift */; }; 37FEFBC8222F1E4F00FCA608 /* ProcessInfoType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37FEFBC7222F1E4F00FCA608 /* ProcessInfoType.swift */; }; - 39742BBF2B27AA8D004944E6 /* ExportDataEnvelopeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39742BBD2B27A91C004944E6 /* ExportDataEnvelopeTests.swift */; }; 399DAD882ACD15D000238BA1 /* UpdateUserAccount.graphql in Resources */ = {isa = PBXBuildFile; fileRef = 06643F3926A5FF1C002C5997 /* UpdateUserAccount.graphql */; }; 399DAD892ACD162C00238BA1 /* FetchProjectFriendsById.graphql in Resources */ = {isa = PBXBuildFile; fileRef = 06BD057526F15CFB00C44E36 /* FetchProjectFriendsById.graphql */; }; 399DAD8A2ACD163400238BA1 /* UnwatchProject.graphql in Resources */ = {isa = PBXBuildFile; fileRef = 478E31C026C1C4C6004BF898 /* UnwatchProject.graphql */; }; @@ -1430,15 +1429,11 @@ D710ADFD2441172100DC7199 /* PledgeViewCTAContainerViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D710ADFC2441172100DC7199 /* PledgeViewCTAContainerViewModelTests.swift */; }; D7180BA222EF9DE900EB0110 /* RewardCellProjectBackingStateTypeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7180BA022EF9DD900EB0110 /* RewardCellProjectBackingStateTypeTests.swift */; }; D72370542118C19B001EA4CA /* SettingsRecommendationsCellViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D72370532118C19B001EA4CA /* SettingsRecommendationsCellViewModelTests.swift */; }; - D723708C2118CAD8001EA4CA /* SettingsDeleteAccountCellViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D723708B2118CAD8001EA4CA /* SettingsDeleteAccountCellViewModelTests.swift */; }; - D723708E2118CD9C001EA4CA /* SettingsRequestDataCellViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D723708D2118CD9B001EA4CA /* SettingsRequestDataCellViewModelTests.swift */; }; - D72370902118E1F5001EA4CA /* ExportDataEnvelopeLenses.swift in Sources */ = {isa = PBXBuildFile; fileRef = D723708F2118E1F5001EA4CA /* ExportDataEnvelopeLenses.swift */; }; + D723708C2118CAD8001EA4CA /* SettingsDeleteOrRequestCellViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D723708B2118CAD8001EA4CA /* SettingsDeleteOrRequestCellViewModelTests.swift */; }; D72370922118FEFA001EA4CA /* SettingsPrivacyViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D72370912118FEFA001EA4CA /* SettingsPrivacyViewModelTests.swift */; }; D72370942119139D001EA4CA /* SettingsPrivacyViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D72370932119139D001EA4CA /* SettingsPrivacyViewControllerTests.swift */; }; D7237096211A1593001EA4CA /* SettingsFollowCellViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7237095211A1593001EA4CA /* SettingsFollowCellViewModelTests.swift */; }; D7237099211A3DA9001EA4CA /* SettingsFollowCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7237097211A3925001EA4CA /* SettingsFollowCell.swift */; }; - D7417CD620BF12F4004DABA6 /* ExportDataEnvelope.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7417CD520BF12F4004DABA6 /* ExportDataEnvelope.swift */; }; - D7417D0E20BF4833004DABA6 /* ExportStateEnvelopeTemplates.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7417D0D20BF4833004DABA6 /* ExportStateEnvelopeTemplates.swift */; }; D755ECA52315E6E10096F189 /* CreateBackingInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = D755ECA42315E6E10096F189 /* CreateBackingInput.swift */; }; D755ECA72315E95C0096F189 /* CreateBackingMutation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D755ECA62315E95C0096F189 /* CreateBackingMutation.swift */; }; D755ECA92319AF4D0096F189 /* CreateBackingEnvelope.swift in Sources */ = {isa = PBXBuildFile; fileRef = D755ECA82319AF4D0096F189 /* CreateBackingEnvelope.swift */; }; @@ -1471,11 +1466,9 @@ D79CF3BF21AC9CB200ECB73A /* PaymentType.swift in Sources */ = {isa = PBXBuildFile; fileRef = D79CF38521AC9AD200ECB73A /* PaymentType.swift */; }; D79D61151FD0979D000F958B /* String+Base64.swift in Sources */ = {isa = PBXBuildFile; fileRef = D79D61141FD0979D000F958B /* String+Base64.swift */; }; D79F0F3721028C2600D3B32C /* SettingsPrivacyRecommendationCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D79F0F3621028C2600D3B32C /* SettingsPrivacyRecommendationCell.swift */; }; - D79F0F6F2102944500D3B32C /* SettingsPrivacyRequestDataCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D79F0F6E2102944500D3B32C /* SettingsPrivacyRequestDataCell.swift */; }; - D79F0F712102973A00D3B32C /* SettingsPrivacyDeleteAccountCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D79F0F702102973A00D3B32C /* SettingsPrivacyDeleteAccountCell.swift */; }; + D79F0F712102973A00D3B32C /* SettingsPrivacyDeleteOrRequestCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D79F0F702102973A00D3B32C /* SettingsPrivacyDeleteOrRequestCell.swift */; }; D79F0F7321067FB500D3B32C /* SettingsRecommendationsCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D79F0F7221067FB500D3B32C /* SettingsRecommendationsCellViewModel.swift */; }; - D79F0F7521068DC800D3B32C /* SettingsDeleteAccountCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D79F0F7421068DC800D3B32C /* SettingsDeleteAccountCellViewModel.swift */; }; - D79F0F772107D60800D3B32C /* SettingsRequestDataCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D79F0F762107D60800D3B32C /* SettingsRequestDataCellViewModel.swift */; }; + D79F0F7521068DC800D3B32C /* SettingsDeleteOrRequestCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D79F0F7421068DC800D3B32C /* SettingsDeleteOrRequestCellViewModel.swift */; }; D7A37C8F1E2EB01700EA066D /* SearchEmptyStateCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7A37C8E1E2EB01700EA066D /* SearchEmptyStateCell.swift */; }; D7A37CCF1E2FF93D00EA066D /* SearchEmptyStateCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7A37CCE1E2FF93D00EA066D /* SearchEmptyStateCellViewModel.swift */; }; D7A37D7A1E367E5A00EA066D /* MostPopularSearchProjectCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7A37D781E367E5A00EA066D /* MostPopularSearchProjectCellViewModel.swift */; }; @@ -1890,7 +1883,6 @@ 37FDAF702273B7FF00662CC8 /* UIStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIStackView.swift; sourceTree = ""; }; 37FDAFAA2273B86800662CC8 /* UIStackView+Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackView+Tests.swift"; sourceTree = ""; }; 37FEFBC7222F1E4F00FCA608 /* ProcessInfoType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProcessInfoType.swift; sourceTree = ""; }; - 39742BBD2B27A91C004944E6 /* ExportDataEnvelopeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExportDataEnvelopeTests.swift; sourceTree = ""; }; 3D1363951F0191FB00B53420 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = ""; }; 4705D8972742E20900A13BBE /* ProjectHeaderCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProjectHeaderCell.swift; sourceTree = ""; }; 470B771926FCDC8900EBD5CA /* RiskMessagingViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RiskMessagingViewModel.swift; sourceTree = ""; }; @@ -3006,16 +2998,12 @@ D710ADFC2441172100DC7199 /* PledgeViewCTAContainerViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PledgeViewCTAContainerViewModelTests.swift; sourceTree = ""; }; D7180BA022EF9DD900EB0110 /* RewardCellProjectBackingStateTypeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RewardCellProjectBackingStateTypeTests.swift; sourceTree = ""; }; D72370532118C19B001EA4CA /* SettingsRecommendationsCellViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsRecommendationsCellViewModelTests.swift; sourceTree = ""; }; - D723708B2118CAD8001EA4CA /* SettingsDeleteAccountCellViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsDeleteAccountCellViewModelTests.swift; sourceTree = ""; }; - D723708D2118CD9B001EA4CA /* SettingsRequestDataCellViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsRequestDataCellViewModelTests.swift; sourceTree = ""; }; - D723708F2118E1F5001EA4CA /* ExportDataEnvelopeLenses.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportDataEnvelopeLenses.swift; sourceTree = ""; }; + D723708B2118CAD8001EA4CA /* SettingsDeleteOrRequestCellViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsDeleteOrRequestCellViewModelTests.swift; sourceTree = ""; }; D72370912118FEFA001EA4CA /* SettingsPrivacyViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsPrivacyViewModelTests.swift; sourceTree = ""; }; D72370932119139D001EA4CA /* SettingsPrivacyViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsPrivacyViewControllerTests.swift; sourceTree = ""; }; D7237095211A1593001EA4CA /* SettingsFollowCellViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsFollowCellViewModelTests.swift; sourceTree = ""; }; D7237097211A3925001EA4CA /* SettingsFollowCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsFollowCell.swift; sourceTree = ""; }; D741577A2284849000C0B907 /* PledgeCTAContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PledgeCTAContainerView.swift; sourceTree = ""; }; - D7417CD520BF12F4004DABA6 /* ExportDataEnvelope.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportDataEnvelope.swift; sourceTree = ""; }; - D7417D0D20BF4833004DABA6 /* ExportStateEnvelopeTemplates.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportStateEnvelopeTemplates.swift; sourceTree = ""; }; D755ECA42315E6E10096F189 /* CreateBackingInput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateBackingInput.swift; sourceTree = ""; }; D755ECA62315E95C0096F189 /* CreateBackingMutation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateBackingMutation.swift; sourceTree = ""; }; D755ECA82319AF4D0096F189 /* CreateBackingEnvelope.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateBackingEnvelope.swift; sourceTree = ""; }; @@ -3049,11 +3037,9 @@ D79CF38521AC9AD200ECB73A /* PaymentType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentType.swift; sourceTree = ""; }; D79D61141FD0979D000F958B /* String+Base64.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Base64.swift"; sourceTree = ""; }; D79F0F3621028C2600D3B32C /* SettingsPrivacyRecommendationCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsPrivacyRecommendationCell.swift; sourceTree = ""; }; - D79F0F6E2102944500D3B32C /* SettingsPrivacyRequestDataCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsPrivacyRequestDataCell.swift; sourceTree = ""; }; - D79F0F702102973A00D3B32C /* SettingsPrivacyDeleteAccountCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsPrivacyDeleteAccountCell.swift; sourceTree = ""; }; + D79F0F702102973A00D3B32C /* SettingsPrivacyDeleteOrRequestCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsPrivacyDeleteOrRequestCell.swift; sourceTree = ""; }; D79F0F7221067FB500D3B32C /* SettingsRecommendationsCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsRecommendationsCellViewModel.swift; sourceTree = ""; }; - D79F0F7421068DC800D3B32C /* SettingsDeleteAccountCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsDeleteAccountCellViewModel.swift; sourceTree = ""; }; - D79F0F762107D60800D3B32C /* SettingsRequestDataCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsRequestDataCellViewModel.swift; sourceTree = ""; }; + D79F0F7421068DC800D3B32C /* SettingsDeleteOrRequestCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsDeleteOrRequestCellViewModel.swift; sourceTree = ""; }; D7A37C8E1E2EB01700EA066D /* SearchEmptyStateCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchEmptyStateCell.swift; sourceTree = ""; }; D7A37CCE1E2FF93D00EA066D /* SearchEmptyStateCellViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchEmptyStateCellViewModel.swift; sourceTree = ""; }; D7A37D781E367E5A00EA066D /* MostPopularSearchProjectCellViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MostPopularSearchProjectCellViewModel.swift; sourceTree = ""; }; @@ -4357,9 +4343,8 @@ isa = PBXGroup; children = ( D7237097211A3925001EA4CA /* SettingsFollowCell.swift */, - D79F0F702102973A00D3B32C /* SettingsPrivacyDeleteAccountCell.swift */, + D79F0F702102973A00D3B32C /* SettingsPrivacyDeleteOrRequestCell.swift */, D79F0F3621028C2600D3B32C /* SettingsPrivacyRecommendationCell.swift */, - D79F0F6E2102944500D3B32C /* SettingsPrivacyRequestDataCell.swift */, D796867F21013C1F00E54C61 /* SettingsPrivacyStaticCell.swift */, 77C5E251214182CA002E1670 /* SettingsPrivacySwitchCell.swift */, ); @@ -6465,8 +6450,8 @@ D0A787BA2204D66A006AE4F4 /* SelectCurrencyViewModel.swift */, D0A7880E2204EF93006AE4F4 /* SelectCurrencyViewModelTests.swift */, D04AAC1D218BB70C00CF713E /* SettingsAccountPickerCellViewModel.swift */, - D79F0F7421068DC800D3B32C /* SettingsDeleteAccountCellViewModel.swift */, - D723708B2118CAD8001EA4CA /* SettingsDeleteAccountCellViewModelTests.swift */, + D79F0F7421068DC800D3B32C /* SettingsDeleteOrRequestCellViewModel.swift */, + D723708B2118CAD8001EA4CA /* SettingsDeleteOrRequestCellViewModelTests.swift */, D796867B20FE655300E54C61 /* SettingsFollowCellViewModel.swift */, D7237095211A1593001EA4CA /* SettingsFollowCellViewModelTests.swift */, D6B6766420FE85000082717D /* SettingsNewslettersCellViewModel.swift */, @@ -6485,8 +6470,6 @@ D72370912118FEFA001EA4CA /* SettingsPrivacyViewModelTests.swift */, D79F0F7221067FB500D3B32C /* SettingsRecommendationsCellViewModel.swift */, D72370532118C19B001EA4CA /* SettingsRecommendationsCellViewModelTests.swift */, - D79F0F762107D60800D3B32C /* SettingsRequestDataCellViewModel.swift */, - D723708D2118CD9B001EA4CA /* SettingsRequestDataCellViewModelTests.swift */, 608E7A5428ABE27400289E92 /* SetYourPasswordViewModel.swift */, 60DA50E928B68990002E2DF1 /* SetYourPasswordViewModelTests.swift */, A75C81161D210BD700B5AD03 /* ShareViewModel.swift */, @@ -6643,8 +6626,6 @@ 8AB64FEC2576C8240075E2E7 /* EmailVerificationResponseEnvelopeTests.swift */, D015878F1EEB2ED6006E7684 /* ErrorEnvelope.swift */, D01587901EEB2ED6006E7684 /* ErrorEnvelopeTests.swift */, - D7417CD520BF12F4004DABA6 /* ExportDataEnvelope.swift */, - 39742BBD2B27A91C004944E6 /* ExportDataEnvelopeTests.swift */, D01587911EEB2ED6006E7684 /* FindFriendsEnvelope.swift */, D01587921EEB2ED6006E7684 /* FindFriendsEnvelopeTests.swift */, D01587931EEB2ED6006E7684 /* FriendStatsEnvelope.swift */, @@ -6729,7 +6710,6 @@ 378CA24522C4449F004E3C86 /* CountryLenses.swift */, D01587A11EEB2ED6006E7684 /* DiscoveryEnvelopeLenses.swift */, D01587A21EEB2ED6006E7684 /* DiscoveryParamsLenses.swift */, - D723708F2118E1F5001EA4CA /* ExportDataEnvelopeLenses.swift */, D01587A31EEB2ED6006E7684 /* FindFriendsEnvelopeLenses.swift */, D01587A41EEB2ED6006E7684 /* FriendStatsEnvelope.StatsLenses.swift */, D01587A51EEB2ED6006E7684 /* FriendStatsEnvelopeLenses.swift */, @@ -6790,7 +6770,6 @@ D01587F71EEB2ED7006E7684 /* ConfigTemplates.swift */, D794408F2208970E00D0A747 /* CreatePaymentSourceTemplate.swift */, D01587F91EEB2ED7006E7684 /* DiscoveryEnvelopeTemplates.swift */, - D7417D0D20BF4833004DABA6 /* ExportStateEnvelopeTemplates.swift */, D01587FA1EEB2ED7006E7684 /* FindFriendsEnvelopeTemplates.swift */, D01587FB1EEB2ED7006E7684 /* FriendStatsEnvelopeTemplates.swift */, D01587FC1EEB2ED7006E7684 /* ItemTemplates.swift */, @@ -7424,7 +7403,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - D79F0F7521068DC800D3B32C /* SettingsDeleteAccountCellViewModel.swift in Sources */, + D79F0F7521068DC800D3B32C /* SettingsDeleteOrRequestCellViewModel.swift in Sources */, D65BF351232FE88300B15B25 /* ManagePledgeSummaryViewModel.swift in Sources */, 37280272226F880100E0ACBB /* CheckoutStyles.swift in Sources */, 013744F81D99A39B00E50C78 /* EmptyStatesViewModel.swift in Sources */, @@ -7516,7 +7495,6 @@ D710ADFB243FB94A00DC7199 /* PledgeViewCTAContainerViewModel.swift in Sources */, 3767EDB122CFFF2B0088E8E4 /* ShippingRulesViewModel.swift in Sources */, 19F0940128B3D75800973138 /* PledgePaymentMethodAddCellViewModel.swift in Sources */, - D79F0F772107D60800D3B32C /* SettingsRequestDataCellViewModel.swift in Sources */, 8A05CB0E23DB82D3002B01EE /* CookieRefTagFunctions.swift in Sources */, 477239772710FA9A00D26CDA /* ProjectNavigationSelectorViewModel.swift in Sources */, A75511621C8642C3005355CF /* LaunchedCountries.swift in Sources */, @@ -7745,7 +7723,7 @@ buildActionMask = 2147483647; files = ( 1611EF6923B275700051CDCC /* MockUUID.swift in Sources */, - D723708C2118CAD8001EA4CA /* SettingsDeleteAccountCellViewModelTests.swift in Sources */, + D723708C2118CAD8001EA4CA /* SettingsDeleteOrRequestCellViewModelTests.swift in Sources */, A7ED1FAC1E831C5C00BFFA01 /* ActivitySampleFollowCellViewModelTests.swift in Sources */, D69C552D23A03D9700B0987A /* ActivityErroredBackingsCellViewModelTests.swift in Sources */, A7ED20021E831C5C00BFFA01 /* ThanksViewModelTests.swift in Sources */, @@ -7865,7 +7843,6 @@ 7720BA7022E0DBD10071FDA1 /* InstantiableTests.swift in Sources */, A7ED1FF91E831C5C00BFFA01 /* ProjectNotificationsViewModelTest.swift in Sources */, A7ED1F361E830FDC00BFFA01 /* String+TruncateTests.swift in Sources */, - D723708E2118CD9C001EA4CA /* SettingsRequestDataCellViewModelTests.swift in Sources */, A7ED1FFA1E831C5C00BFFA01 /* ProjectPamphletContentViewModelTests.swift in Sources */, A7ED1F381E830FDC00BFFA01 /* UIColorTests.swift in Sources */, 77C7B654226E0E54001101AC /* RewardsCollectionViewModelTests.swift in Sources */, @@ -7997,7 +7974,7 @@ 0146E3231CC0296900082C5B /* FacebookConfirmationViewController.swift in Sources */, 20BCBEB0264DAA4B00510EDF /* CommentComposerView.swift in Sources */, 94114D5B265305210063E8F6 /* CommentPostFailedCell.swift in Sources */, - D79F0F712102973A00D3B32C /* SettingsPrivacyDeleteAccountCell.swift in Sources */, + D79F0F712102973A00D3B32C /* SettingsPrivacyDeleteOrRequestCell.swift in Sources */, 379C00012242DAFF00F6F0C2 /* WebViewController.swift in Sources */, 8A4841B424871B9500246223 /* RewardTableViewCell.swift in Sources */, 20C186F126726631008046D8 /* CommentsErrorCell.swift in Sources */, @@ -8159,7 +8136,6 @@ 60C996E42ABCA5E5006BE4F4 /* ReportProjectLabelView.swift in Sources */, A75CBDE81C8A26F800758C55 /* AppDelegateViewModel.swift in Sources */, A72C3AA71D00F7A30075227E /* SortPagerViewController.swift in Sources */, - D79F0F6F2102944500D3B32C /* SettingsPrivacyRequestDataCell.swift in Sources */, D764370A224040D100DAFC9E /* SharedFunctions.swift in Sources */, 77C5E252214182CA002E1670 /* SettingsPrivacySwitchCell.swift in Sources */, A7C795B41C873AC90081977F /* DiscoveryViewController.swift in Sources */, @@ -8379,7 +8355,6 @@ D6B9F943220358D1003282A5 /* AuthorTemplates.swift in Sources */, 06C38CBB26A9D7CC00591CED /* GraphAPI.UpdateUserProfileInput+UpdateUserProfileInput.swift in Sources */, 06232D462795EC4A00A81755 /* TextComponent.swift in Sources */, - D7417D0E20BF4833004DABA6 /* ExportStateEnvelopeTemplates.swift in Sources */, 19047FC72889BC5800BDD1A8 /* ClientSecretEnvelope.swift in Sources */, 7798B56521750041008BC50D /* GraphUser.swift in Sources */, 8A1557072693A07500017845 /* Backing+BackingFragment.swift in Sources */, @@ -8490,7 +8465,6 @@ 194154CE28D8ED69004648C8 /* CreatePaymentSourceSetupIntentInput.swift in Sources */, D01588DF1EEB2ED7006E7684 /* User.StatsLenses.swift in Sources */, 06F7BE1826B31A020094BF37 /* UserCreditCards+UserFragment.swift in Sources */, - D7417CD620BF12F4004DABA6 /* ExportDataEnvelope.swift in Sources */, D6DC65522178CDDD008CF69C /* GraphUserEmailTemplate.swift in Sources */, D0198F3621793FCF0090A9EC /* Service+RequestHelpers.swift in Sources */, D01588CF1EEB2ED7006E7684 /* StarEnvelopeLenses.swift in Sources */, @@ -8594,7 +8568,6 @@ 7798B5632174F494008BC50D /* UserEnvelope.swift in Sources */, D01588491EEB2ED7006E7684 /* Backing.swift in Sources */, D01588CB1EEB2ED7006E7684 /* ShippingRuleLenses.swift in Sources */, - D72370902118E1F5001EA4CA /* ExportDataEnvelopeLenses.swift in Sources */, D01588411EEB2ED7006E7684 /* AccessTokenEnvelope.swift in Sources */, 20EB9313266030CB004FA1C8 /* PostCommentEnvelope.swift in Sources */, D01588BD1EEB2ED7006E7684 /* ProjectStatsEnvelope.RewardDistributionLenses.swift in Sources */, @@ -8791,7 +8764,6 @@ 47A662F726AF75B7001CE7B1 /* GraphAPI.WatchProjectInput+WatchProjectInputTests.swift in Sources */, D0D10C1D1EEB4550005EBAD0 /* UpdatePledgeEnvelopeTests.swift in Sources */, 069CD29726B08C170076045F /* GraphAPI.UpdateUserProfileInput+UpdateUserProfileInputTests.swift in Sources */, - 39742BBF2B27AA8D004944E6 /* ExportDataEnvelopeTests.swift in Sources */, 064AEF11270CF867006605DD /* FetchProjectRewardsByIdQueryTemplate.swift in Sources */, D0D10C0E1EEB4550005EBAD0 /* ItemTests.swift in Sources */, 0620176E276956D600818A47 /* GraphCommentTests.swift in Sources */, diff --git a/KsApi/MockService.swift b/KsApi/MockService.swift index 0fbfc92228..b48e9ea980 100644 --- a/KsApi/MockService.swift +++ b/KsApi/MockService.swift @@ -74,11 +74,6 @@ fileprivate let fetchFriendStatsResponse: FriendStatsEnvelope? fileprivate let fetchFriendStatsError: ErrorEnvelope? - fileprivate let fetchExportStateResponse: ExportDataEnvelope? - fileprivate let fetchExportStateError: ErrorEnvelope? - - fileprivate let exportDataError: ErrorEnvelope? - fileprivate let fetchDraftResponse: UpdateDraft? fileprivate let fetchDraftError: ErrorEnvelope? @@ -256,9 +251,6 @@ fetchFriendsError: ErrorEnvelope? = nil, fetchFriendStatsResponse: FriendStatsEnvelope? = nil, fetchFriendStatsError: ErrorEnvelope? = nil, - fetchExportStateResponse: ExportDataEnvelope? = nil, - fetchExportStateError: ErrorEnvelope? = nil, - exportDataError: ErrorEnvelope? = nil, fetchDraftResponse: UpdateDraft? = nil, fetchDraftError: ErrorEnvelope? = nil, fetchGraphUserResult: Result, ErrorEnvelope>? = nil, @@ -404,11 +396,6 @@ self.fetchFriendStatsResponse = fetchFriendStatsResponse self.fetchFriendStatsError = fetchFriendStatsError - self.fetchExportStateResponse = fetchExportStateResponse - self.fetchExportStateError = fetchExportStateError - - self.exportDataError = exportDataError - self.fetchDraftResponse = fetchDraftResponse self.fetchDraftError = fetchDraftError @@ -791,13 +778,6 @@ return SignalProducer(value: VoidEnvelope()) } - internal func exportData() -> SignalProducer { - if let error = exportDataError { - return SignalProducer(error: error) - } - return SignalProducer(value: VoidEnvelope()) - } - internal func followFriend(userId id: Int) -> SignalProducer { if let error = followFriendError { return SignalProducer(error: error) @@ -1470,15 +1450,6 @@ return SignalProducer(value: VoidEnvelope()) } - func exportDataState() -> SignalProducer { - if let response = fetchExportStateResponse { - return SignalProducer(value: response) - } else if let error = fetchExportStateError { - return SignalProducer(error: error) - } - return SignalProducer(value: .template) - } - internal func searchMessages(query _: String, project _: Project?) -> SignalProducer { return SignalProducer( @@ -1740,9 +1711,6 @@ fetchFriendsError: $1.fetchFriendsError, fetchFriendStatsResponse: $1.fetchFriendStatsResponse, fetchFriendStatsError: $1.fetchFriendStatsError, - fetchExportStateResponse: $1.fetchExportStateResponse, - fetchExportStateError: $1.fetchExportStateError, - exportDataError: $1.exportDataError, fetchDraftResponse: $1.fetchDraftResponse, fetchDraftError: $1.fetchDraftError, fetchGraphUserResult: $1.fetchGraphUserResult, diff --git a/KsApi/Service.swift b/KsApi/Service.swift index 3710d1608c..5df2d6a67a 100644 --- a/KsApi/Service.swift +++ b/KsApi/Service.swift @@ -221,15 +221,6 @@ public struct Service: ServiceType { return request(.deleteImage(image, fromDraft: draft)) } - public func exportData() -> SignalProducer { - return request(.exportData) - } - - public func exportDataState() - -> SignalProducer { - return request(.exportDataState) - } - public func previewUrl(forDraft draft: UpdateDraft) -> URL? { return self.serverConfig.apiBaseUrl .appendingPathComponent("/v1/projects/\(draft.update.projectId)/updates/draft/preview") diff --git a/KsApi/ServiceType.swift b/KsApi/ServiceType.swift index b2bfb0a298..6ef7db4899 100644 --- a/KsApi/ServiceType.swift +++ b/KsApi/ServiceType.swift @@ -106,10 +106,6 @@ public protocol ServiceType { func delete(image: UpdateDraft.Image, fromDraft draft: UpdateDraft) -> SignalProducer - func exportData() -> SignalProducer - - func exportDataState() -> SignalProducer - /// Fetch a page of activities. func fetchActivities(count: Int?) -> SignalProducer diff --git a/KsApi/lib/Route.swift b/KsApi/lib/Route.swift index a868038c70..2d6418c23c 100644 --- a/KsApi/lib/Route.swift +++ b/KsApi/lib/Route.swift @@ -12,8 +12,6 @@ internal enum Route { case config case deleteImage(UpdateDraft.Image, fromDraft: UpdateDraft) case discover(DiscoveryParams) - case exportData - case exportDataState case facebookConnect(facebookAccessToken: String) case facebookLogin(facebookAccessToken: String, code: String?) case facebookSignup(facebookAccessToken: String, sendNewsletters: Bool) @@ -83,12 +81,6 @@ internal enum Route { case .config: return (.GET, "/v1/app/ios/config", ["no_cache": "\(Date().timeIntervalSince1970)"], nil) - case .exportData: - return (.POST, "/v1/users//self/queue_export_data", [:], nil) - - case .exportDataState: - return (.GET, "/v1/users/self/download_export_data", [:], nil) - case let .deleteImage(i, draft): return (.DELETE, "/v1/projects/\(draft.update.projectId)/updates/draft/images/\(i.id)", [:], nil) diff --git a/KsApi/models/ExportDataEnvelope.swift b/KsApi/models/ExportDataEnvelope.swift deleted file mode 100644 index b44c3498dd..0000000000 --- a/KsApi/models/ExportDataEnvelope.swift +++ /dev/null @@ -1,35 +0,0 @@ - - -public struct ExportDataEnvelope { - public let expiresAt: String? - public var state: State - public let dataUrl: String? - - public enum State: String, Decodable, Equatable { - case none - case created - case queued - case assembling - case assembled - case uploading - case completed - case failed - case expired - case unknown // Default value if server response can't be parsed. - - // Throws error if the value isn't a valid string. If the value is a valid string, it maps to - // its corresponding enum case, if it exists, and to `unknown` otherwise. - public init(from decoder: Decoder) throws { - let rawSelf = try decoder.singleValueContainer().decode(String.self) - self = .init(rawValue: rawSelf) ?? .unknown - } - } -} - -extension ExportDataEnvelope: Decodable { - enum CodingKeys: String, CodingKey { - case expiresAt = "expires_at" - case state - case dataUrl = "data_url" - } -} diff --git a/KsApi/models/ExportDataEnvelopeTests.swift b/KsApi/models/ExportDataEnvelopeTests.swift deleted file mode 100644 index bb3a5d9a03..0000000000 --- a/KsApi/models/ExportDataEnvelopeTests.swift +++ /dev/null @@ -1,24 +0,0 @@ -@testable import KsApi -import XCTest - -class ExportDataEnvelopeTests: XCTestCase { - func testJsonDecodingWithValidState() { - let env: ExportDataEnvelope = try! ExportDataEnvelope.decodeJSONDictionary([ - "expires_at": "fake-date", - "state": "none", - "data_url": "fake-url" - ]) - XCTAssertNotNil(env) - XCTAssertEqual(env.state, .none) - } - - func testJsonDecodingWithInvalidState() { - let env: ExportDataEnvelope = try! ExportDataEnvelope.decodeJSONDictionary([ - "expires_at": "fake-date", - "state": "invalid-state", - "data_url": "fake-url" - ]) - XCTAssertNotNil(env) - XCTAssertEqual(env.state, .unknown) - } -} diff --git a/KsApi/models/lenses/ExportDataEnvelopeLenses.swift b/KsApi/models/lenses/ExportDataEnvelopeLenses.swift deleted file mode 100644 index d8fb947b84..0000000000 --- a/KsApi/models/lenses/ExportDataEnvelopeLenses.swift +++ /dev/null @@ -1,18 +0,0 @@ -import Prelude - -extension ExportDataEnvelope { - public enum lens { - public static let expiresAt = Lens( - view: { $0.expiresAt }, - set: { ExportDataEnvelope(expiresAt: $0, state: $1.state, dataUrl: $1.dataUrl) } - ) - public static let state = Lens( - view: { $0.state }, - set: { ExportDataEnvelope(expiresAt: $1.expiresAt, state: $0, dataUrl: $1.dataUrl) } - ) - public static let dataUrl = Lens( - view: { $0.dataUrl }, - set: { ExportDataEnvelope(expiresAt: $1.expiresAt, state: $1.state, dataUrl: $0) } - ) - } -} diff --git a/KsApi/models/templates/ExportStateEnvelopeTemplates.swift b/KsApi/models/templates/ExportStateEnvelopeTemplates.swift deleted file mode 100644 index ea8aff94da..0000000000 --- a/KsApi/models/templates/ExportStateEnvelopeTemplates.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Prelude - -extension ExportDataEnvelope { - internal static let template = ExportDataEnvelope( - expiresAt: "2018-06-19T13:12:00Z", - state: .completed, - dataUrl: "http://kickstarter.com/mydata" - ) -} diff --git a/Library/ViewModels/SettingsDeleteAccountCellViewModel.swift b/Library/ViewModels/SettingsDeleteAccountCellViewModel.swift deleted file mode 100644 index 80e58ad5c0..0000000000 --- a/Library/ViewModels/SettingsDeleteAccountCellViewModel.swift +++ /dev/null @@ -1,46 +0,0 @@ -import Foundation -import KsApi -import Prelude -import ReactiveExtensions -import ReactiveSwift - -public protocol SettingsDeleteAccountCellViewModelInputs { - func configureWith(user: User) - func deleteAccountTapped() -} - -public protocol SettingsDeleteAccountCellViewModelOutputs { - var notifyDeleteAccountTapped: Signal { get } -} - -public protocol SettingsDeleteAccountCellViewModelType { - var inputs: SettingsDeleteAccountCellViewModelInputs { get } - var outputs: SettingsDeleteAccountCellViewModelOutputs { get } -} - -public final class SettingsDeleteAccountCellViewModel: SettingsDeleteAccountCellViewModelType, - SettingsDeleteAccountCellViewModelInputs, SettingsDeleteAccountCellViewModelOutputs { - public init() { - self.notifyDeleteAccountTapped = self.deleteAccountTappedProperty.signal - .map { - AppEnvironment.current.apiService.serverConfig.webBaseUrl - .appendingPathComponent("profile") - .appendingPathComponent("destroy") - } - } - - fileprivate let deleteAccountTappedProperty = MutableProperty(()) - public func deleteAccountTapped() { - self.deleteAccountTappedProperty.value = () - } - - fileprivate let configureWithProperty = MutableProperty(nil) - public func configureWith(user: User) { - self.configureWithProperty.value = user - } - - public let notifyDeleteAccountTapped: Signal - - public var inputs: SettingsDeleteAccountCellViewModelInputs { return self } - public var outputs: SettingsDeleteAccountCellViewModelOutputs { return self } -} diff --git a/Library/ViewModels/SettingsDeleteOrRequestCellViewModel.swift b/Library/ViewModels/SettingsDeleteOrRequestCellViewModel.swift new file mode 100644 index 0000000000..5d13a6c862 --- /dev/null +++ b/Library/ViewModels/SettingsDeleteOrRequestCellViewModel.swift @@ -0,0 +1,45 @@ +import Foundation +import KsApi +import Prelude +import ReactiveExtensions +import ReactiveSwift + +public protocol SettingsDeleteOrRequestCellViewModelInputs { + func configureWith(user: User) + func deleteAccountTapped() +} + +public protocol SettingsDeleteOrRequestCellViewModelOutputs { + var notifyDeleteAccountTapped: Signal { get } +} + +public protocol SettingsDeleteOrRequestCellViewModelType { + var inputs: SettingsDeleteOrRequestCellViewModelInputs { get } + var outputs: SettingsDeleteOrRequestCellViewModelOutputs { get } +} + +public final class SettingsDeleteOrRequestCellViewModel: SettingsDeleteOrRequestCellViewModelType, + SettingsDeleteOrRequestCellViewModelInputs, SettingsDeleteOrRequestCellViewModelOutputs { + public init() { + self.notifyDeleteAccountTapped = self.deleteAccountTappedProperty.signal + .map { + // TODO(MBL-1063): Replace hardcoded URL with translatable string. + URL(string: "https://legal.kickstarter.com/policies/en/?modal=take-control") + }.skipNil() + } + + fileprivate let deleteAccountTappedProperty = MutableProperty(()) + public func deleteAccountTapped() { + self.deleteAccountTappedProperty.value = () + } + + fileprivate let configureWithProperty = MutableProperty(nil) + public func configureWith(user: User) { + self.configureWithProperty.value = user + } + + public let notifyDeleteAccountTapped: Signal + + public var inputs: SettingsDeleteOrRequestCellViewModelInputs { return self } + public var outputs: SettingsDeleteOrRequestCellViewModelOutputs { return self } +} diff --git a/Library/ViewModels/SettingsDeleteAccountCellViewModelTests.swift b/Library/ViewModels/SettingsDeleteOrRequestCellViewModelTests.swift similarity index 70% rename from Library/ViewModels/SettingsDeleteAccountCellViewModelTests.swift rename to Library/ViewModels/SettingsDeleteOrRequestCellViewModelTests.swift index aa618370da..92512f746b 100644 --- a/Library/ViewModels/SettingsDeleteAccountCellViewModelTests.swift +++ b/Library/ViewModels/SettingsDeleteOrRequestCellViewModelTests.swift @@ -6,8 +6,8 @@ import ReactiveExtensions_TestHelpers import ReactiveSwift import XCTest -internal final class SettingsDeleteAccountCellViewModelTests: TestCase { - internal let vm = SettingsDeleteAccountCellViewModel() +internal final class SettingsDeleteOrRequestCellViewModelTests: TestCase { + internal let vm = SettingsDeleteOrRequestCellViewModel() internal let notifyDeleteAccountTapped = TestObserver() internal override func setUp() { @@ -17,8 +17,7 @@ internal final class SettingsDeleteAccountCellViewModelTests: TestCase { func testNotifyDeleteAccountTapped() { let user = User.template - let url = - AppEnvironment.current.apiService.serverConfig.webBaseUrl.appendingPathComponent("/profile/destroy") + let url = URL(string: "https://legal.kickstarter.com/policies/en/?modal=take-control")! self.vm.inputs.configureWith(user: user) self.vm.inputs.deleteAccountTapped() self.notifyDeleteAccountTapped.assertValues([url]) diff --git a/Library/ViewModels/SettingsRequestDataCellViewModel.swift b/Library/ViewModels/SettingsRequestDataCellViewModel.swift deleted file mode 100644 index 418d364004..0000000000 --- a/Library/ViewModels/SettingsRequestDataCellViewModel.swift +++ /dev/null @@ -1,170 +0,0 @@ -import Foundation -import KsApi -import Prelude -import ReactiveExtensions -import ReactiveSwift - -public protocol SettingsRequestDataCellViewModelInputs { - func awakeFromNib() - func configureWith(user: User) - func exportDataTapped() - func startRequestDataTapped() -} - -public protocol SettingsRequestDataCellViewModelOutputs { - var dataExpirationAndChevronHidden: Signal { get } - var goToSafari: Signal { get } - var requestDataButtonEnabled: Signal { get } - var requestedDataExpirationDate: Signal { get } - var requestDataLoadingIndicator: Signal { get } - var requestDataText: Signal { get } - var requestDataTextHidden: Signal { get } - var preparingDataAndCheckBackLaterTextHidden: Signal { get } - var showRequestDataPrompt: Signal { get } - var unableToRequestDataError: Signal { get } -} - -public protocol SettingsRequestDataCellViewModelType { - var inputs: SettingsRequestDataCellViewModelInputs { get } - var outputs: SettingsRequestDataCellViewModelOutputs { get } -} - -public final class SettingsRequestDataCellViewModel: SettingsRequestDataCellViewModelType, - SettingsRequestDataCellViewModelInputs, SettingsRequestDataCellViewModelOutputs { - public init() { - let initialUser = Signal.combineLatest( - self.configureWithUserProperty.signal.skipNil(), - self.awakeFromNibProperty.signal - ).map(first) - - let userEmailEvent = self.configureWithUserProperty.signal.skipNil() - .switchMap { _ in - AppEnvironment.current.apiService.fetchGraphUser(withStoredCards: true) - .ksr_delay(AppEnvironment.current.apiDelayInterval, on: AppEnvironment.current.scheduler) - .materialize() - } - - let requestDataAlertText = userEmailEvent.values().map { - Strings.Youll_receive_an_email_at_email_when_your_download_is_ready(email: $0.me.email ?? "") - } - - let exportEnvelope = initialUser - .switchMap { _ in - AppEnvironment.current.apiService.exportDataState() - .demoteErrors() - } - - self.showRequestDataPrompt = Signal.combineLatest(exportEnvelope, requestDataAlertText) - .filter { canRequestData($0.0) } - .map { _, alertMessage in alertMessage } - .takeWhen(self.exportDataTappedProperty.signal.ignoreValues()) - - let requestDataEvent = self.startRequestDataTappedProperty.signal - .switchMap { _ in - AppEnvironment.current.apiService.exportData() - .ksr_delay(AppEnvironment.current.apiDelayInterval, on: AppEnvironment.current.scheduler) - .materialize() - } - - self.unableToRequestDataError = requestDataEvent.errors() - .map { env in - env.errorMessages.first ?? Strings.Unable_to_request() - } - - self.requestDataLoadingIndicator = Signal.merge( - self.configureWithUserProperty.signal.mapConst(false), - exportEnvelope.map { [.assembling, .assembled, .uploading].contains($0.state) }, - self.startRequestDataTappedProperty.signal.mapConst(true) - ) - - let initialText = self.awakeFromNibProperty.signal.mapConst(Strings.Request_my_personal_data()) - - self.requestDataText = Signal.merge( - initialText, - exportEnvelope - .map { canRequestData($0) - ? Strings.Request_my_personal_data() : Strings.Download_your_personal_data() - } - ) - - self.requestDataButtonEnabled = self.requestDataLoadingIndicator.signal.negate() - - self.requestedDataExpirationDate = exportEnvelope.map { - dateFormatter(for: $0.expiresAt, state: $0.state) - } - - self.dataExpirationAndChevronHidden = Signal.merge( - self.awakeFromNibProperty.signal.mapConst(true), - exportEnvelope - .map(canRequestData) - ) - - self.goToSafari = exportEnvelope - .filter { $0.state == .completed || $0.expiresAt != nil } - .map { $0.dataUrl ?? "" } - .takeWhen(self.exportDataTappedProperty.signal) - - self.preparingDataAndCheckBackLaterTextHidden = Signal.merge( - self.configureWithUserProperty.signal.mapConst(true), - exportEnvelope.map { - ![.assembling, .assembled, .uploading].contains($0.state) - }, - self.startRequestDataTappedProperty.signal.mapConst(false) - ) - - self.requestDataTextHidden = self.preparingDataAndCheckBackLaterTextHidden.signal.map { !$0 } - } - - fileprivate let awakeFromNibProperty = MutableProperty(()) - public func awakeFromNib() { - self.awakeFromNibProperty.value = () - } - - fileprivate let configureWithUserProperty = MutableProperty(nil) - public func configureWith(user: User) { - self.configureWithUserProperty.value = user - } - - fileprivate let exportDataTappedProperty = MutableProperty(()) - public func exportDataTapped() { - self.exportDataTappedProperty.value = () - } - - fileprivate let startRequestDataTappedProperty = MutableProperty(()) - public func startRequestDataTapped() { - self.startRequestDataTappedProperty.value = () - } - - public let dataExpirationAndChevronHidden: Signal - public let goToSafari: Signal - public let requestDataButtonEnabled: Signal - public let requestedDataExpirationDate: Signal - public let requestDataLoadingIndicator: Signal - public let requestDataText: Signal - public let requestDataTextHidden: Signal - public let preparingDataAndCheckBackLaterTextHidden: Signal - public let showRequestDataPrompt: Signal - public let unableToRequestDataError: Signal - - public var inputs: SettingsRequestDataCellViewModelInputs { return self } - public var outputs: SettingsRequestDataCellViewModelOutputs { return self } -} - -private func canRequestData(_ envelope: ExportDataEnvelope) -> Bool { - return envelope.dataUrl == nil || envelope.expiresAt == nil - || [.expired, .failed, .none, .unknown].contains(envelope.state) -} - -private func dateFormatter(for dateString: String?, state: ExportDataEnvelope.State) -> String { - guard let isoDate = dateString else { return "" } - let dateFormatter = DateFormatter() - dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:sZ" - guard let date = dateFormatter.date(from: isoDate) else { return "" } - - let expirationDate = Format.date(secondsInUTC: date.timeIntervalSince1970, template: "MMM d, yyyy") - let expirationTime = Format.date(secondsInUTC: date.timeIntervalSince1970, template: "h:mm a") - - if state == .expired { - return "" - } else { return Strings.Expires_date_at_time(date: expirationDate, time: expirationTime) } -} diff --git a/Library/ViewModels/SettingsRequestDataCellViewModelTests.swift b/Library/ViewModels/SettingsRequestDataCellViewModelTests.swift deleted file mode 100644 index e1f070f9e9..0000000000 --- a/Library/ViewModels/SettingsRequestDataCellViewModelTests.swift +++ /dev/null @@ -1,209 +0,0 @@ -@testable import KsApi -@testable import Library -import Prelude -import ReactiveExtensions -import ReactiveExtensions_TestHelpers -import ReactiveSwift -import XCTest - -internal final class SettingsRequestDataCellViewModelTests: TestCase { - internal let vm = SettingsRequestDataCellViewModel() - internal let dataExpirationAndChevronHidden = TestObserver() - internal let goToSafari = TestObserver() - internal let requestDataButtonEnabled = TestObserver() - internal let requestedDataExpirationDate = TestObserver() - internal let requestDataLoadingIndicator = TestObserver() - internal let requestDataText = TestObserver() - internal let requestDataTextHidden = TestObserver() - internal let preparingDataAndCheckBackLaterTextHidden = TestObserver() - internal let showRequestDataPrompt = TestObserver() - internal let unableToRequestDataError = TestObserver() - - internal override func setUp() { - super.setUp() - self.vm.outputs.goToSafari.observe(self.goToSafari.observer) - self.vm.outputs.requestDataButtonEnabled.observe(self.requestDataButtonEnabled.observer) - self.vm.outputs.requestedDataExpirationDate.observe(self.requestedDataExpirationDate.observer) - self.vm.outputs.requestDataLoadingIndicator.observe(self.requestDataLoadingIndicator.observer) - self.vm.outputs.requestDataText.observe(self.requestDataText.observer) - self.vm.outputs.requestDataTextHidden.observe(self.requestDataTextHidden.observer) - self.vm.outputs.dataExpirationAndChevronHidden.observe(self.dataExpirationAndChevronHidden.observer) - self.vm.outputs.preparingDataAndCheckBackLaterTextHidden - .observe(self.preparingDataAndCheckBackLaterTextHidden.observer) - self.vm.outputs.showRequestDataPrompt.observe(self.showRequestDataPrompt.observer) - self.vm.outputs.unableToRequestDataError.observe(self.unableToRequestDataError.observer) - } - - func testOpenDataUrlInSafari() { - let user = User.template - - withEnvironment(apiService: MockService(fetchExportStateResponse: .template)) { - self.vm.inputs.awakeFromNib() - self.vm.inputs.configureWith(user: user) - self.scheduler.advance() - self.vm.inputs.exportDataTapped() - self.goToSafari.assertValues(["http://kickstarter.com/mydata"]) - } - } - - func testRequestDataButtonIsEnabled() { - let user = User.template - let export = .template - |> ExportDataEnvelope.lens.state .~ .none - |> ExportDataEnvelope.lens.expiresAt .~ nil - |> ExportDataEnvelope.lens.dataUrl .~ nil - - withEnvironment(apiService: MockService(fetchExportStateResponse: export)) { - self.vm.inputs.configureWith(user: user) - self.requestDataButtonEnabled.assertValues([true]) - self.vm.inputs.startRequestDataTapped() - self.requestDataButtonEnabled.assertValues([true, false]) - } - } - - func testRequestDataButtonIsEnabledUnknownState() { - let user = User.template - let export = .template - |> ExportDataEnvelope.lens.state .~ .unknown - |> ExportDataEnvelope.lens.expiresAt .~ nil - |> ExportDataEnvelope.lens.dataUrl .~ nil - - withEnvironment(apiService: MockService(fetchExportStateResponse: export)) { - self.vm.inputs.configureWith(user: user) - self.requestDataButtonEnabled.assertValues([true]) - } - } - - func testDataExpirationDate() { - let user = User.template - - withEnvironment(apiService: MockService(fetchExportStateResponse: .template)) { - self.vm.inputs.awakeFromNib() - self.vm.inputs.configureWith(user: user) - self.scheduler.advance() - self.requestedDataExpirationDate.assertValues(["Expires Jun 19, 2018 at 1:12 PM"]) - } - } - - func testRequestDataText_IsHidden() { - let user = User.template - let export = .template - |> ExportDataEnvelope.lens.state .~ .expired - |> ExportDataEnvelope.lens.expiresAt .~ nil - |> ExportDataEnvelope.lens.dataUrl .~ nil - - withEnvironment(apiService: MockService(fetchExportStateResponse: export)) { - self.vm.inputs.awakeFromNib() - self.requestDataText.assertValues( - [Strings.Request_my_personal_data()], - "Should emit on awakeFromNib to set initial value" - ) - - self.vm.inputs.configureWith(user: user) - - self.scheduler.advance() - - self.requestDataText.assertValues([ - Strings.Request_my_personal_data(), - Strings.Request_my_personal_data() - ]) - - self.vm.inputs.exportDataTapped() - - self.scheduler.advance() - - withEnvironment(apiService: MockService(fetchExportStateResponse: .template)) { - self.vm.inputs.configureWith(user: user) - - self.scheduler.advance() - - self.requestDataText.assertValues([ - Strings.Request_my_personal_data(), - Strings.Request_my_personal_data(), - Strings.Download_your_personal_data() - ]) - } - } - } - - func testDataExpirationAndChevronHidden() { - let user = User.template - - withEnvironment(apiService: MockService(fetchExportStateResponse: .template)) { - self.vm.inputs.awakeFromNib() - self.requestDataText.assertValues( - [Strings.Request_my_personal_data()], - "Should emit on awakeFromNib to set initial value" - ) - self.dataExpirationAndChevronHidden.assertValues([true]) - self.vm.inputs.configureWith(user: user) - self.scheduler.advance() - self.requestDataText.assertValues([ - Strings.Request_my_personal_data(), - Strings.Download_your_personal_data() - ]) - self.dataExpirationAndChevronHidden.assertValues([true, false]) - } - } - - func testShowRequestDataPrompt() { - let user = User.template - let userEnvelope = UserEnvelope(me: GraphUser.template) - let export = .template - |> ExportDataEnvelope.lens.state .~ .none - |> ExportDataEnvelope.lens.expiresAt .~ nil - |> ExportDataEnvelope.lens.dataUrl .~ nil - - withEnvironment(apiService: MockService( - fetchExportStateResponse: export, - fetchGraphUserResult: .success(userEnvelope) - )) { - self.vm.inputs.awakeFromNib() - self.vm.inputs.configureWith(user: user) - self.scheduler.advance() - self.vm.inputs.exportDataTapped() - self.showRequestDataPrompt.assertValues([ - Strings.Youll_receive_an_email_at_email_when_your_download_is_ready(email: "nativesquad@ksr.com") - ]) - } - } - - func testPreparingDataAndCheckBackLaterText() { - let user = User.template - let export = .template - |> ExportDataEnvelope.lens.state .~ .expired - |> ExportDataEnvelope.lens.expiresAt .~ nil - |> ExportDataEnvelope.lens.dataUrl .~ nil - - withEnvironment(apiService: MockService(fetchExportStateResponse: export)) { - self.vm.inputs.configureWith(user: user) - - self.requestDataLoadingIndicator.assertValues([false]) - self.requestDataTextHidden.assertValues([false]) - self.preparingDataAndCheckBackLaterTextHidden.assertValues([true]) - - self.vm.inputs.startRequestDataTapped() - - self.requestDataLoadingIndicator.assertValues([false, true]) - self.requestDataTextHidden.assertValues([false, true]) - self.preparingDataAndCheckBackLaterTextHidden.assertValues([true, false]) - } - } - - func testUnableToRequestDataError() { - let user = User.template - let error = ErrorEnvelope( - errorMessages: ["unable to request data"], - ksrCode: .UnknownCode, - httpCode: 400, - exception: nil - ) - - withEnvironment(apiService: MockService(exportDataError: error)) { - self.vm.inputs.configureWith(user: user) - self.vm.inputs.startRequestDataTapped() - self.scheduler.advance() - self.unableToRequestDataError.assertValueCount(1) - } - } -}