Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a setting option composable method to easily create a group of mutually exclusive options #27

Merged
merged 17 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package com.infomaniak.swisstransfer.ui.components

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.selection.selectable
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.runtime.Composable
Expand All @@ -29,10 +30,26 @@ import com.infomaniak.swisstransfer.ui.theme.CustomShapes
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme

@Composable
fun SharpRippleButton(modifier: Modifier = Modifier, onClick: () -> Unit, content: @Composable RowScope.() -> Unit) {
fun SharpRippleButton(
modifier: Modifier = Modifier,
isSelected: () -> Boolean = { false },
onClick: () -> Unit,
content: @Composable RowScope.() -> Unit,
) {
val colors = if (isSelected()) {
ButtonDefaults.textButtonColors(
contentColor = SwissTransferTheme.colors.primaryTextColor,
containerColor = SwissTransferTheme.colors.selectedSettingItem,
)
} else {
ButtonDefaults.textButtonColors(contentColor = SwissTransferTheme.colors.primaryTextColor)
}
Button(
modifier = modifier,
colors = ButtonDefaults.textButtonColors(contentColor = SwissTransferTheme.colors.primaryTextColor),
modifier = modifier.selectable(
selected = isSelected(),
onClick = onClick,
),
colors = colors,
shape = CustomShapes.None,
onClick = onClick,
content = content,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.infomaniak.swisstransfer.ui.icons.app

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
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.path
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.infomaniak.swisstransfer.ui.icons.AppIcons
import androidx.compose.ui.graphics.StrokeCap.Companion.Round as strokeCapRound
import androidx.compose.ui.graphics.StrokeJoin.Companion.Round as strokeJoinRound

val AppIcons.Checkmark: ImageVector
get() {
if (_checkmark != null) {
return _checkmark!!
}
_checkmark = Builder(
name = "Checkmark",
defaultWidth = 16.0.dp,
defaultHeight = 16.0.dp,
viewportWidth = 16.0f,
viewportHeight = 16.0f
).apply {
path(
fill = null,
stroke = SolidColor(Color(0xFF9F9F9F)),
strokeLineWidth = 2.0f,
strokeLineCap = strokeCapRound,
strokeLineJoin = strokeJoinRound,
strokeLineMiter = 4.0f,
pathFillType = NonZero
) {
moveTo(15.0f, 3.0f)
lineTo(5.593f, 13.419f)
lineTo(1.0f, 9.085f)
}
}.build()
return _checkmark!!
}

private var _checkmark: ImageVector? = null

@Preview
@Composable
private fun Preview() {
Box {
Image(
imageVector = AppIcons.Checkmark,
contentDescription = null,
modifier = Modifier.size(AppIcons.previewSize)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.infomaniak.swisstransfer.ui.icons.app

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
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
import com.infomaniak.swisstransfer.ui.icons.AppIcons
import androidx.compose.ui.graphics.StrokeCap.Companion.Round as strokeCapRound
import androidx.compose.ui.graphics.StrokeJoin.Companion.Round as strokeJoinRound

val AppIcons.Clock: ImageVector
get() {
if (_clock != null) {
return _clock!!
}
_clock = Builder(
name = "Clock", defaultWidth = 24.0.dp, defaultHeight = 24.0.dp, 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(1.5f, 12.0f)
arcToRelative(10.5f, 10.5f, 0.0f, true, false, 21.0f, 0.0f)
arcToRelative(10.5f, 10.5f, 0.0f, false, false, -21.0f, 0.0f)
moveTo(12.0f, 12.0f)
verticalLineTo(8.25f)
moveTo(12.0f, 12.0f)
lineToRelative(4.687f, 4.688f)
}
}
}.build()
return _clock!!
}

private var _clock: ImageVector? = null

@Preview
@Composable
private fun Preview() {
Box {
Image(
imageVector = AppIcons.Clock,
contentDescription = null,
modifier = Modifier.size(AppIcons.previewSize)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.infomaniak.swisstransfer.ui.icons.app

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
import androidx.compose.ui.graphics.Color
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
import com.infomaniak.swisstransfer.ui.icons.AppIcons
import androidx.compose.ui.graphics.StrokeCap.Companion.Round as strokeCapRound
import androidx.compose.ui.graphics.StrokeJoin.Companion.Round as strokeJoinRound

val AppIcons.FileBadgeArrowDown: ImageVector
get() {
if (_fileBadgeArrowDown != null) {
return _fileBadgeArrowDown!!
}
_fileBadgeArrowDown = Builder(
name = "FileBadgeArrowDown",
defaultWidth = 24.0.dp,
defaultHeight = 24.0.dp,
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(11.25f, 17.25f)
arcToRelative(6.0f, 6.0f, 0.0f, true, false, 12.0f, 0.0f)
arcToRelative(6.0f, 6.0f, 0.0f, false, false, -12.0f, 0.0f)
moveToRelative(6.0f, -3.0f)
verticalLineToRelative(6.0f)
moveToRelative(0.0f, 0.0f)
lineTo(15.0f, 18.0f)
moveToRelative(2.25f, 2.25f)
lineTo(19.5f, 18.0f)
}
path(
fill = null,
stroke = SolidColor(Color(0xFF9f9f9f)),
strokeLineWidth = 1.5f,
strokeLineCap = strokeCapRound,
strokeLineJoin = strokeJoinRound,
strokeLineMiter = 4.0f,
pathFillType = NonZero
) {
moveTo(8.25f, 20.25f)
horizontalLineToRelative(-6.0f)
arcToRelative(1.5f, 1.5f, 0.0f, false, true, -1.5f, -1.5f)
verticalLineTo(2.25f)
arcToRelative(1.5f, 1.5f, 0.0f, false, true, 1.5f, -1.5f)
horizontalLineToRelative(10.629f)
arcToRelative(1.5f, 1.5f, 0.0f, false, true, 1.06f, 0.439f)
lineToRelative(2.872f, 2.872f)
arcToRelative(1.5f, 1.5f, 0.0f, false, true, 0.439f, 1.06f)
verticalLineTo(8.25f)
}
}
}.build()
return _fileBadgeArrowDown!!
}

private var _fileBadgeArrowDown: ImageVector? = null

@Preview
@Composable
private fun Preview() {
Box {
Image(
imageVector = AppIcons.FileBadgeArrowDown,
contentDescription = null,
modifier = Modifier.size(AppIcons.previewSize)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.infomaniak.swisstransfer.ui.icons.app

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
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
import com.infomaniak.swisstransfer.ui.icons.AppIcons
import androidx.compose.ui.graphics.StrokeCap.Companion.Round as strokeCapRound
import androidx.compose.ui.graphics.StrokeJoin.Companion.Round as strokeJoinRound

val AppIcons.PaintbrushPalette: ImageVector
get() {
if (_paintbrushPalette != null) {
return _paintbrushPalette!!
}
_paintbrushPalette = Builder(
name = "PaintbrushPalette",
defaultWidth = 24.0.dp,
defaultHeight = 24.0.dp,
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(10.644f, 17.865f)
curveToRelative(1.589f, -1.9f, 0.1f, -4.338f, 1.513f, -5.981f)
arcToRelative(2.759f, 2.759f, 0.0f, true, true, 4.18f, 3.6f)
arcToRelative(6.5f, 6.5f, 0.0f, false, true, -5.693f, 2.38f)
}
path(
fill = null,
stroke = SolidColor(Color(0xFF9f9f9f)),
strokeLineWidth = 1.5f,
strokeLineCap = strokeCapRound,
strokeLineJoin = strokeJoinRound,
strokeLineMiter = 4.0f,
pathFillType = NonZero
) {
moveTo(16.62f, 12.277f)
lineToRelative(6.232f, -8.253f)
arcTo(2.037f, 2.037f, 0.0f, true, false, 19.4f, 1.88f)
lineTo(14.871f, 11.0f)
}
path(
fill = null,
stroke = SolidColor(Color(0xFF9f9f9f)),
strokeLineWidth = 1.5f,
strokeLineCap = strokeCapRound,
strokeLineJoin = strokeJoinRound,
strokeLineMiter = 4.0f,
pathFillType = NonZero
) {
moveTo(13.5f, 5.225f)
horizontalLineTo(3.75f)
arcToRelative(3.0f, 3.0f, 0.0f, false, false, -3.0f, 3.0f)
verticalLineToRelative(12.0f)
arcToRelative(3.0f, 3.0f, 0.0f, false, false, 3.0f, 3.0f)
horizontalLineToRelative(12.0f)
arcToRelative(3.0f, 3.0f, 0.0f, false, false, 3.0f, -3.0f)
verticalLineToRelative(-1.5f)
}
}
}.build()
return _paintbrushPalette!!
}

private var _paintbrushPalette: ImageVector? = null

@Preview
@Composable
private fun Preview() {
Box {
Image(
imageVector = AppIcons.PaintbrushPalette,
contentDescription = null,
modifier = Modifier.size(AppIcons.previewSize)
)
}
}
Loading
Loading