Skip to content

Commit 02936b6

Browse files
authored
Merge pull request #152 from code-payments/chore/bill-3
style: refine bill image rendering a bit more
2 parents ca20fb5 + 5004cfd commit 02936b6

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

  • app/src/main/java/com/getcode/view/main/bill

app/src/main/java/com/getcode/view/main/bill/CashBill.kt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ private class CashBillGeometry(width: Dp, height: Dp) {
181181
val gridWidth: Dp
182182
get() = size.width * 1.75f
183183

184+
val gridPosition: Offset
185+
get() = Offset(
186+
x = 0f,
187+
y = securityStripPosition.y.value
188+
)
189+
184190
val linesHeight: Dp
185191
get() = (topStripHeight.value - 2).dp
186192
val lineSpacing: Dp
@@ -203,6 +209,12 @@ private class CashBillGeometry(width: Dp, height: Dp) {
203209
val valuePadding: Dp
204210
get() = ceil(size.width.value * 0.025f).dp
205211

212+
val wavesPosition: Offset
213+
get() = Offset(
214+
x = (size.width.value * 0.5f),
215+
y = topStripHeight.value + securityStripSize.height.value + securityStripPosition.y.value
216+
)
217+
206218
init {
207219
size = DpSize(width, height)
208220
}
@@ -230,6 +242,7 @@ internal fun CashBill(
230242
.fillMaxHeight()
231243
.fillMaxWidth(0.95f)
232244
.background(CashBillDefaults.BillColor)
245+
.clipToBounds()
233246
) {
234247
val geometry = remember(maxWidth, maxHeight) {
235248
CashBillGeometry(maxWidth, maxHeight)
@@ -248,7 +261,12 @@ internal fun CashBill(
248261
Image(
249262
modifier = Modifier
250263
.requiredWidth(geometry.gridWidth)
251-
.clipToBounds(),
264+
.offset {
265+
IntOffset(
266+
x = geometry.gridPosition.x.toInt(),
267+
y = geometry.gridPosition.y.toInt()
268+
)
269+
},
252270
alpha = 0.5f,
253271
bitmap = it,
254272
contentDescription = null
@@ -274,14 +292,14 @@ internal fun CashBill(
274292
// Waves
275293
Image(
276294
modifier = Modifier
277-
.matchParentSize()
295+
.requiredWidth(geometry.globeWidth)
296+
.fillMaxHeight()
278297
.offset {
279298
IntOffset(
280-
x = 0,
281-
y = geometry.securityStripPosition.y.roundToPx(),
299+
x = geometry.wavesPosition.x.toInt(),
300+
y = geometry.wavesPosition.y.toInt(),
282301
)
283-
}
284-
.clipToBounds(),
302+
},
285303
contentDescription = null,
286304
contentScale = ContentScale.FillBounds,
287305
bitmap = ImageBitmap.imageResource(R.drawable.ic_bill_waves),

0 commit comments

Comments
 (0)