fix: icon size and github tint

This commit is contained in:
FunkyMuse 2023-08-02 12:34:49 +02:00
parent f41a2f576c
commit f37b14836f
2 changed files with 36 additions and 10 deletions

View file

@ -2,6 +2,7 @@ package com.simplemobiletools.commons.compose.screens
import androidx.compose.foundation.layout.*
import androidx.compose.material3.ListItem
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@ -136,7 +137,7 @@ internal fun SocialSection(
SettingsTitleTextComponent(text = stringResource(id = R.string.social), modifier = startingTitlePadding)
}) {
SettingsListItem(click = onFacebookClick, text = stringResource(id = R.string.facebook), icon = R.drawable.ic_facebook_vector, isImage = true)
SettingsListItem(click = onGithubClick, text = stringResource(id = R.string.github), icon = R.drawable.ic_github_vector, isImage = true)
SettingsListItem(click = onGithubClick, text = stringResource(id = R.string.github), icon = R.drawable.ic_github_vector, isImage = true, tint = MaterialTheme.colorScheme.onSurface)
SettingsListItem(click = onRedditClick, text = stringResource(id = R.string.reddit), icon = R.drawable.ic_reddit_vector, isImage = true)
SettingsListItem(click = onTelegramClick, text = stringResource(id = R.string.telegram), icon = R.drawable.ic_telegram_vector, isImage = true)
SettingsHorizontalDivider()

View file

@ -4,12 +4,15 @@ import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.ListItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
@ -25,6 +28,7 @@ fun SettingsListItem(
@DrawableRes icon: Int,
isImage: Boolean = false,
click: (() -> Unit)? = null,
tint: Color? = null
) {
ListItem(
headlineContent = {
@ -36,17 +40,38 @@ fun SettingsListItem(
)
},
leadingContent = {
val imageSize = Modifier.size(48.dp)
.padding(8.dp)
if (isImage) {
Image(
modifier = Modifier.size(24.dp),
painter = painterResource(id = icon),
contentDescription = text,
)
if (tint != null) {
Image(
modifier = imageSize,
painter = painterResource(id = icon),
contentDescription = text,
colorFilter = ColorFilter.tint(tint)
)
} else {
Image(
modifier = imageSize,
painter = painterResource(id = icon),
contentDescription = text,
)
}
} else {
Icon(
painter = painterResource(id = icon),
contentDescription = text,
)
if (tint != null) {
Icon(
modifier = imageSize,
painter = painterResource(id = icon),
contentDescription = text,
tint = tint
)
} else {
Icon(
modifier = imageSize,
painter = painterResource(id = icon),
contentDescription = text,
)
}
}
},
modifier = Modifier