Follow visible card centers and remember Home tracks
Some checks failed
review/design-claude Request changes: separator dot colour, vertical rhythm, focus entry after load
Some checks failed
review/design-claude Request changes: separator dot colour, vertical rhythm, focus entry after load
This commit is contained in:
parent
2b65ee7b53
commit
b54bcc148c
6 changed files with 73 additions and 8 deletions
|
|
@ -132,6 +132,26 @@ class HomeKeysTest {
|
|||
assertEquals(tail.id, (action as HomeAction.SeeAll).row.id)
|
||||
}
|
||||
|
||||
@Test fun mixedWidthRowsUseNearestCenterAndKeepTheTrackWhenMovingBackInsideItsMiddle() {
|
||||
val shell = ShellState(fixturePeople(), "justin").apply { pickerVisible = false; navFocused = false }
|
||||
val cards = HomeFixture(rule.activity).snapshot("justin").rows.first { it.id == "lib-movies" }.cards
|
||||
val posters = HomeRow(id = "posters", kind = HomeRowKind.Shelf, cards = cards)
|
||||
val tiles = posters.copy(id = "tiles", cardKind = HomeCardKind.Tile)
|
||||
shell.view.cards[posters.id] = 3
|
||||
rule.setContent { WolfskinTheme {
|
||||
ShellSurface(shell) { modifier -> HomeScreen(shell, HomeSnapshot(listOf(posters, tiles)), modifier) {} }
|
||||
} }
|
||||
press("DOWN")
|
||||
assertEquals("The third tile is nearest the fourth poster's horizontal center", 2, shell.view.cards[tiles.id])
|
||||
repeat(4) { press("RIGHT") }
|
||||
val left = rule.onNodeWithTag("home-card:tiles:4").fetchSemanticsNode().boundsInRoot.left
|
||||
press("LEFT")
|
||||
assertEquals("Moving back within the visible middle must not shift the track", left,
|
||||
rule.onNodeWithTag("home-card:tiles:4").fetchSemanticsNode().boundsInRoot.left, .1f)
|
||||
press("UP")
|
||||
assertEquals("A visited row retains its column", 3, shell.view.cards[posters.id])
|
||||
}
|
||||
|
||||
private fun press(name: String) {
|
||||
val key = when (name) {
|
||||
"UP" -> Key.DirectionUp; "DOWN" -> Key.DirectionDown
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue