I am using Navigation-Compose in my app :
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
ComposeTheme {
val navController = rememberNavController()
NavHost(navController = navController, startDestination = Screens.Dashboard.title) {
composable(Screens.Dashboard.title) {
DashboardScreen(navController)
}
composable(
Screens.Section.title, arguments = listOf(
navArgument(LINK) {
type = AssetParamType()
}
)
) {
SectionDetailsScreen(navController)
}
}
}
}
}
I have a separate appBar in every screen such as :
@Composable
fun DashboardScreen(
navController: NavHostController,
viewModel: DashboardViewModel = hiltViewModel()
) {
Scaffold(
topBar = {
TopAppBar(
title = {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize()
) {
Text(text = stringResource(id = R.string.label_dashboard))
}
},
elevation = 8.dp,
modifier = Modifier.clip(
RoundedCornerShape(bottomStart = 18.dp, bottomEnd = 18.dp)
)
)
},
content = {
Content(viewModel = viewModel) { dashboard ->
VerticalCollection(dashboard) { link ->
val json = Uri.encode(Gson().toJson(link))
navController.navigate(
Screens.Section.title.replace
("{${LINK}}", json)
)
}
}
})
}
Screens are flashing when I navigate between them in Dark theme. There is a small flashing on appBar when dark theme is off. How to resolve it?
Source code of my project can be found here : https://github.com/alirezaeiii/Navigation-Compose
Addenda :
I found out that if we get use of accompanist library as indicated in this link : TopAppBar flashing when navigating with Compose Navigation Flashing issue will be resolved, but it is a must to use accompanist.
surface
component solved it for me. https://mcmap.net/q/643508/-topappbar-flashing-when-navigating-with-compose-navigation – Doublure