feat(widget): Add 1x1 size support to battery widget

Introduce BatteryLayout enum with size-driven dispatch. Drops minWidth from 80dp to 40dp so the battery widget can be placed at one cell. At 1-cell-wide placements render a compact icon+percent stack; wider sizes keep the current NARROW/WIDE layouts.
This commit is contained in:
darken
2026-04-23 16:11:07 +02:00
committed by Matthias Urhahn
parent 016914ec05
commit 118eaa8d08
8 changed files with 401 additions and 201 deletions
@@ -0,0 +1,39 @@
package eu.darken.capod.main.ui.widget
import eu.darken.capod.main.ui.widget.BatteryLayout.NARROW
import eu.darken.capod.main.ui.widget.BatteryLayout.TINY_COLUMN
import eu.darken.capod.main.ui.widget.BatteryLayout.WIDE
import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test
import testhelpers.BaseTest
class BatteryLayoutTest : BaseTest() {
@Test fun `1 cell wide resolves to tiny column`() {
BatteryLayout.forCells(1) shouldBe TINY_COLUMN
}
@Test fun `2 cells wide resolves to narrow`() {
BatteryLayout.forCells(2) shouldBe NARROW
}
@Test fun `3 cells wide resolves to narrow`() {
BatteryLayout.forCells(3) shouldBe NARROW
}
@Test fun `4 cells wide resolves to narrow`() {
BatteryLayout.forCells(4) shouldBe NARROW
}
@Test fun `5 cells wide resolves to wide`() {
BatteryLayout.forCells(5) shouldBe WIDE
}
@Test fun `8 cells wide resolves to wide`() {
BatteryLayout.forCells(8) shouldBe WIDE
}
@Test fun `zero cells resolves to tiny column not thrown`() {
BatteryLayout.forCells(0) shouldBe TINY_COLUMN
}
}