Skip to content

Commit 045a4c1

Browse files
committed
fix: clean up bill rendering discrepencies
* remove zIndex bump from globe * drop waves above globe in stack * remove gradient from grid Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 7af2f68 commit 045a4c1

2 files changed

Lines changed: 50 additions & 56 deletions

File tree

  • apps/flipcash/shared/bills/src/main/kotlin/com/flipcash/app/bills
  • ui/core/src/main/kotlin/com/getcode/ui/core

apps/flipcash/shared/bills/src/main/kotlin/com/flipcash/app/bills/CashBill.kt

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ private class CashBillGeometry(width: Dp, height: Dp) : Geometry(width, height)
288288
fontSize = 40.nonScaledSp
289289
)
290290
}
291-
292291
}
293292

294293
@SuppressLint("UnusedBoxWithConstraintsScope")
@@ -364,32 +363,7 @@ internal fun CashBill(
364363
topLeft = Offset(
365364
x = geometry.gridPosition.x,
366365
y = geometry.gridPosition.y,
367-
),
368-
alpha = 0.5f,
369-
)
370-
371-
372-
// Waves
373-
Image(
374-
modifier = Modifier
375-
.requiredWidth(geometry.globeWidth)
376-
.fillMaxHeight()
377-
.offset { IntOffset(x = geometry.wavesPosition.x.toInt(), y = 0) }
378-
.drawWithGradient(
379-
brush = { startY, endY ->
380-
CashBillDefaults.billColor(
381-
token,
382-
alpha = CashBillDefaults.CodeBackgroundOpacity,
383-
startY = startY,
384-
endY = endY
385-
)
386-
},
387-
startY = { it / 2f },
388-
blendMode = BlendMode.DstIn
389-
),
390-
contentDescription = null,
391-
contentScale = ContentScale.FillBounds,
392-
painter = painterResource(R.drawable.ic_bill_waves),
366+
)
393367
)
394368
}
395369

@@ -403,11 +377,24 @@ internal fun CashBill(
403377
x = geometry.globePosition.x.toInt(),
404378
y = geometry.globePosition.y.toInt()
405379
)
406-
}.zIndex(99f),
380+
},
407381
painter = painterResource(R.drawable.ic_bill_globe),
408382
contentDescription = null
409383
)
410384

385+
if (!hasCustomTexture) {
386+
// Waves
387+
Image(
388+
modifier = Modifier
389+
.requiredWidth(geometry.globeWidth)
390+
.fillMaxHeight()
391+
.offset { IntOffset(x = geometry.wavesPosition.x.toInt(), y = 0) },
392+
contentDescription = null,
393+
contentScale = ContentScale.FillBounds,
394+
painter = painterResource(R.drawable.ic_bill_waves),
395+
)
396+
}
397+
411398
// Security strip
412399
SecurityStrip(geometry = geometry, token = token)
413400

@@ -523,7 +510,7 @@ private fun SecurityStrip(
523510
.offset(geometry.securityStripPosition.x, geometry.securityStripPosition.y)
524511
.punchRectangle(CashBillDefaults.punchBrushIn(punch = Punch.SecurityStrip, token)),
525512
) {
526-
for (i in 0 until CashBillDefaults.SecurityStripCount) {
513+
repeat(CashBillDefaults.SecurityStripCount) {
527514
Image(
528515
modifier = Modifier
529516
.weight(1f)
@@ -543,7 +530,7 @@ private fun Lines(
543530
spacing: Dp,
544531
) {
545532
Row(modifier = modifier, horizontalArrangement = Arrangement.spacedBy(spacing)) {
546-
for (i in 0 until count) {
533+
repeat(count) {
547534
Box(
548535
modifier = Modifier
549536
.rotate(-18f)
@@ -567,7 +554,6 @@ private fun BillDecorImage(
567554
Canvas(
568555
modifier = modifier,
569556
) {
570-
// Hexagons
571557
image?.let {
572558
drawImage(
573559
image = it,
@@ -594,7 +580,7 @@ private fun BillCode(
594580
modifier = modifier
595581
.punchCircle(
596582
brush = CashBillDefaults.punchBrushIn(punch = Punch.Code, token),
597-
blendMode = BlendMode.SrcOver,
583+
// blendMode = BlendMode.SrcOver,
598584
),
599585
contentAlignment = Alignment.Center
600586
) {

ui/core/src/main/kotlin/com/getcode/ui/core/Modifier.kt

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -199,36 +199,44 @@ fun Modifier.circleBackground(color: Color, padding: Dp): Modifier {
199199
return this then backgroundModifier then layoutModifier
200200
}
201201

202-
fun Modifier.punchRectangle(color: Color, blendMode: BlendMode = BlendMode.Src) = this.drawWithContent {
203-
drawRect(
204-
color,
205-
blendMode = blendMode
206-
)
202+
fun Modifier.punchRectangle(color: Color, blendMode: BlendMode = BlendMode.Src) =
203+
this.drawWithContent {
204+
drawRect(
205+
color,
206+
blendMode = blendMode
207+
)
207208

208-
drawContent()
209-
}
209+
drawContent()
210+
}
210211

211-
fun Modifier.punchRectangle(brush: Brush, blendMode: BlendMode = BlendMode.Src) = this.drawWithContent {
212-
drawRect(
213-
brush,
214-
blendMode = blendMode
215-
)
212+
fun Modifier.punchRectangle(brush: Brush, blendMode: BlendMode = BlendMode.Src) =
213+
this.drawWithContent {
214+
drawRect(
215+
brush,
216+
blendMode = blendMode
217+
)
216218

217-
drawContent()
218-
}
219+
drawContent()
220+
}
219221

220-
fun Modifier.punchCircle(color: Color, blendMode: BlendMode = BlendMode.Src) = this.drawWithContent {
221-
drawCircle(
222-
color,
223-
blendMode = blendMode
224-
)
222+
fun Modifier.punchCircle(color: Color, blendMode: BlendMode = BlendMode.Src) =
223+
this.drawWithContent {
224+
drawCircle(
225+
color,
226+
blendMode = blendMode
227+
)
225228

226-
drawContent()
227-
}
229+
drawContent()
230+
}
228231

229232
fun Modifier.punchCircle(brush: Brush, blendMode: BlendMode = BlendMode.Src) = this.drawWithContent {
230233
drawCircle(
231-
brush,
234+
brush = brush,
235+
blendMode = BlendMode.Clear,
236+
)
237+
238+
drawCircle(
239+
brush = brush,
232240
blendMode = blendMode
233241
)
234242

@@ -271,7 +279,8 @@ fun Modifier.drawWithGradient(
271279
drawRect(
272280
brush = Brush.verticalGradient(
273281
startY = startY(height.toPx()),
274-
endY = endY(height.toPx()).takeIf { it != Float.POSITIVE_INFINITY } ?: height.toPx(),
282+
endY = endY(height.toPx()).takeIf { it != Float.POSITIVE_INFINITY }
283+
?: height.toPx(),
275284
colors = colors,
276285
),
277286
blendMode = blendMode
@@ -291,7 +300,6 @@ fun Modifier.drawWithGradient(
291300

292301
val density = LocalDensity.current
293302

294-
295303
Modifier
296304
.onPlaced {
297305
height = with(density) { it.size.height.toDp() }

0 commit comments

Comments
 (0)