Tp 44449 Get height from parent for trapezium (#210)
This commit is contained in:
committed by
GitHub
parent
909b3ea759
commit
ec076661ad
@@ -13442,12 +13442,11 @@
|
||||
{
|
||||
"property": {
|
||||
"viewType": "Spacer",
|
||||
"height": "200",
|
||||
"height": "20",
|
||||
"width": "2000",
|
||||
"shape": {
|
||||
"shapeType": "TrapeziumShape",
|
||||
"height": 30,
|
||||
"isFlipped":true,
|
||||
"isFlipped":false,
|
||||
"widthDifference": 20
|
||||
},
|
||||
"backgroundColor": "#795287",
|
||||
@@ -13463,7 +13462,8 @@
|
||||
"viewType": "Column",
|
||||
"width": "MATCH_PARENT",
|
||||
"blurData": {
|
||||
"radius": 5
|
||||
"radius": 6,
|
||||
"edgeTreatment": "Unbounded"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,6 @@ data class TicketShapeData(
|
||||
|
||||
@Parcelize
|
||||
data class TrapeziumShapeData(
|
||||
val height: Float? = null,
|
||||
val widthDifference: Float? = null,
|
||||
val isFlipped: Boolean? = null
|
||||
) : UiTronShape(), Parcelable
|
||||
|
||||
@@ -87,7 +87,6 @@ object ShapeUtil {
|
||||
ShapeType.TrapeziumShape.name -> {
|
||||
(shape as TrapeziumShapeData).let {
|
||||
TrapeziumShape(
|
||||
height = shape.height?.dp?.toPx() ?: 0.dp.toPx(),
|
||||
widthDifference = shape.widthDifference?.dp?.toPx() ?: 0.dp.toPx(),
|
||||
isFlipped = shape.isFlipped ?: false
|
||||
)
|
||||
|
||||
@@ -8,7 +8,6 @@ import androidx.compose.ui.unit.Density
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
|
||||
class TrapeziumShape(
|
||||
private val height: Float,
|
||||
private val widthDifference: Float,
|
||||
private val isFlipped: Boolean
|
||||
) : Shape {
|
||||
@@ -18,12 +17,12 @@ class TrapeziumShape(
|
||||
density: Density
|
||||
): Outline {
|
||||
return Outline.Generic(
|
||||
path = drawShadow(size, height, widthDifference, isFlipped = isFlipped)
|
||||
path = drawShadow(size, widthDifference, isFlipped = isFlipped)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun drawShadow(size: Size, height: Float, widthDifference: Float, isFlipped: Boolean): Path {
|
||||
fun drawShadow(size: Size, widthDifference: Float, isFlipped: Boolean): Path {
|
||||
|
||||
val path =
|
||||
when (isFlipped) {
|
||||
@@ -31,8 +30,8 @@ fun drawShadow(size: Size, height: Float, widthDifference: Float, isFlipped: Boo
|
||||
Path().apply {
|
||||
moveTo(widthDifference, 0f)
|
||||
lineTo(size.width - widthDifference, 0f)
|
||||
lineTo(size.width, height)
|
||||
lineTo(0f, height)
|
||||
lineTo(size.width, size.height)
|
||||
lineTo(0f, size.height)
|
||||
close()
|
||||
}
|
||||
}
|
||||
@@ -41,8 +40,8 @@ fun drawShadow(size: Size, height: Float, widthDifference: Float, isFlipped: Boo
|
||||
Path().apply {
|
||||
moveTo(0f, 0f)
|
||||
lineTo(size.width, 0f)
|
||||
lineTo(size.width - widthDifference, height)
|
||||
lineTo( widthDifference, height)
|
||||
lineTo(size.width - widthDifference, size.height)
|
||||
lineTo( widthDifference, size.height)
|
||||
close()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user