From 2ed03d861dd46805ce85105b5821d081221a30b0 Mon Sep 17 00:00:00 2001 From: Xinto Date: Sat, 30 Mar 2024 16:38:12 +0400 Subject: [PATCH] Fix the pin button colors --- .../mauth/ui/component/pinboard/PinButton.kt | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/xinto/mauth/ui/component/pinboard/PinButton.kt b/app/src/main/java/com/xinto/mauth/ui/component/pinboard/PinButton.kt index 401a309..1d2f37c 100644 --- a/app/src/main/java/com/xinto/mauth/ui/component/pinboard/PinButton.kt +++ b/app/src/main/java/com/xinto/mauth/ui/component/pinboard/PinButton.kt @@ -58,6 +58,7 @@ fun PrimaryPinButton( shapes = shapes, content = content ) + @Composable fun PinButton( onClick: () -> Unit, @@ -110,30 +111,43 @@ object PinButtonDefaults { const val AnimationDurationRelease = 150 @Composable - fun plainPinButtonColors(): PinButtonColors { + fun plainPinButtonColors( + backgroundColor: Color = MaterialTheme.colorScheme.surfaceColorAtElevation(3.dp), + backgroundColorPressed: Color = MaterialTheme.colorScheme.primary, + foregroundColor: Color = MaterialTheme.colorScheme.onSurface, + foregroundColorPressed: Color = MaterialTheme.colorScheme.onPrimary + ): PinButtonColors { return PinButtonColors( - backgroundColor = MaterialTheme.colorScheme.surfaceColorAtElevation(3.dp), - backgroundColorPressed = MaterialTheme.colorScheme.primary, - foregroundColor = MaterialTheme.colorScheme.onSurface, - foregroundColorPressed = MaterialTheme.colorScheme.onPrimary + backgroundColor = backgroundColor, + backgroundColorPressed = backgroundColorPressed, + foregroundColor = foregroundColor, + foregroundColorPressed = foregroundColorPressed ) } @Composable - fun primaryPinButtonColors(): PinButtonColors { + fun primaryPinButtonColors( + backgroundColor: Color = MaterialTheme.colorScheme.secondary, + backgroundColorPressed: Color = MaterialTheme.colorScheme.primary, + foregroundColor: Color = MaterialTheme.colorScheme.onSecondary, + foregroundColorPressed: Color = MaterialTheme.colorScheme.onPrimary + ): PinButtonColors { return PinButtonColors( - backgroundColor = MaterialTheme.colorScheme.secondary, - backgroundColorPressed = MaterialTheme.colorScheme.primary, - foregroundColor = MaterialTheme.colorScheme.onSecondary, - foregroundColorPressed = MaterialTheme.colorScheme.onPrimary + backgroundColor = backgroundColor, + backgroundColorPressed = backgroundColorPressed, + foregroundColor = foregroundColor, + foregroundColorPressed = foregroundColorPressed ) } @Composable - fun plainPinButtonShapes(): PinButtonShapes { + fun plainPinButtonShapes( + shape: CornerBasedShape = RoundedCornerShape(50), + shapePressed: CornerBasedShape = MaterialTheme.shapes.large + ): PinButtonShapes { return PinButtonShapes( - shape = RoundedCornerShape(50), - shapePressed = MaterialTheme.shapes.large + shape = shape, + shapePressed = shapePressed ) } @@ -148,7 +162,7 @@ data class PinButtonColors( ) { @Composable fun getBackgroundColor(interactionSource: InteractionSource): State { - val animatable = remember { Animatable(backgroundColor) } + val animatable = remember(backgroundColor) { Animatable(backgroundColor) } return animatePressValue( animatable = animatable, initialValue = backgroundColor, @@ -159,7 +173,7 @@ data class PinButtonColors( @Composable fun getForegroundColor(interactionSource: InteractionSource): State { - val animatable = remember { Animatable(foregroundColor) } + val animatable = remember(foregroundColor) { Animatable(foregroundColor) } return animatePressValue( animatable = animatable, initialValue = foregroundColor,