Skip to content

Commit

Permalink
Show paid feature info in bottomsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Dec 27, 2024
1 parent f33def7 commit 67f5bd7
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ object BuySubscriptionModel {
else -> throw IllegalArgumentException("Unknown IPaidAction")
}

val IPaidAction.bigDescriptionStringRes: Int
get() = when (this) {
TokenInsights -> R.string.Premium_UpgradeFeature_TokenInsights_BigDescription
AdvancedSearch -> R.string.Premium_UpgradeFeature_AdvancedSearch_BigDescription
TradeSignals -> R.string.Premium_UpgradeFeature_TradeSignals_BigDescription
FavorableSwaps -> R.string.Premium_UpgradeFeature_FavorableSwaps_BigDescription
TransactionSpeedTools -> R.string.Premium_UpgradeFeature_TxSpeedTools_BigDescription
DuressMode -> R.string.Premium_UpgradeFeature_DuressMode_BigDescription
AddressVerification -> R.string.Premium_UpgradeFeature_AddressVerification_BigDescription
Tor -> R.string.Premium_UpgradeFeature_Tor_BigDescription
PrivacyMode -> R.string.Premium_UpgradeFeature_PrivacyMode_BigDescription
VIPSupport -> R.string.Premium_UpgradeFeature_VipSupport_BigDescription
VIPClub -> R.string.Premium_UpgradeFeature_VipClub_BigDescription
else -> throw IllegalArgumentException("Unknown IPaidAction")
}

