mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Update: Replace painters with ImageVector in SortFilterSheet
This commit is contained in:
parent
0ec9ddb79b
commit
c98e74a562
@ -23,7 +23,7 @@ import androidx.compose.material3.surfaceColorAtElevation
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.painter.Painter
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.machiav3lli.fdroid.entity.ActionState
|
||||
@ -34,7 +34,7 @@ fun ActionButton(
|
||||
modifier: Modifier = Modifier,
|
||||
text: String,
|
||||
positive: Boolean = true,
|
||||
icon: Painter? = null,
|
||||
icon: ImageVector? = null,
|
||||
enabled: Boolean = true,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
@ -58,7 +58,7 @@ fun ActionButton(
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
if (icon != null) Icon(painter = icon, contentDescription = null)
|
||||
if (icon != null) Icon(imageVector = icon, contentDescription = null)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(text = text)
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
@ -40,9 +40,9 @@ fun SelectChip(
|
||||
@Composable
|
||||
fun ChipsSwitch(
|
||||
firstTextId: Int,
|
||||
firstIconId: Int,
|
||||
firstIcon: ImageVector,
|
||||
secondTextId: Int,
|
||||
secondIconId: Int,
|
||||
secondIcon: ImageVector,
|
||||
firstSelected: Boolean = true,
|
||||
onCheckedChange: (Boolean) -> Unit
|
||||
) {
|
||||
@ -70,7 +70,7 @@ fun ChipsSwitch(
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painter = painterResource(id = firstIconId),
|
||||
imageVector = firstIcon,
|
||||
contentDescription = stringResource(id = firstTextId)
|
||||
)
|
||||
},
|
||||
@ -114,7 +114,7 @@ fun ChipsSwitch(
|
||||
},
|
||||
trailingIcon = {
|
||||
Icon(
|
||||
painter = painterResource(id = secondIconId),
|
||||
imageVector = secondIcon,
|
||||
contentDescription = stringResource(id = secondTextId)
|
||||
)
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
package com.machiav3lli.fdroid.ui.compose.icons.phosphor
|
||||
|
||||
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.StrokeCap.Companion.Butt
|
||||
import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter
|
||||
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.unit.dp
|
||||
import com.machiav3lli.fdroid.ui.compose.icons.Phosphor
|
||||
|
||||
val Phosphor.ArrowUUpLeft: ImageVector
|
||||
get() {
|
||||
if (_ArrowUUpLeft != null) {
|
||||
return _ArrowUUpLeft!!
|
||||
}
|
||||
_ArrowUUpLeft = Builder(
|
||||
name = "Arrow-u-up-left",
|
||||
defaultWidth = 32.0.dp,
|
||||
defaultHeight = 32.0.dp,
|
||||
viewportWidth = 256.0f,
|
||||
viewportHeight = 256.0f,
|
||||
).apply {
|
||||
path(
|
||||
fill = SolidColor(Color(0xFF000000)), stroke = null, strokeLineWidth = 0.0f,
|
||||
strokeLineCap = Butt, strokeLineJoin = Miter, strokeLineMiter = 4.0f,
|
||||
pathFillType = NonZero
|
||||
) {
|
||||
moveTo(232.0f, 144.0f)
|
||||
arcToRelative(64.1f, 64.1f, 0.0f, false, true, -64.0f, 64.0f)
|
||||
horizontalLineTo(80.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, true, 0.0f, -16.0f)
|
||||
horizontalLineToRelative(88.0f)
|
||||
arcToRelative(48.0f, 48.0f, 0.0f, false, false, 0.0f, -96.0f)
|
||||
horizontalLineTo(51.3f)
|
||||
lineToRelative(34.4f, 34.3f)
|
||||
arcToRelative(8.1f, 8.1f, 0.0f, false, true, 0.0f, 11.4f)
|
||||
arcToRelative(8.2f, 8.2f, 0.0f, false, true, -11.4f, 0.0f)
|
||||
lineToRelative(-48.0f, -48.0f)
|
||||
arcToRelative(8.1f, 8.1f, 0.0f, false, true, 0.0f, -11.4f)
|
||||
lineToRelative(48.0f, -48.0f)
|
||||
arcTo(8.1f, 8.1f, 0.0f, false, true, 85.7f, 45.7f)
|
||||
lineTo(51.3f, 80.0f)
|
||||
horizontalLineTo(168.0f)
|
||||
arcTo(64.1f, 64.1f, 0.0f, false, true, 232.0f, 144.0f)
|
||||
close()
|
||||
}
|
||||
}
|
||||
.build()
|
||||
return _ArrowUUpLeft!!
|
||||
}
|
||||
|
||||
private var _ArrowUUpLeft: ImageVector? = null
|
@ -0,0 +1,47 @@
|
||||
package com.machiav3lli.fdroid.ui.compose.icons.phosphor
|
||||
|
||||
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.StrokeCap.Companion.Butt
|
||||
import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter
|
||||
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.unit.dp
|
||||
import com.machiav3lli.fdroid.ui.compose.icons.Phosphor
|
||||
|
||||
val Phosphor.Check: ImageVector
|
||||
get() {
|
||||
if (_check != null) {
|
||||
return _check!!
|
||||
}
|
||||
_check = Builder(
|
||||
name = "Check",
|
||||
defaultWidth = 32.0.dp,
|
||||
defaultHeight = 32.0.dp,
|
||||
viewportWidth = 256.0f,
|
||||
viewportHeight = 256.0f,
|
||||
).apply {
|
||||
path(
|
||||
fill = SolidColor(Color(0xFF000000)), stroke = null, strokeLineWidth = 0.0f,
|
||||
strokeLineCap = Butt, strokeLineJoin = Miter, strokeLineMiter = 4.0f,
|
||||
pathFillType = NonZero
|
||||
) {
|
||||
moveTo(104.0f, 192.0f)
|
||||
arcToRelative(8.5f, 8.5f, 0.0f, false, true, -5.7f, -2.3f)
|
||||
lineToRelative(-56.0f, -56.0f)
|
||||
arcToRelative(8.1f, 8.1f, 0.0f, false, true, 11.4f, -11.4f)
|
||||
lineTo(104.0f, 172.7f)
|
||||
lineTo(210.3f, 66.3f)
|
||||
arcToRelative(8.1f, 8.1f, 0.0f, false, true, 11.4f, 11.4f)
|
||||
lineToRelative(-112.0f, 112.0f)
|
||||
arcTo(8.5f, 8.5f, 0.0f, false, true, 104.0f, 192.0f)
|
||||
close()
|
||||
}
|
||||
}
|
||||
.build()
|
||||
return _check!!
|
||||
}
|
||||
|
||||
private var _check: ImageVector? = null
|
@ -0,0 +1,87 @@
|
||||
package com.machiav3lli.fdroid.ui.compose.icons.phosphor
|
||||
|
||||
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.StrokeCap.Companion.Butt
|
||||
import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter
|
||||
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.unit.dp
|
||||
import com.machiav3lli.fdroid.ui.compose.icons.Phosphor
|
||||
|
||||
val Phosphor.SortAscending: ImageVector
|
||||
get() {
|
||||
if (_SortAscending != null) {
|
||||
return _SortAscending!!
|
||||
}
|
||||
_SortAscending = Builder(
|
||||
name = "Sort-ascending",
|
||||
defaultWidth = 32.0.dp,
|
||||
defaultHeight = 32.0.dp,
|
||||
viewportWidth = 256.0f,
|
||||
viewportHeight = 256.0f,
|
||||
).apply {
|
||||
path(
|
||||
fill = SolidColor(Color(0xFF000000)), stroke = null, strokeLineWidth = 0.0f,
|
||||
strokeLineCap = Butt, strokeLineJoin = Miter, strokeLineMiter = 4.0f,
|
||||
pathFillType = NonZero
|
||||
) {
|
||||
moveTo(229.7f, 173.7f)
|
||||
lineToRelative(-40.0f, 40.0f)
|
||||
horizontalLineToRelative(-0.1f)
|
||||
curveToRelative(-0.1f, 0.2f, -0.3f, 0.3f, -0.5f, 0.5f)
|
||||
lineToRelative(-0.3f, 0.2f)
|
||||
lineToRelative(-0.4f, 0.3f)
|
||||
lineToRelative(-0.3f, 0.2f)
|
||||
lineToRelative(-0.3f, 0.2f)
|
||||
horizontalLineToRelative(-0.4f)
|
||||
lineToRelative(-0.3f, 0.2f)
|
||||
horizontalLineToRelative(-0.4f)
|
||||
lineToRelative(-0.4f, 0.2f)
|
||||
horizontalLineToRelative(-4.6f)
|
||||
lineToRelative(-0.4f, -0.2f)
|
||||
horizontalLineToRelative(-0.4f)
|
||||
lineToRelative(-0.3f, -0.2f)
|
||||
horizontalLineToRelative(-0.4f)
|
||||
lineToRelative(-0.3f, -0.2f)
|
||||
lineToRelative(-0.3f, -0.2f)
|
||||
lineToRelative(-0.4f, -0.3f)
|
||||
lineToRelative(-0.3f, -0.2f)
|
||||
lineToRelative(-0.5f, -0.5f)
|
||||
horizontalLineToRelative(-0.1f)
|
||||
lineToRelative(-40.0f, -40.0f)
|
||||
arcToRelative(8.1f, 8.1f, 0.0f, false, true, 11.4f, -11.4f)
|
||||
lineTo(176.0f, 188.7f)
|
||||
lineTo(176.0f, 112.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, true, 16.0f, 0.0f)
|
||||
verticalLineToRelative(76.7f)
|
||||
lineToRelative(26.3f, -26.4f)
|
||||
arcToRelative(8.1f, 8.1f, 0.0f, false, true, 11.4f, 11.4f)
|
||||
close()
|
||||
moveTo(120.0f, 120.0f)
|
||||
lineTo(48.0f, 120.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, false, 0.0f, 16.0f)
|
||||
horizontalLineToRelative(72.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, false, 0.0f, -16.0f)
|
||||
close()
|
||||
moveTo(48.0f, 72.0f)
|
||||
lineTo(184.0f, 72.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, false, 0.0f, -16.0f)
|
||||
lineTo(48.0f, 56.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, false, 0.0f, 16.0f)
|
||||
close()
|
||||
moveTo(104.0f, 184.0f)
|
||||
lineTo(48.0f, 184.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, false, 0.0f, 16.0f)
|
||||
horizontalLineToRelative(56.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, false, 0.0f, -16.0f)
|
||||
close()
|
||||
}
|
||||
}
|
||||
.build()
|
||||
return _SortAscending!!
|
||||
}
|
||||
|
||||
private var _SortAscending: ImageVector? = null
|
@ -0,0 +1,89 @@
|
||||
package com.machiav3lli.fdroid.ui.compose.icons.phosphor
|
||||
|
||||
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.StrokeCap.Companion.Butt
|
||||
import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter
|
||||
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.unit.dp
|
||||
import com.machiav3lli.fdroid.ui.compose.icons.Phosphor
|
||||
|
||||
val Phosphor.SortDescending: ImageVector
|
||||
get() {
|
||||
if (_SortDescending != null) {
|
||||
return _SortDescending!!
|
||||
}
|
||||
_SortDescending = Builder(
|
||||
name = "Sort-descending",
|
||||
defaultWidth = 32.0.dp,
|
||||
defaultHeight = 32.0.dp,
|
||||
viewportWidth = 256.0f,
|
||||
viewportHeight = 256.0f,
|
||||
).apply {
|
||||
path(
|
||||
fill = SolidColor(Color(0xFF000000)), stroke = null, strokeLineWidth = 0.0f,
|
||||
strokeLineCap = Butt, strokeLineJoin = Miter, strokeLineMiter = 4.0f,
|
||||
pathFillType = NonZero
|
||||
) {
|
||||
moveTo(229.7f, 93.6f)
|
||||
arcToRelative(8.1f, 8.1f, 0.0f, false, true, -11.4f, 0.1f)
|
||||
lineTo(192.0f, 67.3f)
|
||||
lineTo(192.0f, 144.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, true, -16.0f, 0.0f)
|
||||
lineTo(176.0f, 67.3f)
|
||||
lineTo(149.7f, 93.7f)
|
||||
arcToRelative(8.2f, 8.2f, 0.0f, false, true, -11.4f, 0.0f)
|
||||
arcToRelative(8.1f, 8.1f, 0.0f, false, true, 0.0f, -11.4f)
|
||||
lineToRelative(40.0f, -40.0f)
|
||||
horizontalLineToRelative(0.1f)
|
||||
curveToRelative(0.2f, -0.2f, 0.4f, -0.3f, 0.5f, -0.5f)
|
||||
lineToRelative(0.3f, -0.2f)
|
||||
lineToRelative(0.4f, -0.3f)
|
||||
lineToRelative(0.3f, -0.2f)
|
||||
lineToRelative(0.3f, -0.2f)
|
||||
horizontalLineToRelative(0.4f)
|
||||
lineToRelative(0.3f, -0.2f)
|
||||
horizontalLineToRelative(0.4f)
|
||||
lineToRelative(0.4f, -0.2f)
|
||||
horizontalLineToRelative(4.6f)
|
||||
lineToRelative(0.4f, 0.2f)
|
||||
horizontalLineToRelative(0.4f)
|
||||
lineToRelative(0.3f, 0.2f)
|
||||
horizontalLineToRelative(0.4f)
|
||||
lineToRelative(0.3f, 0.2f)
|
||||
lineToRelative(0.3f, 0.2f)
|
||||
lineToRelative(0.4f, 0.3f)
|
||||
lineToRelative(0.3f, 0.2f)
|
||||
curveToRelative(0.2f, 0.2f, 0.4f, 0.3f, 0.5f, 0.5f)
|
||||
horizontalLineToRelative(0.1f)
|
||||
lineToRelative(40.0f, 40.0f)
|
||||
arcTo(8.0f, 8.0f, 0.0f, false, true, 229.7f, 93.6f)
|
||||
close()
|
||||
moveTo(48.0f, 136.0f)
|
||||
horizontalLineToRelative(72.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, false, 0.0f, -16.0f)
|
||||
lineTo(48.0f, 120.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, false, 0.0f, 16.0f)
|
||||
close()
|
||||
moveTo(48.0f, 72.0f)
|
||||
horizontalLineToRelative(56.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, false, 0.0f, -16.0f)
|
||||
lineTo(48.0f, 56.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, false, 0.0f, 16.0f)
|
||||
close()
|
||||
moveTo(184.0f, 184.0f)
|
||||
lineTo(48.0f, 184.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, false, 0.0f, 16.0f)
|
||||
lineTo(184.0f, 200.0f)
|
||||
arcToRelative(8.0f, 8.0f, 0.0f, false, false, 0.0f, -16.0f)
|
||||
close()
|
||||
}
|
||||
}
|
||||
.build()
|
||||
return _SortDescending!!
|
||||
}
|
||||
|
||||
private var _SortDescending: ImageVector? = null
|
@ -30,7 +30,6 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
@ -44,6 +43,11 @@ import com.machiav3lli.fdroid.index.RepositoryUpdater.db
|
||||
import com.machiav3lli.fdroid.ui.compose.components.ActionButton
|
||||
import com.machiav3lli.fdroid.ui.compose.components.ChipsSwitch
|
||||
import com.machiav3lli.fdroid.ui.compose.components.SelectChip
|
||||
import com.machiav3lli.fdroid.ui.compose.icons.Phosphor
|
||||
import com.machiav3lli.fdroid.ui.compose.icons.phosphor.ArrowUUpLeft
|
||||
import com.machiav3lli.fdroid.ui.compose.icons.phosphor.Check
|
||||
import com.machiav3lli.fdroid.ui.compose.icons.phosphor.SortAscending
|
||||
import com.machiav3lli.fdroid.ui.compose.icons.phosphor.SortDescending
|
||||
import com.machiav3lli.fdroid.ui.compose.theme.AppTheme
|
||||
import com.machiav3lli.fdroid.ui.navigation.NavItem
|
||||
import com.machiav3lli.fdroid.utility.isDarkTheme
|
||||
@ -142,13 +146,13 @@ class SortFilterSheet() : FullscreenBottomSheetDialogFragment() {
|
||||
ActionButton(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = stringResource(id = R.string.action_reset),
|
||||
icon = painterResource(id = R.drawable.ic_delete),
|
||||
icon = Phosphor.ArrowUUpLeft,
|
||||
positive = false,
|
||||
onClick = ::dismissAllowingStateLoss
|
||||
)
|
||||
ActionButton(
|
||||
text = stringResource(id = R.string.action_apply),
|
||||
icon = painterResource(id = R.drawable.ic_check),
|
||||
icon = Phosphor.Check,
|
||||
modifier = Modifier.weight(1f),
|
||||
positive = true,
|
||||
onClick = {
|
||||
@ -197,9 +201,9 @@ class SortFilterSheet() : FullscreenBottomSheetDialogFragment() {
|
||||
|
||||
ChipsSwitch(
|
||||
firstTextId = R.string.sort_ascending,
|
||||
firstIconId = R.drawable.ic_arrow_up,
|
||||
firstIcon = Phosphor.SortAscending,
|
||||
secondTextId = R.string.sort_descending,
|
||||
secondIconId = R.drawable.ic_arrow_down,
|
||||
secondIcon = Phosphor.SortDescending,
|
||||
firstSelected = sortAscending,
|
||||
onCheckedChange = { checked ->
|
||||
sortAscending = checked
|
||||
|
Loading…
x
Reference in New Issue
Block a user