5.10
jetpack compose 主题设计
fun EmailDetailAppBar(
email: Email,
isFullScreen: Boolean,
modifier: Modifier = Modifier,
onBackPressed: () -> Unit
) {
TopAppBar(
modifier = modifier,
title = {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = if (isFullScreen) Alignment.CenterHorizontally
else Alignment.Start
) {
Text(
text = email.subject,
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Text(
modifier = Modifier.padding(top = 4.dp),
text = "${email.threads.size} ${stringResource(id = R.string.messages)}",
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.outline
)
}
},
navigationIcon = {
if (isFullScreen) {
FilledIconButton(
onClick = onBackPressed,
modifier = Modifier.padding(8.dp),
colors = IconButtonDefaults.filledIconButtonColors(
containerColor = MaterialTheme.colorScheme.surface,
contentColor = MaterialTheme.colorScheme.onSurface
)
) {
Icon(
imageVector = Icons.Default.ArrowBack,
contentDescription = stringResource(id = R.string.back_button),
modifier = Modifier.size(14.dp)
)
}
}
},
actions = {
IconButton(
onClick = { /*Click Implementation*/ },
) {
Icon(
imageVector = Icons.Default.MoreVert,
contentDescription = stringResource(id = R.string.more_options_button),
tint = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
)
}