-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[NT-1371] Add-on Reward Selection and Continue Button #1252
Merged
justinswart
merged 2 commits into
NT-1370-filter-add-ons-by-location
from
NT-1371-add-ons-continue-button
Jul 17, 2020
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
103 changes: 103 additions & 0 deletions
103
Kickstarter-iOS/Views/RewardAddOnSelectionContinueCTAView.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,103 @@ | ||
import KsApi | ||
import Library | ||
import Prelude | ||
import UIKit | ||
|
||
protocol RewardAddOnSelectionContinueCTAViewDelegate: AnyObject { | ||
func continueButtonTapped() | ||
} | ||
|
||
private enum Layout { | ||
enum Button { | ||
static let minHeight: CGFloat = 48.0 | ||
} | ||
} | ||
|
||
final class RewardAddOnSelectionContinueCTAView: UIView { | ||
// MARK: - Properties | ||
|
||
private(set) lazy var continueButton: UIButton = { | ||
UIButton(type: .custom) | ||
|> \.translatesAutoresizingMaskIntoConstraints .~ false | ||
}() | ||
|
||
weak var delegate: RewardAddOnSelectionContinueCTAViewDelegate? | ||
|
||
private let viewModel: RewardAddOnSelectionContinueCTAViewModelType | ||
= RewardAddOnSelectionContinueCTAViewModel() | ||
|
||
// MARK: - Lifecycle | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
self.configureSubviews() | ||
self.setupConstraints() | ||
self.bindViewModel() | ||
} | ||
|
||
required init?(coder _: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
// MARK: - Styles | ||
|
||
override func bindStyles() { | ||
super.bindStyles() | ||
|
||
_ = self | ||
|> \.layoutMargins .~ .init(all: Styles.grid(3)) | ||
|
||
_ = self.layer | ||
|> checkoutLayerCardRoundedStyle | ||
|> \.backgroundColor .~ UIColor.white.cgColor | ||
|> \.shadowColor .~ UIColor.black.cgColor | ||
|> \.shadowOpacity .~ 0.12 | ||
|> \.shadowOffset .~ CGSize(width: 0, height: -1.0) | ||
|> \.shadowRadius .~ CGFloat(1.0) | ||
|> \.maskedCorners .~ [ | ||
CACornerMask.layerMaxXMinYCorner, | ||
CACornerMask.layerMinXMinYCorner | ||
] | ||
} | ||
|
||
// MARK: - View Model | ||
|
||
override func bindViewModel() { | ||
super.bindViewModel() | ||
|
||
self.continueButton.rac.title = self.viewModel.outputs.buttonTitle | ||
|
||
self.viewModel.outputs.buttonStyle | ||
.observeForUI() | ||
.observeValues { [weak self] buttonStyleType in | ||
_ = self?.continueButton | ||
?|> buttonStyleType.style | ||
|
||
guard let buttonFont = self?.continueButton.titleLabel?.font else { return } | ||
|
||
_ = self?.continueButton | ||
?|> UIButton.lens.titleLabel.font .~ buttonFont.monospaced | ||
} | ||
} | ||
|
||
// MARK: - Configuration | ||
|
||
func configure(with data: RewardAddOnSelectionContinueCTAViewData) { | ||
self.viewModel.inputs.configure(with: data) | ||
} | ||
|
||
// MARK: Functions | ||
|
||
private func configureSubviews() { | ||
_ = (self.continueButton, self) | ||
|> ksr_addSubviewToParent() | ||
|> ksr_constrainViewToMarginsInParent() | ||
} | ||
|
||
private func setupConstraints() { | ||
NSLayoutConstraint.activate([ | ||
self.continueButton.heightAnchor.constraint(greaterThanOrEqualToConstant: Layout.Button.minHeight) | ||
]) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split these out into a signal that updates the data source and reloads the table view, and another that only updates the data source. This is so that the table view is not reloaded each time we change a selection on one of the cells but also to maintain data integrity for when we recycle cells as we scroll the view.