Skip to content

Commit

Permalink
chore: Simplify some Spacers code
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Nov 19, 2024
1 parent 2f14f6f commit bb2852d
Show file tree
Hide file tree
Showing 24 changed files with 58 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fun BottomSheetItem(imageVector: ImageVector, @StringRes titleRes: Int, onClick:
contentDescription = null,
tint = SwissTransferTheme.materialColors.primary,
)
Spacer(modifier = Modifier.width(Margin.Large))
Spacer(Modifier.width(Margin.Large))
Text(
text = stringResource(id = titleRes),
style = SwissTransferTheme.typography.bodyRegular,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ fun BrandTopAppBar() {
title = {
Row(verticalAlignment = Alignment.CenterVertically) {
Image(imageVector = AppIllus.LogoInfomaniak, contentDescription = null)
Spacer(modifier = Modifier.width(Margin.Medium))
Spacer(Modifier.width(Margin.Medium))
VerticalDivider(modifier = Modifier.height(Margin.Large), color = SwissTransferTheme.colors.toolbarTextColor)
Spacer(modifier = Modifier.width(Margin.Medium))
Spacer(Modifier.width(Margin.Medium))
Image(imageVector = AppIllus.LogoSwissTransfer, contentDescription = null)
Spacer(modifier = Modifier.width(Margin.Mini))
Spacer(Modifier.width(Margin.Mini))
Text(text = stringResource(id = R.string.appName), color = SwissTransferTheme.colors.toolbarTextColor)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fun KeepButtonSize(imageVector: ImageVector?, titleRes: Int, content: @Composabl
private fun ButtonTextContent(imageVector: ImageVector?, titleRes: Int) {
imageVector?.let {
Icon(modifier = Modifier.size(Margin.Medium), imageVector = it, contentDescription = null)
Spacer(modifier = Modifier.width(Margin.Mini))
Spacer(Modifier.width(Margin.Mini))
}
Text(text = stringResource(id = titleRes), style = SwissTransferTheme.typography.bodyMedium)
}
Expand Down Expand Up @@ -208,7 +208,7 @@ private fun LargeButtonPreview() {
ButtonType.entries.forEach {
Row {
LargeButton(titleRes = R.string.appName, style = it, onClick = {}, imageVector = AppIcons.Add)
Spacer(modifier = Modifier.width(Margin.Mini))
Spacer(Modifier.width(Margin.Mini))
LargeButton(
titleRes = R.string.appName,
style = it,
Expand All @@ -217,10 +217,10 @@ private fun LargeButtonPreview() {
imageVector = AppIcons.Add
)

Spacer(modifier = Modifier.width(Margin.Mini))
Spacer(Modifier.width(Margin.Mini))

SmallButton(titleRes = R.string.appName, style = it, imageVector = AppIcons.Add, onClick = {})
Spacer(modifier = Modifier.width(Margin.Mini))
Spacer(Modifier.width(Margin.Mini))
SmallButton(
titleRes = R.string.appName,
style = it,
Expand All @@ -229,7 +229,7 @@ private fun LargeButtonPreview() {
onClick = {}
)
}
Spacer(modifier = Modifier.height(Margin.Medium))
Spacer(Modifier.height(Margin.Medium))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private fun VerticallyStackedButtons(
.padding(horizontal = Margin.Medium),
)

Spacer(modifier = Modifier.height(Margin.Medium))
Spacer(Modifier.height(Margin.Medium))

bottomButton(
Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private fun FileItemPreview(@PreviewParameter(FileUiListPreviewParameter::class)
onRemove = {},
)

Spacer(modifier = Modifier.height(Margin.Medium))
Spacer(Modifier.height(Margin.Medium))

val imageFile = files[1]
FileItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ private fun NewTransferFabPreview() {
Surface {
Row {
NewTransferFab(newTransferFabType = NewTransferFabType.BOTTOM_BAR)
Spacer(modifier = Modifier.width(Margin.Large))
Spacer(Modifier.width(Margin.Large))
NewTransferFab(newTransferFabType = NewTransferFabType.EMPTY_STATE)
Spacer(modifier = Modifier.width(Margin.Large))
Spacer(Modifier.width(Margin.Large))
NewTransferFab(newTransferFabType = NewTransferFabType.NAVIGATION_RAIL)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private fun SmallFileItemPreview(@PreviewParameter(FileUiListPreviewParameter::c
onRemove = {}
)

Spacer(modifier = Modifier.height(Margin.Medium))
Spacer(Modifier.height(Margin.Medium))

SmallFileItem(
file = file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private fun BottomSheetContent(

imageVector?.let {
Image(modifier = paddedModifier, imageVector = imageVector, contentDescription = null)
Spacer(modifier = Modifier.height(Margin.Large))
Spacer(Modifier.height(Margin.Large))
}

title?.let {
Expand All @@ -114,7 +114,7 @@ private fun BottomSheetContent(
color = SwissTransferTheme.colors.primaryTextColor,
textAlign = TextAlign.Center,
)
Spacer(modifier = Modifier.height(Margin.Large))
Spacer(Modifier.height(Margin.Large))
}

description?.let {
Expand All @@ -125,12 +125,12 @@ private fun BottomSheetContent(
color = SwissTransferTheme.colors.secondaryTextColor,
textAlign = TextAlign.Center,
)
Spacer(modifier = Modifier.height(Margin.Large))
Spacer(Modifier.height(Margin.Large))
}

content?.let {
it()
Spacer(modifier = Modifier.height(Margin.Large))
Spacer(Modifier.height(Margin.Large))
}

DoubleButtonCombo(topButton = topButton, bottomButton = bottomButton)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private fun SwissTransferFabPreview() {
SwissTransferTheme {
Row {
SwissTransferFab(onClick = {})
Spacer(modifier = Modifier.width(Margin.Large))
Spacer(Modifier.width(Margin.Large))
SwissTransferFab(fabType = FabType.BIG, onClick = {})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ fun TransferItem(
overflow = TextOverflow.MiddleEllipsis,
)

Spacer(modifier = Modifier.height(Margin.Mini))
Spacer(Modifier.height(Margin.Mini))
TextDotText(
firstText = { uploadedSize },
secondText = { expiryText },
optionalSecondTextColor = expiryColor,
)

Spacer(modifier = Modifier.height(Margin.Mini))
Spacer(Modifier.height(Margin.Mini))
ContextualFlowRow(
itemCount = files.count(),
maxLines = 1,
Expand All @@ -105,7 +105,7 @@ fun TransferItem(
}
}

Spacer(modifier = Modifier.width(Margin.Medium))
Spacer(Modifier.width(Margin.Medium))
Icon(
imageVector = AppIcons.ChevronRightThick,
contentDescription = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ fun SentEmptyScreen() {
style = SwissTransferTheme.typography.specificMedium32,
textAlign = TextAlign.Center,
)
Spacer(modifier = Modifier.height(Margin.Medium))
Spacer(Modifier.height(Margin.Medium))
Text(
modifier = Modifier.widthIn(max = maxWidth),
text = stringResource(id = R.string.firstTransferDescription),
style = SwissTransferTheme.typography.bodyRegular,
color = SwissTransferTheme.colors.secondaryTextColor,
)
Spacer(modifier = Modifier.height(Margin.Medium))
Spacer(Modifier.height(Margin.Medium))
ConstraintLayout {
val (icon, fab) = createRefs()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private fun SettingItemContent(
} else {
Image(imageVector = it, contentDescription = null)
}
Spacer(modifier = Modifier.width(Margin.Medium))
Spacer(Modifier.width(Margin.Medium))
}

Column(modifier = Modifier.weight(1.0f)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ private fun SettingOptionItem(item: SettingOption, isSelected: Boolean, onClick:
) {
item.icon?.let {
Image(imageVector = it, contentDescription = null)
Spacer(modifier = Modifier.width(Margin.Medium))
Spacer(Modifier.width(Margin.Medium))
} ?: run {
// Make sure the items with no icons have the same height as the ones with icons
Spacer(modifier = Modifier.height(Margin.Large))
Spacer(Modifier.height(Margin.Large))
}

Text(text = item.title(), Modifier.weight(1.0f), style = SwissTransferTheme.typography.bodyRegular)

if (isSelected) Spacer(modifier = Modifier.width(Margin.Medium))
if (isSelected) Spacer(Modifier.width(Margin.Medium))
AnimatedVisibility(
visible = isSelected,
enter = scaleIn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ private fun ColumnScope.FilesList(
setUidCheckStatus = { fileUid, isChecked -> setFileCheckStatus(fileUid, isChecked) },
header = {
Column {
Spacer(modifier = Modifier.height(Margin.Large))
Spacer(Modifier.height(Margin.Large))
TransferInfo(transfer)
Spacer(modifier = Modifier.height(Margin.Large))
Spacer(Modifier.height(Margin.Large))
if (shouldDisplayRecipients) TransferRecipients(transferRecipients)
if (shouldDisplayRecipients && shouldDisplayMessage) Spacer(modifier = Modifier.height(Margin.Mini))
if (shouldDisplayRecipients && shouldDisplayMessage) Spacer(Modifier.height(Margin.Mini))
if (shouldDisplayMessage) TransferMessage(transfer.message!!)
if (shouldDisplayRecipients || shouldDisplayMessage) Spacer(modifier = Modifier.height(Margin.Large))
if (shouldDisplayRecipients || shouldDisplayMessage) Spacer(Modifier.height(Margin.Large))
TransferContentHeader()
}
},
Expand All @@ -197,7 +197,7 @@ private fun TransferRecipients(recipients: List<String>) {
style = SwissTransferTheme.typography.bodySmallRegular,
color = SwissTransferTheme.colors.secondaryTextColor,
)
Spacer(modifier = Modifier.height(Margin.Mini))
Spacer(Modifier.height(Margin.Mini))
EmailsFlowRow(recipients)
}

Expand All @@ -208,7 +208,7 @@ private fun TransferMessage(transferMessage: String) {
style = SwissTransferTheme.typography.bodySmallRegular,
color = SwissTransferTheme.colors.secondaryTextColor,
)
Spacer(modifier = Modifier.height(Margin.Medium))
Spacer(Modifier.height(Margin.Medium))
SwissTransferCard {
Text(
text = transferMessage,
Expand Down Expand Up @@ -246,14 +246,14 @@ private fun BottomBar(direction: TransferDirection, isMultiselectOn: () -> Boole

when (direction) {
TransferDirection.SENT -> {
Spacer(modifier = Modifier.width(Margin.Medium))
Spacer(Modifier.width(Margin.Medium))
BottomBarButton(BottomBarItem.QR_CODE, onClick)

Spacer(modifier = Modifier.width(Margin.Medium))
Spacer(Modifier.width(Margin.Medium))
BottomBarButton(BottomBarItem.PASSWORD, onClick)
}
TransferDirection.RECEIVED -> {
Spacer(modifier = Modifier.width(Margin.Medium))
Spacer(Modifier.width(Margin.Medium))
BottomBarButton(BottomBarItem.DOWNLOAD, onClick)
}
}
Expand All @@ -275,7 +275,7 @@ private fun RowScope.BottomBarButton(item: BottomBarItem, onClick: (BottomBarIte
horizontalAlignment = Alignment.CenterHorizontally,
) {
Icon(item.icon, null)
Spacer(modifier = Modifier.height(Margin.Micro))
Spacer(Modifier.height(Margin.Micro))
Text(stringResource(item.label))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ fun QrCodeBottomSheet(isVisible: () -> Boolean, transferUrl: String, closeBottom
descriptionRes = R.string.shareQrCodeDescription,
) {
Column {
Spacer(modifier = Modifier.height(Margin.Large))
Spacer(Modifier.height(Margin.Large))
QrCode(transferUrl)
Spacer(modifier = Modifier.height(Margin.Large))
Spacer(Modifier.height(Margin.Large))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fun ImportedFilesCard(
secondText = { formatSpaceLeft(humanReadableSize) },
modifier = Modifier.padding(start = Margin.Medium),
)
Spacer(modifier = Modifier.weight(1f))
Spacer(Modifier.weight(1.0f))
Icon(
imageVector = AppIcons.ChevronRightThick,
contentDescription = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ fun TransferOptionType(
tint = SwissTransferTheme.materialColors.primary,
contentDescription = null,
)
Spacer(modifier = Modifier.width(Margin.Small))
Spacer(Modifier.width(Margin.Small))
Text(
text = stringResource(transferOptionType.buttonText),
color = SwissTransferTheme.materialColors.primary,
style = SwissTransferTheme.typography.bodySmallMedium,
)
Spacer(modifier = Modifier.weight(1.0f))
Spacer(Modifier.weight(1.0f))
SettingValue(selectedSetting)
Spacer(modifier = Modifier.width(Margin.Small))
Spacer(Modifier.width(Margin.Small))
Icon(
modifier = Modifier.size(Dimens.SmallIconSize),
imageVector = AppIcons.ChevronRightThick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fun TransferTypeButton(
contentPadding = PaddingValues(Margin.Medium),
) {
Icon(modifier = Modifier.size(Dimens.IconSize), imageVector = transferType.buttonIcon, contentDescription = null)
Spacer(modifier = Modifier.width(Margin.Mini))
Spacer(Modifier.width(Margin.Mini))
Text(text = stringResource(transferType.buttonTextRes), style = SwissTransferTheme.typography.bodySmallRegular)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ private fun UploadProgressScreen(
) {
AdHeader(adScreenType)

Spacer(modifier = Modifier.height(Margin.Medium))
Spacer(Modifier.height(Margin.Medium))
Text(stringResource(R.string.uploadProgressIndication))
Progress(progressState, totalSizeInBytes)
Spacer(modifier = Modifier.height(Margin.Huge))
Spacer(Modifier.height(Margin.Huge))
}

if (showBottomSheet.get()) CancelUploadBottomSheet(onCancel = onCancel, closeButtonSheet = { showBottomSheet.set(false) })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fun UploadSuccessEmailScreen(
description = pluralStringResource(TransferTypeUi.MAIL.descriptionRes!!, emails.count()),
)

Spacer(modifier = Modifier.height(Margin.Medium))
Spacer(Modifier.height(Margin.Medium))

EmailsFlowRow(
emails = emails,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private fun ColumnScope.SuccessMessage(transferType: TransferTypeUi, transferUrl
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
Spacer(modifier = Modifier.height(Margin.Medium))
Spacer(Modifier.height(Margin.Medium))

Image(imageVector = AppIllus.Beers.image(), contentDescription = null)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ fun ColumnScope.AdHeader(adScreenType: UploadProgressAdType) {
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Spacer(modifier = Modifier.height(Margin.Giant))
Spacer(Modifier.height(Margin.Giant))

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

Spacer(modifier = Modifier.height(Margin.Huge))
Spacer(Modifier.height(Margin.Huge))
Text(
text = adScreenType.description(),
modifier = Modifier.widthIn(max = Dimens.DescriptionWidth),
Expand Down
Loading

0 comments on commit bb2852d

Please sign in to comment.