-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v7' into update-localPayment
- Loading branch information
Showing
18 changed files
with
224 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import UIKit | ||
|
||
class Toggle: UIView { | ||
|
||
private let toggle = UISwitch() | ||
private let title: String | ||
|
||
var isOn: Bool { | ||
toggle.isOn | ||
} | ||
|
||
init(title: String) { | ||
self.title = title | ||
super.init(frame: .zero) | ||
layoutUI() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func layoutUI() { | ||
let label = UILabel() | ||
label.text = title | ||
label.translatesAutoresizingMaskIntoConstraints = false | ||
|
||
toggle.translatesAutoresizingMaskIntoConstraints = false | ||
|
||
let stackView = UIStackView(arrangedSubviews: [label, toggle]) | ||
stackView.alignment = .fill | ||
stackView.distribution = .fill | ||
stackView.translatesAutoresizingMaskIntoConstraints = false | ||
addSubview(stackView) | ||
|
||
NSLayoutConstraint.activate([ | ||
stackView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor), | ||
stackView.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor), | ||
stackView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor), | ||
stackView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor) | ||
]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,18 @@ class PayPalWebCheckoutViewController: PaymentButtonBaseViewController { | |
lazy var emailTextField: UITextField = { | ||
let textField = UITextField() | ||
textField.placeholder = "[email protected]" | ||
textField.textAlignment = .right | ||
textField.backgroundColor = .systemBackground | ||
textField.keyboardType = .emailAddress | ||
return textField | ||
}() | ||
|
||
lazy var emailStackView: UIStackView = { | ||
let stackView = UIStackView(arrangedSubviews: [emailLabel, emailTextField]) | ||
stackView.distribution = .fillProportionally | ||
return stackView | ||
}() | ||
|
||
lazy var countryCodeLabel: UILabel = { | ||
let label = UILabel() | ||
label.text = "Country Code:" | ||
|
@@ -33,11 +41,18 @@ class PayPalWebCheckoutViewController: PaymentButtonBaseViewController { | |
lazy var countryCodeTextField: UITextField = { | ||
let textField = UITextField() | ||
textField.placeholder = "1" | ||
textField.textAlignment = .right | ||
textField.backgroundColor = .systemBackground | ||
textField.keyboardType = .phonePad | ||
return textField | ||
}() | ||
|
||
lazy var countryCodeStackView: UIStackView = { | ||
let stackView = UIStackView(arrangedSubviews: [countryCodeLabel, countryCodeTextField]) | ||
stackView.distribution = .fillEqually | ||
return stackView | ||
}() | ||
|
||
lazy var nationalNumberLabel: UILabel = { | ||
let label = UILabel() | ||
label.text = "National Number:" | ||
|
@@ -47,40 +62,26 @@ class PayPalWebCheckoutViewController: PaymentButtonBaseViewController { | |
lazy var nationalNumberTextField: UITextField = { | ||
let textField = UITextField() | ||
textField.placeholder = "000-000-000" | ||
textField.textAlignment = .right | ||
textField.backgroundColor = .systemBackground | ||
textField.keyboardType = .phonePad | ||
return textField | ||
}() | ||
|
||
lazy var payLaterToggleLabel: UILabel = { | ||
let label = UILabel() | ||
label.text = "Offer Pay Later" | ||
label.font = .preferredFont(forTextStyle: .footnote) | ||
return label | ||
}() | ||
|
||
let payLaterToggle = UISwitch() | ||
|
||
lazy var newPayPalCheckoutToggleLabel: UILabel = { | ||
let label = UILabel() | ||
label.text = "New PayPal Checkout Experience" | ||
label.font = .preferredFont(forTextStyle: .footnote) | ||
return label | ||
lazy var nationalNumberStackView: UIStackView = { | ||
let stackView = UIStackView(arrangedSubviews: [nationalNumberLabel, nationalNumberTextField]) | ||
stackView.distribution = .fillEqually | ||
return stackView | ||
}() | ||
|
||
let newPayPalCheckoutToggle = UISwitch() | ||
let payLaterToggle = Toggle(title: "Offer Pay Later") | ||
|
||
lazy var rbaDataToggleLabel: UILabel = { | ||
let label = UILabel() | ||
label.text = "Recurring Billing (RBA) Data" | ||
label.font = .preferredFont(forTextStyle: .footnote) | ||
return label | ||
}() | ||
let newPayPalCheckoutToggle = Toggle(title: "New PayPal Checkout Experience") | ||
|
||
let rbaDataToggle = UISwitch() | ||
let rbaDataToggle = Toggle(title: "Recurring Billing (RBA) Data") | ||
|
||
override func viewDidLoad() { | ||
super.heightConstraint = 350 | ||
super.heightConstraint = 400 | ||
super.viewDidLoad() | ||
} | ||
|
||
|
@@ -90,20 +91,22 @@ class PayPalWebCheckoutViewController: PaymentButtonBaseViewController { | |
let payPalAppSwitchButton = createButton(title: "PayPal App Switch", action: #selector(tappedPayPalAppSwitch)) | ||
|
||
let oneTimeCheckoutStackView = buttonsStackView(label: "1-Time Checkout", views: [ | ||
UIStackView(arrangedSubviews: [payLaterToggleLabel, payLaterToggle]), | ||
UIStackView(arrangedSubviews: [newPayPalCheckoutToggleLabel, newPayPalCheckoutToggle]), | ||
payLaterToggle, | ||
newPayPalCheckoutToggle, | ||
payPalCheckoutButton | ||
]) | ||
oneTimeCheckoutStackView.spacing = 12 | ||
let vaultStackView = buttonsStackView(label: "Vault", views: [ | ||
UIStackView(arrangedSubviews: [rbaDataToggleLabel, rbaDataToggle]), | ||
rbaDataToggle, | ||
payPalVaultButton, | ||
payPalAppSwitchButton | ||
]) | ||
vaultStackView.spacing = 12 | ||
|
||
let stackView = UIStackView(arrangedSubviews: [ | ||
UIStackView(arrangedSubviews: [emailLabel, emailTextField]), | ||
UIStackView(arrangedSubviews: [countryCodeLabel, countryCodeTextField]), | ||
UIStackView(arrangedSubviews: [nationalNumberLabel, nationalNumberTextField]), | ||
emailStackView, | ||
countryCodeStackView, | ||
nationalNumberStackView, | ||
oneTimeCheckoutStackView, | ||
vaultStackView | ||
]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.