diff --git a/app/src/main/kotlin/de/hbch/traewelling/shared/HexagonShape.kt b/app/src/main/kotlin/de/hbch/traewelling/shared/HexagonShape.kt new file mode 100644 index 00000000..823ad021 --- /dev/null +++ b/app/src/main/kotlin/de/hbch/traewelling/shared/HexagonShape.kt @@ -0,0 +1,31 @@ +package de.hbch.traewelling.shared + +import androidx.compose.ui.geometry.Size +import androidx.compose.ui.graphics.Outline +import androidx.compose.ui.graphics.Path +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.unit.Density + +/** + * Forms a hexagon shape with symmetric sides + */ +open class HexagonShape(val intent: Float = 0.2f, val peek: Float = 0.5f) : Shape { + + + override fun createOutline( + size: Size, + layoutDirection: androidx.compose.ui.unit.LayoutDirection, + density: Density + ): Outline { + val path = Path().apply { + moveTo(size.width * intent, 0f) + lineTo(size.width * (1 - intent), 0f) + lineTo(size.width, size.height * peek) + lineTo(size.width * (1 - intent), size.height) + lineTo(size.width * intent, size.height) + lineTo(0f, size.height * peek) + close() + } + return Outline.Generic(path) + } +} diff --git a/app/src/main/kotlin/de/hbch/traewelling/shared/TrapezoidShape.kt b/app/src/main/kotlin/de/hbch/traewelling/shared/TrapezoidShape.kt new file mode 100644 index 00000000..96f894f6 --- /dev/null +++ b/app/src/main/kotlin/de/hbch/traewelling/shared/TrapezoidShape.kt @@ -0,0 +1,8 @@ +package de.hbch.traewelling.shared + +/** + * Forms a trapezoid shape with a broad top and a narrow bottom side + */ +open class TrapezoidShape() : HexagonShape(peek = 0f) { + +} diff --git a/app/src/main/kotlin/de/hbch/traewelling/ui/composables/LineIcon.kt b/app/src/main/kotlin/de/hbch/traewelling/ui/composables/LineIcon.kt index f1deafde..2285df16 100644 --- a/app/src/main/kotlin/de/hbch/traewelling/ui/composables/LineIcon.kt +++ b/app/src/main/kotlin/de/hbch/traewelling/ui/composables/LineIcon.kt @@ -24,8 +24,10 @@ import androidx.compose.ui.unit.dp import androidx.lifecycle.ViewModelStoreOwner import androidx.lifecycle.viewmodel.compose.viewModel import de.hbch.traewelling.api.models.lineIcons.LineIconShape +import de.hbch.traewelling.shared.HexagonShape import de.hbch.traewelling.shared.LineIcons import de.hbch.traewelling.shared.SettingsViewModel +import de.hbch.traewelling.shared.TrapezoidShape import de.hbch.traewelling.theme.LineIconStyle import de.hbch.traewelling.theme.LocalFont import de.hbch.traewelling.util.getSwitzerlandLineName @@ -54,8 +56,10 @@ fun LineIcon( } val shape: Shape = when (lineIcon?.shape) { + LineIconShape.hexagon -> HexagonShape() LineIconShape.pill -> RoundedCornerShape(percent = 50) LineIconShape.rectangle_rounded_corner -> RoundedCornerShape(percent = 20) + LineIconShape.trapezoid -> TrapezoidShape() else -> RectangleShape } val borderColor: Color = lineIcon?.getBorderColor() ?: Color.Transparent diff --git a/app/src/main/kotlin/de/hbch/traewelling/util/Extensions.kt b/app/src/main/kotlin/de/hbch/traewelling/util/Extensions.kt index 899e49ee..8bc1a991 100644 --- a/app/src/main/kotlin/de/hbch/traewelling/util/Extensions.kt +++ b/app/src/main/kotlin/de/hbch/traewelling/util/Extensions.kt @@ -272,7 +272,8 @@ fun Context.shareImage( suspend fun Context.readOrDownloadLineIcons( overwrite: Boolean = false ): List { - val lineColorCsvUrl = URL("https://raw.githubusercontent.com/Traewelling/line-colors/main/line-colors.csv") +// val lineColorCsvUrl = URL("https://raw.githubusercontent.com/Traewelling/line-colors/main/line-colors.csv") + val lineColorCsvUrl = URL("https://raw.githubusercontent.com/TheOneWithTheBraid/line-colors/braid/hvv-shapes/line-colors.csv") val file = File(filesDir, "line-colors.csv") val icons = try { withContext(Dispatchers.IO) {