forked from stripe/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.
update footer view for payment sheet
- Loading branch information
1 parent
964c963
commit cbaed50
Showing
4 changed files
with
115 additions
and
5 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
87 changes: 87 additions & 0 deletions
87
StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/Views/SheetFooterView.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,87 @@ | ||
// | ||
// SheetFooterView.swift | ||
// StripePaymentSheet | ||
// | ||
// Created by Virginia Cook on 12/12/23. | ||
// | ||
|
||
import Foundation | ||
@_spi(STP) import StripeCore | ||
@_spi(STP) import StripeUICore | ||
import UIKit | ||
/// For internal SDK use only | ||
@objc(STP_Internal_SheetFooterView) | ||
class SheetFooterView: UIView { | ||
|
||
private let stackView: UIStackView = { | ||
let stackView = UIStackView() | ||
stackView.axis = .vertical | ||
stackView.alignment = .fill | ||
stackView.distribution = .fill | ||
stackView.spacing = 12.0 | ||
return stackView | ||
}() | ||
|
||
private let topLine: UIView = { | ||
let line = UIView() | ||
line.backgroundColor = UIColor(red: 0.86, green: 0.86, blue: 0.86, alpha: 1.00) | ||
line.translatesAutoresizingMaskIntoConstraints = false | ||
NSLayoutConstraint.activate([ | ||
line.heightAnchor.constraint(equalToConstant: 1) | ||
]) | ||
return line | ||
}() | ||
|
||
private let button: UIView | ||
|
||
// MARK: - Initializers | ||
|
||
init(button: UIView) { | ||
self.button = button | ||
super.init(frame: .zero) | ||
commonInit() | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
self.button = UIView() | ||
super.init(coder: aDecoder) | ||
commonInit() | ||
} | ||
|
||
private func commonInit() { | ||
setupViews() | ||
setupConstraints() | ||
} | ||
|
||
// MARK: - Setup Methods | ||
|
||
private func setupViews() { | ||
addSubview(stackView) | ||
stackView.addArrangedSubview(topLine) | ||
|
||
// Create a container view for the button with horizontal margins | ||
let buttonContainerView = UIView() | ||
buttonContainerView.addSubview(button) | ||
|
||
// Set up constraints for the button inside the container view | ||
button.translatesAutoresizingMaskIntoConstraints = false | ||
NSLayoutConstraint.activate([ | ||
button.leadingAnchor.constraint(equalTo: buttonContainerView.leadingAnchor, constant: PaymentSheetUI.defaultPadding), | ||
button.trailingAnchor.constraint(equalTo: buttonContainerView.trailingAnchor, constant: -PaymentSheetUI.defaultPadding), | ||
button.topAnchor.constraint(equalTo: buttonContainerView.topAnchor), | ||
button.bottomAnchor.constraint(equalTo: buttonContainerView.bottomAnchor) | ||
]) | ||
|
||
stackView.addArrangedSubview(buttonContainerView) | ||
} | ||
|
||
private func setupConstraints() { | ||
stackView.translatesAutoresizingMaskIntoConstraints = false | ||
NSLayoutConstraint.activate([ | ||
stackView.leadingAnchor.constraint(equalTo: leadingAnchor), | ||
stackView.trailingAnchor.constraint(equalTo: trailingAnchor), | ||
stackView.topAnchor.constraint(equalTo: topAnchor), | ||
stackView.bottomAnchor.constraint(equalTo: bottomAnchor) | ||
]) | ||
} | ||
} |