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
[π] Manage pledge menu #588
Conversation
β¦ the pledge sheet is opened. - When it's visible, an options menu is present in the rewards toolbar. - The menu has options for Update pledge, Change payment method, View rewards, Cancel pledge and Contact creator - Added PledgeReason that will be used to configure PledgeFragment UI - PledgeData.screenLocation is now optional. - PledgeFragment hides mini reward if no ScreenLocation. - Renamed RewardFragment to RewardsFragment. - Renamed RewardFragmentViewModel to RewardsFragmentViewModel. - Testz
} | ||
} | ||
|
||
private fun renderProject(backingFragment: BackingFragment, rewardsFragment: RewardsFragment, project: Project) { |
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 happens when we have two methods with the same name? I see that we have another renderProject
above with a different function signature. Is it able to detect which one to invoke based on the arguments?
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.
Yep! I was considering naming it renderProjectInFragments
but it's kinda long and redundant.
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 guess I'm still learning how the files in this codebase are structured and what the purpose of each of these functions are. It looks like the one above renders an action button for the project? Could it be something like renderProjectActionButton
or is that too specific? (disregard if I misunderstood)
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.
ooh it's doing more than that. It's loading the project into the ProjectAdapter
, loading the old style rewards if the native checkout flag is off, and configuring the button
} | ||
|
||
@Test | ||
fun testManagePledgeMenuIsVisible_whenProjectNotBacked() { |
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 do you think about adding Not
to this test name testManagePledgeMenuIsNotVisible_whenProjectNotBacked
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've been trying to structure tests like test[output]_when[condition]. Does that make sense? Nino and I have been flopping around about it.
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 both make a lot of sense. Personally when I read tests that I'm unfamiliar with, I appreciate being able to get as much context from it without having to read through the whole test body. It saves me some time and allows me to jump back to the code.
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.
Yeah, we've been discussing ways to make the tests more readable for people that are unfamiliar with the codebase. The pattern @eoji mentioned above is used on iOS too. Once you get into inputs/outputs it will make more sense, but maybe a discussion about it would be worth it.
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.
Great work, @eoji . I left a some comments and questions.
app/src/main/java/com/kickstarter/ui/activities/ProjectActivity.kt
Outdated
Show resolved
Hide resolved
interface Outputs { | ||
/** Emits the current project. */ | ||
fun project(): Observable<Project> | ||
} |
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.
Why is project
being sent through input and being emitted as an output without any logic applied to it? Is this for tests purposes? π€
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.
Yeah, just for tests. The designs for this screen aren't done so I just left it blank for now.
app/src/main/java/com/kickstarter/viewmodels/ProjectViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/kickstarter/viewmodels/ProjectViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/test/java/com/kickstarter/viewmodels/ProjectViewModelTest.kt
Outdated
Show resolved
Hide resolved
@@ -339,21 +351,21 @@ class ProjectViewModelTest : KSRobolectricTestCase() { | |||
} | |||
|
|||
@Test | |||
fun testHideRewardsFragment() { | |||
fun testExpandPledgeSheet_whenHiding() { |
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.
Could this be renamed to testExpandPledgeSheet_whenHidingFragment
just to be more explicit?
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.
went with testExpandPledgeSheet_whenCollapsingSheet
} | ||
|
||
@Test | ||
fun testShowRewardsFragment() { | ||
fun testExpandPledgeSheet_whenShowing() { |
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.
And here too
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.
went with testExpandPledgeSheet_whenExpandingSheet
@@ -435,13 +447,18 @@ class ProjectViewModelTest : KSRobolectricTestCase() { | |||
} | |||
|
|||
@Test | |||
fun testScrimIsVisible() { | |||
fun testScrimIsVisible_whenNativeCheckoutDisabled() { |
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.
Should we test the scrimIsVisible
when native checkout is enabled as well?
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.
yeah that's what happens in the next 2 tests
@Test
fun testScrimIsVisible_whenNotBackedProject() {
setUpEnvironment(environmentWithNativeCheckoutEnabled())
@Test
fun testScrimIsVisible_whenBackedProject() {
setUpEnvironment(environmentWithNativeCheckoutEnabled())
should I rename them?
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.
Approved! (There's a alpha off due a renaming, but aside that it looks good) π
@@ -47,7 +53,7 @@ interface ProjectViewModel { | |||
fun heartButtonClicked() | |||
|
|||
/** Call when horizontal rewards sheet should hide. */ | |||
fun hideRewardsSheetClicked() | |||
fun collapsePledgeSheet() |
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.
And now the alpha is off lol
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.
LOL
π² What
Showing an interstitial screen with menu options when the pledge sheet is expanded and the user has backed the project.
π€ Why
MANAGE UR PLEDGE
π How
ProjectActivity
displaysBackingFragment
as the primary screen when the pledge sheet is opened.Update pledge
,Change payment method
,View rewards
,Cancel pledge
andContact creator
PledgeReason
that will be used to configurePledgeFragment
UIPledgeData.screenLocation
is now optional.PledgeFragment
hides mini reward if noScreenLocation
.RewardFragment
toRewardsFragment
.RewardFragmentViewModel
toRewardsFragmentViewModel
.π See
π QA
1οΈβ£When a user has backed a live project, clicking
Manage
reveals the Manage Your Pledge screen (it's blank for now) with an options menu.2οΈβ£ The menu contains
Update pledge
,Change payment method
,View rewards
,Cancel pledge
andContact creator
.3οΈβ£
Update pledge
-> Pledge screen (not currently configured)4οΈβ£
Change payment method
-> Pledge screen (not currently configured)5οΈβ£
View rewards
-> Rewards screen (scrolled to current reward)6οΈβ£
Cancel pledge
-> Cancel modal (needs new UI)7οΈβ£
Contact creator
-> Conversation with creatorStory π
https://dripsprint.atlassian.net/browse/NT-108