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

[NT-1355] Lights On header bugfix #1224

Merged
merged 4 commits into from
Jun 16, 2020
Merged

Conversation

justinswart
Copy link
Contributor

📲 What

Fixes a bug causing the project cards to be scrolled behind the Lights On header in the editorial projects collection.

Note: Contains unrelated formatting updates from bin/format.sh . not being run in #1223 😅

🤔 Why

This is a regression introduced where DiscoveryPageViewController's backgroundColor is changed after it's added as a child of EditorialProjectsViewController. We need this to remain clear for the behaviour in the editorial projects list.

🛠 How

When this DiscoveryPageViewController's viewWillAppear is called we pass in a boolean to indicate whether its parent is EditorialProjectsViewController and we don't emit the backgroundColor or contentInset changes in that case as these are configured by the parent VC.

Note: Initially I thought I would just pass the VC's class into the VM for this logic but that would require the VM to be aware of VC classes.

👀 See

Before 🐛 After 🦋
2020-06-11 17 47 09 2020-06-11 17 21 25

✅ Acceptance criteria

  • When viewing the Lights On editorial collection the projects scroll behind the header.

@@ -241,7 +243,7 @@ public final class DiscoveryPageViewModel: DiscoveryPageViewModelType, Discovery
}
}

self.contentInset = self.viewWillAppearProperty.signal
self.contentInset = self.viewWillAppearIsEditorialProperty.signal.filter(isFalse)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhh sorry about that! 🙈 I actually noticed this and thought it always went under the header haha.

The problem is when the native_project_cards experiment is turned on, the the background color needs to be updated so there's enough contrast with the cards :\

Simulator Screen Shot - iPhone 8 - 2020-06-12 at 10 08 32

It's not terrible, I guess.

Another approach would be to prevent the new project cards from displaying if the cards are within the context of an EditorialViewController.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll go with the latter for now.

@@ -241,7 +243,7 @@ public final class DiscoveryPageViewModel: DiscoveryPageViewModelType, Discovery
}
}

self.contentInset = self.viewWillAppearProperty.signal
self.contentInset = self.viewWillAppearIsEditorialProperty.signal.filter(isFalse)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does updating the content inset actually break anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is updated by the parent when contained in editorial VC.

@justinswart justinswart force-pushed the NT-1355-editorial-header-bugfix branch from 4c9b998 to c2b8e07 Compare June 12, 2020 22:26
# Conflicts:
#	Library/ViewModels/DiscoveryPageViewModel.swift
@justinswart
Copy link
Contributor Author

Note this has since been updated to instead provide the background color for discovery from a shared function which is used for the cells and the background of DiscoveryPageViewController.

_ = self.view
|> \.backgroundColor .~ (
// Update the background if it is not currently clear (contained in EditorialProjectsViewController)
self.view.backgroundColor != .clear ? discoveryPageBackgroundColor() : self.view.backgroundColor
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately snapshot tests wouldn't pass without this - it seems setting the backgroundColor any earlier than bindStyles was ineffective. We only ever set the backgroundColor to .clear when this is contained in EditorialProjectsViewController.

Copy link
Contributor

@jgsamudio jgsamudio left a comment

Choose a reason for hiding this comment

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

Everything looks good, Approved. The only callout would be when pulling to refresh. Do we want to zoom in on the image when the user pulls to refresh?

@justinswart
Copy link
Contributor Author

@jgsamudio good question - we did this for the header originally when we used it for Go Rewardless (#971), but perhaps it doesn't work for this particular image, what do you think, @colleenmacd?

@colleenmacd
Copy link

colleenmacd commented Jun 15, 2020 via email

@justinswart justinswart merged commit f6821b5 into master Jun 16, 2020
@justinswart justinswart deleted the NT-1355-editorial-header-bugfix branch June 16, 2020 01:11
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.

4 participants