Skip to content

Commit

Permalink
fix: Update TextDotText to handle the possibility to set the 2nd te…
Browse files Browse the repository at this point in the history
…xt in "error mode"
  • Loading branch information
KevinBoulongne committed Oct 31, 2024
1 parent b9f55fa commit 4b02440
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fun TextDotText(
modifier: Modifier = Modifier,
color: Color = SwissTransferTheme.colors.secondaryTextColor,
style: TextStyle = SwissTransferTheme.typography.bodySmallRegular,
optionalSecondTextColor: Color? = null,
) {
Row(modifier) {
CustomText(firstText, color, style)
Expand All @@ -45,7 +46,7 @@ fun TextDotText(
style = style,
)
Spacer(Modifier.width(Margin.Mini))
CustomText(secondText, color, style)
CustomText(secondText, optionalSecondTextColor ?: color, style)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ fun TransferItem(
val uploadedSize = Formatter.formatShortFileSize(LocalContext.current, transfer.sizeUploaded)
val files = transfer.files
val filesCount = files.count()
val (expiryText, expiryColor) = when {
remainingDays < 0 -> {
stringResource(R.string.expiredThe, expirationDate.format(FORMAT_DATE_SIMPLE)) to
SwissTransferTheme.materialColors.error
}
remainingDownloads == 0 -> {
"Transfert expiré (TODO)" to SwissTransferTheme.materialColors.error
}
else -> {
stringResource(R.string.expiresIn, remainingDays) to SwissTransferTheme.colors.secondaryTextColor
}
}

Card(
onClick = onClick,
Expand All @@ -83,24 +95,8 @@ fun TransferItem(
Spacer(modifier = Modifier.height(Margin.Mini))
TextDotText(
firstText = { uploadedSize },
secondText = {

val (text, color) = when {
remainingDays < 0 -> {
stringResource(R.string.expiredThe, expirationDate.format(FORMAT_DATE_SIMPLE)) to
SwissTransferTheme.materialColors.error
}
remainingDownloads == 0 -> {
"Transfert expiré (TODO)" to SwissTransferTheme.materialColors.error
}
else -> {
stringResource(R.string.expiresIn, remainingDays) to SwissTransferTheme.colors.secondaryTextColor
}
}

// TODO: Find a way to also send the color
text to color
},
secondText = { expiryText },
optionalSecondTextColor = expiryColor,
)

Spacer(modifier = Modifier.height(Margin.Mini))
Expand Down

0 comments on commit 4b02440

Please sign in to comment.