Skip to content

Commit

Permalink
Fix detekt warnings 2810 (Ivy-Apps#2813)
Browse files Browse the repository at this point in the history
* Bump Gradle Wrapper from 8.3 to 8.4 (Ivy-Apps#2759)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Iliyan Germanov <iliyan.germanov971@gmail.com>

* Issue: 2810 - Add previews and fix modifier order

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Iliyan Germanov <iliyan.germanov971@gmail.com>
Co-authored-by: Priyatanu <priyatanu.dey@neugelb.com>
  • Loading branch information
5 people authored Nov 4, 2023
1 parent 0b88cab commit 74c9994
Showing 1 changed file with 41 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.ivy.design.l0_system.UI
import com.ivy.resources.R
import com.ivy.legacy.IvyWalletComponentPreview
import com.ivy.resources.R
import com.ivy.wallet.ui.theme.Gradient

@Deprecated("Old design system. Use `:ivy-design` and Material3")
@Composable
fun CloseButton(
modifier: Modifier = Modifier,
onClick: () -> Unit
onClick: () -> Unit,
) {
CircleButton(
modifier = modifier,
icon = R.drawable.ic_dismiss,
contentDescription = "close",
onClick = onClick
onClick = onClick,
)
}

Expand All @@ -43,18 +43,18 @@ fun CircleButton(
backgroundColor: Color = UI.colors.pure,
borderColor: Color = UI.colors.medium,
tint: Color? = UI.colors.pureInverse,
onClick: () -> Unit
onClick: () -> Unit,
) {
Icon(
modifier = modifier
.clip(CircleShape)
.clickable(onClick = onClick)
.background(backgroundColor, CircleShape)
.border(2.dp, borderColor, CircleShape)
.padding(6.dp), // enlarge click area
.clickable(onClick = onClick) // enlarge click area
.padding(6.dp),
painter = painterResource(id = icon),
contentDescription = contentDescription,
tint = tint ?: Color.Unspecified
tint = tint ?: Color.Unspecified,
)
}

Expand All @@ -67,17 +67,17 @@ fun CircleButtonFilled(
backgroundColor: Color = UI.colors.medium,
tint: Color? = UI.colors.pureInverse,
clickAreaPadding: Dp = 8.dp,
onClick: () -> Unit
onClick: () -> Unit,
) {
Icon(
modifier = modifier
.clip(CircleShape)
.clickable(onClick = onClick)
.background(backgroundColor, CircleShape)
.padding(clickAreaPadding), // enlarge click area
.clickable(onClick = onClick) // enlarge click area
.padding(clickAreaPadding),
painter = painterResource(id = icon),
contentDescription = contentDescription,
tint = tint ?: Color.Unspecified
tint = tint ?: Color.Unspecified,
)
}

Expand All @@ -90,32 +90,31 @@ fun CircleButtonFilledGradient(
iconPadding: Dp = 8.dp,
backgroundGradient: Gradient = Gradient.solid(UI.colors.medium),
tint: Color? = UI.colors.pureInverse,
onClick: () -> Unit
onClick: () -> Unit,
) {
Icon(
modifier = modifier
.clip(CircleShape)
.clickable(onClick = onClick)
.background(backgroundGradient.asHorizontalBrush(), CircleShape)
.padding(iconPadding), // enlarge click area

.clickable(onClick = onClick) // enlarge click area
.padding(iconPadding),
painter = painterResource(id = icon),
contentDescription = contentDescription,
tint = tint ?: Color.Unspecified
tint = tint ?: Color.Unspecified,
)
}

@Deprecated("Old design system. Use `:ivy-design` and Material3")
@Composable
fun BackButton(
modifier: Modifier = Modifier,
onClick: () -> Unit
onClick: () -> Unit,
) {
CircleButton(
modifier = modifier,
icon = R.drawable.ic_back,
contentDescription = "back",
onClick = onClick
onClick = onClick,
)
}

Expand All @@ -136,3 +135,27 @@ private fun PreviewBackButton() {
}
}
}

@Preview
@Composable
private fun PreviewCircleButtonFilled() {
IvyWalletComponentPreview {
CircleButtonFilled(
icon = R.drawable.ic_sort_by_alpha_24,
onClick = {},
clickAreaPadding = 12.dp,
)
}
}

@Preview
@Composable
private fun PreviewCircleButtonFilledGradient() {
IvyWalletComponentPreview {
CircleButtonFilledGradient(
icon = R.drawable.ic_sort_by_alpha_24,
onClick = {},
iconPadding = 12.dp,
)
}
}

0 comments on commit 74c9994

Please sign in to comment.