Skip to content

Commit

Permalink
ui: change icon painterResource to ImageVector.vectorResource
Browse files Browse the repository at this point in the history
  • Loading branch information
plateaukao committed Sep 30, 2024
1 parent 9d49568 commit dbd3191
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogWindowProvider
Expand Down Expand Up @@ -222,7 +223,7 @@ fun GptActionListContent(
// icon: action type
Icon(
modifier = Modifier.wrapContentWidth(),
painter = painterResource(id = iconRes),
imageVector = ImageVector.vectorResource(id = iconRes),
contentDescription = "Action Type",
)
Spacer(modifier = Modifier.width(15.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -118,7 +119,7 @@ class GptQueryListActivity : ComponentActivity() {
showExportFileChooser()
}) {
Icon(
painterResource(id = R.drawable.icon_export),
imageVector = ImageVector.vectorResource(id = R.drawable.icon_export),
contentDescription = "Export"
)
}
Expand Down Expand Up @@ -283,7 +284,7 @@ fun QueryItem(
.clickable {
onLinkClick()
},
painter = painterResource(id = R.drawable.icon_exit),
imageVector = ImageVector.vectorResource(id = R.drawable.icon_exit),
contentDescription = "link",
tint = MaterialTheme.colors.onBackground
)
Expand All @@ -300,7 +301,7 @@ fun QueryItem(
modifier = Modifier
.size(20.dp)
.clickable { deleteQuery() },
painter = painterResource(id = R.drawable.icon_delete),
imageVector = ImageVector.vectorResource(id = R.drawable.icon_delete),
contentDescription = "delete",
tint = MaterialTheme.colors.onBackground
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewModelScope
Expand All @@ -65,7 +66,7 @@ import kotlinx.coroutines.withContext
import java.text.SimpleDateFormat
import java.util.Locale

class HighlightsActivity : ComponentActivity() {
class HighlightsActivity : ComponentActivity() {
private val highlightViewModel: HighlightViewModel by viewModels()
private val backupUnit: BackupUnit by lazy { BackupUnit(this) }

Expand Down Expand Up @@ -223,7 +224,7 @@ fun ArticleItem(
modifier = Modifier
.padding(end = 5.dp)
.size(23.dp),
painter = painterResource(id = R.drawable.icon_exit),
imageVector = ImageVector.vectorResource(id = R.drawable.icon_exit),
contentDescription = "link",
tint = MaterialTheme.colors.onBackground,
)
Expand All @@ -238,7 +239,7 @@ fun ArticleItem(
modifier = Modifier
.size(23.dp)
.clickable { deleteArticle(article) },
painter = painterResource(id = R.drawable.icon_delete),
imageVector = ImageVector.vectorResource(id = R.drawable.icon_delete),
contentDescription = "delete",
tint = MaterialTheme.colors.onBackground,
)
Expand Down Expand Up @@ -314,7 +315,7 @@ fun HighlightItem(
.clickable {
ShareUtil.copyToClipboard(context, highlight.content)
},
painter = painterResource(id = R.drawable.ic_copy),
imageVector = ImageVector.vectorResource(id = R.drawable.ic_copy),
contentDescription = "copy",
tint = MaterialTheme.colors.onBackground,
)
Expand All @@ -325,7 +326,7 @@ fun HighlightItem(
.clickable {
deleteHighlight(highlight)
},
painter = painterResource(id = R.drawable.icon_delete),
imageVector = ImageVector.vectorResource(id = R.drawable.icon_delete),
contentDescription = "delete",
tint = MaterialTheme.colors.onBackground,
)
Expand Down Expand Up @@ -359,7 +360,7 @@ fun HighlightsBar(
IconButton(onClick = onClick) {
Icon(
tint = MaterialTheme.colors.onPrimary,
painter = painterResource(id = R.drawable.icon_export),
imageVector = ImageVector.vectorResource(id = R.drawable.icon_export),
contentDescription = ""
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
Expand Down Expand Up @@ -83,7 +84,7 @@ fun SettingItemUi(
) {
if (setting.iconId != 0) {
Icon(
painter = painterResource(id = setting.iconId), contentDescription = null,
imageVector = ImageVector.vectorResource(id = setting.iconId), contentDescription = null,
modifier = Modifier
.padding(horizontal = 6.dp)
.fillMaxHeight(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.platform.AbstractComposeView
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.ImeAction
Expand Down Expand Up @@ -261,7 +262,7 @@ fun TextBarIcon(
.width(40.dp)
.clickable { onClick() }
.padding(8.dp),
painter = painterResource(id = iconResId),
imageVector = ImageVector.vectorResource(id = iconResId),
contentDescription = null,
tint = MaterialTheme.colors.onBackground
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -92,7 +93,7 @@ private fun RecordItem(
.align(Alignment.CenterVertically)
.size(30.dp)
.padding(end = 5.dp),
painter = painterResource(id = R.drawable.icon_bookmark),
imageVector = ImageVector.vectorResource(id = R.drawable.icon_bookmark),
contentDescription = null,
tint = MaterialTheme.colors.onBackground
)
Expand All @@ -111,7 +112,7 @@ private fun RecordItem(
.align(Alignment.CenterVertically)
.size(30.dp)
.padding(end = 5.dp),
painter = painterResource(id = R.drawable.ic_history),
imageVector = ImageVector.vectorResource(id = R.drawable.ic_history),
contentDescription = null,
tint = MaterialTheme.colors.onBackground
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.AbstractComposeView
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -356,7 +357,7 @@ private fun TabItem(
modifier = Modifier
.size(36.dp)
.padding(end = 5.dp),
painter = painterResource(id = R.drawable.ic_translate),
imageVector = ImageVector.vectorResource(id = R.drawable.ic_translate),
contentDescription = null,
tint = MaterialTheme.colors.onBackground
)
Expand All @@ -374,7 +375,7 @@ private fun TabItem(
modifier = Modifier
.size(36.dp)
.padding(end = 5.dp),
painter = painterResource(id = R.drawable.ic_earth),
imageVector = ImageVector.vectorResource(id = R.drawable.ic_earth),
contentDescription = null,
tint = MaterialTheme.colors.onBackground
)
Expand Down Expand Up @@ -472,7 +473,7 @@ fun ButtonIcon(
onLongClick = onLongClick
)
.padding(12.dp),
painter = painterResource(id = iconResId),
imageVector = ImageVector.vectorResource(id = iconResId),
contentDescription = null,
tint = MaterialTheme.colors.onBackground
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.AbstractComposeView
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import info.plateaukao.einkbro.R
Expand Down Expand Up @@ -93,7 +95,7 @@ fun SearchBarIcon(
.width(40.dp)
.clickable { onClick() }
.padding(8.dp),
painter = painterResource(id = iconResId),
imageVector = ImageVector.vectorResource(id = iconResId),
contentDescription = null,
tint = MaterialTheme.colors.onBackground
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.text.style.TextAlign
Expand Down Expand Up @@ -251,7 +252,7 @@ fun ToolbarIcon(
if (iconResId != 0) {
Icon(
modifier = modifier,
painter = painterResource(id = iconResId),
imageVector = ImageVector.vectorResource(id = iconResId),
contentDescription = stringResource(id = toolbarAction.titleResId),
tint = MaterialTheme.colors.onBackground
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -362,7 +363,7 @@ fun BookmarkItem(
if (shouldShowDragHandle) {
Icon(
modifier = dragModifier.padding(8.dp),
painter = painterResource(id = R.drawable.ic_drag),
imageVector = ImageVector.vectorResource(id = R.drawable.ic_drag),
contentDescription = null,
tint = MaterialTheme.colors.onBackground
)
Expand Down Expand Up @@ -413,7 +414,7 @@ fun ActionIcon(
onClick = { action?.invoke() },
onLongClick = { longClickAction?.invoke() },
),
painter = painterResource(id = iconResId),
imageVector = ImageVector.vectorResource(id = iconResId),
contentDescription = null,
tint = MaterialTheme.colors.onBackground
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
Expand Down Expand Up @@ -190,7 +190,7 @@ fun ToggleItem(

if (iconResId > 0) {
Icon(
painter = painterResource(id = iconResId), contentDescription = null,
imageVector = ImageVector.vectorResource(id = iconResId), contentDescription = null,
modifier = Modifier
.padding(horizontal = 6.dp)
.fillMaxHeight(),
Expand Down Expand Up @@ -219,7 +219,7 @@ fun ToggleItem(
)
if (onEditAction != null) {
Icon(
painter = painterResource(id = R.drawable.icon_edit), contentDescription = null,
imageVector = ImageVector.vectorResource(id = R.drawable.icon_edit), contentDescription = null,
modifier = Modifier
.padding(horizontal = 6.dp)
.fillMaxHeight()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
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.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import info.plateaukao.einkbro.preference.HighlightStyle
Expand Down Expand Up @@ -81,7 +82,7 @@ private fun HighlightStyleContent(
) {
Icon(
modifier = Modifier.size(30.dp),
painter = painterResource(id = highlightStyle.iconResId),
imageVector = ImageVector.vectorResource(id = highlightStyle.iconResId),
contentDescription = null,
tint = highlightStyle.color ?: MaterialTheme.colors.onBackground
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -458,7 +458,7 @@ fun MenuItem(
)
} else {
Icon(
painter = painterResource(id = iconResId), contentDescription = null,
imageVector = ImageVector.vectorResource(id = iconResId), contentDescription = null,
modifier = Modifier
.size(if (isLargeType) 55.dp else 44.dp)
.padding(horizontal = 6.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import info.plateaukao.einkbro.R
Expand Down Expand Up @@ -166,7 +167,7 @@ fun ToolbarToggleItem(
}
Icon(
modifier = modifier.padding(4.dp),
painter = painterResource(id = R.drawable.ic_drag), contentDescription = null,
imageVector = ImageVector.vectorResource(id = R.drawable.ic_drag), contentDescription = null,
tint = MaterialTheme.colors.onBackground
)
}
Expand Down
Loading

0 comments on commit dbd3191

Please sign in to comment.