@@ -20,10 +20,12 @@ import androidx.compose.foundation.layout.fillMaxWidth
2020import androidx.compose.foundation.layout.height
2121import androidx.compose.foundation.layout.offset
2222import androidx.compose.foundation.layout.padding
23+ import androidx.compose.foundation.layout.requiredWidth
2324import androidx.compose.foundation.layout.size
2425import androidx.compose.foundation.layout.statusBarsIgnoringVisibility
2526import androidx.compose.foundation.layout.width
2627import androidx.compose.foundation.layout.windowInsetsPadding
28+ import androidx.compose.foundation.layout.wrapContentHeight
2729import androidx.compose.material.Text
2830import androidx.compose.runtime.Composable
2931import androidx.compose.runtime.getValue
@@ -59,6 +61,7 @@ import com.getcode.model.KinAmount
5961import com.getcode.solana.keys.Key32.Companion.kinMint
6062import com.getcode.solana.keys.base58
6163import com.getcode.theme.CodeTheme
64+ import com.getcode.ui.utils.debugBounds
6265import com.getcode.util.formattedRaw
6366import com.getcode.ui.utils.nonScaledSp
6467import com.getcode.ui.utils.punchCircle
@@ -167,12 +170,16 @@ private class CashBillGeometry(width: Dp, height: Dp) {
167170 val codeSize: Dp
168171 get() = size.width * 0.6f
169172
173+ val globeWidth: Dp
174+ get() = size.width * 1.45f
170175 val globePosition: Offset
171176 get() = Offset (
172- x = - (size.width.value * 1.25f ),
173- y = size.height.value * 0.5f
177+ x = - (size.width.value * 0.75f ),
178+ y = size.height.value * 0.65f
174179 )
175180
181+ val gridWidth: Dp
182+ get() = size.width * 1.75f
176183
177184 val linesHeight: Dp
178185 get() = (topStripHeight.value - 2 ).dp
@@ -235,41 +242,49 @@ internal fun CashBill(
235242 image = ImageBitmap .imageResource(R .drawable.ic_bill_hexagons),
236243 blendMode = BlendMode .Multiply ,
237244 alpha = 0.6f ,
238- fill = true ,
239- )
240-
241- // Waves
242- BillDecorImage (
243- modifier = Modifier
244- .matchParentSize()
245- .clipToBounds(),
246- image = ImageBitmap .imageResource(R .drawable.ic_bill_waves),
247- fill = true ,
248- topLeft = Offset (
249- x = 0f ,
250- y = with (LocalDensity .current) { geometry.securityStripPosition.y.toPx() }),
251245 )
246+ // Grid pattern
247+ CashBillAssets .grid?.let {
248+ Image (
249+ modifier = Modifier
250+ .requiredWidth(geometry.gridWidth)
251+ .clipToBounds(),
252+ alpha = 0.5f ,
253+ bitmap = it,
254+ contentDescription = null
255+ )
256+ }
252257
253258 // Globe
254- BillDecorImage (
255- modifier = Modifier
256- .matchParentSize()
257- .clipToBounds(),
258- size = DpSize (width = geometry.size.width * 1.45f , height = Dp .Unspecified ),
259- image = CashBillAssets .globe,
260- topLeft = geometry.globePosition
261- )
259+ CashBillAssets .globe?.let {
260+ Image (
261+ modifier = Modifier
262+ .requiredWidth(geometry.globeWidth)
263+ .offset {
264+ IntOffset (
265+ x = geometry.globePosition.x.toInt(),
266+ y = geometry.globePosition.y.toInt()
267+ )
268+ },
269+ bitmap = it,
270+ contentDescription = null
271+ )
272+ }
262273
263- // Grid pattern
264- BillDecorImage (
274+ // Waves
275+ Image (
265276 modifier = Modifier
266277 .matchParentSize()
278+ .offset {
279+ IntOffset (
280+ x = 0 ,
281+ y = geometry.securityStripPosition.y.roundToPx(),
282+ )
283+ }
267284 .clipToBounds(),
268- image = CashBillAssets .grid,
269- alpha = 0.5f ,
270- topLeft = Offset (
271- x = 0f ,
272- y = with (LocalDensity .current) { geometry.securityStripPosition.y.toPx() }),
285+ contentDescription = null ,
286+ contentScale = ContentScale .FillBounds ,
287+ bitmap = ImageBitmap .imageResource(R .drawable.ic_bill_waves),
273288 )
274289
275290 // Security strip
@@ -408,36 +423,22 @@ private fun BillDecorImage(
408423 size : DpSize = DpSize .Unspecified ,
409424 topLeft : Offset = Offset .Zero ,
410425 blendMode : BlendMode = DrawScope .DefaultBlendMode ,
411- fill : Boolean = false,
412426) {
413427 Canvas (
414428 modifier = modifier,
415429 ) {
416430 // Hexagons
417431 image?.let {
418- if (fill) {
419- drawImage(
420- image = it,
421- dstSize = IntSize (
422- width = if (size.isSpecified && size.width.isSpecified) size.width.roundToPx() else this .size.width.toInt(),
423- height = if (size.isSpecified && size.height.isSpecified) size.height.roundToPx() else this .size.height.toInt(),
424- ),
425- alpha = alpha,
426- dstOffset = IntOffset (topLeft.x.roundToInt(), topLeft.y.roundToInt()),
427- blendMode = blendMode,
428- )
429- } else {
430- drawImage(
431- image = it,
432- alpha = alpha,
433- dstSize = IntSize (
434- width = if (size.isSpecified && size.width.isSpecified) size.width.roundToPx() else this .size.width.toInt(),
435- height = if (size.isSpecified && size.height.isSpecified) size.height.roundToPx() else this .size.height.toInt(),
436- ),
437- dstOffset = IntOffset (topLeft.x.roundToInt(), topLeft.y.roundToInt()),
438- blendMode = blendMode,
439- )
440- }
432+ drawImage(
433+ image = it,
434+ dstSize = IntSize (
435+ width = if (size.isSpecified && size.width.isSpecified) size.width.roundToPx() else this .size.width.toInt(),
436+ height = if (size.isSpecified && size.height.isSpecified) size.height.roundToPx() else this .size.height.toInt(),
437+ ),
438+ alpha = alpha,
439+ dstOffset = IntOffset (topLeft.x.roundToInt(), topLeft.y.roundToInt()),
440+ blendMode = blendMode,
441+ )
441442 }
442443 }
443444}
0 commit comments