This repository was archived by the owner on May 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed
app/src/main/kotlin/de/hbch/traewelling Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ package de.hbch.traewelling.shared
2
+
3
+ import androidx.compose.ui.geometry.Size
4
+ import androidx.compose.ui.graphics.Outline
5
+ import androidx.compose.ui.graphics.Path
6
+ import androidx.compose.ui.graphics.Shape
7
+ import androidx.compose.ui.unit.Density
8
+
9
+ /* *
10
+ * Forms a hexagon shape with symmetric sides
11
+ */
12
+ open class HexagonShape (val intent : Float = 0.2f , val peek : Float = 0.5f ) : Shape {
13
+
14
+
15
+ override fun createOutline (
16
+ size : Size ,
17
+ layoutDirection : androidx.compose.ui.unit.LayoutDirection ,
18
+ density : Density
19
+ ): Outline {
20
+ val path = Path ().apply {
21
+ moveTo(size.width * intent, 0f )
22
+ lineTo(size.width * (1 - intent), 0f )
23
+ lineTo(size.width, size.height * peek)
24
+ lineTo(size.width * (1 - intent), size.height)
25
+ lineTo(size.width * intent, size.height)
26
+ lineTo(0f , size.height * peek)
27
+ close()
28
+ }
29
+ return Outline .Generic (path)
30
+ }
31
+ }
Original file line number Diff line number Diff line change
1
+ package de.hbch.traewelling.shared
2
+
3
+ /* *
4
+ * Forms a trapezoid shape with a broad top and a narrow bottom side
5
+ */
6
+ open class TrapezoidShape () : HexagonShape(peek = 0f ) {
7
+
8
+ }
Original file line number Diff line number Diff line change @@ -24,8 +24,10 @@ import androidx.compose.ui.unit.dp
24
24
import androidx.lifecycle.ViewModelStoreOwner
25
25
import androidx.lifecycle.viewmodel.compose.viewModel
26
26
import de.hbch.traewelling.api.models.lineIcons.LineIconShape
27
+ import de.hbch.traewelling.shared.HexagonShape
27
28
import de.hbch.traewelling.shared.LineIcons
28
29
import de.hbch.traewelling.shared.SettingsViewModel
30
+ import de.hbch.traewelling.shared.TrapezoidShape
29
31
import de.hbch.traewelling.theme.LineIconStyle
30
32
import de.hbch.traewelling.theme.LocalFont
31
33
import de.hbch.traewelling.util.getSwitzerlandLineName
@@ -54,8 +56,10 @@ fun LineIcon(
54
56
}
55
57
56
58
val shape: Shape = when (lineIcon?.shape) {
59
+ LineIconShape .hexagon -> HexagonShape ()
57
60
LineIconShape .pill -> RoundedCornerShape (percent = 50 )
58
61
LineIconShape .rectangle_rounded_corner -> RoundedCornerShape (percent = 20 )
62
+ LineIconShape .trapezoid -> TrapezoidShape ()
59
63
else -> RectangleShape
60
64
}
61
65
val borderColor: Color = lineIcon?.getBorderColor() ? : Color .Transparent
You can’t perform that action at this time.
0 commit comments