diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt index 2b70524e4..083ae2d95 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt @@ -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 @@ -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), } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/Chain.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/Chain.kt index 99555e643..d11718e8c 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/Chain.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/images/icons/Chain.kt @@ -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 @@ -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 @@ -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!! diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButton.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButton.kt index b5c02a72d..206accd96 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButton.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButton.kt @@ -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 @@ -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 @@ -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) @@ -69,7 +70,8 @@ private fun TransferTypeButtonPreview() { TransferType.entries.forEach { entry -> TransferTypeButton( transferType = entry, - isActive = { entry.ordinal == 0 } + isActive = { entry.ordinal == 0 }, + onClick = {}, ) } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButtons.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButtons.kt index 254ac8e4e..b52220934 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButtons.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButtons.kt @@ -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 @@ -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), @@ -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 = {}) } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/theme/Dimens.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/theme/Dimens.kt index fb54fcf51..ff95a3e97 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/theme/Dimens.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/theme/Dimens.kt @@ -23,4 +23,5 @@ object Dimens { val SettingHorizontalMargin = Margin.Medium val SettingVerticalMargin = 12.dp val DescriptionWidth = 300.dp + val LargeButtonHeight = 56.dp }