package com.suno.android.common_ui.components.aura import android.os.Build.VERSION import android.os.Build.VERSION_CODES import androidx.compose.runtime.Composable import androidx.compose.runtime.Stable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.DrawModifier import androidx.compose.ui.graphics.drawscope.ContentDrawScope @Composable @Stable fun Modifier.auraBackground( style: AuraStyle = AuraStyle(), enabled: Boolean = true, ): Modifier { if (VERSION.SDK_INT < VERSION_CODES.TIRAMISU) return this val state = rememberAuraState(enabled) val shaderBrush = rememberAuraBrush(style) val auraModifier = remember(state, shaderBrush) { AuraBackground( shaderBrush = shaderBrush, state = state, ) } return this.then(auraModifier) } internal class AuraBackground( private val shaderBrush: AuraBrush, private val state: AuraState, ) : DrawModifier { override fun ContentDrawScope.draw() { shaderBrush.update(state.time, state.enabledScalar.value) drawRect(shaderBrush.brush) drawContent() } }