commonMain.Separators.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core-jvm Show documentation
Show all versions of core-jvm Show documentation
Unstyled, fully accesible Compose Multiplatform components that you can customize to your heart's desire.
package com.composables.core
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
@Composable
fun HorizontalSeparator(color: Color, modifier: Modifier = Modifier, thickness: Dp = Dp.Hairline) {
Canvas(modifier.fillMaxWidth().height(thickness)) {
drawLine(
color = color,
strokeWidth = thickness.toPx(),
start = Offset(0f, thickness.toPx() / 2),
end = Offset(size.width, thickness.toPx() / 2),
)
}
}
@Composable
fun VerticalSeparator(color: Color, modifier: Modifier = Modifier, thickness: Dp = Dp.Hairline) {
Canvas(modifier.width(thickness).fillMaxHeight()) {
drawLine(
color = color,
strokeWidth = thickness.toPx(),
start = Offset(thickness.toPx() / 2, 0f),
end = Offset(thickness.toPx() / 2, size.height),
)
}
}