Consolidate subscription information and manage button to a single row.

This commit is contained in:
Alex Hart
2024-05-20 11:25:29 -03:00
committed by Cody Henthorne
parent f37efd7e15
commit 0fb1514da2
3 changed files with 15 additions and 13 deletions

View File

@@ -34,7 +34,8 @@ object ActiveSubscriptionPreference {
val activeSubscription: ActiveSubscription.Subscription?,
val subscriberRequiresCancel: Boolean,
val onContactSupport: () -> Unit,
val onPendingClick: (FiatMoney) -> Unit
val onPendingClick: (FiatMoney) -> Unit,
val onRowClick: (ManageDonationsState.RedemptionState) -> Unit
) : PreferenceModel<Model>() {
override fun areItemsTheSame(newItem: Model): Boolean {
return subscription.id == newItem.subscription.id
@@ -73,6 +74,9 @@ object ActiveSubscriptionPreference {
expiry.movementMethod = LinkMovementMethod.getInstance()
itemView.setOnClickListener { model.onRowClick(model.redemptionState) }
itemView.isClickable = model.redemptionState != ManageDonationsState.RedemptionState.IN_PROGRESS
when (model.redemptionState) {
ManageDonationsState.RedemptionState.NONE -> presentRenewalState(model)
ManageDonationsState.RedemptionState.IS_PENDING_BANK_TRANSFER -> presentPendingBankTransferState(model)

View File

@@ -275,6 +275,11 @@ class ManageDonationsFragment :
},
activeSubscription = activeSubscription,
subscriberRequiresCancel = state.subscriberRequiresCancel,
onRowClick = {
if (it != ManageDonationsState.RedemptionState.IN_PROGRESS) {
findNavController().safeNavigate(ManageDonationsFragmentDirections.actionManageDonationsFragmentToDonateToSignalFragment(InAppPaymentTable.Type.RECURRING_DONATION))
}
},
onPendingClick = {
displayPendingDialog(it)
}
@@ -297,7 +302,8 @@ class ManageDonationsFragment :
onContactSupport = {},
activeSubscription = null,
subscriberRequiresCancel = state.subscriberRequiresCancel,
onPendingClick = {}
onPendingClick = {},
onRowClick = {}
)
)
}
@@ -315,15 +321,6 @@ class ManageDonationsFragment :
presentPendingOrProcessingOneTimeDonationState(state)
clickPref(
title = DSLSettingsText.from(R.string.ManageDonationsFragment__manage_subscription),
icon = DSLSettingsIcon.from(R.drawable.symbol_person_24),
isEnabled = state.getMonthlyDonorRedemptionState() != ManageDonationsState.RedemptionState.IN_PROGRESS,
onClick = {
findNavController().safeNavigate(ManageDonationsFragmentDirections.actionManageDonationsFragmentToDonateToSignalFragment(InAppPaymentTable.Type.RECURRING_DONATION))
}
)
presentBadges()
presentOtherWaysToGive()

View File

@@ -4,8 +4,9 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/active_subscription_gutter_start"
android:layout_marginEnd="@dimen/dsl_settings_gutter">
android:background="?selectableItemBackground"
android:paddingStart="@dimen/active_subscription_gutter_start"
android:paddingEnd="@dimen/dsl_settings_gutter">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"