Skip to content

Commit

Permalink
Convert Premium subscription activity to fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Dec 18, 2024
1 parent 1234e58 commit cffb1b9
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 195 deletions.
3 changes: 0 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@
<activity
android:name=".modules.keystore.KeyStoreActivity"
android:screenOrientation="portrait" />
<activity
android:name=".modules.premium.PremiumActivity"
android:screenOrientation="portrait" />

<activity-alias
android:name="${applicationId}.MainLauncherAlias"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
package io.horizontalsystems.bankwallet.modules.premium

import android.os.Bundle
import androidx.activity.compose.setContent
import android.os.Parcelable
import androidx.compose.runtime.Composable
import androidx.navigation.NavController
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import io.horizontalsystems.bankwallet.core.BaseActivity
import io.horizontalsystems.bankwallet.core.BaseComposeFragment
import io.horizontalsystems.bankwallet.core.composablePage
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.subscriptions.core.IPaidAction
import kotlinx.parcelize.Parcelize

class PremiumActivity : BaseActivity() {
class PremiumFragment : BaseComposeFragment() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContent {
ComposeAppTheme {
PremiumNavHost(
onClose = { finish() }
)
}
@Composable
override fun GetContent(navController: NavController) {
ComposeAppTheme {
PremiumNavHost(
navController = navController,
onClose = { navController.popBackStack() }
)
}
setStatusBarTransparent()
}

@Parcelize
data class Input(val action: IPaidAction) : Parcelable

@Parcelize
class Result : Parcelable
}

@Composable
fun PremiumNavHost(
navController: NavController,
onClose: () -> Unit
) {
val navController = rememberNavController()
val navHostController = rememberNavController()
NavHost(
navController = navController,
navController = navHostController,
startDestination = "select_premium_plan",
) {
composable("select_premium_plan") {
SelectPremiumPlanScreen(
navController,
navHostController,
onCloseClick = onClose
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.horizontalsystems.bankwallet.modules.premium

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
Expand All @@ -11,16 +13,14 @@ import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.paint
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.Darkest
import io.horizontalsystems.bankwallet.ui.compose.SteelLight
import io.horizontalsystems.bankwallet.ui.compose.components.RadialBackground
import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer

@Composable
Expand All @@ -29,81 +29,90 @@ fun PremiumSubscribedScreen(
onCloseClick: () -> Unit
) {
Scaffold(
backgroundColor = Darkest,
backgroundColor = ComposeAppTheme.colors.tyler,
topBar = {
TitleCenteredTopBar(
modifier = Modifier.padding(top = 24.dp),
title = stringResource(R.string.Premium_Title),
color = SteelLight,
onCloseClick = onCloseClick
)
}
) { paddingValues ->
Column(
Box(
modifier = Modifier
.padding(paddingValues)
.paint(
painterResource(id = R.drawable.prem_backround),
contentScale = ContentScale.FillBounds
),
.fillMaxSize()
) {
Column(
modifier = Modifier
.padding(paddingValues)
.weight(1f)
.verticalScroll(rememberScrollState())
)
{
VSpacer(24.dp)
Image(
painter = painterResource(id = R.drawable.prem_star_launch),
contentDescription = null,
modifier = Modifier
.height(200.dp)
.fillMaxWidth()
)
VSpacer(24.dp)
Text(
text = stringResource(R.string.Premium_ThankYouForSubscription),
style = ComposeAppTheme.typography.headline1,
color = ComposeAppTheme.colors.white,
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 44.dp)
)
val text = highlightText(
text = stringResource(
R.string.Premium_YouHaveActivatedPlan,
stringResource(type.titleResId)
),
highlightPart = stringResource(type.titleResId),
color = ComposeAppTheme.colors.jacob
)
VSpacer(12.dp)
Text(
text = text,
style = ComposeAppTheme.typography.body,
color = ComposeAppTheme.colors.grey,
textAlign = TextAlign.Center,
RadialBackground()
Column {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 32.dp)
)
VSpacer(24.dp)
}
Column(
Modifier
.padding(horizontal = 24.dp)
.padding(bottom = 56.dp)
) {
ButtonPrimaryCustomColor(
modifier = Modifier.fillMaxWidth(),
title = stringResource(R.string.Premium_GoToApp),
brush = yellowGradient,
onClick = onCloseClick,
.padding(paddingValues)
.weight(1f)
.verticalScroll(rememberScrollState())
)
{
VSpacer(24.dp)
Image(
painter = painterResource(id = R.drawable.prem_star_launch),
contentDescription = null,
modifier = Modifier
.height(200.dp)
.fillMaxWidth()
)
VSpacer(24.dp)
Text(
text = stringResource(R.string.Premium_ThankYouForSubscription),
style = ComposeAppTheme.typography.headline1,
color = ComposeAppTheme.colors.white,
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 44.dp)
)
val text = highlightText(
text = stringResource(
R.string.Premium_YouHaveActivatedPlan,
stringResource(type.titleResId)
),
highlightPart = stringResource(type.titleResId),
color = ComposeAppTheme.colors.jacob
)
VSpacer(12.dp)
Text(
text = text,
style = ComposeAppTheme.typography.body,
color = ComposeAppTheme.colors.grey,
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 32.dp)
)
VSpacer(24.dp)
}
Column(
Modifier
.padding(horizontal = 24.dp)
.padding(bottom = 56.dp)
) {
ButtonPrimaryCustomColor(
modifier = Modifier.fillMaxWidth(),
title = stringResource(R.string.Premium_GoToApp),
brush = yellowGradient,
onClick = onCloseClick,
)
}
}
}
}
}

@Preview
@Composable
fun PremiumSubscribedPreview() {
ComposeAppTheme {
PremiumSubscribedScreen(
type = PremiumPlanType.ProPlan,
onCloseClick = {}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ package io.horizontalsystems.bankwallet.modules.premium
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ExperimentalMaterialApi
Expand All @@ -32,12 +30,11 @@ import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.Darkest
import io.horizontalsystems.bankwallet.ui.compose.SteelLight
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryDefaults
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonSecondary
import io.horizontalsystems.bankwallet.ui.compose.components.HsIconButton
import io.horizontalsystems.bankwallet.ui.compose.components.SecondaryButtonDefaults.buttonColors
import io.horizontalsystems.bankwallet.ui.compose.components.headline1_leah

@Composable
fun highlightText(
Expand Down Expand Up @@ -120,7 +117,6 @@ fun ButtonPrimaryCustomColor(
@Composable
fun TitleCenteredTopBar(
title: String,
color: Color = SteelLight,
modifier: Modifier = Modifier,
onCloseClick: () -> Unit
) {
Expand All @@ -129,12 +125,8 @@ fun TitleCenteredTopBar(
.height(64.dp)
.fillMaxWidth(),
) {
Text(
headline1_leah(
text = title,
color = color,
style = ComposeAppTheme.typography.headline1,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.align(Alignment.Center)
)
HsIconButton(
Expand Down Expand Up @@ -176,33 +168,3 @@ fun ColoredTextSecondaryButton(
},
)
}

@Composable
fun ButtonsGroupWithDarkShade(
buttonsContent: @Composable (() -> Unit)
) {
Column(
modifier = Modifier.offset(y = -(24.dp))
) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(24.dp)
.background(
brush = Brush.verticalGradient(
listOf(
ComposeAppTheme.colors.transparent,
Darkest
)
)
)
)
Box(
modifier = Modifier
.background(Darkest)
.padding(bottom = 8.dp)
) {
buttonsContent()
}
}
}
Loading

0 comments on commit cffb1b9

Please sign in to comment.