Font size on 'All Chats' was changing mid animation (#2073)
* Font size on 'All Chats' was changing mid animation
This commit is contained in:
parent
9eb249c9e7
commit
96ebe1a11c
2 changed files with 116 additions and 110 deletions
1
changelog.d/1572.bugfix
Normal file
1
changelog.d/1572.bugfix
Normal file
|
|
@ -0,0 +1 @@
|
|||
Font size in 'All Chats' header was changing mid-animation.
|
||||
|
|
@ -24,6 +24,7 @@ import androidx.compose.foundation.layout.padding
|
|||
import androidx.compose.foundation.layout.statusBars
|
||||
import androidx.compose.foundation.layout.statusBarsPadding
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.TopAppBarScrollBehavior
|
||||
import androidx.compose.material3.rememberTopAppBarState
|
||||
|
|
@ -149,6 +150,20 @@ private fun DefaultRoomListTopBar(
|
|||
val statusBarPadding = with(LocalDensity.current) { WindowInsets.statusBars.getTop(this).toDp() }
|
||||
|
||||
Box(modifier = modifier) {
|
||||
val collapsedTitleTextStyle = ElementTheme.typography.aliasScreenTitle
|
||||
val expandedTitleTextStyle = ElementTheme.typography.fontHeadingLgBold.copy(
|
||||
// Due to a limitation of MediumTopAppBar, and to avoid the text to be truncated,
|
||||
// ensure that the font size will never be bigger than 28.dp.
|
||||
fontSize = 28.dp.applyScaleDown().toSp()
|
||||
)
|
||||
MaterialTheme(
|
||||
colorScheme = ElementTheme.materialColors,
|
||||
shapes = MaterialTheme.shapes,
|
||||
typography = ElementTheme.materialTypography.copy(
|
||||
headlineSmall = expandedTitleTextStyle,
|
||||
titleLarge = collapsedTitleTextStyle
|
||||
),
|
||||
) {
|
||||
MediumTopAppBar(
|
||||
modifier = Modifier
|
||||
.onSizeChanged {
|
||||
|
|
@ -179,18 +194,7 @@ private fun DefaultRoomListTopBar(
|
|||
scrolledContainerColor = Color.Transparent,
|
||||
),
|
||||
title = {
|
||||
val fontStyle = if (scrollBehavior.state.collapsedFraction > 0.5)
|
||||
ElementTheme.typography.aliasScreenTitle
|
||||
else
|
||||
ElementTheme.typography.fontHeadingLgBold.copy(
|
||||
// Due to a limitation of MediumTopAppBar, and to avoid the text to be truncated,
|
||||
// ensure that the font size will never be bigger than 28.dp.
|
||||
fontSize = 28.dp.applyScaleDown().toSp()
|
||||
)
|
||||
Text(
|
||||
style = fontStyle,
|
||||
text = stringResource(id = R.string.screen_roomlist_main_space_title)
|
||||
)
|
||||
Text(text = stringResource(id = R.string.screen_roomlist_main_space_title))
|
||||
},
|
||||
navigationIcon = {
|
||||
avatarData?.let {
|
||||
|
|
@ -273,6 +277,7 @@ private fun DefaultRoomListTopBar(
|
|||
scrollBehavior = scrollBehavior,
|
||||
windowInsets = WindowInsets(0.dp),
|
||||
)
|
||||
}
|
||||
|
||||
HorizontalDivider(
|
||||
modifier =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue