Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ’²[Native Checkout] Pledge Screen Separators #760

Merged
merged 5 commits into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 64 additions & 7 deletions Kickstarter-iOS/Views/Controllers/PledgeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ import UIKit
final class PledgeViewController: UIViewController {
// MARK: - Properties

private lazy var descriptionSectionSeparatorView: UIView = {
UIView(frame: .zero)
|> \.translatesAutoresizingMaskIntoConstraints .~ false
}()

private lazy var sectionSeparatorViews = {
[self.descriptionSectionSeparatorView, self.summarySectionSeparator]
}()

private lazy var summarySectionSeparator: UIView = {
UIView(frame: .zero)
|> \.translatesAutoresizingMaskIntoConstraints .~ false
}()

private lazy var pledgeAmountViewController = {
PledgeAmountViewController.instantiate()
|> \.delegate .~ self
Expand All @@ -15,21 +29,41 @@ final class PledgeViewController: UIViewController {
PledgeContinueViewController.instantiate()
}()

private lazy var pledgeDescriptionSectionViews = {
[self.pledgeDescriptionViewController.view, self.descriptionSectionSeparatorView]
}()

private lazy var pledgeDescriptionViewController = {
PledgeDescriptionViewController.instantiate()
}()

private lazy var pledgeSummaryViewController = {
PledgeSummaryViewController.instantiate()
private lazy var pledgeInputsSectionViews = {
[self.pledgeAmountViewController.view, self.pledgeShippingLocationViewController.view]
}()

private lazy var pledgeLoginSectionViews = {
[self.pledgeContinueViewController.view]
}()

private lazy var pledgePaymentMethodsSectionViews = {
[self.pledgePaymentMethodsViewController.view]
ifbarrera marked this conversation as resolved.
Show resolved Hide resolved
}()

private lazy var pledgePaymentMethodsViewController = {
PledgePaymentMethodsViewController.instantiate()
}()

private lazy var pledgeShippingLocationViewController = {
PledgeShippingLocationViewController.instantiate()
|> \.delegate .~ self
}()

private lazy var pledgePaymentMethodsViewController = {
PledgePaymentMethodsViewController.instantiate()
private lazy var pledgeSummarySectionViews = {
[self.summarySectionSeparator, self.pledgeSummaryViewController.view]
}()

private lazy var pledgeSummaryViewController = {
PledgeSummaryViewController.instantiate()
}()

private lazy var rootScrollView: UIScrollView = { UIScrollView(frame: .zero) }()
Expand Down Expand Up @@ -61,13 +95,13 @@ final class PledgeViewController: UIViewController {
|> ksr_addSubviewToParent()
|> ksr_constrainViewToEdgesInParent()

self.configureChildViewControllers()

self.view.addGestureRecognizer(
UITapGestureRecognizer(target: self, action: #selector(PledgeViewController.dismissKeyboard))
)

self.configureChildViewControllers()
self.setupConstraints()

self.viewModel.inputs.viewDidLoad()
}

Expand All @@ -87,9 +121,22 @@ final class PledgeViewController: UIViewController {
self.pledgePaymentMethodsViewController
]

let arrangedSubviews = [
self.pledgeDescriptionSectionViews,
self.pledgeInputsSectionViews,
self.pledgeSummarySectionViews,
self.pledgeLoginSectionViews,
self.pledgePaymentMethodsSectionViews
]
.flatMap { $0 }
.compact()

arrangedSubviews.forEach { view in
self.rootStackView.addArrangedSubview(view)
}

childViewControllers.forEach { viewController in
self.addChild(viewController)
self.rootStackView.addArrangedSubview(viewController.view)
viewController.didMove(toParent: self)
}
}
Expand All @@ -98,6 +145,13 @@ final class PledgeViewController: UIViewController {
NSLayoutConstraint.activate([
self.rootStackView.widthAnchor.constraint(equalTo: self.rootScrollView.widthAnchor)
])

self.sectionSeparatorViews.forEach { view in
_ = view.heightAnchor.constraint(equalToConstant: 1)
ifbarrera marked this conversation as resolved.
Show resolved Hide resolved
|> \.isActive .~ true

view.setContentCompressionResistancePriority(.required, for: .vertical)
}
}

// MARK: - Styles
Expand All @@ -113,6 +167,9 @@ final class PledgeViewController: UIViewController {

_ = self.rootStackView
|> rootStackViewStyle

_ = self.sectionSeparatorViews
||> separatorStyleDark
}

// MARK: - View model
Expand Down
6 changes: 6 additions & 0 deletions Library/Styles/BaseStyles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public let separatorStyle: ViewStyle = { (view: UIView) in
|> \.accessibilityElementsHidden .~ true
}

public let separatorStyleDark: ViewStyle = { view in
ifbarrera marked this conversation as resolved.
Show resolved Hide resolved
view
|> \.backgroundColor .~ UIColor.ksr_grey_500
|> \.accessibilityElementsHidden .~ true
}

/**
- parameter r: The corner radius. This parameter is optional, and will use a default value if omitted.

Expand Down