Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Use scale instead textSize in topbar
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkitSuda committed Nov 22, 2022
1 parent 009b9d1 commit a8f0db6
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,27 @@
package com.ankitsuda.rebound.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.zIndex
import com.ankitsuda.base.util.TopBarAlignment
import androidx.compose.ui.unit.times
import com.ankitsuda.rebound.ui.theme.LocalThemeState
import com.ankitsuda.rebound.ui.theme.ReboundTheme
import com.google.accompanist.insets.LocalWindowInsets
import com.google.accompanist.insets.statusBarsHeight
import com.google.accompanist.insets.statusBarsPadding
import me.onebone.toolbar.CollapsingToolbarScope
import me.onebone.toolbar.CollapsingToolbarState

Expand Down Expand Up @@ -70,7 +68,7 @@ fun CollapsingToolbarScope.TopBar2(
val contentColor = theme.topBarContentColor
val elevation = theme.topBarElevation

val titleSize = if (toolbarState != null) (20 + (30 - 20) * toolbarState.progress).sp else 20.sp
val titleScale = if (toolbarState != null) (1f + (1.5f - 1f) * toolbarState.progress) else 1f

val toolbarHeight = 58.dp

Expand Down Expand Up @@ -174,13 +172,18 @@ fun CollapsingToolbarScope.TopBar2(
) {
Text(
modifier = Modifier
.padding(top = statusBarHeight),
.padding(top = statusBarHeight)
.graphicsLayer(
scaleX = titleScale,
scaleY = titleScale,
transformOrigin = TransformOrigin(0f, 0.5f)
),
text = title,
style = ReboundTheme.typography.h6.copy(
fontStyle = if (italicTitle) FontStyle.Italic else FontStyle.Normal
),
fontWeight = FontWeight.Bold,
fontSize = titleSize,
fontSize = 20.sp,
textAlign = TextAlign.Start,
color = contentColor,
maxLines = 1
Expand Down

0 comments on commit a8f0db6

Please sign in to comment.