Skip to content

Commit bf7f477

Browse files
author
Clara Bayarri
committed
Fix AppBar padding and alignment issues
AppBar was missing a start padding that caused it to extend to the edge of the screen on Compact size classes. Updated the SearchBar component usage away from the deprecated method version as an internal usage of Modifier.fillMaxWidth in the deprecated method was now causing the AppBar to always fill max width on all Window Size Classes (vs the intended end-aligned smaller version in non-Compact)
1 parent d673e1b commit bf7f477

File tree

1 file changed

+30
-21
lines changed
  • Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home

1 file changed

+30
-21
lines changed

Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import androidx.compose.material3.Icon
5858
import androidx.compose.material3.MaterialTheme
5959
import androidx.compose.material3.Scaffold
6060
import androidx.compose.material3.SearchBar
61+
import androidx.compose.material3.SearchBarDefaults
6162
import androidx.compose.material3.SnackbarHost
6263
import androidx.compose.material3.SnackbarHostState
6364
import androidx.compose.material3.Surface
@@ -383,31 +384,39 @@ private fun HomeAppBar(
383384
modifier = modifier
384385
.fillMaxWidth()
385386
.background(Color.Transparent)
386-
.padding(end = 16.dp, top = 8.dp, bottom = 8.dp)
387+
.padding(end = 16.dp, top = 8.dp, bottom = 8.dp, start = 16.dp)
387388
) {
388389
SearchBar(
389-
query = "",
390-
onQueryChange = {},
391-
placeholder = {
392-
Text(stringResource(id = R.string.search_for_a_podcast))
393-
},
394-
onSearch = {},
395-
active = false,
396-
onActiveChange = {},
397-
leadingIcon = {
398-
Icon(
399-
imageVector = Icons.Default.Search,
400-
contentDescription = null
401-
)
402-
},
403-
trailingIcon = {
404-
Icon(
405-
imageVector = Icons.Default.AccountCircle,
406-
contentDescription = stringResource(R.string.cd_account)
390+
inputField = {
391+
SearchBarDefaults.InputField(
392+
query = "",
393+
onQueryChange = {},
394+
onSearch = {},
395+
expanded = false,
396+
onExpandedChange = {},
397+
enabled = true,
398+
placeholder = {
399+
Text(stringResource(id = R.string.search_for_a_podcast))
400+
},
401+
leadingIcon = {
402+
Icon(
403+
imageVector = Icons.Default.Search,
404+
contentDescription = null
405+
)
406+
},
407+
trailingIcon = {
408+
Icon(
409+
imageVector = Icons.Default.AccountCircle,
410+
contentDescription = stringResource(R.string.cd_account)
411+
)
412+
},
413+
interactionSource = null,
414+
modifier = if (isExpanded) Modifier.fillMaxWidth() else Modifier
407415
)
408416
},
409-
modifier = if (isExpanded) Modifier else Modifier.fillMaxWidth()
410-
) { }
417+
expanded = false,
418+
onExpandedChange = {}
419+
) {}
411420
}
412421
}
413422

0 commit comments

Comments
 (0)