Remove unnecessary Box wrapping.
This commit is contained in:
parent
81f32b36b8
commit
62e25fa996
2 changed files with 93 additions and 97 deletions
|
|
@ -59,56 +59,54 @@ fun GradientFloatingActionButton(
|
||||||
shape: Shape = RoundedCornerShape(25),
|
shape: Shape = RoundedCornerShape(25),
|
||||||
content: @Composable () -> Unit,
|
content: @Composable () -> Unit,
|
||||||
) {
|
) {
|
||||||
Box {
|
val linearShaderBrush = remember {
|
||||||
val linearShaderBrush = remember {
|
object : ShaderBrush() {
|
||||||
object : ShaderBrush() {
|
override fun createShader(size: Size): Shader {
|
||||||
override fun createShader(size: Size): Shader {
|
return LinearGradientShader(
|
||||||
return LinearGradientShader(
|
from = Offset(size.width, size.height),
|
||||||
from = Offset(size.width, size.height),
|
to = Offset(size.width, 0f),
|
||||||
to = Offset(size.width, 0f),
|
colors = listOf(
|
||||||
colors = listOf(
|
LightColorTokens.colorBlue900,
|
||||||
LightColorTokens.colorBlue900,
|
LightColorTokens.colorGreen700,
|
||||||
LightColorTokens.colorGreen700,
|
),
|
||||||
),
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val radialShaderBrush = remember {
|
}
|
||||||
object : ShaderBrush() {
|
val radialShaderBrush = remember {
|
||||||
override fun createShader(size: Size): Shader {
|
object : ShaderBrush() {
|
||||||
return RadialGradientShader(
|
override fun createShader(size: Size): Shader {
|
||||||
center = size.center,
|
return RadialGradientShader(
|
||||||
radius = size.width / 2,
|
center = size.center,
|
||||||
colors = listOf(
|
radius = size.width / 2,
|
||||||
LightColorTokens.colorGreen700,
|
colors = listOf(
|
||||||
LightColorTokens.colorBlue900,
|
LightColorTokens.colorGreen700,
|
||||||
)
|
LightColorTokens.colorBlue900,
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.minimumInteractiveComponentSize()
|
.minimumInteractiveComponentSize()
|
||||||
.graphicsLayer(shape = shape, clip = false)
|
.graphicsLayer(shape = shape, clip = false)
|
||||||
.clip(shape)
|
.clip(shape)
|
||||||
.drawBehind {
|
.drawBehind {
|
||||||
drawRect(brush = radialShaderBrush, alpha = 0.4f)
|
drawRect(brush = radialShaderBrush, alpha = 0.4f)
|
||||||
drawRect(brush = linearShaderBrush)
|
drawRect(brush = linearShaderBrush)
|
||||||
}
|
|
||||||
.clickable(
|
|
||||||
enabled = true,
|
|
||||||
onClick = onClick,
|
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
|
||||||
indication = rememberRipple(color = Color.White)
|
|
||||||
),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
CompositionLocalProvider(LocalContentColor provides Color.White) {
|
|
||||||
content()
|
|
||||||
}
|
}
|
||||||
|
.clickable(
|
||||||
|
enabled = true,
|
||||||
|
onClick = onClick,
|
||||||
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
|
indication = rememberRipple(color = Color.White)
|
||||||
|
),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
CompositionLocalProvider(LocalContentColor provides Color.White) {
|
||||||
|
content()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,66 +71,64 @@ fun SuperButton(
|
||||||
ButtonSize.Small -> PaddingValues(horizontal = 16.dp, vertical = 5.dp)
|
ButtonSize.Small -> PaddingValues(horizontal = 16.dp, vertical = 5.dp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Box {
|
val isLightTheme = ElementTheme.isLightTheme
|
||||||
val isLightTheme = ElementTheme.isLightTheme
|
val colors = remember(isLightTheme) {
|
||||||
val colors = remember(isLightTheme) {
|
if (isLightTheme) {
|
||||||
if (isLightTheme) {
|
listOf(
|
||||||
listOf(
|
LightColorTokens.colorBlue900,
|
||||||
LightColorTokens.colorBlue900,
|
LightColorTokens.colorGreen1100,
|
||||||
LightColorTokens.colorGreen1100,
|
)
|
||||||
)
|
|
||||||
} else {
|
|
||||||
listOf(
|
|
||||||
DarkColorTokens.colorBlue900,
|
|
||||||
DarkColorTokens.colorGreen1100,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val shaderBrush = remember(colors) {
|
|
||||||
object : ShaderBrush() {
|
|
||||||
override fun createShader(size: Size): Shader {
|
|
||||||
return LinearGradientShader(
|
|
||||||
from = Offset(0f, size.height),
|
|
||||||
to = Offset(size.width, 0f),
|
|
||||||
colors = colors,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val border = if (enabled) {
|
|
||||||
BorderStroke(1.dp, shaderBrush)
|
|
||||||
} else {
|
} else {
|
||||||
BorderStroke(1.dp, ElementTheme.colors.borderDisabled)
|
listOf(
|
||||||
|
DarkColorTokens.colorBlue900,
|
||||||
|
DarkColorTokens.colorGreen1100,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
val backgroundColor = ElementTheme.colors.bgCanvasDefault
|
}
|
||||||
Box(
|
|
||||||
modifier = modifier
|
val shaderBrush = remember(colors) {
|
||||||
.minimumInteractiveComponentSize()
|
object : ShaderBrush() {
|
||||||
.graphicsLayer(shape = shape, clip = false)
|
override fun createShader(size: Size): Shader {
|
||||||
.clip(shape)
|
return LinearGradientShader(
|
||||||
.border(border, shape)
|
from = Offset(0f, size.height),
|
||||||
.drawBehind {
|
to = Offset(size.width, 0f),
|
||||||
drawRect(backgroundColor)
|
colors = colors,
|
||||||
drawRect(brush = shaderBrush, alpha = 0.04f)
|
|
||||||
}
|
|
||||||
.clickable(
|
|
||||||
enabled = enabled,
|
|
||||||
onClick = onClick,
|
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
|
||||||
indication = rememberRipple()
|
|
||||||
)
|
)
|
||||||
.padding(contentPadding),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
CompositionLocalProvider(
|
|
||||||
LocalContentColor provides if (enabled) ElementTheme.colors.textPrimary else ElementTheme.colors.textDisabled,
|
|
||||||
LocalTextStyle provides ElementTheme.typography.fontBodyLgMedium,
|
|
||||||
) {
|
|
||||||
content()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val border = if (enabled) {
|
||||||
|
BorderStroke(1.dp, shaderBrush)
|
||||||
|
} else {
|
||||||
|
BorderStroke(1.dp, ElementTheme.colors.borderDisabled)
|
||||||
|
}
|
||||||
|
val backgroundColor = ElementTheme.colors.bgCanvasDefault
|
||||||
|
Box(
|
||||||
|
modifier = modifier
|
||||||
|
.minimumInteractiveComponentSize()
|
||||||
|
.graphicsLayer(shape = shape, clip = false)
|
||||||
|
.clip(shape)
|
||||||
|
.border(border, shape)
|
||||||
|
.drawBehind {
|
||||||
|
drawRect(backgroundColor)
|
||||||
|
drawRect(brush = shaderBrush, alpha = 0.04f)
|
||||||
|
}
|
||||||
|
.clickable(
|
||||||
|
enabled = enabled,
|
||||||
|
onClick = onClick,
|
||||||
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
|
indication = rememberRipple()
|
||||||
|
)
|
||||||
|
.padding(contentPadding),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
CompositionLocalProvider(
|
||||||
|
LocalContentColor provides if (enabled) ElementTheme.colors.textPrimary else ElementTheme.colors.textDisabled,
|
||||||
|
LocalTextStyle provides ElementTheme.typography.fontBodyLgMedium,
|
||||||
|
) {
|
||||||
|
content()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue