From dbd319112c66212e7c32658b34404bc312d4d40a Mon Sep 17 00:00:00 2001 From: Daniel Kao Date: Mon, 30 Sep 2024 13:19:45 +0800 Subject: [PATCH] ui: change icon painterResource to ImageVector.vectorResource --- .../einkbro/activity/GptActionsActivity.kt | 5 +++-- .../einkbro/activity/GptQueryListActivity.kt | 9 +++++---- .../einkbro/activity/HighlightsActivity.kt | 15 ++++++++------- .../einkbro/setting/SettingComposeUi.kt | 5 +++-- .../view/compose/AutoCompleteTextField.kt | 5 +++-- .../einkbro/view/compose/BrowseHistoryList.kt | 7 ++++--- .../einkbro/view/compose/HistoryAndTabs.kt | 9 +++++---- .../einkbro/view/compose/SearchBar.kt | 4 +++- .../plateaukao/einkbro/view/compose/Toolbar.kt | 5 +++-- .../dialog/compose/BookmarksDialogFragment.kt | 7 ++++--- .../dialog/compose/FastToggleDialogFragment.kt | 6 +++--- .../compose/HighlightStyleDialogFragment.kt | 5 +++-- .../view/dialog/compose/MenuDialogFragment.kt | 4 ++-- .../compose/ToolbarConfigDialogFragment.kt | 5 +++-- .../dialog/compose/TouchAreaDialogFragment.kt | 7 ++++--- .../dialog/compose/TranslateDialogFragment.kt | 17 +++++++++-------- 16 files changed, 65 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/info/plateaukao/einkbro/activity/GptActionsActivity.kt b/app/src/main/java/info/plateaukao/einkbro/activity/GptActionsActivity.kt index 1bbb51785..863368484 100644 --- a/app/src/main/java/info/plateaukao/einkbro/activity/GptActionsActivity.kt +++ b/app/src/main/java/info/plateaukao/einkbro/activity/GptActionsActivity.kt @@ -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 @@ -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)) diff --git a/app/src/main/java/info/plateaukao/einkbro/activity/GptQueryListActivity.kt b/app/src/main/java/info/plateaukao/einkbro/activity/GptQueryListActivity.kt index ca7c8d5a1..faf4c5588 100644 --- a/app/src/main/java/info/plateaukao/einkbro/activity/GptQueryListActivity.kt +++ b/app/src/main/java/info/plateaukao/einkbro/activity/GptQueryListActivity.kt @@ -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 @@ -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" ) } @@ -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 ) @@ -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 ) diff --git a/app/src/main/java/info/plateaukao/einkbro/activity/HighlightsActivity.kt b/app/src/main/java/info/plateaukao/einkbro/activity/HighlightsActivity.kt index 0c4d8ab5c..6da5ce882 100644 --- a/app/src/main/java/info/plateaukao/einkbro/activity/HighlightsActivity.kt +++ b/app/src/main/java/info/plateaukao/einkbro/activity/HighlightsActivity.kt @@ -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 @@ -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) } @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) @@ -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 = "" ) } diff --git a/app/src/main/java/info/plateaukao/einkbro/setting/SettingComposeUi.kt b/app/src/main/java/info/plateaukao/einkbro/setting/SettingComposeUi.kt index bea25db96..e6ece3712 100644 --- a/app/src/main/java/info/plateaukao/einkbro/setting/SettingComposeUi.kt +++ b/app/src/main/java/info/plateaukao/einkbro/setting/SettingComposeUi.kt @@ -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 @@ -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(), diff --git a/app/src/main/java/info/plateaukao/einkbro/view/compose/AutoCompleteTextField.kt b/app/src/main/java/info/plateaukao/einkbro/view/compose/AutoCompleteTextField.kt index 98354484d..d77158cbf 100644 --- a/app/src/main/java/info/plateaukao/einkbro/view/compose/AutoCompleteTextField.kt +++ b/app/src/main/java/info/plateaukao/einkbro/view/compose/AutoCompleteTextField.kt @@ -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 @@ -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 ) diff --git a/app/src/main/java/info/plateaukao/einkbro/view/compose/BrowseHistoryList.kt b/app/src/main/java/info/plateaukao/einkbro/view/compose/BrowseHistoryList.kt index 5037e4ae3..138e7e3e1 100644 --- a/app/src/main/java/info/plateaukao/einkbro/view/compose/BrowseHistoryList.kt +++ b/app/src/main/java/info/plateaukao/einkbro/view/compose/BrowseHistoryList.kt @@ -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 @@ -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 ) @@ -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 ) diff --git a/app/src/main/java/info/plateaukao/einkbro/view/compose/HistoryAndTabs.kt b/app/src/main/java/info/plateaukao/einkbro/view/compose/HistoryAndTabs.kt index 314817e24..9d20b36e0 100644 --- a/app/src/main/java/info/plateaukao/einkbro/view/compose/HistoryAndTabs.kt +++ b/app/src/main/java/info/plateaukao/einkbro/view/compose/HistoryAndTabs.kt @@ -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 @@ -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 ) @@ -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 ) @@ -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 ) diff --git a/app/src/main/java/info/plateaukao/einkbro/view/compose/SearchBar.kt b/app/src/main/java/info/plateaukao/einkbro/view/compose/SearchBar.kt index db113da02..e4f106d2d 100644 --- a/app/src/main/java/info/plateaukao/einkbro/view/compose/SearchBar.kt +++ b/app/src/main/java/info/plateaukao/einkbro/view/compose/SearchBar.kt @@ -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 @@ -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 ) diff --git a/app/src/main/java/info/plateaukao/einkbro/view/compose/Toolbar.kt b/app/src/main/java/info/plateaukao/einkbro/view/compose/Toolbar.kt index e96459770..72dff8bf1 100644 --- a/app/src/main/java/info/plateaukao/einkbro/view/compose/Toolbar.kt +++ b/app/src/main/java/info/plateaukao/einkbro/view/compose/Toolbar.kt @@ -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 @@ -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 ) diff --git a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/BookmarksDialogFragment.kt b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/BookmarksDialogFragment.kt index e1e7f937d..9c12ce132 100644 --- a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/BookmarksDialogFragment.kt +++ b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/BookmarksDialogFragment.kt @@ -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 @@ -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 ) @@ -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 ) diff --git a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/FastToggleDialogFragment.kt b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/FastToggleDialogFragment.kt index 4b653af45..ec22c4650 100644 --- a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/FastToggleDialogFragment.kt +++ b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/FastToggleDialogFragment.kt @@ -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 @@ -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(), @@ -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() diff --git a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/HighlightStyleDialogFragment.kt b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/HighlightStyleDialogFragment.kt index 2ebbffedd..c44e9fecd 100644 --- a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/HighlightStyleDialogFragment.kt +++ b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/HighlightStyleDialogFragment.kt @@ -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 @@ -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 ) diff --git a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/MenuDialogFragment.kt b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/MenuDialogFragment.kt index c4ce82862..d3fb531be 100644 --- a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/MenuDialogFragment.kt +++ b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/MenuDialogFragment.kt @@ -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 @@ -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), diff --git a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/ToolbarConfigDialogFragment.kt b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/ToolbarConfigDialogFragment.kt index 6089f32eb..b4ccbbf50 100644 --- a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/ToolbarConfigDialogFragment.kt +++ b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/ToolbarConfigDialogFragment.kt @@ -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 @@ -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 ) } diff --git a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/TouchAreaDialogFragment.kt b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/TouchAreaDialogFragment.kt index e72486e0b..526556711 100644 --- a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/TouchAreaDialogFragment.kt +++ b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/TouchAreaDialogFragment.kt @@ -22,8 +22,9 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember 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.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview @@ -248,7 +249,7 @@ fun TouchAreaItem( verticalArrangement = Arrangement.Center, ) { Icon( - painter = painterResource(id = iconResId), + imageVector = ImageVector.vectorResource(id = iconResId), contentDescription = null, modifier = Modifier .height(80.dp) @@ -292,7 +293,7 @@ fun ActionItem( color = MaterialTheme.colors.onBackground, ) Icon( - painter = painterResource(id = R.drawable.icon_arrow_right_gest), + imageVector = ImageVector.vectorResource(id = R.drawable.icon_arrow_right_gest), contentDescription = null, tint = MaterialTheme.colors.onBackground ) diff --git a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/TranslateDialogFragment.kt b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/TranslateDialogFragment.kt index 0be1e797e..6d5c2aa26 100644 --- a/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/TranslateDialogFragment.kt +++ b/app/src/main/java/info/plateaukao/einkbro/view/dialog/compose/TranslateDialogFragment.kt @@ -44,8 +44,9 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.rotate import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.vectorResource import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview @@ -229,7 +230,7 @@ private fun CloseButton( closeClick: () -> Unit, ) { Icon( - painter = painterResource(id = R.drawable.icon_close), + imageVector = ImageVector.vectorResource(id = R.drawable.icon_close), contentDescription = "Close Icon", tint = MaterialTheme.colors.onBackground, modifier = Modifier @@ -245,7 +246,7 @@ private fun InfoButton( iconSize: Dp, ) { Icon( - painter = painterResource( + imageVector = ImageVector.vectorResource( id = if (showRequest.value) R.drawable.icon_arrow_up_gest else R.drawable.icon_info ), contentDescription = "Info Icon", @@ -266,7 +267,7 @@ private fun NaverButton( translateNaver: () -> Unit, ) { Icon( - painter = painterResource(id = R.drawable.icon_search), + imageVector = ImageVector.vectorResource(id = R.drawable.icon_search), contentDescription = "Naver dict icon", tint = MaterialTheme.colors.onBackground, modifier = Modifier @@ -287,7 +288,7 @@ private fun PapagoButton( onTargetLanguageClick: () -> Unit, ) { Icon( - painter = painterResource(id = R.drawable.ic_papago), + imageVector = ImageVector.vectorResource(id = R.drawable.ic_papago), contentDescription = "Papago Translate Icon", tint = MaterialTheme.colors.onBackground, modifier = Modifier @@ -309,7 +310,7 @@ private fun GoogleButton( onTargetLanguageClick: () -> Unit, ) { Icon( - painter = painterResource(id = R.drawable.ic_translate_google), + imageVector = ImageVector.vectorResource(id = R.drawable.ic_translate_google), contentDescription = "Google Translate", tint = MaterialTheme.colors.onBackground, modifier = Modifier @@ -331,7 +332,7 @@ private fun DeepLButton( onTargetLanguageClick: () -> Unit, ) { Icon( - painter = painterResource(id = R.drawable.ic_translate), + imageVector = ImageVector.vectorResource(id = R.drawable.ic_translate), contentDescription = "Deepl Translate", tint = MaterialTheme.colors.onBackground, modifier = Modifier @@ -352,7 +353,7 @@ private fun CopyButton( ) { val context = LocalContext.current Icon( - painter = painterResource(id = R.drawable.ic_copy), + imageVector = ImageVector.vectorResource(id = R.drawable.ic_copy), contentDescription = "Copy text", tint = MaterialTheme.colors.onBackground, modifier = Modifier