From 4189975fad347f01657c29d027ef762613f80908 Mon Sep 17 00:00:00 2001 From: christella Date: Tue, 4 Feb 2020 16:15:12 -0500 Subject: [PATCH 1/3] zipcodeTextField is not longer a first responder when user taps save after entering card info --- .../Views/Controllers/AddNewCardViewController.swift | 6 ------ Library/ViewModels/AddNewCardViewModel.swift | 3 --- 2 files changed, 9 deletions(-) diff --git a/Kickstarter-iOS/Views/Controllers/AddNewCardViewController.swift b/Kickstarter-iOS/Views/Controllers/AddNewCardViewController.swift index 5125a4790a..f4020bbb09 100644 --- a/Kickstarter-iOS/Views/Controllers/AddNewCardViewController.swift +++ b/Kickstarter-iOS/Views/Controllers/AddNewCardViewController.swift @@ -224,12 +224,6 @@ internal final class AddNewCardViewController: UIViewController, self?.messageBannerViewController?.showBanner(with: .error, message: errorMessage) } - self.viewModel.outputs.zipcodeTextFieldBecomeFirstResponder - .observeForControllerAction() - .observeValues { [weak self] _ in - self?.zipcodeView.textField.becomeFirstResponder() - } - Keyboard.change .observeForUI() .observeValues { [weak self] change in diff --git a/Library/ViewModels/AddNewCardViewModel.swift b/Library/ViewModels/AddNewCardViewModel.swift index 084242def0..5a437e1948 100644 --- a/Library/ViewModels/AddNewCardViewModel.swift +++ b/Library/ViewModels/AddNewCardViewModel.swift @@ -45,7 +45,6 @@ public protocol AddNewCardViewModelOutputs { var saveButtonIsEnabled: Signal { get } var setStripePublishableKey: Signal { get } var unsupportedCardBrandErrorText: Signal { get } - var zipcodeTextFieldBecomeFirstResponder: Signal { get } } public protocol AddNewCardViewModelType { @@ -78,7 +77,6 @@ public final class AddNewCardViewModel: AddNewCardViewModelType, AddNewCardViewM self.cardholderNameBecomeFirstResponder = self.viewDidLoadProperty.signal self.paymentDetailsBecomeFirstResponder = self.cardholderNameTextFieldReturnProperty.signal - self.zipcodeTextFieldBecomeFirstResponder = self.paymentCardTextFieldDidEndEditingProperty.signal let zipcode = self.zipcodeProperty.signal.skipNil() let zipcodeIsValid: Signal = zipcode.map { !$0.isEmpty } @@ -306,7 +304,6 @@ public final class AddNewCardViewModel: AddNewCardViewModelType, AddNewCardViewM public let saveButtonIsEnabled: Signal public let setStripePublishableKey: Signal public let unsupportedCardBrandErrorText: Signal - public let zipcodeTextFieldBecomeFirstResponder: Signal public var inputs: AddNewCardViewModelInputs { return self } public var outputs: AddNewCardViewModelOutputs { return self } From 84d89fbeb9ccc154c6332040a0a642aa3093dce6 Mon Sep 17 00:00:00 2001 From: christella Date: Tue, 4 Feb 2020 16:19:40 -0500 Subject: [PATCH 2/3] removed zipcodeTextFieldBecomeFirstResponder untested output --- Library/ViewModels/AddNewCardViewModelTests.swift | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Library/ViewModels/AddNewCardViewModelTests.swift b/Library/ViewModels/AddNewCardViewModelTests.swift index 5dae2aff0a..4ccb5b3f2d 100644 --- a/Library/ViewModels/AddNewCardViewModelTests.swift +++ b/Library/ViewModels/AddNewCardViewModelTests.swift @@ -27,7 +27,6 @@ internal final class AddNewCardViewModelTests: TestCase { private let setStripePublishableKey = TestObserver() private let unsupportedCardBrandErrorText = TestObserver() private let zipcode = TestObserver() - private let zipcodeTextFieldBecomeFirstResponder = TestObserver() override func setUp() { super.setUp() @@ -55,8 +54,6 @@ internal final class AddNewCardViewModelTests: TestCase { self.vm.outputs.saveButtonIsEnabled.observe(self.saveButtonIsEnabled.observer) self.vm.outputs.setStripePublishableKey.observe(self.setStripePublishableKey.observer) self.vm.outputs.unsupportedCardBrandErrorText.observe(self.unsupportedCardBrandErrorText.observer) - self.vm.outputs.zipcodeTextFieldBecomeFirstResponder - .observe(self.zipcodeTextFieldBecomeFirstResponder.observer) } func testZipcodeTextFieldReturn_submitsPaymentDetails() { @@ -172,7 +169,6 @@ internal final class AddNewCardViewModelTests: TestCase { func testBecomeFirstResponder() { self.cardholderNameBecomeFirstResponder.assertDidNotEmitValue() self.paymentDetailsBecomeFirstResponder.assertDidNotEmitValue() - self.zipcodeTextFieldBecomeFirstResponder.assertDidNotEmitValue() self.activityIndicatorShouldShow.assertDidNotEmitValue() self.saveButtonIsEnabled.assertDidNotEmitValue() @@ -182,7 +178,6 @@ internal final class AddNewCardViewModelTests: TestCase { self.cardholderNameBecomeFirstResponder .assertValueCount(1, "Cardholder name field is first responder when view loads.") self.paymentDetailsBecomeFirstResponder.assertDidNotEmitValue("Not first responder when view loads") - self.zipcodeTextFieldBecomeFirstResponder.assertDidNotEmitValue() self.vm.inputs.cardholderNameChanged("") self.vm.inputs.paymentInfo(isValid: false) self.vm.inputs.zipcodeChanged(zipcode: "") From ad00117e63cae68e372acc481768d973b0cf0e7d Mon Sep 17 00:00:00 2001 From: christella Date: Wed, 5 Feb 2020 14:02:41 -0500 Subject: [PATCH 3/3] removed paymentCardTextFieldDidEndEditing --- .../Views/Controllers/AddNewCardViewController.swift | 4 ---- Library/ViewModels/AddNewCardViewModel.swift | 6 ------ 2 files changed, 10 deletions(-) diff --git a/Kickstarter-iOS/Views/Controllers/AddNewCardViewController.swift b/Kickstarter-iOS/Views/Controllers/AddNewCardViewController.swift index f4020bbb09..a1a25e6415 100644 --- a/Kickstarter-iOS/Views/Controllers/AddNewCardViewController.swift +++ b/Kickstarter-iOS/Views/Controllers/AddNewCardViewController.swift @@ -369,10 +369,6 @@ extension AddNewCardViewController { textField.expirationYear, textField.cvc, stpCardBrand.creditCardType )) } - - internal func paymentCardTextFieldDidEndEditing(_: STPPaymentCardTextField) { - self.viewModel.inputs.paymentCardTextFieldDidEndEditing() - } } // MARK: - Styles diff --git a/Library/ViewModels/AddNewCardViewModel.swift b/Library/ViewModels/AddNewCardViewModel.swift index 5a437e1948..258d9524dd 100644 --- a/Library/ViewModels/AddNewCardViewModel.swift +++ b/Library/ViewModels/AddNewCardViewModel.swift @@ -19,7 +19,6 @@ public protocol AddNewCardViewModelInputs { func cardholderNameTextFieldReturn() func creditCardChanged(cardDetails: CardDetails) func configure(with intent: AddNewCardIntent, project: Project?) - func paymentCardTextFieldDidEndEditing() func paymentInfo(isValid: Bool) func rememberThisCardToggleChanged(to value: Bool) func saveButtonTapped() @@ -239,11 +238,6 @@ public final class AddNewCardViewModel: AddNewCardViewModelType, AddNewCardViewM self.addNewCardIntentAndProjectProperty.value = (intent, project) } - private let paymentCardTextFieldDidEndEditingProperty = MutableProperty(()) - public func paymentCardTextFieldDidEndEditing() { - self.paymentCardTextFieldDidEndEditingProperty.value = () - } - private let paymentInfoIsValidProperty = MutableProperty(false) public func paymentInfo(isValid: Bool) { self.paymentInfoIsValidProperty.value = isValid