Skip to content
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 @@ -5,20 +5,33 @@ import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.drawOutline
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLayoutDirection
import com.getcode.theme.CodeTheme

@Composable
fun Modifier.shimmer(
shape: Shape = CodeTheme.shapes.medium
): Modifier {
val alpha = rememberShimmerAlpha()
return this.background(Color.White.copy(alpha = alpha), shape)
val density = LocalDensity.current
val layoutDirection = LocalLayoutDirection.current
return this.drawWithCache {
val outline = shape.createOutline(size, layoutDirection, density)
onDrawBehind {
drawOutline(
outline = outline,
color = Color.White.copy(alpha = alpha),
)
}
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,13 +612,12 @@ private fun BillCode(

@Composable
private fun loadBillAsset(drawableRes: Int): ImageBitmap {
val option = BitmapFactory.Options()
option.inPreferredConfig = Bitmap.Config.ARGB_8888
return BitmapFactory.decodeResource(
LocalResources.current,
drawableRes,
option
).asImageBitmap()
val resources = LocalResources.current
return remember(drawableRes) {
val option = BitmapFactory.Options()
option.inPreferredConfig = Bitmap.Config.ARGB_8888
BitmapFactory.decodeResource(resources, drawableRes, option).asImageBitmap()
}
}

private class BillPunchShape(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ internal fun AmountTextAnimated(
}
val digitDecimalVisibility = remember(totalDecimals) { mutableStateListOf(*Array(totalDecimals) { false }) }
val digitDecimalZeroVisibility = remember(totalDecimals) { mutableStateListOf(*Array(totalDecimals) { false }) }
var firstDigit by remember(isInitiallyZero, initialAmount) { mutableStateOf(if (!isInitiallyZero && initialAmount.isNotEmpty()) initialAmount.first().toString() else "") }

//Font states
var textSize by remember { mutableStateOf(textStyle.fontSize) }
val fontDecreasePoints = remember { HashMap<Int, Float>() }
Expand All @@ -116,8 +114,10 @@ internal fun AmountTextAnimated(
val isDecimal = amountSplit.size > 1
val isZero = amountSplit[0] == "0" || amountSplit[0].isEmpty()

if (amountSplit.firstOrNull() != null && !isZero) {
firstDigit = uiModel.amountData.amountText.first().toString()
val firstDigit = remember(uiModel.amountData.amountText, isZero) {
if (!isZero && uiModel.amountData.amountText.isNotEmpty())
uiModel.amountData.amountText.first().toString()
else ""
}

fun getValue(i1: Int, i2: Int): String? =
Expand Down
Loading