Fix Tooltip with inverted LayoutDirection
This commit is contained in:
parent
d648b8a05e
commit
c4f0b41610
1 changed files with 25 additions and 18 deletions
|
|
@ -11,13 +11,16 @@ import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.Surface
|
import androidx.compose.material.Surface
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalLayoutDirection
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.DpOffset
|
import androidx.compose.ui.unit.DpOffset
|
||||||
|
import androidx.compose.ui.unit.LayoutDirection
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
|
|
@ -71,29 +74,33 @@ private fun BasicTooltip(
|
||||||
elevation: Dp = BasicTooltipDefault.elevation,
|
elevation: Dp = BasicTooltipDefault.elevation,
|
||||||
tooltip: BasicTooltipUio,
|
tooltip: BasicTooltipUio,
|
||||||
) {
|
) {
|
||||||
Surface(
|
CompositionLocalProvider(
|
||||||
modifier = Modifier
|
LocalLayoutDirection provides LayoutDirection.Ltr,
|
||||||
.padding(16.dp)
|
|
||||||
.then(other = modifier),
|
|
||||||
color = MaterialTheme.colors.surface,
|
|
||||||
elevation = elevation,
|
|
||||||
shape = remember { RoundedCornerShape(4.dp) }
|
|
||||||
) {
|
) {
|
||||||
Column(
|
Surface(
|
||||||
modifier = Modifier.padding(16.dp),
|
modifier = Modifier
|
||||||
verticalArrangement = Arrangement.spacedBy(space = 4.dp),
|
.padding(16.dp)
|
||||||
|
.then(other = modifier),
|
||||||
|
color = MaterialTheme.colors.surface,
|
||||||
|
elevation = elevation,
|
||||||
|
shape = remember { RoundedCornerShape(4.dp) }
|
||||||
) {
|
) {
|
||||||
tooltip.title?.let {
|
Column(
|
||||||
|
modifier = Modifier.padding(16.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(space = 4.dp),
|
||||||
|
) {
|
||||||
|
tooltip.title?.let {
|
||||||
|
Text(
|
||||||
|
style = MaterialTheme.typography.body2,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
text = it
|
||||||
|
)
|
||||||
|
}
|
||||||
Text(
|
Text(
|
||||||
style = MaterialTheme.typography.body2,
|
style = MaterialTheme.typography.caption,
|
||||||
fontWeight = FontWeight.Bold,
|
text = tooltip.description
|
||||||
text = it
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Text(
|
|
||||||
style = MaterialTheme.typography.caption,
|
|
||||||
text = tooltip.description
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue