Updated on 2026-08-14

This commit is contained in:
Tangem 2023-04-07 20:39:24 +08:00
parent 069605e151
commit 36516c900f
234 changed files with 902 additions and 1618 deletions

View file

@ -8,10 +8,7 @@ import androidx.compose.runtime.CompositionLocalProvider
* Used for disable ripple if button is enable = false
*/
@Composable
fun ToggledRippleTheme(
isEnabled: Boolean,
content: @Composable () -> Unit,
) {
fun ToggledRippleTheme(isEnabled: Boolean, content: @Composable () -> Unit) {
val theme = LocalRippleTheme provides if (isEnabled) LocalRippleTheme.current else NoRippleTheme()
CompositionLocalProvider(theme) { content() }
}

View file

@ -53,16 +53,22 @@ fun ComposeDialogManager() {
ShowTheDialog(dialogSate)
LaunchedEffect(key1 = Unit, block = {
domainStore.subscribe(subscriber) { state ->
state.skipRepeats { oldState, newState ->
oldState.globalState == newState.globalState
}.select { it.globalState }
}
})
DisposableEffect(key1 = Unit, effect = {
onDispose { domainStore.unsubscribe(subscriber) }
})
LaunchedEffect(
key1 = Unit,
block = {
domainStore.subscribe(subscriber) { state ->
state.skipRepeats { oldState, newState ->
oldState.globalState == newState.globalState
}.select { it.globalState }
}
},
)
DisposableEffect(
key1 = Unit,
effect = {
onDispose { domainStore.unsubscribe(subscriber) }
},
)
}
@Composable
@ -77,7 +83,7 @@ private fun ShowTheDialog(dialogState: MutableState<DomainDialog?>) {
is DomainDialog.DialogError -> ErrorDialog(
title = stringResource(id = R.string.common_error),
body = errorConverter.convert(dialog.error).message,
onDismissRequest
onDismissRequest,
)
is DomainDialog.SelectTokenDialog -> SelectTokenNetworkDialog(dialog, onDismissRequest)
else -> {}
@ -97,14 +103,14 @@ fun <T> SimpleDialog(
) {
Dialog(
properties = DialogProperties(false, false),
onDismissRequest = { }
onDismissRequest = { },
) {
Surface(
modifier = Modifier.fillMaxWidth(),
shape = MaterialTheme.shapes.medium
shape = MaterialTheme.shapes.medium,
) {
Column(
modifier = Modifier.padding(22.dp)
modifier = Modifier.padding(22.dp),
) {
DialogTitle(title = title)
LazyColumn {
@ -133,19 +139,15 @@ private fun DialogTitle(title: String) {
style = LocalTextStyle.provides(
TextStyle(
fontWeight = FontWeight.Bold,
fontSize = 20.sp
)
).value
fontSize = 20.sp,
),
).value,
)
SpacerH16()
}
@Composable
fun ErrorDialog(
title: String,
body: String,
onDismissRequest: () -> Unit,
) {
fun ErrorDialog(title: String, body: String, onDismissRequest: () -> Unit) {
AlertDialog(
title = { DialogTitle(title) },
text = { Text(body) },
@ -154,6 +156,6 @@ fun ErrorDialog(
Button(onClick = onDismissRequest) {
Text(text = stringResource(id = R.string.common_ok))
}
}
},
)
}

View file

@ -15,11 +15,7 @@ import androidx.compose.ui.unit.dp
[REDACTED_AUTHOR]
*/
@Composable
fun ErrorView(
text: String,
modifier: Modifier = Modifier,
style: TextStyle = LocalTextStyle.current,
) {
fun ErrorView(text: String, modifier: Modifier = Modifier, style: TextStyle = LocalTextStyle.current) {
Text(
text,
color = MaterialTheme.colors.error,

View file

@ -213,10 +213,7 @@ private fun OutlinedProgressTextField(
}
@Composable
private fun AnimatedErrorView(
errorConverter: ModuleMessageConverter,
error: ModuleError? = null,
) {
private fun AnimatedErrorView(errorConverter: ModuleMessageConverter, error: ModuleError? = null) {
AnimatedVisibility(
visible = error != null,
enter = fadeIn() + slideInVertically(),

View file

@ -110,10 +110,7 @@ fun PinCodeWidget(
}
@Composable
private fun PinElement(
config: PinViewConfig,
pinSymbol: String,
) {
private fun PinElement(config: PinViewConfig, pinSymbol: String) {
Box(Modifier.padding(config.pinBoxPadding)) {
Box(config.pinBoxModifier) {
Text(

View file

@ -128,11 +128,7 @@ internal data class TangemTextFieldColors(
}
@Composable
override fun labelColor(
enabled: Boolean,
error: Boolean,
interactionSource: InteractionSource,
): State<Color> {
override fun labelColor(enabled: Boolean, error: Boolean, interactionSource: InteractionSource): State<Color> {
val focused by interactionSource.collectIsFocusedAsState()
val targetValue = when {

View file

@ -12,16 +12,13 @@ import androidx.compose.ui.unit.sp
*/
@Composable
fun TitleSubtitle(
title: String,
subtitle: String
) {
fun TitleSubtitle(title: String, subtitle: String) {
Column {
Text(text = title)
Text(
text = subtitle,
fontSize = 12.sp,
color = Color.Gray
color = Color.Gray,
)
}
}

View file

@ -21,11 +21,7 @@ import com.tangem.wallet.R
[REDACTED_AUTHOR]
*/
@Composable
fun AddCustomTokenWarning(
warning: ModuleMessage,
converter: ModuleMessageConverter,
modifier: Modifier = Modifier,
) {
fun AddCustomTokenWarning(warning: ModuleMessage, converter: ModuleMessageConverter, modifier: Modifier = Modifier) {
Surface(
modifier = modifier,
shape = MaterialTheme.shapes.small,
@ -39,14 +35,14 @@ fun AddCustomTokenWarning(
text = stringResource(id = R.string.common_warning),
color = colorResource(id = R.color.white),
fontSize = 14.sp,
fontWeight = FontWeight.Bold
fontWeight = FontWeight.Bold,
)
SpacerH8()
Text(
text = converter.convert(warning).message,
color = colorResource(id = R.color.white),
fontSize = 13.sp,
lineHeight = 18.sp
lineHeight = 18.sp,
)
}
}

View file

@ -1,6 +1,10 @@
package com.tangem.tap.common.compose.extensions
import androidx.compose.animation.core.*
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.AnimationVector1D
import androidx.compose.animation.core.Easing
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
@ -41,8 +45,8 @@ fun animatable(
targetValue = values.second,
animationSpec = tween(
durationMillis = duration,
easing = easing
)
easing = easing,
),
)
}
}