Use color from Semantics.
This commit is contained in:
parent
0bf2fd6acf
commit
8951744aba
1 changed files with 28 additions and 27 deletions
|
|
@ -18,7 +18,6 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.draw.drawWithCache
|
import androidx.compose.ui.draw.drawWithCache
|
||||||
import androidx.compose.ui.geometry.Offset
|
import androidx.compose.ui.geometry.Offset
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.graphics.LinearGradientShader
|
import androidx.compose.ui.graphics.LinearGradientShader
|
||||||
import androidx.compose.ui.graphics.ShaderBrush
|
import androidx.compose.ui.graphics.ShaderBrush
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
@ -62,13 +61,7 @@ internal fun SendButton(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
.size(36.dp)
|
.size(36.dp)
|
||||||
.then(
|
.buttonBackgroundModifier(canSendMessage)
|
||||||
if (canSendMessage) {
|
|
||||||
buttonBackgroundModifier()
|
|
||||||
} else {
|
|
||||||
Modifier
|
|
||||||
}
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
@ -91,27 +84,35 @@ internal fun SendButton(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buttonBackgroundModifier() = Modifier.drawWithCache {
|
@Composable
|
||||||
// We have a square button, so height == width.
|
private fun Modifier.buttonBackgroundModifier(
|
||||||
val height = size.height
|
canSendMessage: Boolean,
|
||||||
val verticalGradientBrush = ShaderBrush(
|
) = then(
|
||||||
LinearGradientShader(
|
if (canSendMessage) {
|
||||||
from = Offset(0f, 0f),
|
val colors = listOf(
|
||||||
to = Offset(0f, height),
|
ElementTheme.colors.gradientActionStop1,
|
||||||
colors = listOf(
|
ElementTheme.colors.gradientActionStop2,
|
||||||
Color(0xFF79DD98),
|
ElementTheme.colors.gradientActionStop3,
|
||||||
Color(0xFF0DBD8B),
|
ElementTheme.colors.gradientActionStop4,
|
||||||
Color(0xFF128585),
|
)
|
||||||
Color(0xFF24446B),
|
Modifier.drawWithCache {
|
||||||
|
val verticalGradientBrush = ShaderBrush(
|
||||||
|
LinearGradientShader(
|
||||||
|
from = Offset(0f, 0f),
|
||||||
|
to = Offset(0f, size.height),
|
||||||
|
colors = colors,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
onDrawBehind {
|
||||||
)
|
drawRect(
|
||||||
onDrawBehind {
|
brush = verticalGradientBrush,
|
||||||
drawRect(
|
)
|
||||||
brush = verticalGradientBrush,
|
}
|
||||||
)
|
}
|
||||||
|
} else {
|
||||||
|
Modifier
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue