forked from hideokamoto/stripe-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show initial blank vertical view controller in vertical mode for Flow…
…Controller (stripe#3563) ## Summary - Make `FlowControllerViewControllerDelegate` which abstracts out FC's view controller. Both horizontal & vertical VCs conform to it. - Adds `PaymentSheetVerticalViewController`, barebones implementation. PaymentSheet to follow ## Testing Manually tested for now.
- Loading branch information
1 parent
a45b584
commit ec6f349
Showing
5 changed files
with
137 additions
and
43 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
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
85 changes: 85 additions & 0 deletions
85
...PaymentSheet/Source/PaymentSheet/ViewControllers/PaymentSheetVerticalViewController.swift
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,85 @@ | ||
// | ||
// PaymentSheetVerticalViewController.swift | ||
// StripePaymentSheet | ||
// | ||
// Created by Yuki Tokuhiro on 5/3/24. | ||
// | ||
|
||
@_spi(STP) import StripeCore | ||
@_spi(STP) import StripePayments | ||
@_spi(STP) import StripePaymentsUI | ||
@_spi(STP) import StripeUICore | ||
import UIKit | ||
|
||
class PaymentSheetVerticalViewController: UIViewController, FlowControllerViewController { | ||
var selectedPaymentOption: PaymentSheet.PaymentOption? | ||
/// The type of the payment method that's currently selected in the UI, or unknown if no payment method is selected. | ||
var selectedPaymentMethodType: PaymentSheet.PaymentMethodType = .stripe(.unknown) | ||
weak var delegate: FlowControllerViewControllerDelegate? | ||
let loadResult: PaymentSheetLoader.LoadResult | ||
let configuration: PaymentSheet.Configuration | ||
var intent: Intent { | ||
return loadResult.intent | ||
} | ||
var error: Error? | ||
|
||
// MARK: - UI properties | ||
|
||
lazy var navigationBar: SheetNavigationBar = { | ||
let navBar = SheetNavigationBar(isTestMode: configuration.apiClient.isTestmode, | ||
appearance: configuration.appearance) | ||
// TODO: set navBar.delegate = self | ||
return navBar | ||
}() | ||
|
||
// MARK: - Initializers | ||
|
||
init(configuration: PaymentSheet.Configuration, loadResult: PaymentSheetLoader.LoadResult) { | ||
// TODO: Deal with previousPaymentOption | ||
self.loadResult = loadResult | ||
self.configuration = configuration | ||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
// MARK: - UIViewController Methods | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
view.backgroundColor = configuration.appearance.colors.background | ||
configuration.style.configure(self) | ||
|
||
let dummyView = UILabel() | ||
dummyView.text = "Welcome to vertical mode" | ||
|
||
// One stack view contains all our subviews | ||
let stackView = UIStackView(arrangedSubviews: [ | ||
dummyView, | ||
]) | ||
view.addAndPinSubview(stackView, insets: .init(top: 0, leading: 0, bottom: 0, trailing: PaymentSheetUI.defaultSheetMargins.bottom)) | ||
} | ||
} | ||
|
||
// MARK: - BottomSheetContentViewController | ||
extension PaymentSheetVerticalViewController: BottomSheetContentViewController { | ||
var allowsDragToDismiss: Bool { | ||
// TODO | ||
return true | ||
} | ||
|
||
func didTapOrSwipeToDismiss() { | ||
// TODO | ||
delegate?.flowControllerViewControllerShouldClose(self, didCancel: true) | ||
} | ||
|
||
var requiresFullScreen: Bool { | ||
// TODO | ||
return false | ||
} | ||
|
||
func didFinishAnimatingHeight() { | ||
// no-op | ||
} | ||
} |
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