-
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-505] Project page creators header #930
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
c92be4f
Created ProjectPamphletCreatorHeaderCell
Scollaco 83dba29
Fixed top margin, added border
Scollaco e71d473
Added viewModel and logic to show the text according to project state
Scollaco 5d6afe8
Added delegate
Scollaco 9eb8a4e
Added tests
Scollaco 283c0f3
Added viewcontroller test
Scollaco 588bdfa
Merge remote-tracking branch 'oss/master' into project-page-creators-…
Scollaco 8f2a20c
Strings
Scollaco 51a74ca
Replaces hardcoded strings
Scollaco 2032902
Added missing viewController test
Scollaco 0f4bfc4
Merge remote-tracking branch 'oss/master' into project-page-creators-…
Scollaco fde2f35
Added DataSource tests and generated snapshots
Scollaco be5763f
Swiftformat
Scollaco 88609a7
Fixed video container top margin
Scollaco 2edc779
Snapshots
Scollaco 34e0f07
Removed recordMode line
Scollaco ef91760
Removed print function
Scollaco 920c913
Fixed margins and navBar height
Scollaco 0317c0e
Updated snapshots
Scollaco 20d7ca1
SwiftFormat
Scollaco bd1f320
Merge branch 'master' into project-page-creators-header
Scollaco 7dad6ff
Pass timezone on date format function
Scollaco 8678939
SwiftFormat
Scollaco 6b266d5
Merge branch 'project-page-creators-header' of https://github.com/kic…
Scollaco 88b3d41
Merge branch 'master' into project-page-creators-header
Scollaco 6bb7351
Merge branch 'master' into project-page-creators-header
Scollaco 832e145
Added spacing to stackView, fixed data used on tests
Scollaco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
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
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
140 changes: 140 additions & 0 deletions
140
Kickstarter-iOS/Views/Cells/ProjectPamphletCreatorHeaderCell.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,140 @@ | ||
import KsApi | ||
import Library | ||
import Prelude | ||
import UIKit | ||
|
||
private enum Layout { | ||
enum Button { | ||
static let height: CGFloat = 48 | ||
static let width: CGFloat = 152 | ||
} | ||
} | ||
|
||
protocol ProjectPamphletCreatorHeaderCellDelegate: class { | ||
func projectPamphletCreatorHeaderCellDidTapButton( | ||
_ cell: ProjectPamphletCreatorHeaderCell, | ||
project: Project | ||
) | ||
} | ||
|
||
final class ProjectPamphletCreatorHeaderCell: UITableViewCell, ValueCell { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still not sure about this name 🤔 Would |
||
// MARK: Properties | ||
|
||
private let launchDateLabel: UILabel = { UILabel(frame: .zero) }() | ||
private let rootStackView: UIStackView = { UIStackView(frame: .zero) }() | ||
private let viewProgressButton: UIButton = { UIButton(frame: .zero) }() | ||
private let viewModel: ProjectPamphletCreatorHeaderCellViewModelType = | ||
ProjectPamphletCreatorHeaderCellViewModel() | ||
|
||
internal weak var delegate: ProjectPamphletCreatorHeaderCellDelegate? | ||
|
||
// MARK: Lifecycle | ||
|
||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
self.configureViews() | ||
self.setupConstraints() | ||
self.bindViewModel() | ||
} | ||
|
||
required init?(coder _: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
// MARK: Configuration | ||
|
||
internal func configureWith(value project: Project) { | ||
self.viewModel.inputs.configure(with: project) | ||
} | ||
|
||
private func configureViews() { | ||
_ = ([self.launchDateLabel, self.viewProgressButton], self.rootStackView) | ||
|> ksr_addArrangedSubviewsToStackView() | ||
|
||
_ = (self.rootStackView, self.contentView) | ||
|> ksr_addSubviewToParent() | ||
|> ksr_constrainViewToMarginsInParent() | ||
|
||
self.viewProgressButton.addTarget( | ||
self, action: #selector(self.viewProgressButtonTapped), for: .touchUpInside | ||
) | ||
} | ||
|
||
private func setupConstraints() { | ||
NSLayoutConstraint.activate([ | ||
self.viewProgressButton.heightAnchor.constraint(equalToConstant: Layout.Button.height), | ||
self.viewProgressButton.widthAnchor.constraint(equalToConstant: Layout.Button.width) | ||
]) | ||
} | ||
|
||
// MARK: - View model | ||
|
||
override func bindViewModel() { | ||
super.bindViewModel() | ||
self.launchDateLabel.rac.attributedText = self.viewModel.outputs.launchDateLabelAttributedText | ||
self.viewProgressButton.rac.title = self.viewModel.outputs.buttonTitle | ||
|
||
self.viewModel.outputs.notifyDelegateViewProgressButtonTapped | ||
.observeForUI() | ||
.observeValues { [weak self] project in | ||
guard let self = self else { return } | ||
|
||
self.delegate?.projectPamphletCreatorHeaderCellDidTapButton(self, project: project) | ||
} | ||
} | ||
|
||
// MARK: - Styles | ||
|
||
override func bindStyles() { | ||
super.bindStyles() | ||
|
||
_ = self.contentView | ||
|> contentViewStyle | ||
|
||
_ = self.launchDateLabel | ||
|> projectCreationInfoLabelStyle | ||
|
||
_ = self.rootStackView | ||
|> checkoutAdaptableStackViewStyle( | ||
self.traitCollection.preferredContentSizeCategory.isAccessibilityCategory | ||
) | ||
|> rootStackViewStyle | ||
|
||
_ = self.viewProgressButton | ||
|> viewProgressButtonStyle | ||
} | ||
|
||
// MARK: - Actions | ||
|
||
@objc private func viewProgressButtonTapped() { | ||
self.viewModel.inputs.viewProgressButtonTapped() | ||
} | ||
} | ||
|
||
// MARK: Styles | ||
|
||
private let contentViewStyle: ViewStyle = { view in | ||
view | ||
|> \.layer.borderWidth .~ 2.0 | ||
|> \.backgroundColor .~ UIColor.ksr_grey_100 | ||
|> \.layer.borderColor .~ UIColor.ksr_grey_500.cgColor | ||
|> \.layoutMargins %~~ { _, _ in | ||
.init(topBottom: Styles.grid(3), leftRight: 0) | ||
} | ||
} | ||
|
||
private let projectCreationInfoLabelStyle: LabelStyle = { label in | ||
label | ||
|> \.adjustsFontForContentSizeCategory .~ true | ||
|> \.numberOfLines .~ 0 | ||
} | ||
|
||
private let rootStackViewStyle: StackViewStyle = { stackView in | ||
stackView | ||
|> \.spacing .~ Styles.grid(1) | ||
} | ||
|
||
private let viewProgressButtonStyle: ButtonStyle = { button in | ||
button | ||
|> greyButtonStyle | ||
} |
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.
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.
Where are these constants from?
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.
This comes from Abstract.