-
Notifications
You must be signed in to change notification settings - Fork 631
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
Create empty manage PMs screen #8523
Changes from 8 commits
54df907
e3f57c2
050aa72
7338c16
93511f9
19190a0
2fbbf23
f921f1b
d46815b
85ea850
1bc000f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,55 +16,69 @@ internal class HeaderTextFactory( | |
types: List<PaymentMethodCode>, | ||
): Int? { | ||
return if (isCompleteFlow) { | ||
when (screen) { | ||
is PaymentSheetScreen.SelectSavedPaymentMethods -> { | ||
if (isWalletEnabled) { | ||
null | ||
} else { | ||
R.string.stripe_paymentsheet_select_payment_method | ||
} | ||
} | ||
is PaymentSheetScreen.AddFirstPaymentMethod, PaymentSheetScreen.VerticalMode -> { | ||
R.string.stripe_paymentsheet_add_payment_method_title.takeUnless { | ||
isWalletEnabled | ||
} | ||
} | ||
is PaymentSheetScreen.EditPaymentMethod -> { | ||
StripeR.string.stripe_title_update_card | ||
} | ||
is PaymentSheetScreen.Loading, | ||
is PaymentSheetScreen.AddAnotherPaymentMethod, | ||
is PaymentSheetScreen.Form, | ||
null -> { | ||
null | ||
} | ||
} | ||
createForCompleteFlow(screen, isWalletEnabled) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ran into a linter issue about this function being too complex, so separated some of it out There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only actually new thing in this file is the PaymentSheetScreen.ManageSavedPaymentMethods branch |
||
} else { | ||
when (screen) { | ||
is PaymentSheetScreen.Loading, is PaymentSheetScreen.Form -> { | ||
null | ||
} | ||
is PaymentSheetScreen.SelectSavedPaymentMethods -> { | ||
R.string.stripe_paymentsheet_select_payment_method | ||
} | ||
is PaymentSheetScreen.AddFirstPaymentMethod, | ||
is PaymentSheetScreen.AddAnotherPaymentMethod, | ||
is PaymentSheetScreen.VerticalMode -> { | ||
val title = if (types.singleOrNull() == PaymentMethod.Type.Card.code) { | ||
StripeR.string.stripe_title_add_a_card | ||
} else { | ||
R.string.stripe_paymentsheet_choose_payment_method | ||
} | ||
createForFlowController(screen, types, isWalletEnabled) | ||
} | ||
} | ||
|
||
private fun createForCompleteFlow( | ||
screen: PaymentSheetScreen?, | ||
isWalletEnabled: Boolean | ||
) = when (screen) { | ||
is PaymentSheetScreen.SelectSavedPaymentMethods -> { | ||
if (isWalletEnabled) { | ||
null | ||
} else { | ||
R.string.stripe_paymentsheet_select_payment_method | ||
} | ||
} | ||
is PaymentSheetScreen.AddFirstPaymentMethod, PaymentSheetScreen.VerticalMode -> { | ||
R.string.stripe_paymentsheet_add_payment_method_title.takeUnless { | ||
isWalletEnabled | ||
} | ||
} | ||
is PaymentSheetScreen.EditPaymentMethod -> { | ||
StripeR.string.stripe_title_update_card | ||
} | ||
is PaymentSheetScreen.ManageSavedPaymentMethods -> { | ||
R.string.stripe_paymentsheet_select_payment_method | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test for this (if it's the final variant). I've been skipping tests for all the stuff I've added, since it isn't done yet. |
||
} | ||
is PaymentSheetScreen.Loading, | ||
is PaymentSheetScreen.AddAnotherPaymentMethod, | ||
is PaymentSheetScreen.Form, | ||
null -> { | ||
null | ||
} | ||
} | ||
|
||
title.takeUnless { isWalletEnabled } | ||
} | ||
is PaymentSheetScreen.EditPaymentMethod -> { | ||
StripeR.string.stripe_title_update_card | ||
} | ||
null -> { | ||
null | ||
} | ||
private fun createForFlowController( | ||
screen: PaymentSheetScreen?, | ||
types: List<PaymentMethodCode>, | ||
isWalletEnabled: Boolean | ||
) = when (screen) { | ||
is PaymentSheetScreen.Loading, is PaymentSheetScreen.Form -> { | ||
null | ||
} | ||
is PaymentSheetScreen.SelectSavedPaymentMethods, is PaymentSheetScreen.ManageSavedPaymentMethods -> { | ||
R.string.stripe_paymentsheet_select_payment_method | ||
} | ||
is PaymentSheetScreen.AddFirstPaymentMethod, | ||
is PaymentSheetScreen.AddAnotherPaymentMethod, | ||
is PaymentSheetScreen.VerticalMode -> { | ||
val title = if (types.singleOrNull() == PaymentMethod.Type.Card.code) { | ||
StripeR.string.stripe_title_add_a_card | ||
} else { | ||
R.string.stripe_paymentsheet_choose_payment_method | ||
} | ||
|
||
title.takeUnless { isWalletEnabled } | ||
} | ||
is PaymentSheetScreen.EditPaymentMethod -> { | ||
StripeR.string.stripe_title_update_card | ||
} | ||
null -> { | ||
null | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.stripe.android.paymentsheet.ui | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.TextButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import com.stripe.android.lpmfoundations.luxe.SupportedPaymentMethod | ||
import com.stripe.android.uicore.image.StripeImageLoader | ||
|
||
@Composable | ||
internal fun PaymentMethodVerticalLayoutUI( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created this new layout for the list of both saved PMs + new PMs (using the existing NewPaymentMethodVerticalLayoutUI). Once there is a saved PM displayed in this layout, it will have a "View more" button and clicking that button should call the onViewMorePaymentMethods function that is included here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we will probably keep doing this for a while. I'm hoping to refactor some stuff in this realm too. But I'm on board with this as iterative progress! |
||
paymentMethods: List<SupportedPaymentMethod>, | ||
selectedIndex: Int, | ||
isEnabled: Boolean, | ||
onViewMorePaymentMethods: () -> Unit, | ||
onItemSelectedListener: (SupportedPaymentMethod) -> Unit, | ||
imageLoader: StripeImageLoader, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(12.dp)) { | ||
TextButton(onClick = { onViewMorePaymentMethods() }) { | ||
Text(text = "Go to manage screen") | ||
} | ||
|
||
NewPaymentMethodVerticalLayoutUI( | ||
paymentMethods = paymentMethods, | ||
selectedIndex = selectedIndex, | ||
isEnabled = isEnabled, | ||
onItemSelectedListener = onItemSelectedListener, | ||
imageLoader = imageLoader | ||
) | ||
} | ||
} |
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.
In a follow up, I will make this a column of SavedPaymentMethodRowButtons