-
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-361] Select new reward polish #899
Conversation
# 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
# 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
self.viewModel.outputs.backedRewardIndexPath | ||
.observeForUI() | ||
.observeValues { [weak self] indexPath in | ||
self?.collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true) |
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 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()) |
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.
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()) |
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.
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
.map(titleForContext) | ||
|
||
self.backedRewardIndexPath = Signal.combineLatest(project, rewards) | ||
.takeWhen(self.viewDidLayoutSubviewsProperty.signal.ignoreValues()) |
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.
Using viewWillAppearProperty
here didn't do anything, so viewDidLayoutSubviews
was the way to go.
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.
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.
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 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? { |
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.
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
func viewDidLoad() | ||
func viewWillAppear() | ||
} | ||
|
||
public protocol RewardsCollectionViewModelOutputs { | ||
var backedRewardIndexPath: Signal<IndexPath, Never> { get } |
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.
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()) |
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.
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.
…rter/ios-oss into select-new-reward-polish
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.
🚢 🚢 🚢
📲 What
RewardsCollectionViewController
based on the RewardsCollectionViewContext.🤔 Why
To match the behavior and design shown here.
🛠 How
RewardsCollectionViewContext
enum. I thought of reusingRewardCardViewContext
, but while I was developing this, I noticed that the code was getting harder to understand.👀 See
✅ Acceptance criteria
non-backed
project and open the Rewards Carousel. TheNo reward
should be centralized and the title should showBack this project
backed
andlive
project and open the Rewards Carousel by selectingChoose another reward
from the update pledge menu. The collection view should centralize the backed reward and the title should showChoose another reward