Skip to content

Commit

Permalink
show correct subscription options
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Sep 15, 2023
1 parent 06cbc66 commit d620dff
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.habitrpg.android.habitica.models.shops.ShopItem
import com.habitrpg.android.habitica.models.social.Group
import com.habitrpg.android.habitica.ui.adapter.inventory.ShopRecyclerAdapter
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
import com.habitrpg.android.habitica.ui.fragments.purchases.EventOutcomeSubscriptionBottomSheetFragment
import com.habitrpg.android.habitica.ui.fragments.purchases.SubscriptionBottomSheetFragment
import com.habitrpg.android.habitica.ui.helpers.SafeDefaultItemAnimator
import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
Expand Down Expand Up @@ -118,7 +119,9 @@ open class ShopFragment : BaseMainFragment<FragmentRefreshRecyclerviewBinding>()
adapter?.onShowPurchaseDialog = { item, isPinned ->
if (item.key == "gem" && userViewModel.user.value?.isSubscribed != true) {
Analytics.sendEvent("View gems for gold CTA", EventCategory.BEHAVIOUR, HitType.EVENT)
val subscriptionBottomSheet = SubscriptionBottomSheetFragment()
val subscriptionBottomSheet = EventOutcomeSubscriptionBottomSheetFragment().apply {
eventType = EventOutcomeSubscriptionBottomSheetFragment.EVENT_GEMS_FOR_GOLD
}
activity?.let { activity ->
subscriptionBottomSheet.show(activity.supportFragmentManager, SubscriptionBottomSheetFragment.TAG)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class EventOutcomeSubscriptionBottomSheetFragment : SubscriptionBottomSheetFragm
when (eventType) {
EVENT_ARMOIRE_OPENED -> setArmoireEventSubscriptionViews()
EVENT_DEATH_SCREEN -> setDeathScreenEventSubscriptionViews()
EVENT_GEMS_FOR_GOLD -> setGemsForGoldEventSubscriptionViews()
}

}
Expand All @@ -29,9 +30,17 @@ class EventOutcomeSubscriptionBottomSheetFragment : SubscriptionBottomSheetFragm
binding.subscriberBenefits.hideDeathBenefit()
}

private fun setGemsForGoldEventSubscriptionViews() {
binding.subscriberBenefitBanner.visibility = View.GONE
binding.subscribeBenefits.text = getString(R.string.subscribe_gems_for_gold_incentive_text)
binding.subscriberBenefits.hideGemsForGoldBenefit()
binding.subscription3month.visibility = View.GONE
}

companion object {
const val TAG = "EventOutcomeSubscriptionBottomSheet"
const val EVENT_ARMOIRE_OPENED = "armoire_opened"
const val EVENT_DEATH_SCREEN = "death_screen"
const val EVENT_GEMS_FOR_GOLD = "gems_for_gold"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ open class SubscriptionBottomSheetFragment : BottomSheetDialogFragment() {
private fun buttonForSku(sku: String?): SubscriptionOptionView? {
return when (sku) {
PurchaseTypes.Subscription1Month -> binding.subscription1month
PurchaseTypes.Subscription3Month -> binding.subscription1month
PurchaseTypes.Subscription3Month -> binding.subscription3month
PurchaseTypes.Subscription12Month -> binding.subscription12month
else -> null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,8 @@ class SubscriberBenefitView @JvmOverloads constructor(
fun hideArmoireBenefit() {
binding.benefitArmoireWrapper.isVisible = false
}

fun hideGemsForGoldBenefit() {
binding.benefitGemsForGoldWrapper.isVisible = false
}
}

0 comments on commit d620dff

Please sign in to comment.