Skip to content

Commit

Permalink
Merge pull request #193 from Infomaniak/clean-code
Browse files Browse the repository at this point in the history
Clean Spacers & Strokes code
  • Loading branch information
KevinBoulongne authored Nov 19, 2024
2 parents 4de535b + 811cc53 commit 017723f
Show file tree
Hide file tree
Showing 32 changed files with 71 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ internal val FileTypeIcons.Archive: ImageVector
).apply {
path(
fill = SolidColor(Color(0xFF9F9F9F)),
stroke = null,
strokeLineWidth = 0.0f,
strokeLineCap = Butt,
strokeLineJoin = Miter,
strokeLineMiter = 4.0f,
pathFillType = NonZero
pathFillType = NonZero,
) {
moveTo(9.75f, 15.25f)
arcToRelative(0.375f, 0.375f, 0.0f, false, true, 0.0f, -0.75f)
Expand Down Expand Up @@ -101,12 +96,7 @@ internal val FileTypeIcons.Archive: ImageVector
}
path(
fill = SolidColor(Color(0xFF9F9F9F)),
stroke = null,
strokeLineWidth = 0.0f,
strokeLineCap = Butt,
strokeLineJoin = Miter,
strokeLineMiter = 4.0f,
pathFillType = NonZero
pathFillType = NonZero,
) {
moveTo(11.726f, 4.807f)
arcToRelative(1.95f, 1.95f, 0.0f, false, true, -0.474f, 1.533f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ internal val FileTypeIcons.Points: ImageVector
}
path(
fill = SolidColor(Color(0xFF9F9F9F)),
stroke = null,
strokeLineWidth = 0.0f,
strokeLineCap = Butt,
strokeLineJoin = Miter,
strokeLineMiter = 4.0f,
pathFillType = NonZero
pathFillType = NonZero,
) {
moveTo(13.0f, 5.007f)
verticalLineToRelative(6.0f)
Expand All @@ -69,12 +64,7 @@ internal val FileTypeIcons.Points: ImageVector
}
path(
fill = SolidColor(Color(0xFF9F9F9F)),
stroke = null,
strokeLineWidth = 0.0f,
strokeLineCap = Butt,
strokeLineJoin = Miter,
strokeLineMiter = 4.0f,
pathFillType = NonZero
pathFillType = NonZero,
) {
moveTo(11.0f, 7.007f)
arcToRelative(6.0f, 6.0f, 0.0f, true, false, 6.0f, 6.0f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ internal val FileTypeIcons.Video: ImageVector
}
path(
fill = SolidColor(Color(0xFF9F9F9F)),
stroke = null,
strokeLineWidth = 0.0f,
strokeLineCap = Butt,
strokeLineJoin = Miter,
strokeLineMiter = 4.0f,
pathFillType = NonZero
pathFillType = NonZero,
) {
moveTo(9.488f, 15.667f)
arcTo(0.856f, 0.856f, 0.0f, false, true, 8.25f, 14.9f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,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(Dimens.SmallIconSize), 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,11 +51,6 @@ val AppIcons.CircleBlackAndWhite: ImageVector
).apply {
path(
fill = SolidColor(Color(0xFF000000)),
stroke = null,
strokeLineWidth = 0.0f,
strokeLineCap = Butt,
strokeLineJoin = Miter,
strokeLineMiter = 4.0f,
pathFillType = NonZero,
) {
moveTo(12.0f, 0.0f)
Expand All @@ -75,11 +70,6 @@ val AppIcons.CircleBlackAndWhite: ImageVector
}) {
path(
fill = SolidColor(Color(0xFFF5F5F5)),
stroke = null,
strokeLineWidth = 0.0f,
strokeLineCap = Butt,
strokeLineJoin = Miter,
strokeLineMiter = 4.0f,
pathFillType = NonZero,
) {
moveTo(-4.5f, 27.5f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ val AppIcons.EyeCrossed: ImageVector
).apply {
path(
fill = SolidColor(Color(0xFF9F9F9F)),
stroke = null,
strokeLineWidth = 0.0f,
strokeLineCap = Butt,
strokeLineJoin = Miter,
strokeLineMiter = 4.0f,
pathFillType = NonZero,
) {
moveTo(14.715f, 1.154f)
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
Loading

0 comments on commit 017723f

Please sign in to comment.