Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: attachments menu blends with background [WPB-15102] #3761

Merged
merged 5 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private fun UsernameTile(
modifier: Modifier = Modifier,
) {
val color =
if (isSpeaking) colorsScheme().primary else darkColorsScheme().surfaceContainerLowest
if (isSpeaking) colorsScheme().primary else darkColorsScheme().inverseOnSurface
val nameLabelColor =
when {
isSpeaking -> colorsScheme().onPrimary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import androidx.compose.foundation.layout.isImeVisible
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.shape.GenericShape
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -55,12 +55,20 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.RoundRect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.geometry.toRect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.drawscope.Fill
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Popup
Expand Down Expand Up @@ -326,11 +334,12 @@ fun EnabledMessageComposer(
showAttachments(false)
}
) {
val rippleColor = colorsScheme().surface
val shape = if (isImeVisible) {
RectangleShape
} else {
RoundedCornerShape(dimensions().corner14x)
val rippleColor = colorsScheme().surfaceContainerLowest
val borderColor = colorsScheme().divider
val borderWidthPx = if (isImeVisible) 0f else dimensions().spacing1x.toPx(density)
val cornerRadiusPx = if (isImeVisible) 0f else dimensions().corner14x.toPx(density)
val shape = GenericShape { size, _ ->
addPath(calculateOptionsPath(cornerRadiusPx, rippleProgress.value, isImeVisible, size))
}

Box(
Expand All @@ -351,21 +360,22 @@ fun EnabledMessageComposer(
.clip(shape)
.drawBehind {
if (!hideRipple || rippleProgress.value > 0f) {
val maxRadius = size.getDistanceToCorner(Offset(0f, 0f))
val currentRadius = maxRadius * rippleProgress.value

drawCircle(
color = rippleColor,
radius = currentRadius,
center = Offset(
0f,
if (isImeVisible) {
0f
} else {
size.height
}
calculateOptionsPath(cornerRadiusPx, rippleProgress.value, isImeVisible, size).let {
drawPath(
path = it,
color = rippleColor,
style = Fill
)
)
if (borderWidthPx > 0f) {
drawPath(
path = it,
color = borderColor,
style = Stroke(
width = borderWidthPx * 2f // double to make inner stroke, outer half is clipped anyway
)
)
}
}
}
}

Expand Down Expand Up @@ -402,7 +412,30 @@ fun EnabledMessageComposer(
}
}

fun Size.getDistanceToCorner(corner: Offset): Float {
private fun Size.getDistanceToCorner(corner: Offset): Float {
val cornerOffset = Offset(width - corner.x, height - corner.y)
return cornerOffset.getDistance()
}

private fun calculateOptionsPath(cornerRadiusPx: Float, rippleProgress: Float, isImeVisible: Boolean, size: Size): Path {
val ripplePath = Path()
ripplePath.addOval(
oval = Rect(
center = Offset(
x = 0f,
y = if (isImeVisible) 0f else size.height
),
radius = rippleProgress * size.getDistanceToCorner(Offset(0f, 0f))
)
)
val shapePath = Path()
shapePath.addRoundRect(
roundRect = RoundRect(
rect = size.toRect(),
cornerRadius = CornerRadius(cornerRadiusPx, cornerRadiusPx)
)
)
return ripplePath.and(shapePath)
}

private fun Dp.toPx(density: Density) = with(density) { toPx() }
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private val DarkWireColorScheme = WireColorScheme(
surfaceVariant = WireColorPalette.Gray90, onSurfaceVariant = Color.White,
inverseSurface = Color.White, inverseOnSurface = Color.Black,
surfaceBright = WireColorPalette.Gray70, surfaceDim = WireColorPalette.Gray95,
surfaceContainerLowest = Color.Black,
surfaceContainerLowest = WireColorPalette.Gray100,
surfaceContainerLow = WireColorPalette.Gray95,
surfaceContainer = WireColorPalette.Gray90,
surfaceContainerHigh = WireColorPalette.Gray80,
Expand Down
Loading