-
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
[MBL-902] [MBL-934] [MBL-928] Use of AI Screen, Analytics, Question Headers, Translations #1843
Merged
Merged
Changes from 12 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
bfde6bc
Updated model with ai disclosure fields
msadoon bb2c048
added use of ai tab
msadoon 32dd553
Merge branch 'main' into mbl-900/new-tab-use-of-ai
msadoon b879f74
Merge branch 'main' into mbl-900/new-tab-use-of-ai
msadoon f913b88
fixed a test for use of ai tab title
msadoon e32af42
Merge branch 'mbl-900/new-tab-use-of-ai' of https://github.com/kickstβ¦
msadoon ad87197
formatting
msadoon f10b5dd
updated all cells for use of ai tab except the funding ones. Up next.
msadoon aafa8a2
added final cell and tested - pretty close to design, one padding issβ¦
msadoon 7bb8164
Merge branch 'main' into mbl-902/use-of-ai-screen
msadoon 590d75f
Stop using stack view in order to align checkmark and label
ifosli 0d66016
Update footer to link to AI policy
ifosli fecc868
Update link to have plain text default
ifosli 06b15b2
Merge branch 'main' into mbl-902/use-of-ai-screen
msadoon de7f8b2
Use translatable strings
ifosli b84815b
added analytics, checking if involves ai is true along with the existβ¦
msadoon 90764de
Merge branch 'mbl-902/use-of-ai-screen' of https://github.com/kickstaβ¦
msadoon 15e8a20
Add a11y label so voiceover reads tab correctly
ifosli 84b77b1
Added titles to questions and answers, all sections should be accuratβ¦
msadoon 55736ad
Merge branch 'mbl-902/use-of-ai-screen' of https://github.com/kickstaβ¦
msadoon c433f53
correct to title headers and order
msadoon 2b17624
tested kickstarter-ios and library
msadoon 2a0559f
ksapi changes tested
msadoon f657b3c
Merge branch 'main' into mbl-902/use-of-ai-screen
msadoon 923813b
pr comments
msadoon 9cfd437
Merge branch 'mbl-902/use-of-ai-screen' of https://github.com/kickstaβ¦
msadoon 7973635
removing cell separator and added a FIXME for title cell
msadoon File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,11 @@ internal final class ProjectPageViewControllerDataSource: ValueCellDataSource { | |
case risksHeader | ||
case risks | ||
case risksDisclaimer | ||
case aiDisclosureHeader | ||
case aiDisclosureFunding | ||
case aiDisclosureGenerated | ||
case aiDisclosureOtherDetails | ||
case aiDisclosureDisclaimer | ||
case environmentalCommitmentsHeader | ||
case environmentalCommitments | ||
case environmentalCommitmentsDisclaimer | ||
|
@@ -29,6 +34,7 @@ internal final class ProjectPageViewControllerDataSource: ValueCellDataSource { | |
case environmentalCommitments | ||
case faqs | ||
case risks | ||
case aiDisclosure | ||
|
||
var description: String { | ||
switch self { | ||
|
@@ -42,6 +48,8 @@ internal final class ProjectPageViewControllerDataSource: ValueCellDataSource { | |
return Strings.Frequently_asked_questions() | ||
case .risks: | ||
return Strings.Risks_and_challenges() | ||
case .aiDisclosure: | ||
return "Use of AI" | ||
} | ||
} | ||
} | ||
|
@@ -207,8 +215,52 @@ internal final class ProjectPageViewControllerDataSource: ValueCellDataSource { | |
inSection: Section.risksDisclaimer.rawValue | ||
) | ||
case .aiDisclosure: | ||
// TODO: Doing in: https://kickstarter.atlassian.net/browse/MBL-902 | ||
_ = {} | ||
self.set( | ||
values: [HeaderValue.aiDisclosure.description], | ||
cellClass: ProjectHeaderCell.self, | ||
inSection: Section.aiDisclosureHeader.rawValue | ||
) | ||
|
||
guard let aiDisclosure = project.extendedProjectProperties?.aiDisclosure else { | ||
self.set( | ||
values: [.environmental], | ||
cellClass: ProjectTabDisclaimerCell.self, | ||
inSection: Section.environmentalCommitmentsDisclaimer.rawValue | ||
) | ||
|
||
return | ||
} | ||
|
||
if aiDisclosure.funding.fundingForAiAttribution || aiDisclosure.funding | ||
.fundingForAiConsent || aiDisclosure.funding.fundingForAiOption { | ||
self.set( | ||
values: [aiDisclosure.funding], | ||
cellClass: ProjectTabCheckmarkListCell.self, | ||
inSection: Section.aiDisclosureFunding.rawValue | ||
) | ||
} | ||
|
||
if let consentAndDetailAIDetailValues = aiDisclosure.generatedByAiConsentAndDetails { | ||
self.set( | ||
values: [consentAndDetailAIDetailValues], | ||
cellClass: ProjectTabCategoryDescriptionCell.self, | ||
inSection: Section.aiDisclosureGenerated.rawValue | ||
) | ||
} | ||
|
||
if let otherAIDetailValues = aiDisclosure.otherAiDetails { | ||
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. And here we should also check that |
||
self.set( | ||
values: [otherAIDetailValues], | ||
cellClass: ProjectTabCategoryDescriptionCell.self, | ||
inSection: Section.aiDisclosureOtherDetails.rawValue | ||
) | ||
} | ||
|
||
self.set( | ||
values: [.aiDisclosure], | ||
cellClass: ProjectTabDisclaimerCell.self, | ||
inSection: Section.environmentalCommitmentsDisclaimer.rawValue | ||
) | ||
case .environmentalCommitments: | ||
let environmentalCommitments = project.extendedProjectProperties?.environmentalCommitments ?? [] | ||
|
||
|
@@ -220,24 +272,26 @@ internal final class ProjectPageViewControllerDataSource: ValueCellDataSource { | |
|
||
self.set( | ||
values: environmentalCommitments, | ||
cellClass: ProjectEnvironmentalCommitmentCell.self, | ||
cellClass: ProjectTabCategoryDescriptionCell.self, | ||
inSection: Section.environmentalCommitments.rawValue | ||
) | ||
|
||
self.set( | ||
values: [()], | ||
cellClass: ProjectEnvironmentalCommitmentDisclaimerCell.self, | ||
values: [.environmental], | ||
cellClass: ProjectTabDisclaimerCell.self, | ||
inSection: Section.environmentalCommitmentsDisclaimer.rawValue | ||
) | ||
} | ||
} | ||
|
||
override func configureCell(tableCell cell: UITableViewCell, withValue value: Any) { | ||
switch (cell, value) { | ||
case let (cell as ProjectEnvironmentalCommitmentCell, value as ProjectEnvironmentalCommitment): | ||
case let (cell as ProjectTabCategoryDescriptionCell, value as ProjectTabCategoryDescription): | ||
cell.configureWith(value: value) | ||
case let (cell as ProjectTabCheckmarkListCell, value as ProjectTabFundingOptions): | ||
cell.configureWith(value: value) | ||
case let (cell as ProjectTabDisclaimerCell, value as ProjectDisclaimerType): | ||
cell.configureWith(value: value) | ||
case let (cell as ProjectEnvironmentalCommitmentDisclaimerCell, _): | ||
cell.configureWith(value: ()) | ||
case let (cell as ProjectHeaderCell, value as String): | ||
cell.configureWith(value: value) | ||
case let (cell as ProjectFAQsAskAQuestionCell, _): | ||
|
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
166 changes: 166 additions & 0 deletions
166
Kickstarter-iOS/Features/ProjectPage/Views/Cells/ProjectTabCheckmarkListCell.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,166 @@ | ||
import KsApi | ||
import Library | ||
import Prelude | ||
import UIKit | ||
|
||
final class ProjectTabCheckmarkListCell: UITableViewCell, ValueCell { | ||
// MARK: - Properties | ||
|
||
private let viewModel = ProjectTabCheckmarkListCellViewModel() | ||
|
||
private lazy var categoryLabel: UILabel = { | ||
UILabel(frame: .zero) | ||
|> \.translatesAutoresizingMaskIntoConstraints .~ false | ||
}() | ||
|
||
private lazy var fundingStackView: UIStackView = { | ||
UIStackView(frame: .zero) | ||
|> \.translatesAutoresizingMaskIntoConstraints .~ false | ||
}() | ||
|
||
private lazy var rootStackView = { | ||
UIStackView(frame: .zero) | ||
|> \.translatesAutoresizingMaskIntoConstraints .~ false | ||
}() | ||
|
||
// MARK: - Lifecycle | ||
|
||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
|
||
self.bindStyles() | ||
self.configureViews() | ||
self.bindViewModel() | ||
} | ||
|
||
required init?(coder _: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
// MARK: - Bindings | ||
|
||
override func bindViewModel() { | ||
super.bindViewModel() | ||
|
||
self.categoryLabel.rac.text = self.viewModel.outputs.categoryLabelText | ||
|
||
self.viewModel.outputs.descriptionOptionsText | ||
.observeForUI() | ||
.observeValues { [weak self] options in | ||
self?.fundingStackView.arrangedSubviews.forEach { $0.removeFromSuperview() } | ||
|
||
_ = options.map { [weak self] optionText in | ||
let imageLabelView = UIView(frame: .zero) | ||
|
||
let label = UILabel(frame: .zero) | ||
|> \.text .~ optionText | ||
|> optionTextLabelStyle | ||
|
||
let icon = UIImageView(frame: .zero) | ||
|> iconImageStyle | ||
|
||
imageLabelView.addSubview(icon) | ||
imageLabelView.addSubview(label) | ||
|
||
NSLayoutConstraint.activate([ | ||
msadoon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
icon.leadingAnchor.constraint(equalTo: imageLabelView.leadingAnchor), | ||
icon.topAnchor.constraint(equalTo: imageLabelView.topAnchor, constant: Styles.grid(1)), | ||
label.leadingAnchor.constraint(equalTo: icon.trailingAnchor, constant: Styles.grid(2)), | ||
label.topAnchor.constraint(equalTo: imageLabelView.topAnchor), | ||
label.trailingAnchor.constraint(equalTo: imageLabelView.trailingAnchor), | ||
label.bottomAnchor.constraint(equalTo: imageLabelView.bottomAnchor) | ||
]) | ||
|
||
self?.fundingStackView.addArrangedSubview(imageLabelView) | ||
} | ||
|
||
self?.fundingStackView.setNeedsDisplay() | ||
} | ||
} | ||
|
||
override func bindStyles() { | ||
super.bindStyles() | ||
|
||
_ = self | ||
|> baseTableViewCellStyle() | ||
|> \.separatorInset .~ .init(leftRight: Styles.projectPageLeftRightInset) | ||
|
||
_ = self.contentView | ||
|> \.layoutMargins .~ | ||
.init( | ||
topBottom: Styles.grid(2), | ||
leftRight: Styles.projectPageLeftRightInset | ||
) | ||
|
||
_ = self.categoryLabel | ||
|> categoryLabelStyle | ||
|
||
_ = self.rootStackView | ||
|> rootStackViewStyle | ||
|
||
_ = self.fundingStackView | ||
|> fundingStackViewStyle | ||
} | ||
|
||
// MARK: - Configuration | ||
|
||
func configureWith(value: ProjectTabFundingOptions) { | ||
self.viewModel.inputs.configureWith(value: value) | ||
} | ||
|
||
private func configureViews() { | ||
_ = (self.rootStackView, self.contentView) | ||
|> ksr_addSubviewToParent() | ||
|> ksr_constrainViewToMarginsInParent() | ||
|
||
_ = ([self.categoryLabel, self.fundingStackView], self.rootStackView) | ||
|> ksr_addArrangedSubviewsToStackView() | ||
} | ||
} | ||
|
||
// MARK: - Styles | ||
|
||
private let categoryLabelStyle: LabelStyle = { label in | ||
label | ||
|> \.adjustsFontForContentSizeCategory .~ true | ||
|> \.font .~ UIFont.ksr_title3().bolded | ||
|> \.numberOfLines .~ 0 | ||
|> \.textColor .~ .ksr_support_700 | ||
} | ||
|
||
private let rootStackViewStyle: StackViewStyle = { stackView in | ||
stackView | ||
|> \.axis .~ .vertical | ||
|> \.insetsLayoutMarginsFromSafeArea .~ false | ||
|> \.isLayoutMarginsRelativeArrangement .~ true | ||
|> \.spacing .~ Styles.grid(3) | ||
} | ||
|
||
private let fundingStackViewStyle: StackViewStyle = { stackView in | ||
stackView | ||
|> \.axis .~ .vertical | ||
|> \.isLayoutMarginsRelativeArrangement .~ true | ||
|> \.layoutMargins .~ UIEdgeInsets(all: Styles.grid(1)) | ||
|> \.spacing .~ Styles.grid(2) | ||
} | ||
|
||
private let iconImageStyle: ImageViewStyle = { imageView in | ||
imageView | ||
|> \.tintColor .~ .ksr_create_700 | ||
|> \.contentMode .~ .scaleAspectFit | ||
|> \.image .~ Library.image(named: "checkmark") | ||
|> UIImageView.lens.contentHuggingPriority(for: .vertical) .~ .defaultLow | ||
|> UIImageView.lens.contentHuggingPriority(for: .horizontal) .~ .defaultLow | ||
|> UIImageView.lens.contentCompressionResistancePriority(for: .vertical) .~ .required | ||
|> UIImageView.lens.contentCompressionResistancePriority(for: .horizontal) .~ .required | ||
|> \.translatesAutoresizingMaskIntoConstraints .~ false | ||
} | ||
|
||
private let optionTextLabelStyle: LabelStyle = { label in | ||
label | ||
|> \.adjustsFontForContentSizeCategory .~ true | ||
|> \.font .~ UIFont.ksr_body() | ||
|> \.numberOfLines .~ 0 | ||
|> \.textColor .~ .ksr_support_700 | ||
|> \.translatesAutoresizingMaskIntoConstraints .~ false | ||
} |
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.
I think we should be checking that
.involvesFunding
is true here, in addition to this check.