Add color dancing shader effect of a critial result of a detail roll card.
This commit is contained in:
		
							parent
							
								
									244bed9ded
								
							
						
					
					
						commit
						251e2a972f
					
				
					 2 changed files with 38 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -5,6 +5,8 @@ import android.os.Build
 | 
			
		|||
import androidx.annotation.RequiresApi
 | 
			
		||||
import androidx.compose.foundation.Image
 | 
			
		||||
import androidx.compose.foundation.layout.fillMaxWidth
 | 
			
		||||
import androidx.compose.material.Text
 | 
			
		||||
import androidx.compose.material3.MaterialTheme
 | 
			
		||||
import androidx.compose.runtime.Composable
 | 
			
		||||
import androidx.compose.runtime.State
 | 
			
		||||
import androidx.compose.runtime.mutableFloatStateOf
 | 
			
		||||
| 
						 | 
				
			
			@ -20,6 +22,7 @@ import androidx.compose.ui.layout.ContentScale
 | 
			
		|||
import androidx.compose.ui.res.painterResource
 | 
			
		||||
import androidx.compose.ui.tooling.preview.Preview
 | 
			
		||||
import com.pixelized.rplexicon.R
 | 
			
		||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
 | 
			
		||||
import org.intellij.lang.annotations.Language
 | 
			
		||||
 | 
			
		||||
@Language("AGSL")
 | 
			
		||||
| 
						 | 
				
			
			@ -84,3 +87,21 @@ private fun DancingColor() {
 | 
			
		|||
        contentDescription = null,
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
 | 
			
		||||
@Composable
 | 
			
		||||
@Preview
 | 
			
		||||
private fun TextDancingColor() {
 | 
			
		||||
    LexiconTheme {
 | 
			
		||||
 | 
			
		||||
        Text(
 | 
			
		||||
            modifier = Modifier.dancingColor(
 | 
			
		||||
                transition = remember { mutableFloatStateOf(1.0f) },
 | 
			
		||||
                time = rememberTimeState(),
 | 
			
		||||
                default = Color.White,
 | 
			
		||||
            ),
 | 
			
		||||
            style = MaterialTheme.typography.displayLarge,
 | 
			
		||||
            text = "20",
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -4,6 +4,7 @@ import android.content.res.Configuration
 | 
			
		|||
import androidx.annotation.DrawableRes
 | 
			
		||||
import androidx.compose.animation.AnimatedVisibility
 | 
			
		||||
import androidx.compose.animation.animateContentSize
 | 
			
		||||
import androidx.compose.animation.core.animateFloatAsState
 | 
			
		||||
import androidx.compose.animation.expandVertically
 | 
			
		||||
import androidx.compose.animation.fadeIn
 | 
			
		||||
import androidx.compose.animation.fadeOut
 | 
			
		||||
| 
						 | 
				
			
			@ -48,6 +49,8 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider
 | 
			
		|||
import androidx.compose.ui.unit.Dp
 | 
			
		||||
import androidx.compose.ui.unit.dp
 | 
			
		||||
import com.pixelized.rplexicon.R
 | 
			
		||||
import com.pixelized.rplexicon.ui.agsl.dancingColor
 | 
			
		||||
import com.pixelized.rplexicon.ui.agsl.rememberTimeState
 | 
			
		||||
import com.pixelized.rplexicon.ui.screens.rolls.composable.ThrowsCardUio.Throw.Type
 | 
			
		||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
 | 
			
		||||
import com.pixelized.rplexicon.utilitary.extentions.annotatedSpan
 | 
			
		||||
| 
						 | 
				
			
			@ -170,7 +173,20 @@ fun ThrowsCard(
 | 
			
		|||
                    text = "=",
 | 
			
		||||
                )
 | 
			
		||||
                Text(
 | 
			
		||||
                    modifier = Modifier.widthIn(min = resultWidth),
 | 
			
		||||
                    modifier = Modifier
 | 
			
		||||
                        .widthIn(min = resultWidth)
 | 
			
		||||
                        .dancingColor(
 | 
			
		||||
                            transition = animateFloatAsState(
 | 
			
		||||
                                targetValue = if (throws.isCriticalSuccess) 1f else 0f,
 | 
			
		||||
                                label = "ShaderTransitionAnimation",
 | 
			
		||||
                            ),
 | 
			
		||||
                            time = rememberTimeState(),
 | 
			
		||||
                            default = when {
 | 
			
		||||
                                throws.isCriticalSuccess -> MaterialTheme.colorScheme.primary
 | 
			
		||||
                                throws.isCriticalFailure -> Color.Red
 | 
			
		||||
                                else -> MaterialTheme.colorScheme.onSurface
 | 
			
		||||
                            },
 | 
			
		||||
                        ),
 | 
			
		||||
                    style = MaterialTheme.typography.displaySmall,
 | 
			
		||||
                    textAlign = TextAlign.Center,
 | 
			
		||||
                    color = when {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue