Skip to content

Commit

Permalink
refactor: Remove double signature for HighlightedText
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarX committed Dec 4, 2024
1 parent 56e47a6 commit c331413
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,6 @@ fun HighlightedText(
)
}

@Composable
fun HighlightedText(
modifier: Modifier = Modifier,
templateRes: Int,
argumentRes: Int,
style: TextStyle,
verticalPadding: Float = VERTICAL_PADDING,
horizontalPadding: Float = HORIZONTAL_PADDING,
angleDegrees: Double = ROTATION_ANGLE_DEGREE,
) {
var isHighlighted by rememberSaveable { mutableStateOf(false) }
LaunchedEffect(Unit) { isHighlighted = true }

HighlightedTextCore(
templateRes,
argumentRes,
style,
modifier,
verticalPadding,
horizontalPadding,
angleDegrees,
{ isHighlighted },
)
}

@Composable
private fun HighlightedTextCore(
templateRes: Int,
Expand All @@ -108,7 +83,7 @@ private fun HighlightedTextCore(
verticalPadding: Float,
horizontalPadding: Float,
angleDegrees: Double,
isHighlighted: () -> Boolean
isHighlighted: () -> Boolean,
) {
val template = stringResource(templateRes)
val argument = stringResource(argumentRes)
Expand Down Expand Up @@ -259,12 +234,16 @@ private fun areOnDifferentLines(previousRect: Rect, currentRect: Rect) = previou
@Composable
private fun Preview() {
SwissTransferTheme {
var isHighlighted by rememberSaveable { mutableStateOf(false) }
LaunchedEffect(Unit) { isHighlighted = true }

Surface {
Box(modifier = Modifier.padding(20.dp)) {
HighlightedText(
templateRes = R.string.uploadProgressTitleTemplate,
argumentRes = R.string.uploadProgressTitleArgument,
style = SwissTransferTheme.typography.bodyMedium,
isHighlighted = { isHighlighted }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
Expand All @@ -44,12 +45,16 @@ fun ColumnScope.AdHeader(adScreenType: UploadProgressAdType) {
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally,
) {
var isHighlighted by rememberSaveable { mutableStateOf(false) }
LaunchedEffect(Unit) { isHighlighted = true }

Spacer(Modifier.height(Margin.Giant))

HighlightedText(
templateRes = R.string.uploadProgressTitleTemplate,
argumentRes = R.string.uploadProgressTitleArgument,
style = SwissTransferTheme.typography.bodyMedium,
isHighlighted = { isHighlighted }
)

Spacer(Modifier.height(Margin.Huge))
Expand Down

0 comments on commit c331413

Please sign in to comment.