Skip to content

Commit

Permalink
chore(TransferTypeButtons): Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Oct 16, 2024
1 parent 42707c7 commit 4c205a6
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.compose.ui.unit.dp
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons
import com.infomaniak.swisstransfer.ui.images.icons.Add
import com.infomaniak.swisstransfer.ui.theme.Dimens
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.Shapes
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
Expand Down Expand Up @@ -112,8 +113,8 @@ enum class ButtonType(val buttonColors: @Composable () -> ButtonColors) {
}),
}

enum class ButtonSize(val height: Dp) {
LARGE(56.dp),
private enum class ButtonSize(val height: Dp) {
LARGE(Dimens.LargeButtonHeight),
SMALL(40.dp),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.infomaniak.swisstransfer.ui.images.icons

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand All @@ -11,7 +10,6 @@ import androidx.compose.ui.graphics.PathFillType.Companion.NonZero
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.graphics.vector.group
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -31,37 +29,35 @@ val AppIcons.Chain: ImageVector
viewportWidth = 24.0f,
viewportHeight = 24.0f,
).apply {
group {
path(
fill = null,
stroke = SolidColor(Color(0xFF9F9F9F)),
strokeLineWidth = 1.5f,
strokeLineCap = strokeCapRound,
strokeLineJoin = strokeJoinRound,
strokeLineMiter = 4.0f,
pathFillType = NonZero,
) {
moveTo(9.365f, 19.127f)
lineToRelative(-0.932f, 0.932f)
arcToRelative(4.5f, 4.5f, 0.0f, false, true, -6.364f, -6.364f)
lineTo(6.842f, 8.92f)
arcToRelative(4.5f, 4.5f, 0.0f, false, true, 6.826f, 5.825f)
}
path(
fill = null,
stroke = SolidColor(Color(0xFF9F9F9F)),
strokeLineWidth = 1.5f,
strokeLineCap = strokeCapRound,
strokeLineJoin = strokeJoinRound,
strokeLineMiter = 4.0f,
pathFillType = NonZero
) {
moveTo(14.82f, 6.194f)
lineToRelative(0.75f, -0.75f)
arcToRelative(4.5f, 4.5f, 0.0f, true, true, 6.363f, 6.364f)
lineTo(17.16f, 16.58f)
arcToRelative(4.5f, 4.5f, 0.0f, false, true, -6.824f, -5.826f)
}
path(
fill = null,
stroke = SolidColor(Color(0xFF9F9F9F)),
strokeLineWidth = 1.5f,
strokeLineCap = strokeCapRound,
strokeLineJoin = strokeJoinRound,
strokeLineMiter = 4.0f,
pathFillType = NonZero,
) {
moveTo(9.365f, 19.127f)
lineToRelative(-0.932f, 0.932f)
arcToRelative(4.5f, 4.5f, 0.0f, false, true, -6.364f, -6.364f)
lineTo(6.842f, 8.92f)
arcToRelative(4.5f, 4.5f, 0.0f, false, true, 6.826f, 5.825f)
}
path(
fill = null,
stroke = SolidColor(Color(0xFF9F9F9F)),
strokeLineWidth = 1.5f,
strokeLineCap = strokeCapRound,
strokeLineJoin = strokeJoinRound,
strokeLineMiter = 4.0f,
pathFillType = NonZero
) {
moveTo(14.82f, 6.194f)
lineToRelative(0.75f, -0.75f)
arcToRelative(4.5f, 4.5f, 0.0f, true, true, 6.363f, 6.364f)
lineTo(17.16f, 16.58f)
arcToRelative(4.5f, 4.5f, 0.0f, false, true, -6.824f, -5.826f)
}
}.build()
return _chain!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.infomaniak.swisstransfer.ui.components.ButtonSize
import com.infomaniak.swisstransfer.ui.theme.Dimens
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.Shapes
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
Expand All @@ -36,6 +36,7 @@ import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
fun TransferTypeButton(
transferType: TransferType,
isActive: () -> Boolean,
onClick: () -> Unit,
) {
val (borderColor, contentColor) = if (isActive()) {
SwissTransferTheme.materialColors.primary to SwissTransferTheme.materialColors.primary
Expand All @@ -46,11 +47,11 @@ fun TransferTypeButton(
Button(
modifier = Modifier
.padding(Margin.XSmall)
.height(ButtonSize.LARGE.height)
.height(Dimens.LargeButtonHeight)
.border(width = 1.dp, color = borderColor, shape = Shapes.small),
shape = Shapes.small,
colors = ButtonDefaults.buttonColors(containerColor = Color.Transparent, contentColor = contentColor),
onClick = transferType.onClick,
onClick = onClick,
contentPadding = PaddingValues(Margin.Medium),
) {
Icon(modifier = Modifier.size(Margin.Medium), imageVector = transferType.buttonIcon, contentDescription = null)
Expand All @@ -69,7 +70,8 @@ private fun TransferTypeButtonPreview() {
TransferType.entries.forEach { entry ->
TransferTypeButton(
transferType = entry,
isActive = { entry.ordinal == 0 }
isActive = { entry.ordinal == 0 },
onClick = {},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme

@Composable
fun TransferTypeButtons(selectedTransferType: TransferType) {
fun TransferTypeButtons(initialSelectedTransferType: TransferType, onClick: (TransferType) -> Unit) {

val selectedItem by rememberSaveable { mutableStateOf(selectedTransferType) }
val selectedItem by rememberSaveable { mutableStateOf(initialSelectedTransferType) }

Row(
modifier = Modifier
Expand All @@ -54,13 +54,13 @@ fun TransferTypeButtons(selectedTransferType: TransferType) {
TransferTypeButton(
transferType = transferTypeEntry,
isActive = { transferTypeEntry == selectedItem },
onClick = { onClick(transferTypeEntry) },
)
}
}
}

// TODO: onClick
enum class TransferType(val buttonIcon: ImageVector, @StringRes val buttonText: Int, val onClick: () -> Unit = {}) {
enum class TransferType(val buttonIcon: ImageVector, @StringRes val buttonText: Int) {
LINK(buttonIcon = AppIcons.Chain, buttonText = R.string.transferTypeLink),
QR_CODE(buttonIcon = AppIcons.QrCode, buttonText = R.string.transferTypeQrCode),
PROXIMITY(buttonIcon = AppIcons.WifiWave, buttonText = R.string.transferTypeProximity),
Expand All @@ -73,7 +73,7 @@ enum class TransferType(val buttonIcon: ImageVector, @StringRes val buttonText:
private fun TransferTypeButtonsPreview() {
SwissTransferTheme {
Surface {
TransferTypeButtons(selectedTransferType = TransferType.QR_CODE)
TransferTypeButtons(initialSelectedTransferType = TransferType.QR_CODE, onClick = {})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ object Dimens {
val SettingHorizontalMargin = Margin.Medium
val SettingVerticalMargin = 12.dp
val DescriptionWidth = 300.dp
val LargeButtonHeight = 56.dp
}

0 comments on commit 4c205a6

Please sign in to comment.