How come my first implementation has `NavHost` tra...
# compose
k
How come my first implementation has
NavHost
transition working correctly, and second implementation breaks
NavHost
animation transition? Note that I am navigation from screen A to screen B, and implementation in thread is screen B.
Works
Copy code
@Composable
fun FriendRosterScreen(
    userFirstAndLastName: String,
    navigateBack: () -> Unit
) {
    Box(
        modifier = Modifier
            .fillMaxSize()
    )
}
Does not work:
Copy code
@Composable
fun FriendRosterScreen(
    userFirstAndLastName: String,
    navigateBack: () -> Unit
) {
    Scaffold(
        topBar = {
            AppSmallTopBar(
                title = {
                    Text(
                        style = MaterialTheme.typography.titleLarge,
                        text = userFirstAndLastName,
                        color = MaterialTheme.colorScheme.onPrimary
                    )
                },
                navigationIcon = {
                    IconButton(onClick = navigateBack) {
                        Icon(
                            imageVector = Icons.AutoMirrored.Default.ArrowBack,
                            contentDescription = stringResource(id = R.string.back_button_content_description),
                            tint = MaterialTheme.colorScheme.onPrimary
                        )
                    }
                },
                containerColor = MaterialTheme.colorScheme.primary
            )
        }
    ) {
        Box(
            modifier = Modifier
                .padding(it)
                .fillMaxSize()
        )
    }
}
s
Does the Scaffold take up the entire space given to it automatically? If you pass a
fillMaxSize
as the modifier of the Scaffold too, does that change anything? Also might be worth it to share what exactly it is that does not work besides just that it breaks?
k
fillMaxSize() on Scaffold modifier or maxing Scaffold wrapped in a Box and have on box fillMaxSize() doesn't do much. So what happens is there is no animation transition, screen B just appears like there is no animation.
s
If you change from a Scaffold to a Column which has the AppSmallTopBar and then the content does it behave the same? I really don’t see a reason why this would not work if you are literally just calling these two functions and you make sure that in either case they take up the entire screen’s size otherwise 🤔