-
Notifications
You must be signed in to change notification settings - Fork 989
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MLB-1797 Added titles for payments and collection plan on CheckoutScr…
…een (#2167) * Added titles for payments and collection plan on Checkoutscreen - Added prop validation for plotEnabled on CheckOutScreen, render title and collection plan component if plorEnabled is true, fix some styles of collection plan component * adressed comments * fix * set isPlotEnabled as false on ProjectPledgeButtonAndFragmentCointainer * remove unused import --------- Co-authored-by: Isabel Martin <[email protected]>
- Loading branch information
Showing
5 changed files
with
119 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | ||
import androidx.activity.viewModels | ||
import com.kickstarter.features.pledgeredemption.viewmodels.PledgeRedemptionViewModel | ||
import com.kickstarter.libs.featureflag.FlagKey | ||
import com.kickstarter.libs.utils.extensions.getEnvironment | ||
import com.kickstarter.libs.utils.extensions.isDarkModeEnabled | ||
import com.kickstarter.mock.factories.RewardFactory | ||
|
@@ -35,14 +36,20 @@ class PledgeRedemptionActivity : ComponentActivity() { | |
val shippingAmount = backing.shippingAmount().toDouble() | ||
val totalAmount = backing.amount() | ||
val bonus = backing.bonusAmount() | ||
val pledgeReason = PledgeReason.PLEDGE | ||
|
||
backing.reward()?.let { lists.add(it) } | ||
backing.addOns()?.map { lists.add(it) } | ||
|
||
val darModeEnabled = this.isDarkModeEnabled(env = requireNotNull(env)) | ||
KickstarterApp(useDarkTheme = darModeEnabled) { | ||
CheckoutScreen( | ||
rewardsList = lists.map { Pair(it.title() ?: "", it.pledgeAmount().toString()) }, | ||
rewardsList = lists.map { | ||
Pair( | ||
it.title() ?: "", | ||
it.pledgeAmount().toString() | ||
) | ||
}, | ||
environment = env, | ||
shippingAmount = shippingAmount, | ||
selectedReward = RewardFactory.rewardWithShipping(), | ||
|
@@ -52,12 +59,14 @@ class PledgeRedemptionActivity : ComponentActivity() { | |
storedCards = emptyList(), | ||
project = project, | ||
email = "[email protected]", | ||
pledgeReason = PledgeReason.PLEDGE, | ||
pledgeReason = pledgeReason, | ||
rewardsHaveShippables = true, | ||
onPledgeCtaClicked = { }, | ||
newPaymentMethodClicked = { }, | ||
onDisclaimerItemClicked = {}, | ||
onAccountabilityLinkClicked = {} | ||
onAccountabilityLinkClicked = {}, | ||
isPlotEnabled = env.featureFlagClient() | ||
?.getBoolean(FlagKey.ANDROID_PLEDGE_OVER_TIME) ?: false, | ||
) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.kickstarter.ui.activities.compose.projectpage | ||
|
||
import CollectionPlan | ||
import android.content.res.Configuration | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.background | ||
|
@@ -121,11 +122,55 @@ fun CheckoutScreenPreview() { | |
newPaymentMethodClicked = { }, | ||
onDisclaimerItemClicked = {}, | ||
onAccountabilityLinkClicked = {}, | ||
onChangedPaymentMethod = {} | ||
onChangedPaymentMethod = {}, | ||
isPlotEnabled = false | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview(name = "Light", uiMode = Configuration.UI_MODE_NIGHT_NO) | ||
@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES) | ||
fun CheckoutScreenisPlotEnabledPreview() { | ||
KSTheme { | ||
CheckoutScreen( | ||
rewardsList = (1..6).map { | ||
Pair("Cool Item $it", "$20") | ||
}, | ||
environment = Environment.Builder().build(), | ||
shippingAmount = 4.0, | ||
selectedReward = RewardFactory.rewardWithShipping(), | ||
currentShippingRule = ShippingRule.builder().build(), | ||
totalAmount = 60.0, | ||
totalBonusSupport = 5.0, | ||
storedCards = listOf( | ||
StoredCardFactory.visa(), StoredCardFactory.discoverCard(), StoredCardFactory.visa() | ||
), | ||
project = | ||
Project.builder() | ||
.currency("USD") | ||
.currentCurrency("USD") | ||
.state(Project.STATE_LIVE) | ||
.availableCardTypes( | ||
listOf( | ||
CreditCardTypes.AMEX.rawValue(), | ||
CreditCardTypes.MASTERCARD.rawValue(), | ||
CreditCardTypes.VISA.rawValue() | ||
) | ||
) | ||
.build(), | ||
email = "[email protected]", | ||
pledgeReason = PledgeReason.PLEDGE, | ||
rewardsHaveShippables = true, | ||
onPledgeCtaClicked = { }, | ||
newPaymentMethodClicked = { }, | ||
onDisclaimerItemClicked = {}, | ||
onAccountabilityLinkClicked = {}, | ||
onChangedPaymentMethod = {}, | ||
isPlotEnabled = true | ||
) | ||
} | ||
} | ||
@Composable | ||
fun CheckoutScreen( | ||
storedCards: List<StoredCard> = listOf(), | ||
|
@@ -148,7 +193,7 @@ fun CheckoutScreen( | |
onDisclaimerItemClicked: (disclaimerItem: DisclaimerItems) -> Unit, | ||
onAccountabilityLinkClicked: () -> Unit, | ||
onChangedPaymentMethod: (StoredCard?) -> Unit = {}, | ||
plotSelected: Boolean = false, | ||
isPlotEnabled: Boolean | ||
) { | ||
val selectedOption = remember { | ||
mutableStateOf( | ||
|
@@ -328,8 +373,33 @@ fun CheckoutScreen( | |
style = typography.title3Bold, | ||
color = colors.kds_black, | ||
) | ||
|
||
Spacer(modifier = Modifier.height(dimensions.paddingMediumSmall)) | ||
if (isPlotEnabled) { | ||
Text( | ||
modifier = Modifier.padding( | ||
start = dimensions.paddingMediumLarge, | ||
end = dimensions.paddingMediumLarge | ||
), | ||
text = stringResource(id = R.string.fpo_collection_plan), | ||
style = typography.headline, | ||
color = colors.kds_black, | ||
) | ||
Spacer(modifier = Modifier.height(dimensions.paddingMediumSmall)) | ||
|
||
CollectionPlan(isEligible = true) | ||
Spacer(modifier = Modifier.height(dimensions.paddingMediumSmall)) | ||
Text( | ||
modifier = Modifier.padding( | ||
start = dimensions.paddingMediumLarge, | ||
end = dimensions.paddingMediumLarge | ||
), | ||
text = stringResource(id = R.string.fpo_payment), | ||
style = typography.headline, | ||
color = colors.kds_black, | ||
) | ||
Spacer(modifier = Modifier.height(dimensions.paddingMediumSmall)) | ||
} | ||
storedCards.forEachIndexed { index, card -> | ||
val isAvailable = | ||
project.acceptedCardType(card.type()) || card.isFromPaymentSheet() | ||
|
@@ -495,7 +565,7 @@ fun CheckoutScreen( | |
totalBonusSupport = totalBonusSupportString, | ||
deliveryDateString = deliveryDateString, | ||
rewardsHaveShippables = rewardsHaveShippables, | ||
disclaimerText = if (plotSelected) plotDisclaimerText else disclaimerText, | ||
disclaimerText = if (isPlotEnabled) plotDisclaimerText else disclaimerText, | ||
plotSelected = false | ||
) | ||
} else { | ||
|
@@ -506,7 +576,7 @@ fun CheckoutScreen( | |
initialBonusSupport = initialBonusSupportString, | ||
totalBonusSupport = totalAmountString, | ||
shippingAmount = shippingAmount, | ||
disclaimerText = if (plotSelected) plotDisclaimerText else disclaimerText, | ||
disclaimerText = if (isPlotEnabled) plotDisclaimerText else disclaimerText, | ||
plotSelected = false | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters