Skip to content

Commit bbf6eca

Browse files
authored
Fix AppBar padding and alignment issues (#1482)
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) Phone - after ![jetcaster_phone_after](https://github.com/user-attachments/assets/8a1532d4-3d33-40ca-bbf4-1de1d55a1b2f) Phone - before ![jetcaster_phone_before](https://github.com/user-attachments/assets/4f8fd12f-87a8-4aa5-b641-3dbd80024dd8) Tablet - after ![jetcaster_tablet_after](https://github.com/user-attachments/assets/825a2a02-2d41-4580-a793-e3e38e08662a) Tablet - before ![jetcaster_tablet_before](https://github.com/user-attachments/assets/49fbe610-13c9-4791-bc1f-9644cd5bebcc)
2 parents d673e1b + bf7f477 commit bbf6eca

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)