Alexander Black
08/06/2021, 11:42 PMColton Idle
08/06/2021, 11:54 PMAlexander Black
08/06/2021, 11:56 PMColton Idle
08/07/2021, 12:04 AMAlexander Black
08/07/2021, 12:06 AMAbhishek Dewan
08/07/2021, 2:03 AMAlexander Black
08/07/2021, 2:04 AMAbhishek Dewan
08/07/2021, 2:04 AMAlexander Black
08/07/2021, 2:05 AMAbhishek Dewan
08/07/2021, 2:08 AMAlexander Black
08/07/2021, 2:08 AMTin Tran
08/07/2021, 4:38 AMBox
with circle shape to make a custom radio and add custom animation to it tooAlexander Black
08/07/2021, 4:39 AMK Merle
08/07/2021, 6:34 AMAlexander Black
08/07/2021, 2:24 PMprivate const val RadioAnimationDuration = 100
private val RadioButtonRippleRadius = 24.dp
private val RadioButtonPadding = 2.dp
private val RadioButtonSize = 20.dp
private val RadioRadius = RadioButtonSize / 2
private val RadioButtonDotSize = 12.dp
private val RadioStrokeWidth = 2.dp
So I simply created a class to hold those values and created a method to create a default instance that has overrides for everything like this:
fun defaultRadioButtonProperties(
animationDuration: Int = 100,
buttonRippleRadius: Dp = 24.dp,
buttonPadding: Dp = 2.dp,
buttonSize: Dp = 20.dp,
radius: Dp = buttonSize / 2,
// so the default size is 12.dp, but i'd like this to be calculated,
// so we can change the size without effecting the proportions.
dotSize: Dp = (0.6 * buttonSize.value).dp,
strokeWidth: Dp = 2.dp
): RadioButtonProperties {
return RadioButtonProperties(
animationDuration,
buttonRippleRadius,
buttonPadding,
buttonSize,
radius,
dotSize,
strokeWidth
)
}
@Immutable
class RadioButtonProperties(
val animationDuration: Int,
val buttonRippleRadius: Dp,
val buttonPadding: Dp,
val buttonSize: Dp,
val radius: Dp,
val buttonDotSize: Dp,
val strokeWidth: Dp,
)
Colton Idle
08/07/2021, 4:36 PMAlexander Black
08/07/2021, 4:51 PMColton Idle
08/07/2021, 5:25 PMAlexander Black
08/07/2021, 5:49 PM