Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Random/Regular buttons with Random toggle #6716

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.modules.pin.unlock.PinUnlockModule.InputState
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonSecondaryDefault
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonSecondaryYellow
import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer
import io.horizontalsystems.core.helpers.HudHelper

Expand Down Expand Up @@ -89,22 +90,28 @@ fun PinNumpad(
){
if (showRandomizer) {
VSpacer(24.dp)
ButtonSecondaryDefault(
title = if (isRandomized) {
stringResource(R.string.Unlock_Regular)
val onClick = {
isRandomized = !isRandomized
numpadNumbers = if (isRandomized) {
generateRandomNumpadNumbers()
} else {
stringResource(R.string.Unlock_Random)
},
onClick = {
isRandomized = !isRandomized
numpadNumbers = if (isRandomized) {
generateRandomNumpadNumbers()
} else {
generateOriginalNumpadNumbers()
}
},
enabled = enabled
)
generateOriginalNumpadNumbers()
}
}

if (isRandomized) {
ButtonSecondaryYellow(
title = stringResource(R.string.Unlock_Random),
onClick = onClick,
enabled = enabled,
)
} else {
ButtonSecondaryDefault(
title = stringResource(R.string.Unlock_Random),
onClick = onClick,
enabled = enabled,
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,26 @@ package io.horizontalsystems.bankwallet.ui.compose.components
import androidx.annotation.DrawableRes
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.material.Button
import androidx.compose.material.ButtonColors
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Icon
import androidx.compose.material.ProvideTextStyle
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -43,6 +59,33 @@ fun ButtonSecondaryDefault(
)
}

@Composable
fun ButtonSecondaryYellow(
modifier: Modifier = Modifier,
title: String,
onClick: () -> Unit,
enabled: Boolean = true,
) {
ButtonSecondary(
modifier = modifier,
onClick = onClick,
buttonColors = ButtonPrimaryDefaults.textButtonColors(
backgroundColor = ComposeAppTheme.colors.yellowD,
contentColor = ComposeAppTheme.colors.dark,
disabledBackgroundColor = ComposeAppTheme.colors.steel20,
disabledContentColor = ComposeAppTheme.colors.grey50,
),
content = {
Text(
title,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
},
enabled = enabled
)
}

@Composable
fun ButtonSecondaryWithIcon(
modifier: Modifier = Modifier,
Expand Down