Skip to content

Commit

Permalink
[NT-549] Keyboard dismissal when user taps save (#1058)
Browse files Browse the repository at this point in the history
* zipcodeTextField is not longer a first responder when user taps save after entering card info

* removed zipcodeTextFieldBecomeFirstResponder untested output

* removed paymentCardTextFieldDidEndEditing
  • Loading branch information
cdolm92 authored Feb 5, 2020
1 parent 09457af commit 84a3ca9
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 24 deletions.
10 changes: 0 additions & 10 deletions Kickstarter-iOS/Views/Controllers/AddNewCardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -375,10 +369,6 @@ extension AddNewCardViewController {
textField.expirationYear, textField.cvc, stpCardBrand.creditCardType
))
}

internal func paymentCardTextFieldDidEndEditing(_: STPPaymentCardTextField) {
self.viewModel.inputs.paymentCardTextFieldDidEndEditing()
}
}

// MARK: - Styles
Expand Down
9 changes: 0 additions & 9 deletions Library/ViewModels/AddNewCardViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -45,7 +44,6 @@ public protocol AddNewCardViewModelOutputs {
var saveButtonIsEnabled: Signal<Bool, Never> { get }
var setStripePublishableKey: Signal<String, Never> { get }
var unsupportedCardBrandErrorText: Signal<String, Never> { get }
var zipcodeTextFieldBecomeFirstResponder: Signal<Void, Never> { get }
}

public protocol AddNewCardViewModelType {
Expand Down Expand Up @@ -78,7 +76,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<Bool, Never> = zipcode.map { !$0.isEmpty }
Expand Down Expand Up @@ -241,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
Expand Down Expand Up @@ -306,7 +298,6 @@ public final class AddNewCardViewModel: AddNewCardViewModelType, AddNewCardViewM
public let saveButtonIsEnabled: Signal<Bool, Never>
public let setStripePublishableKey: Signal<String, Never>
public let unsupportedCardBrandErrorText: Signal<String, Never>
public let zipcodeTextFieldBecomeFirstResponder: Signal<Void, Never>

public var inputs: AddNewCardViewModelInputs { return self }
public var outputs: AddNewCardViewModelOutputs { return self }
Expand Down
5 changes: 0 additions & 5 deletions Library/ViewModels/AddNewCardViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ internal final class AddNewCardViewModelTests: TestCase {
private let setStripePublishableKey = TestObserver<String, Never>()
private let unsupportedCardBrandErrorText = TestObserver<String, Never>()
private let zipcode = TestObserver<String, Never>()
private let zipcodeTextFieldBecomeFirstResponder = TestObserver<Void, Never>()

override func setUp() {
super.setUp()
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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()

Expand All @@ -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: "")
Expand Down

0 comments on commit 84a3ca9

Please sign in to comment.