Skip to content

Commit 5c5ba27

Browse files
authored
feat(bills): add GoldBar composable with holographic tilt effect (#879)
- Add GoldBar composable with AGSL RuntimeShader metallic PBR rendering (API 33+) and classic Canvas fallback - Device tilt sensor (3-axis: pitch, roll, yaw) drives holographic specular sweeps via SensorManager - Low-pass filter + dead zone prevents sensor noise jitter on emulators - Dynamic reference pitch/azimuth capture adapts to hand-held orientation - RenderedBill selects GoldBar UI by mint address instead of sealed class variant - Fix protobuf round-trip bug: use launchpadCurrencyReserveStateOrNull to prevent empty message serialization for USDF Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 10f2c5f commit 5c5ba27

11 files changed

Lines changed: 1330 additions & 73 deletions

File tree

apps/flipcash/features/scanner/src/main/kotlin/com/flipcash/app/scanner/internal/bills/BillContainerView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ internal fun BillContainer(
279279
//Bill Received Bottom Dialog
280280
AnimatedVisibility(
281281
modifier = Modifier.align(BottomCenter),
282-
visible = (updatedBillState.bill as? Bill.Cash)?.didReceive ?: false,
282+
visible = updatedBillState.bill?.didReceive ?: false,
283283
enter = AnimationUtils.modalEnter(billState.confirmationDelayMillis),
284284
exit = AnimationUtils.modalExit,
285285
) {
@@ -288,7 +288,7 @@ internal fun BillContainer(
288288
contentAlignment = BottomCenter
289289
) {
290290
ReceivedFundsConfirmation(
291-
bill = updatedBillState.bill as Bill.Cash,
291+
bill = updatedBillState.bill!!,
292292
onClaim = { session.dismissBill(PutInWallet) }
293293
)
294294
}

apps/flipcash/features/scanner/src/main/kotlin/com/flipcash/app/scanner/internal/ui/modals/ReceivedFundsConfirmation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import com.getcode.ui.theme.CodeButton
2424

2525
@Composable
2626
internal fun ReceivedFundsConfirmation(
27-
bill: Bill.Cash,
27+
bill: Bill,
2828
onClaim: () -> Unit,
2929
) {
3030
val exchange = LocalExchange.current

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

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ import com.getcode.opencode.compose.LocalExchange
8484
import com.getcode.opencode.model.financial.LocalFiat
8585
import com.getcode.opencode.model.financial.Token
8686
import com.getcode.opencode.model.ui.BillBackground
87+
import com.getcode.opencode.model.ui.BillTexture
88+
import com.getcode.opencode.model.ui.TokenBillCustomizations
89+
import com.getcode.solana.keys.Mint
8790
import com.getcode.opencode.model.ui.BlendMode as PlaygroundBlendMode
8891
import com.getcode.solana.keys.base58
8992
import com.getcode.theme.CodeTheme
@@ -109,12 +112,12 @@ private object CashBillDefaults {
109112
const val AspectRatio = 0.555f
110113

111114
fun billColor(
112-
token: Token,
115+
billCustomizations: TokenBillCustomizations?,
113116
alpha: Float = 1f,
114117
startY: Float = 0f,
115118
endY: Float = Float.POSITIVE_INFINITY,
116119
): Brush {
117-
val billCustomizations = token.billCustomizations ?: return Brush.verticalGradient(
120+
val billCustomizations = billCustomizations ?: return Brush.verticalGradient(
118121
listOf(Color(0xFF06450F), Color(0xFF06450F))
119122
)
120123

@@ -144,8 +147,8 @@ private object CashBillDefaults {
144147
const val CodeBackgroundOpacity = 0.8f
145148

146149
@Composable
147-
fun punchBrushIn(punch: Punch, token: Token): Brush {
148-
val billCustomizations = token.billCustomizations
150+
fun punchBrushIn(punch: Punch,billCustomizations: TokenBillCustomizations?): Brush {
151+
val billCustomizations = billCustomizations
149152
if (billCustomizations?.background == null) {
150153
val color = Black.copy(0.15f)
151154
.compositeOver(CodeTheme.colors.cashBillColor.copy(alpha = CodeBackgroundOpacity))
@@ -291,13 +294,32 @@ private class CashBillGeometry(width: Dp, height: Dp) : Geometry(width, height)
291294
@OptIn(ExperimentalLayoutApi::class)
292295
@Composable
293296
internal fun CashBill(
294-
modifier: Modifier = Modifier,
295297
payloadData: List<Byte>,
298+
amount: LocalFiat,
296299
token: Token,
300+
modifier: Modifier = Modifier,
301+
) {
302+
CashBill(
303+
payloadData = payloadData,
304+
amount = amount,
305+
mint = token.address.base58(),
306+
billCustomizations = token.billCustomizations,
307+
modifier = modifier,
308+
)
309+
}
310+
311+
@SuppressLint("UnusedBoxWithConstraintsScope")
312+
@OptIn(ExperimentalLayoutApi::class)
313+
@Composable
314+
internal fun CashBill(
315+
payloadData: List<Byte>,
297316
amount: LocalFiat,
317+
modifier: Modifier = Modifier,
318+
billCustomizations: TokenBillCustomizations? = null,
319+
mint: String,
298320
) {
299321
val exchange = LocalExchange.current
300-
val customTexture = token.billCustomizations?.texture
322+
val customTexture = billCustomizations?.texture
301323
val hasCustomTexture = customTexture != null
302324

303325
Box(
@@ -326,7 +348,7 @@ internal fun CashBill(
326348
Box(
327349
modifier = Modifier
328350
.fillMaxSize()
329-
.background(CashBillDefaults.billColor(token), punchShape)
351+
.background(CashBillDefaults.billColor(billCustomizations), punchShape)
330352
)
331353

332354
// Texture layers — clipped with even-odd punch
@@ -412,7 +434,7 @@ internal fun CashBill(
412434
}
413435

414436
// Security strip
415-
SecurityStrip(geometry = geometry, token = token)
437+
SecurityStrip(geometry = geometry, billCustomizations = billCustomizations)
416438

417439
// Bill Value Top Left
418440
BillAmount(
@@ -462,7 +484,7 @@ internal fun CashBill(
462484
) {
463485
// Mint
464486
Text(
465-
text = token.address.base58(),
487+
text = mint,
466488
fontSize = geometry.mintFontSize,
467489
color = CashBillDefaults.DecorColor,
468490
)
@@ -508,7 +530,7 @@ internal fun CashBill(
508530
modifier = Modifier.align(Alignment.Center),
509531
geometry = geometry,
510532
data = payloadData,
511-
token = token
533+
billCustomizations = billCustomizations
512534
)
513535
}
514536
}
@@ -518,13 +540,13 @@ internal fun CashBill(
518540
private fun SecurityStrip(
519541
modifier: Modifier = Modifier,
520542
geometry: CashBillGeometry,
521-
token: Token,
543+
billCustomizations: TokenBillCustomizations?,
522544
) {
523545
Row(
524546
modifier = modifier
525547
.size(geometry.securityStripSize)
526548
.offset(geometry.securityStripPosition.x, geometry.securityStripPosition.y)
527-
.punchRectangle(CashBillDefaults.punchBrushIn(punch = Punch.SecurityStrip, token)),
549+
.punchRectangle(CashBillDefaults.punchBrushIn(punch = Punch.SecurityStrip, billCustomizations)),
528550
) {
529551
repeat(CashBillDefaults.SecurityStripCount) {
530552
Image(
@@ -590,12 +612,12 @@ private fun BillCode(
590612
modifier: Modifier = Modifier,
591613
geometry: CashBillGeometry,
592614
data: List<Byte>,
593-
token: Token
615+
billCustomizations: TokenBillCustomizations?,
594616
) {
595617
Box(
596618
modifier = modifier
597619
.punchCircle(
598-
brush = CashBillDefaults.punchBrushIn(punch = Punch.Code, token),
620+
brush = CashBillDefaults.punchBrushIn(punch = Punch.Code, billCustomizations),
599621
),
600622
contentAlignment = Alignment.Center
601623
) {
@@ -604,7 +626,7 @@ private fun BillCode(
604626
modifier = Modifier
605627
.size(geometry.codeSize),
606628
data = data,
607-
token = token
629+
billCustomizations = billCustomizations
608630
)
609631
}
610632
}

0 commit comments

Comments
 (0)