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

[MBL-983] Already Reported Project Label #1857

Merged
merged 22 commits into from Sep 28, 2023

Conversation

scottkicks
Copy link
Contributor

@scottkicks scottkicks commented Sep 23, 2023

📲 What

Replace the "Report this project to Kickstarter" cell with a SwiftUI view that dynamically shows either the original label or a label informing the user that they've already reported the project.

🤔 Why

If a user has already reported a project there's no need to do it again.

🛠 How

Instead of adding a label to the ProjectPamphletSubpage, we can build the new labels with SwiftUI and add it as its own section to the project page's table view datasource. Giving us more control and more SwiftUI.

Uses the new flagging property on Projects to conditionally render the labels.
The new "Already reported" label should not be tappable and include 2 hyperlinks.

Followed Android's implementation as a design reference.

👀 See

iPad iPhone
Simulator Screen Recording - iPad Pro (12 9-inch) (6th generation) - 2023-09-25 at 11 23 26 Simulator Screen Recording - iPhone 14 - 2023-09-25 at 11 27 19

✅ Acceptance criteria

You'll need to ask someone on web team A to add your staging account email to the project "Undercover:: The cover art of underglow comics - 200+ pages". This is a test project that has been marked as flagged, but you'll still need it associated with your account so that you see the "Already reported" label.

Also, I didn't choose which project to test with so sorry if that projects cover art is a bit saucy.

Otherwise, any other project will show the "Report this project" label as normal

* UITableView cell will be added to the Project Page Table View
* Used to display a new swiftui view for the report this project label and already reported label
ReportProjectLabelView (SwiftUI View) re-renders when its text labels contain hyperlinks. Since we're rendering hyperlinks with the helper in Text+HTML.swift, this seems to cause a `precondition failure: cyclic graph` crash. This check prevents that by making sure the cell is only configured once on dequeue.
needs to be called because we're adding a SwiftUI view to the cell's contentView
@scottkicks scottkicks self-assigned this Sep 23, 2023
@scottkicks scottkicks added this to the release-5.11.0 milestone Sep 23, 2023
@kickstarter kickstarter deleted a comment from nativeksr Sep 25, 2023
@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

Merging #1857 (b38f921) into main (70dc8b3) will decrease coverage by 0.04%.
The diff coverage is 56.92%.

@@            Coverage Diff             @@
##             main    #1857      +/-   ##
==========================================
- Coverage   83.98%   83.95%   -0.04%     
==========================================
  Files        1287     1289       +2     
  Lines      117044   117118      +74     
  Branches    31129    31158      +29     
==========================================
+ Hits        98302    98327      +25     
- Misses      17655    17702      +47     
- Partials     1087     1089       +2     
Files Coverage Δ
...rce/ProjectPageViewControllerDataSourceTests.swift 97.44% <100.00%> (-0.03%) ⬇️
Library/HelpType.swift 87.67% <100.00%> (ø)
Library/ViewModels/ProjectPageViewModelTests.swift 98.16% <100.00%> (+<0.01%) ⬆️
...ewModels/ProjectPamphletSubpageCellViewModel.swift 73.43% <100.00%> (-5.67%) ⬇️
...tasource/ProjectPageViewControllerDataSource.swift 83.79% <87.50%> (-0.10%) ⬇️
...es/ProjectPage/Views/Cells/ReportProjectCell.swift 97.14% <97.14%> (ø)
Library/ViewModels/ProjectPageViewModel.swift 97.04% <0.00%> (-0.27%) ⬇️
...Features/ReportProject/ReportProjectInfoView.swift 0.00% <0.00%> (ø)
...ectPage/Controller/ProjectPageViewController.swift 50.30% <50.00%> (+0.23%) ⬆️
Library/SwiftUI+Extensions/Text+HTML.swift 0.00% <0.00%> (ø)
... and 1 more

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@ifosli ifosli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, though I have some concerns. See comments. Also, a11y for this cell needs to be updated as well (mark ReportProjectCell as an a11y element and as a button, at least when it's not flagged) but I can fold that in to the other a11y things if you'd prefer.

import UIKit

internal final class ReportProjectCell: UITableViewCell, ValueCell {
let isIpad = AppEnvironment.current.device.userInterfaceIdiom == .pad
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should look at the horizontal size class instead. This is important to make layouts look good on iPad split screen, for example.

struct ReportProjectLabelView: View {
let flagged: Bool

let isIpad = AppEnvironment.current.device.userInterfaceIdiom == .pad
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here; look at the size class instead of the device type.

} else {
HStack {
Text(Strings.Report_this_project_to())
.font(Font(UIFont.ksr_footnote()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest using .ksr_body(size: 14) as the font here instead, to match the project subpage cell.

@@ -16,7 +16,7 @@ internal final class ProjectPamphletContentDataSource: ValueCellDataSource {

let values = [
ProjectPamphletSubpage.comments(project.stats.commentsCount as Int?, .first),
ProjectPamphletSubpage.updates(project.stats.updatesCount as Int?, .last)
ProjectPamphletSubpage.updates(project.stats.updatesCount as Int?, .middle)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This file is marked as deprecated - I'm not sure we need this change (or the file?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yea, good catch. was just making sure all uses of these cells had the right positioning. I'll undo this change. Looking forward to removing this file completely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this cell is still clickable, even when it's already flagged. I'm not 100% sure, since I just overwrote the flagged bool locally to test this (instead of contacting team A to get myself added to the flagged list). Will you double check and make the cell non-interactive if needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double checked and the "already reported" label is never tappable. Only when flagged is false do we show the tappable "report this project" label

@scottkicks scottkicks force-pushed the mbl-983-already-reported-label branch 2 times, most recently from bc2ac13 to e7576a2 Compare September 28, 2023 02:11
Copy link
Contributor

@ifosli ifosli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Size class stuff looks good - thanks for updating! Accessibility still isn't quite there, but I'll leave it up to you if you want to fix that now or not.

Comment on lines +26 to +32
let accessibilityTraits = projectFlagged
? UIAccessibilityTraits.staticText
: UIAccessibilityTraits.button

_ = self
|> baseTableViewCellStyle()
|> ReportProjectCell.lens.accessibilityTraits .~ accessibilityTraits
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this! Unfortunately, I don't think it does anything currently; we'd need to also set isAccessibilityElement = true and the accessibility label. I don't see an easy way to set the label based on the swiftui child view. So I'd suggest either leaving this alone for now or adding it just for the button state. Ex:

if projectFlagged  {
  self.accessibilityTraits = super.accessibilityTraits
  self.isAccessibilityElement = false
} else {
  self.accessibilityTraits.insert(.button)
  self.isAccessibilityElement = true
  self.accessibilityLabel = Strings.Report_this_project_to()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, good callout! I'll look into this in the next PR

@scottkicks scottkicks merged commit 8f40c4c into main Sep 28, 2023
7 checks passed
@scottkicks scottkicks deleted the mbl-983-already-reported-label branch September 28, 2023 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants