Skip to content

Commit

Permalink
[Link] Collect name Part 2: Modal signup (#1131)
Browse files Browse the repository at this point in the history
* Extract UI logic into a view model

* Implement name collection

* Add test for `String.isBlank`

* Cleanup
  • Loading branch information
ramont-stripe authored May 18, 2022
1 parent 7aaac3f commit 49a9a65
Show file tree
Hide file tree
Showing 7 changed files with 408 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,13 @@ extension PaymentSheetUITest {
phoneField.tap()
app.typeTextWithKeyboard("3105551234")

// The name field is only required for non-US countries. Only fill it out if it exists.
let nameField = modal.textFields["Name"]
if nameField.exists {
nameField.tap()
nameField.typeText("Jane Done")
}

// Terms and privacy policy
for linkText in ["Terms", "Privacy Policy"] {
modal.links[linkText].tap()
Expand Down
4 changes: 4 additions & 0 deletions Stripe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@
D09A20D326DEE66800A0D4D9 /* CardBrandView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D09A20D226DEE66800A0D4D9 /* CardBrandView.swift */; };
D09F2FCD27F3D26200D3DFD9 /* OneTimeCodeTextField-TextStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D09F2FCC27F3D26200D3DFD9 /* OneTimeCodeTextField-TextStorage.swift */; };
D09FCA8F28134B4300B482DE /* ConsumerSession-SignupResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = D09FCA8E28134B4300B482DE /* ConsumerSession-SignupResponse.swift */; };
D0AF32DB2833005700BDE839 /* PayWithLinkViewController-SignUpViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0AF32DA2833005700BDE839 /* PayWithLinkViewController-SignUpViewModel.swift */; };
D0BBBC9326DE9243007A9F48 /* STPCardCVCInputTextFieldTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BBBC9226DE9243007A9F48 /* STPCardCVCInputTextFieldTests.swift */; };
D0BEB400273CAA770031D677 /* PayWithLinkViewController-WalletViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BEB3FF273CAA770031D677 /* PayWithLinkViewController-WalletViewController.swift */; };
D0BEB407273CABFC0031D677 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = D0BEB404273CABFC0031D677 /* [email protected] */; };
Expand Down Expand Up @@ -1747,6 +1748,7 @@
D09A20D226DEE66800A0D4D9 /* CardBrandView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardBrandView.swift; sourceTree = "<group>"; };
D09F2FCC27F3D26200D3DFD9 /* OneTimeCodeTextField-TextStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OneTimeCodeTextField-TextStorage.swift"; sourceTree = "<group>"; };
D09FCA8E28134B4300B482DE /* ConsumerSession-SignupResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConsumerSession-SignupResponse.swift"; sourceTree = "<group>"; };
D0AF32DA2833005700BDE839 /* PayWithLinkViewController-SignUpViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PayWithLinkViewController-SignUpViewModel.swift"; sourceTree = "<group>"; };
D0BBBC9226DE9243007A9F48 /* STPCardCVCInputTextFieldTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPCardCVCInputTextFieldTests.swift; sourceTree = "<group>"; };
D0BEB3FF273CAA770031D677 /* PayWithLinkViewController-WalletViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PayWithLinkViewController-WalletViewController.swift"; sourceTree = "<group>"; };
D0BEB404273CABFC0031D677 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3533,6 +3535,7 @@
D0F2031A273C33C100AB10BF /* PayWithLinkViewController-NewPaymentViewController.swift */,
61D0FBD927A36A440006ED6E /* PayWithLinkViewController-UpdatePaymentViewController.swift */,
D0F20319273C33C100AB10BF /* PayWithLinkViewController-SignUpViewController.swift */,
D0AF32DA2833005700BDE839 /* PayWithLinkViewController-SignUpViewModel.swift */,
D0EC8709278CF23E00CFACDC /* PayWithLinkViewController-VerifyAccountViewController.swift */,
D0BEB3FF273CAA770031D677 /* PayWithLinkViewController-WalletViewController.swift */,
D07E180D27F50EF4000BB6B7 /* PayWithLinkViewController-WalletViewModel.swift */,
Expand Down Expand Up @@ -4533,6 +4536,7 @@
31949091251449C600AD8F0B /* STPPostalCodeValidator.swift in Sources */,
B67243172524E3E5002E1AAF /* STPPaymentMethodPrzelewy24.swift in Sources */,
B67BC546257B024200B7349B /* PaymentMethodTypeCollectionView.swift in Sources */,
D0AF32DB2833005700BDE839 /* PayWithLinkViewController-SignUpViewModel.swift in Sources */,
310AF46B271E0961007339F4 /* STPPaymentMethodCard.swift in Sources */,
36ADAE182523A5B100302DFB /* STPPaymentIntentLastPaymentError.swift in Sources */,
31F2E8782524143F004D4B5E /* STPPaymentResult.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Stripe/LinkInlineSignupViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ final class LinkInlineSignupViewModel {
return false
}

return !legalName.isEmpty
return !legalName.isBlank
}

var shouldShowEmailField: Bool {
Expand Down
6 changes: 6 additions & 0 deletions Stripe/NSString+Stripe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
import Foundation

extension String {

/// A Boolean value indicating whether the string contains only whitespace.
var isBlank: Bool {
return allSatisfy({ $0.isWhitespace })
}

/// Returns a substring up to the specified index.
///
/// This method clamps out-of-bound indexes and always returns a valid (non-nil) string.
Expand Down
Loading

0 comments on commit 49a9a65

Please sign in to comment.