ui: stop the offline strip reserving a 48dp touch target

The clickable Surface enforced Material's minimum interactive size, so
trimming its row only moved the text inside a band that stayed 48dp
tall and kept the gap to the tabs. Make the strip itself clickable
instead, so it sizes from its padding, and pin it at 36dp.
This commit is contained in:
austinried
2026-10-21 10:14:10 +00:00
parent 72e1b61bff
commit 9feaf54cd2
2 changed files with 31 additions and 33 deletions
@@ -99,6 +99,7 @@ import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
@@ -708,7 +709,7 @@ private fun ListOptionsSheet(
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp),
modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
) {
Icon(Icons.Rounded.Search, contentDescription = null, tint = MaterialTheme.colorScheme.onSurfaceVariant)
Text(stringResource(R.string.search_this_list), color = MaterialTheme.colorScheme.onSurfaceVariant)
@@ -1019,38 +1020,34 @@ private fun OfflineStrip(
headerColor: Color,
modifier: Modifier = Modifier,
) {
Surface(
onClick = onGoOnline,
color = lerp(headerColor, MaterialTheme.colorScheme.primary, OFFLINE_STRIP_TINT),
contentColor = MaterialTheme.colorScheme.onBackground,
modifier = modifier.fillMaxWidth(),
Row(
modifier =
modifier
.fillMaxWidth()
.background(lerp(headerColor, MaterialTheme.colorScheme.primary, OFFLINE_STRIP_TINT))
.clickable(role = Role.Button, onClick = onGoOnline)
.padding(horizontal = 16.dp, vertical = 8.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
Row(
modifier =
Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
Icon(
imageVector = Icons.Rounded.CloudOff,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
modifier = Modifier.size(18.dp),
)
Text(
text = stringResource(R.string.offline_mode_banner),
style = MaterialTheme.typography.bodyMedium,
maxLines = 2,
modifier = Modifier.weight(1f),
)
Text(
text = stringResource(R.string.offline_go_online),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary,
)
}
Icon(
imageVector = Icons.Rounded.CloudOff,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
modifier = Modifier.size(18.dp),
)
Text(
text = stringResource(R.string.offline_mode_banner),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onBackground,
maxLines = 2,
modifier = Modifier.weight(1f),
)
Text(
text = stringResource(R.string.offline_go_online),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary,
)
}
}
@@ -5,6 +5,7 @@ import androidx.compose.foundation.pager.PagerState
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.test.assertHeightIsEqualTo
import androidx.compose.ui.test.assertWidthIsEqualTo
import androidx.compose.ui.test.junit4.v2.createAndroidComposeRule
import androidx.compose.ui.test.onAllNodesWithContentDescription
@@ -533,7 +534,7 @@ class LibraryScreenTest {
}
composeRule.waitForIdle()
composeRule.onNodeWithText(composeRule.activity.getString(R.string.offline_mode_banner)).performClick()
composeRule.onNodeWithText(composeRule.activity.getString(R.string.offline_mode_banner)).assertHeightIsEqualTo(36.dp).performClick()
assertTrue("the offline strip should leave offline mode", exited)
composeRule
.onNodeWithContentDescription(composeRule.activity.getString(R.string.navigation_tabs_settings))