val IPaidAction.iconRes: Int
get() = when (this) {
TokenInsights -> R.drawable.prem_portfolio_24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand All @@ -47,11 +48,17 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavController
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.modules.evmfee.ButtonsGroupWithShade
import io.horizontalsystems.bankwallet.modules.usersubscription.BuySubscriptionModel.bigDescriptionStringRes
import io.horizontalsystems.bankwallet.modules.usersubscription.BuySubscriptionModel.iconRes
import io.horizontalsystems.bankwallet.modules.usersubscription.BuySubscriptionModel.titleStringRes
import io.horizontalsystems.bankwallet.modules.usersubscription.BuySubscriptionViewModel
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.components.RadialBackground
import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer
import io.horizontalsystems.bankwallet.ui.compose.components.body_bran
import io.horizontalsystems.bankwallet.ui.compose.components.body_grey
import io.horizontalsystems.bankwallet.ui.extensions.BottomSheetHeader
import io.horizontalsystems.subscriptions.core.IPaidAction
import io.horizontalsystems.subscriptions.core.Subscription
import kotlinx.coroutines.launch

Expand All @@ -70,11 +77,15 @@ fun SelectSubscriptionScreen(

val coroutineScope = rememberCoroutineScope()
val selectedTabIndex = remember { mutableStateOf(0) }
val modalBottomSheetState =
val plansModalBottomSheetState =
androidx.compose.material3.rememberModalBottomSheetState(skipPartiallyExpanded = true)
var isBottomSheetVisible by remember { mutableStateOf(false) }
val infoModalBottomSheetState =
androidx.compose.material3.rememberModalBottomSheetState(skipPartiallyExpanded = true)
var isPlanSelectBottomSheetVisible by remember { mutableStateOf(false) }
var isInfoBottomSheetVisible by remember { mutableStateOf(false) }
val scrollScope = rememberCoroutineScope()
val pagerState = rememberPagerState(initialPage = selectedTabIndex.value) { 2 }
var infoBottomSheetAction: IPaidAction? = null

Scaffold(
backgroundColor = ComposeAppTheme.colors.tyler,
Expand Down Expand Up @@ -125,7 +136,16 @@ fun SelectSubscriptionScreen(
state = pagerState,
userScrollEnabled = false
) { page ->
PlanItems(subscriptions[page].actions)
PlanItems(
items = subscriptions[page].actions,
onItemClick = { action ->
infoBottomSheetAction = action
coroutineScope.launch {
isInfoBottomSheetVisible = true
infoModalBottomSheetState.show()
}
}
)
}
VSpacer(32.dp)
}
Expand All @@ -142,8 +162,8 @@ fun SelectSubscriptionScreen(
brush = yellowGradient,
onClick = {
coroutineScope.launch {
isBottomSheetVisible = true
modalBottomSheetState.show()
isPlanSelectBottomSheetVisible = true
plansModalBottomSheetState.show()
}
},
)
Expand All @@ -159,26 +179,78 @@ fun SelectSubscriptionScreen(
}
}
}
if (isBottomSheetVisible) {
if (isPlanSelectBottomSheetVisible) {
SubscriptionBottomSheet(
modalBottomSheetState = modalBottomSheetState,
modalBottomSheetState = plansModalBottomSheetState,
subscriptions = subscriptions,
selectedTabIndex = selectedTabIndex,
navController = navController,
hideBottomSheet = {
coroutineScope.launch {
modalBottomSheetState.hide()
plansModalBottomSheetState.hide()
}
isBottomSheetVisible = false
isPlanSelectBottomSheetVisible = false
}
)
}
if (isInfoBottomSheetVisible) {
infoBottomSheetAction?.let {
InfoBottomSheet(
icon = it.iconRes,
title = stringResource(it.titleStringRes),
description = stringResource(it.bigDescriptionStringRes),
hideBottomSheet = {
coroutineScope.launch {
infoModalBottomSheetState.hide()
}
infoBottomSheetAction = null
isInfoBottomSheetVisible = false
}
)
}
}
}
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun InfoBottomSheet(
icon: Int,
title: String,
description: String,
hideBottomSheet: () -> Unit
) {
ModalBottomSheet(
onDismissRequest = hideBottomSheet,
sheetState = androidx.compose.material3.rememberModalBottomSheetState(skipPartiallyExpanded = true),
containerColor = ComposeAppTheme.colors.transparent
) {
BottomSheetHeader(
iconPainter = painterResource(icon),
title = title,
titleColor = ComposeAppTheme.colors.jacob,
iconTint = ColorFilter.tint(ComposeAppTheme.colors.jacob),
onCloseClick = hideBottomSheet
) {
Column(
modifier = Modifier
.padding(vertical = 12.dp, horizontal = 32.dp)
.fillMaxWidth()
) {
body_bran(
text = description,
modifier = Modifier.fillMaxWidth(),
)
VSpacer(52.dp)
}
}
}

}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun SubscriptionBottomSheet(
modalBottomSheetState: SheetState,
subscriptions: List<Subscription>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,18 @@ fun SubscriptionOption(
}

@Composable
fun PlanItems(items: List<IPaidAction>) {
fun PlanItems(
items: List<IPaidAction>,
onItemClick: (IPaidAction) -> Unit
) {
Column {
items.forEachIndexed { index, item ->
PremiumFeatureItem(
icon = item.iconRes,
title = item.titleStringRes,
subtitle = item.descriptionStringRes,
tint = if (item is VIPClub || item is VIPSupport) ComposeAppTheme.colors.jacob else ComposeAppTheme.colors.leah
tint = if (item is VIPClub || item is VIPSupport) ComposeAppTheme.colors.jacob else ComposeAppTheme.colors.leah,
click = { onItemClick(item) }
)
if (index < items.size - 1) {
Divider(color = ComposeAppTheme.colors.steel20)
Expand All @@ -246,6 +250,7 @@ fun PremiumFeatureItem(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.clickable { click() }
.background(ComposeAppTheme.colors.steel10)
.padding(vertical = 12.dp, horizontal = 16.dp)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@ import android.view.View
import android.widget.FrameLayout
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
Expand All @@ -25,7 +35,10 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.components.*
import io.horizontalsystems.bankwallet.ui.compose.components.HsIconButton
import io.horizontalsystems.bankwallet.ui.compose.components.body_grey
import io.horizontalsystems.bankwallet.ui.compose.components.body_leah
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey

open class BaseComposableBottomSheetFragment : BottomSheetDialogFragment() {

Expand Down Expand Up @@ -58,19 +71,22 @@ fun BottomSheetHeader(
iconPainter: Painter,
title: String,
onCloseClick: () -> Unit,
titleColor: Color = ComposeAppTheme.colors.leah,
iconTint: ColorFilter? = null,
content: @Composable() (ColumnScope.() -> Unit),
) {
BottomSheetHeader(
iconPainter = iconPainter,
titleContent = {
headline2_leah(
Text(
text = title,
modifier = Modifier
.padding(horizontal = 16.dp)
.weight(1f)
.align(Alignment.CenterVertically),
text = title,
maxLines = 1,
style = ComposeAppTheme.typography.headline2,
color = titleColor,
)
},
onCloseClick = onCloseClick,
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,18 @@
<string name="Premium_UpgradeFeature_Tor_Description">Secure connection.</string>
<string name="Premium_UpgradeFeature_PrivacyMode_Description">Full disconnection from data collection.</string>

<string name="Premium_UpgradeFeature_VipSupport_BigDescription">Fast response support.</string>
<string name="Premium_UpgradeFeature_VipClub_BigDescription">Private chat with exclusive information.</string>
<string name="Premium_UpgradeFeature_TokenInsights_BigDescription">Token Insights provides a comprehensive view of a token’s activity and performance metrics. This includes trading volume, liquidity levels, holder behavior, total value locked (TVL), and transaction activity. By offering detailed analytics, the feature enables users to evaluate token potential, monitor market trends, and make data-driven investment decisions. It’s a powerful tool for those who seek to understand token ecosystems and market dynamics in-depth.</string>
<string name="Premium_UpgradeFeature_AdvancedSearch_BigDescription">Custom filters for token searches.</string>
<string name="Premium_UpgradeFeature_TradeSignals_BigDescription">Signals for confident trading.</string>
<string name="Premium_UpgradeFeature_FavorableSwaps_BigDescription">Swaps with no extra fees.</string>
<string name="Premium_UpgradeFeature_TxSpeedTools_BigDescription">Speed up and cancel transactions.</string>
<string name="Premium_UpgradeFeature_DuressMode_BigDescription">Hides main wallets in case of coercion.</string>
<string name="Premium_UpgradeFeature_AddressVerification_BigDescription">Additional address check for fraud prevention.</string>
<string name="Premium_UpgradeFeature_Tor_BigDescription">Secure connection.</string>
<string name="Premium_UpgradeFeature_PrivacyMode_BigDescription">Full disconnection from data collection.</string>

<string name="Premium_SubscriptionPeriod_Month">month</string>
<string name="Premium_SubscriptionPeriod_Year">year</string>

Expand Down

0 comments on commit 67f5bd7

Please sign in to comment.