refactor(ui): drop focus border from circular buttons

- Remove focusedBorderWidth/focusedBorderColor from CircularIconButton
- Add new CircularTextButton component
- Replace skip segment FilledTonalButton with CircularTextButton
- Clean up unused imports
This commit is contained in:
2026-06-19 14:32:18 +00:00
parent 1ec9ff9c95
commit 31f9fe5d4c
7 changed files with 82 additions and 56 deletions

View File

@@ -2,7 +2,6 @@ package hu.bbara.purefin.ui.common.button
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.FilledIconButton
@@ -22,7 +21,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@Composable
internal fun CircularIconButton(
fun CircularIconButton(
icon: ImageVector,
contentDescription: String?,
containerColor: Color,
@@ -31,8 +30,6 @@ internal fun CircularIconButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
focusedScale: Float = 1f,
focusedBorderWidth: Dp,
focusedBorderColor: Color,
focusedBackgroundColor: Color = containerColor
) {
var isFocused by remember { mutableStateOf(false) }
@@ -40,10 +37,6 @@ internal fun CircularIconButton(
targetValue = if (isFocused) focusedScale else 1f,
label = "scale"
)
val borderColor by animateColorAsState(
targetValue = if (isFocused) focusedBorderColor else Color.Transparent,
label = "border"
)
val backgroundColor by animateColorAsState(
targetValue = if (isFocused) focusedBackgroundColor else containerColor,
label = "background"
@@ -60,11 +53,6 @@ internal fun CircularIconButton(
modifier = modifier
.graphicsLayer { scaleX = scale; scaleY = scale }
.size(size)
.border(
width = if (isFocused) focusedBorderWidth else focusedBorderWidth * 0,
color = borderColor,
shape = CircleShape
)
.onFocusChanged { isFocused = it.isFocused || it.hasFocus }
) {
Icon(

View File

@@ -0,0 +1,63 @@
package hu.bbara.purefin.ui.common.button
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.sp
@Composable
fun CircularTextButton(
text: String,
textColor: Color,
fontSize: Int,
containerColor: Color,
size: Dp,
onClick: () -> Unit,
modifier: Modifier = Modifier,
focusedScale: Float = 1f,
focusedBackgroundColor: Color = containerColor
) {
var isFocused by remember { mutableStateOf(false) }
val scale by animateFloatAsState(
targetValue = if (isFocused) focusedScale else 1f,
label = "scale"
)
val backgroundColor by animateColorAsState(
targetValue = if (isFocused) focusedBackgroundColor else containerColor,
label = "background"
)
FilledTonalButton(
onClick = onClick,
colors = ButtonDefaults.filledTonalButtonColors(
containerColor = backgroundColor,
contentColor = textColor
),
shape = CircleShape,
modifier = modifier
.graphicsLayer { scaleX = scale; scaleY = scale }
.height(size)
.onFocusChanged { isFocused = it.isFocused || it.hasFocus }
) {
Text(
text = text,
fontSize = fontSize.sp,
fontWeight = FontWeight.Bold
)
}
}

View File

@@ -5,7 +5,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@Composable
@@ -15,8 +14,6 @@ fun GhostIconButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
focusedScale: Float = 1f,
focusedBorderWidth: Dp = 0.dp,
focusedBorderColor: Color = Color.Transparent,
focusedBackgroundColor: Color? = null
) {
val scheme = MaterialTheme.colorScheme
@@ -31,7 +28,5 @@ fun GhostIconButton(
onClick = onClick,
modifier = modifier,
focusedScale = focusedScale,
focusedBorderWidth = focusedBorderWidth,
focusedBorderColor = focusedBorderColor
)
}

View File

@@ -30,7 +30,5 @@ fun MediaActionButton(
onClick = onClick,
modifier = modifier,
focusedScale = focusedScale,
focusedBorderWidth = focusedBorderWidth,
focusedBorderColor = focusedBorderColor
)
}

View File

@@ -5,7 +5,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@Composable
@@ -16,8 +15,6 @@ fun PurefinIconButton(
modifier: Modifier = Modifier,
size: Int = 52,
focusedScale: Float = 1f,
focusedBorderWidth: Dp = 0.dp,
focusedBorderColor: Color = Color.Transparent,
focusedBackgroundColor: Color? = null
) {
val scheme = MaterialTheme.colorScheme
@@ -31,7 +28,5 @@ fun PurefinIconButton(
onClick = onClick,
modifier = modifier,
focusedScale = focusedScale,
focusedBorderWidth = focusedBorderWidth,
focusedBorderColor = focusedBorderColor
)
}