Restore approved picker Settings centring
This commit is contained in:
parent
a27e922675
commit
7c67596cb6
4 changed files with 24 additions and 11 deletions
|
|
@ -26,7 +26,7 @@ import org.justinvisser.wolfskin.design.WolfskinTokens.Color as C
|
|||
import org.justinvisser.wolfskin.design.WolfskinTokens.Layout as L
|
||||
import org.justinvisser.wolfskin.design.WolfskinTokens.Shell as S
|
||||
|
||||
/** The picker covers the nav; Down from any person reaches Settings below the final avatar. */
|
||||
/** The picker covers the nav; Down from any person reaches the centred Settings gear. */
|
||||
@Composable
|
||||
fun WhosWatching(state: ShellState, modifier: Modifier = Modifier) {
|
||||
Box(modifier.fillMaxSize().background(C.bg)) {
|
||||
|
|
@ -53,7 +53,7 @@ private fun PeoplePicker(state: ShellState) {
|
|||
}
|
||||
}
|
||||
}
|
||||
val left = (S.stageWidth - L.gear + (L.pickerAvatar + L.pickerGap) * (state.people.size - 1)) / 2
|
||||
val left = (S.stageWidth - L.gear) / 2
|
||||
Box(Modifier.offset(left, S.pickerGearTop).size(L.gear).testTag("picker-settings").focusScale(state.gearFocused, WolfskinTokens.Focus.scaleCard)
|
||||
.focusRing(state.gearFocused, L.gear / 2, WolfskinTokens.Focus.ringPickerRing)
|
||||
.clickable { state.gearFocused = true; state.key(ShellKey.Ok) }, contentAlignment = Alignment.Center) {
|
||||
|
|
|
|||
|
|
@ -49,16 +49,17 @@ class PickerNavigationTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test fun settingsGearIsCenteredUnderTheFinalAvatarForAnyProfileCount() {
|
||||
@Test fun settingsGearIsCenteredUnderTheWholePeopleRowForAnyProfileCount() {
|
||||
val state = ShellState(fixturePeople(), "justin")
|
||||
rule.setContent { WolfskinTheme { ShellSurface(state) } }
|
||||
for (count in 1..5) {
|
||||
val people = (0 until count).map { ShellPerson("person-$it", "Person $it", "$it", false) }
|
||||
rule.runOnIdle { state.updatePeople(people); state.gearFocused = true }
|
||||
rule.mainClock.advanceTimeBy(400)
|
||||
val first = rule.onNodeWithTag("picker-person:${people.first().key}").fetchSemanticsNode().boundsInRoot
|
||||
val last = rule.onNodeWithTag("picker-person:${people.last().key}").fetchSemanticsNode().boundsInRoot
|
||||
val gear = rule.onNodeWithTag("picker-settings").fetchSemanticsNode().boundsInRoot
|
||||
assertEquals("Settings must stay under the last profile for $count people", last.center.x, gear.center.x, .1f)
|
||||
assertEquals("Settings must stay centred under the whole row for $count people", (first.center.x + last.center.x) / 2, gear.center.x, .1f)
|
||||
assertTrue("Settings must be below the avatars", gear.top > last.bottom)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue