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-361] Select new reward polish #899

Merged
merged 49 commits into from
Oct 25, 2019
Merged

[NT-361] Select new reward polish #899

merged 49 commits into from
Oct 25, 2019

Conversation

Scollaco
Copy link
Contributor

@Scollaco Scollaco commented Oct 17, 2019

📲 What

  • Changes the title of the RewardsCollectionViewController based on the RewardsCollectionViewContext.
  • Centralizes horizontally the backed reward card when presenting screen from ManagePledgeViewController.

🤔 Why

To match the behavior and design shown here.

🛠 How

  • Creating RewardsCollectionViewContext enum. I thought of reusing RewardCardViewContext, but while I was developing this, I noticed that the code was getting harder to understand.
  • Adding output that emits title based of the context
  • Adding output that emits IndexPath of backed reward. This will allow the collection view to centralize the reward when presenting the carousel from the ManagePledge screen.
  • Adding and fixing tests

👀 See

Backing Project Managing Pledge
Simulator Screen Shot - iPhone 8 - 2019-10-03 at 15 46 44

✅ Acceptance criteria

  • Select a non-backed project and open the Rewards Carousel. The No reward should be centralized and the title should show Back this project
  • Select a backed and live project and open the Rewards Carousel by selecting Choose another reward from the update pledge menu. The collection view should centralize the backed reward and the title should show Choose another reward

# Conflicts:
#	Screenshots/_64/Kickstarter_Framework_iOSTests.PledgeViewControllerTests/testView_UpdateContext_lang_de_device_pad@2x.png
#	Screenshots/_64/Kickstarter_Framework_iOSTests.PledgeViewControllerTests/testView_UpdateContext_lang_de_device_phone4_7inch@2x.png
#	Screenshots/_64/Kickstarter_Framework_iOSTests.PledgeViewControllerTests/testView_UpdateContext_lang_es_device_pad@2x.png
#	Screenshots/_64/Kickstarter_Framework_iOSTests.PledgeViewControllerTests/testView_UpdateContext_lang_es_device_phone4_7inch@2x.png
#	Screenshots/_64/Kickstarter_Framework_iOSTests.PledgeViewControllerTests/testView_UpdateContext_lang_fr_device_pad@2x.png
#	Screenshots/_64/Kickstarter_Framework_iOSTests.PledgeViewControllerTests/testView_UpdateContext_lang_fr_device_phone4_7inch@2x.png
#	Screenshots/_64/Kickstarter_Framework_iOSTests.PledgeViewControllerTests/testView_UpdateContext_lang_ja_device_pad@2x.png
#	Screenshots/_64/Kickstarter_Framework_iOSTests.PledgeViewControllerTests/testView_UpdateContext_lang_ja_device_phone4_7inch@2x.png
justinswart and others added 6 commits October 16, 2019 14:23
# Conflicts:
#	Kickstarter-iOS/Views/Controllers/PledgeAmountSummaryViewController.swift
#	Library/PledgeViewContext.swift
#	Library/PledgeViewContextTests.swift
#	Library/ViewModels/PledgeViewModel.swift
#	Library/ViewModels/PledgeViewModelTests.swift
#	Screenshots/_64/Kickstarter_Framework_iOSTests.PledgeViewControllerTests/testView_ChangePaymentMethodContext_lang_de_device_phone4_7inch@2x.png
#	Screenshots/_64/Kickstarter_Framework_iOSTests.PledgeViewControllerTests/testView_ChangePaymentMethodContext_lang_en_device_phone4_7inch@2x.png
#	Screenshots/_64/Kickstarter_Framework_iOSTests.PledgeViewControllerTests/testView_ChangePaymentMethodContext_lang_fr_device_phone4_7inch@2x.png
@Scollaco Scollaco changed the title Select new reward polish [NT-361] Select new reward polish Oct 17, 2019
self.viewModel.outputs.backedRewardIndexPath
.observeForUI()
.observeValues { [weak self] indexPath in
self?.collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)
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 we want this to be animated: false or was it specified that it should animate over to the reward? I would've expect that the view would just appear centered on the reward that I backed.

self.reloadDataWithValues = Signal.combineLatest(project, rewards)
.map { project, rewards in
rewards.map { (project, Either<Reward, Backing>.left($0)) }
}

self.backedRewardIndexPath = Signal.combineLatest(project, rewards)
.takeWhen(self.viewDidAppearProperty.signal.ignoreValues())
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on my other comment (if we want the centering to have happened before the view appears) we might want to tie this to viewWillAppear.

@@ -46,11 +53,21 @@ public final class RewardsCollectionViewModel: RewardsCollectionViewModelType,
let rewards = project
.map { $0.rewards }

self.title = configData
.map(third)
.takeWhen(self.viewDidLoadProperty.signal.ignoreValues())
Copy link
Contributor

Choose a reason for hiding this comment

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

We typically always want our configData to be combineLatest with viewDidLoad. This is just to ensure that we aren't concerned with the order in which these events occur.

# Conflicts:
#	Library/ViewModels/PledgeAmountViewModelTests.swift
#	Library/ViewModels/PledgeViewModelTests.swift
#	Library/ViewModels/RewardsCollectionViewModelTests.swift
@justinswart justinswart changed the base branch from select-this-reward-instead to master October 22, 2019 00:13
.map(titleForContext)

self.backedRewardIndexPath = Signal.combineLatest(project, rewards)
.takeWhen(self.viewDidLayoutSubviewsProperty.signal.ignoreValues())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using viewWillAppearProperty here didn't do anything, so viewDidLayoutSubviews was the way to go.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting 🤔 I believe it needs a run loop to render the cells. We could probably go ahead with this but for interest sake, if you used viewWillAppear and added .ksr_delay(AppEnvironment.current.apiDelayInterval, on: AppEnvironment.current.scheduler) which is a delay of 0 and just puts the emission on the next run loop, that would also work.

Copy link
Contributor

@justinswart justinswart left a comment

Choose a reason for hiding this comment

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

This mostly checks out! Had one more suggestion and then just want to test again once we're able to 'change to no reward'.

return context == .createPledge ? Strings.Back_this_project() : Strings.Choose_another_reward()
}

private func backedReward(_ project: Project, rewards: [Reward]) -> IndexPath? {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update this to use the function @ifbarrera is using in #905 when that merges.

https://github.com/kickstarter/ios-oss/pull/905/files#diff-234cfa58d101616352832cb332756878R33

@ifbarrera ifbarrera mentioned this pull request Oct 24, 2019
3 tasks
func viewDidLoad()
func viewWillAppear()
}

public protocol RewardsCollectionViewModelOutputs {
var backedRewardIndexPath: Signal<IndexPath, Never> { get }
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh hey could we rename this to scrollToBackedRewardIndexPath just to make it clearer what this output does?

.map(titleForContext)

self.backedRewardIndexPath = Signal.combineLatest(project, rewards)
.takeWhen(self.viewDidLayoutSubviewsProperty.signal.ignoreValues())
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting 🤔 I believe it needs a run loop to render the cells. We could probably go ahead with this but for interest sake, if you used viewWillAppear and added .ksr_delay(AppEnvironment.current.apiDelayInterval, on: AppEnvironment.current.scheduler) which is a delay of 0 and just puts the emission on the next run loop, that would also work.

Copy link
Contributor

@justinswart justinswart left a comment

Choose a reason for hiding this comment

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

🚢 🚢 🚢

@Scollaco Scollaco merged commit 47e2808 into master Oct 25, 2019
@Scollaco Scollaco deleted the select-new-reward-polish branch October 25, 2019 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants