PM-17769 Icons added to the settings menu rows (#4673)

This commit is contained in:
Dave Severns
2025-02-03 15:18:32 -05:00
committed by GitHub
parent efe1475fbf
commit 5f52c49a68
6 changed files with 103 additions and 13 deletions

View File

@@ -142,6 +142,15 @@ fun Modifier.bottomDivider(
alpha: Float = 1f,
): Modifier = drawWithCache {
onDrawWithContent {
val (startX, endX) = when (layoutDirection) {
LayoutDirection.Ltr -> {
paddingStart.toPx() to (size.width - paddingEnd.toPx())
}
LayoutDirection.Rtl -> {
(size.width - paddingEnd.toPx()) to paddingStart.toPx()
}
}
drawContent()
if (enabled) {
drawLine(
@@ -149,11 +158,11 @@ fun Modifier.bottomDivider(
color = color,
strokeWidth = thickness.toPx(),
start = Offset(
x = paddingStart.toPx(),
x = startX,
y = size.height - thickness.toPx() / 2,
),
end = Offset(
x = size.width - paddingEnd.toPx(),
x = endX,
y = size.height - thickness.toPx() / 2,
),
)

View File

@@ -1,5 +1,6 @@
package com.x8bit.bitwarden.ui.platform.feature.settings
import androidx.annotation.DrawableRes
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@@ -98,7 +99,12 @@ fun SettingsScreen(
key = settingEntry,
defaultValue = 0,
),
cardStyle = Settings.entries.toListItemCardStyle(index = index),
cardStyle = Settings.entries.toListItemCardStyle(
index = index,
// Start padding, plus icon, plus spacing between text.
dividerPadding = 48.dp,
),
iconVectorResource = settingEntry.vectorIconRes,
modifier = Modifier
.testTag(tag = settingEntry.testTag)
.standardHorizontalMargin()
@@ -115,28 +121,40 @@ private fun SettingsRow(
onClick: () -> Unit,
notificationCount: Int,
cardStyle: CardStyle?,
@DrawableRes iconVectorResource: Int,
modifier: Modifier = Modifier,
) {
Row(
modifier = modifier
.fillMaxWidth()
.defaultMinSize(minHeight = 60.dp)
.cardStyle(
cardStyle = cardStyle,
onClick = onClick,
paddingStart = 16.dp,
paddingStart = 12.dp,
paddingEnd = 12.dp,
),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
) {
Text(
modifier = Modifier
.padding(end = 16.dp)
.weight(weight = 1f),
text = text(),
style = BitwardenTheme.typography.bodyLarge,
color = BitwardenTheme.colorScheme.text.primary,
)
Row(
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
painter = rememberVectorPainter(iconVectorResource),
contentDescription = null,
tint = BitwardenTheme.colorScheme.icon.primary,
modifier = Modifier.size(24.dp),
)
Spacer(Modifier.width(12.dp))
Text(
modifier = Modifier
.padding(end = 16.dp),
text = text(),
style = BitwardenTheme.typography.bodyLarge,
color = BitwardenTheme.colorScheme.text.primary,
)
}
TrailingContent(notificationCount = notificationCount)
}
}
@@ -185,7 +203,11 @@ private fun SettingsRows_preview() {
text = it.text,
onClick = { },
notificationCount = index % 3,
cardStyle = Settings.entries.toListItemCardStyle(index = index),
iconVectorResource = it.vectorIconRes,
cardStyle = Settings.entries.toListItemCardStyle(
index = index,
dividerPadding = 48.dp,
),
)
}
}

View File

@@ -1,5 +1,6 @@
package com.x8bit.bitwarden.ui.platform.feature.settings
import androidx.annotation.DrawableRes
import androidx.compose.material3.Text
import androidx.lifecycle.viewModelScope
import com.x8bit.bitwarden.R
@@ -194,30 +195,37 @@ sealed class SettingsAction {
*/
enum class Settings(
val text: Text,
@DrawableRes val vectorIconRes: Int,
val testTag: String,
) {
ACCOUNT_SECURITY(
text = R.string.account_security.asText(),
vectorIconRes = R.drawable.ic_locked,
testTag = "AccountSecuritySettingsButton",
),
AUTO_FILL(
text = R.string.autofill.asText(),
vectorIconRes = R.drawable.ic_check_mark,
testTag = "AutofillSettingsButton",
),
VAULT(
text = R.string.vault.asText(),
vectorIconRes = R.drawable.ic_vault,
testTag = "VaultSettingsButton",
),
APPEARANCE(
text = R.string.appearance.asText(),
vectorIconRes = R.drawable.ic_paintbrush,
testTag = "AppearanceSettingsButton",
),
OTHER(
text = R.string.other.asText(),
vectorIconRes = R.drawable.ic_filter,
testTag = "OtherSettingsButton",
),
ABOUT(
text = R.string.about.asText(),
vectorIconRes = R.drawable.ic_info_circle,
testTag = "AboutSettingsButton",
),
}

View File

@@ -0,0 +1,22 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M3,4.3C3,3.582 3.582,3 4.3,3H10.007C10.725,3 11.307,3.582 11.307,4.3V10.008C11.307,10.726 10.725,11.308 10.007,11.308H4.3C3.582,11.308 3,10.726 3,10.008V4.3ZM4.5,9.808V4.5H9.807V9.808H4.5Z"
android:fillColor="#5A6D91"
android:fillType="evenOdd"/>
<path
android:pathData="M3,13.993C3,13.275 3.582,12.693 4.3,12.693H10.007C10.725,12.693 11.307,13.275 11.307,13.993V19.7C11.307,20.418 10.725,21 10.007,21H4.3C3.582,21 3,20.418 3,19.7V13.993ZM4.5,19.5V14.193H9.807V19.5H4.5Z"
android:fillColor="#5A6D91"
android:fillType="evenOdd"/>
<path
android:pathData="M13.993,3C13.275,3 12.693,3.582 12.693,4.3V10.008C12.693,10.726 13.275,11.308 13.993,11.308H19.7C20.418,11.308 21,10.726 21,10.008V4.3C21,3.582 20.418,3 19.7,3H13.993ZM14.193,4.5V9.808H19.5V4.5H14.193Z"
android:fillColor="#5A6D91"
android:fillType="evenOdd"/>
<path
android:pathData="M12.693,13.993C12.693,13.275 13.275,12.693 13.993,12.693H19.7C20.418,12.693 21,13.275 21,13.993V19.7C21,20.418 20.418,21 19.7,21H13.993C13.275,21 12.693,20.418 12.693,19.7V13.993ZM14.193,19.5V14.193H19.5V19.5H14.193Z"
android:fillColor="#5A6D91"
android:fillType="evenOdd"/>
</vector>

View File

@@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M9.688,10.438C9.688,10.023 10.023,9.688 10.438,9.688H12C12.414,9.688 12.75,10.023 12.75,10.438V17.313C12.75,17.727 12.414,18.063 12,18.063C11.586,18.063 11.25,17.727 11.25,17.313V11.188H10.438C10.023,11.188 9.688,10.852 9.688,10.438Z"
android:fillColor="#5A6D91"/>
<path
android:pathData="M12,8.25C12.69,8.25 13.25,7.69 13.25,7C13.25,6.31 12.69,5.75 12,5.75C11.31,5.75 10.75,6.31 10.75,7C10.75,7.69 11.31,8.25 12,8.25Z"
android:fillColor="#5A6D91"/>
<path
android:pathData="M12,22C17.523,22 22,17.523 22,12C22,6.477 17.523,2 12,2C6.477,2 2,6.477 2,12C2,17.523 6.477,22 12,22ZM12,20.5C16.694,20.5 20.5,16.694 20.5,12C20.5,7.306 16.694,3.5 12,3.5C7.306,3.5 3.5,7.306 3.5,12C3.5,16.694 7.306,20.5 12,20.5Z"
android:fillColor="#5A6D91"
android:fillType="evenOdd"/>
</vector>

View File

@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M2.018,20.738L2.765,20.902L2.924,21.65C2.67,21.704 2.405,21.625 2.222,21.441C2.039,21.257 1.962,20.992 2.018,20.738Z"
android:fillColor="#5A6D91"/>
<path
android:pathData="M2.765,20.902L2.924,21.65L3.087,21.615C3.192,21.593 3.342,21.561 3.526,21.521C3.894,21.442 4.396,21.333 4.935,21.213C6.001,20.976 7.243,20.691 7.844,20.518C8.341,20.374 9.172,20.02 9.751,19.441C10.302,18.891 10.664,18.222 10.833,17.519L21.091,7.066C22.311,5.823 22.302,3.829 21.07,2.597C19.837,1.364 17.84,1.356 16.597,2.579L6.142,12.866C5.45,13.038 4.793,13.398 4.25,13.941C3.671,14.52 3.319,15.349 3.174,15.844L3.174,15.846C3,16.444 2.709,17.678 2.466,18.739C2.344,19.275 2.232,19.774 2.15,20.14C2.11,20.323 2.076,20.472 2.054,20.576L2.018,20.738L2.765,20.902ZM5.332,15.023C5.748,14.607 6.265,14.366 6.792,14.298L9.394,16.895C9.327,17.423 9.086,17.942 8.669,18.359C8.343,18.686 7.784,18.942 7.42,19.047C6.874,19.205 5.683,19.479 4.603,19.719C4.31,19.784 4.027,19.846 3.772,19.902C3.829,19.649 3.892,19.37 3.958,19.08C4.204,18.007 4.484,16.82 4.643,16.273C4.751,15.904 5.006,15.348 5.332,15.023ZM13.197,12.925L19.999,5.994C20.631,5.35 20.626,4.317 19.988,3.679C19.349,3.04 18.315,3.036 17.671,3.67L10.75,10.479L13.197,12.925ZM12.125,14.018L9.659,11.552L7.921,13.262L10.419,15.756L12.125,14.018Z"
android:fillColor="#5A6D91"
android:fillType="evenOdd"/>
</vector>