Skip to content

Commit

Permalink
chores(TransferTypeButtons): Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Oct 16, 2024
1 parent 8811f4a commit 42707c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
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 Down Expand Up @@ -65,4 +64,4 @@ private fun Preview() {
modifier = Modifier.size(AppImages.previewSize)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fun TransferTypeButton(
} else {
SwissTransferTheme.materialColors.outlineVariant to SwissTransferTheme.colors.secondaryTextColor
}

Button(
modifier = Modifier
.padding(Margin.XSmall)
Expand All @@ -54,7 +55,7 @@ fun TransferTypeButton(
) {
Icon(modifier = Modifier.size(Margin.Medium), imageVector = transferType.buttonIcon, contentDescription = null)
Spacer(modifier = Modifier.width(Margin.Small))
Text(text = stringResource(id = transferType.buttonText), style = SwissTransferTheme.typography.bodyRegular)
Text(text = stringResource(transferType.buttonText), style = SwissTransferTheme.typography.bodySmallRegular)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.content.res.Configuration
import androidx.annotation.StringRes
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
Expand All @@ -36,23 +37,29 @@ import com.infomaniak.swisstransfer.ui.images.icons.Chain
import com.infomaniak.swisstransfer.ui.images.icons.Envelope
import com.infomaniak.swisstransfer.ui.images.icons.QrCode
import com.infomaniak.swisstransfer.ui.images.icons.WifiWave
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme

@Composable
fun TransferTypeButtons(selectedTransferType: TransferType) {

val selectedItem by rememberSaveable { mutableStateOf(selectedTransferType) }

Row(modifier = Modifier.horizontalScroll(rememberScrollState())) {
for (entry in TransferType.entries) {
Row(
modifier = Modifier
.horizontalScroll(rememberScrollState())
.padding(horizontal = Margin.Small),
) {
for (transferTypeEntry in TransferType.entries) {
TransferTypeButton(
transferType = entry,
isActive = { entry == selectedItem },
transferType = transferTypeEntry,
isActive = { transferTypeEntry == selectedItem },
)
}
}
}

// TODO: onClick
enum class TransferType(val buttonIcon: ImageVector, @StringRes val buttonText: Int, val onClick: () -> Unit = {}) {
LINK(buttonIcon = AppIcons.Chain, buttonText = R.string.transferTypeLink),
QR_CODE(buttonIcon = AppIcons.QrCode, buttonText = R.string.transferTypeQrCode),
Expand Down

0 comments on commit 42707c7

Please sign in to comment.