From 838d9a84c97849fbd2295b3ed3483de89ec56156 Mon Sep 17 00:00:00 2001 From: Thomas Kioko Date: Thu, 16 Nov 2023 20:28:39 +0100 Subject: [PATCH] Replace painterResource with imageVector --- .../tvmaniac/compose/components/Buttons.kt | 8 ++++---- .../tvmaniac/compose/components/EmptyLayout.kt | 12 ++++++------ .../tvmaniac/compose/components/TopBar.kt | 4 +--- .../thomaskioko/tvmaniac/profile/ProfileScreen.kt | 4 ++-- .../tvmaniac/settings/SettingsScreen.kt | 5 ++--- .../thomaskioko/showdetails/ShowDetailScreen.kt | 14 +++++++------- .../tvmaniac/watchlist/WatchlistScreen.kt | 6 +++--- 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/android-core/designsystem/src/main/kotlin/com/thomaskioko/tvmaniac/compose/components/Buttons.kt b/android-core/designsystem/src/main/kotlin/com/thomaskioko/tvmaniac/compose/components/Buttons.kt index f37d9c332..92ff09257 100644 --- a/android-core/designsystem/src/main/kotlin/com/thomaskioko/tvmaniac/compose/components/Buttons.kt +++ b/android-core/designsystem/src/main/kotlin/com/thomaskioko/tvmaniac/compose/components/Buttons.kt @@ -10,6 +10,8 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.sizeIn import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.LibraryAddCheck import androidx.compose.material3.ButtonColors import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme @@ -23,11 +25,9 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.graphics.Shape -import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.thomaskioko.tvmaniac.compose.theme.TvManiacTheme -import com.thomaskioko.tvmaniac.resources.R @Composable fun TvManiacTextButton( @@ -116,7 +116,7 @@ fun TvManiacOutlinedButton( }, ), - ) + ) } @Composable @@ -204,7 +204,7 @@ fun TvManiacOutlinedButtonPreview() { enabled = true, leadingIcon = { Image( - painter = painterResource(id = R.drawable.ic_baseline_check_box_24), + imageVector = Icons.Filled.LibraryAddCheck, contentDescription = null, colorFilter = ColorFilter.tint( MaterialTheme.colorScheme.secondary.copy( diff --git a/android-core/designsystem/src/main/kotlin/com/thomaskioko/tvmaniac/compose/components/EmptyLayout.kt b/android-core/designsystem/src/main/kotlin/com/thomaskioko/tvmaniac/compose/components/EmptyLayout.kt index 5eecadf5a..1d28d36da 100644 --- a/android-core/designsystem/src/main/kotlin/com/thomaskioko/tvmaniac/compose/components/EmptyLayout.kt +++ b/android-core/designsystem/src/main/kotlin/com/thomaskioko/tvmaniac/compose/components/EmptyLayout.kt @@ -9,6 +9,8 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Inbox import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text @@ -16,18 +18,16 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.ColorFilter -import androidx.compose.ui.graphics.painter.Painter -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 import com.thomaskioko.tvmaniac.common.localization.MR import com.thomaskioko.tvmaniac.compose.theme.TvManiacTheme -import com.thomaskioko.tvmaniac.resources.R @Composable fun EmptyContent( - painter: Painter, + imageVector: ImageVector, message: String, modifier: Modifier = Modifier, ) { @@ -37,7 +37,7 @@ fun EmptyContent( horizontalAlignment = Alignment.CenterHorizontally, ) { Image( - painter = painter, + imageVector = imageVector, colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.secondary.copy(alpha = 0.8F)), modifier = Modifier.size(120.dp), contentDescription = null, @@ -62,7 +62,7 @@ fun EmptyContentViewPreview() { TvManiacTheme { Surface { EmptyContent( - painter = painterResource(id = R.drawable.ic_watchlist_empty), + imageVector = Icons.Outlined.Inbox, message = stringResource(id = MR.strings.generic_empty_content.resourceId), ) } diff --git a/android-core/designsystem/src/main/kotlin/com/thomaskioko/tvmaniac/compose/components/TopBar.kt b/android-core/designsystem/src/main/kotlin/com/thomaskioko/tvmaniac/compose/components/TopBar.kt index 248eee8a1..c8f24b4e4 100644 --- a/android-core/designsystem/src/main/kotlin/com/thomaskioko/tvmaniac/compose/components/TopBar.kt +++ b/android-core/designsystem/src/main/kotlin/com/thomaskioko/tvmaniac/compose/components/TopBar.kt @@ -31,7 +31,6 @@ import androidx.compose.ui.draw.shadow import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.Dp @@ -39,7 +38,6 @@ import androidx.compose.ui.unit.dp import com.thomaskioko.tvmaniac.common.localization.MR import com.thomaskioko.tvmaniac.compose.extensions.iconButtonBackgroundScrim import com.thomaskioko.tvmaniac.compose.theme.TvManiacTheme -import com.thomaskioko.tvmaniac.resources.R @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -72,7 +70,7 @@ fun TvManiacTopBar( navigationIcon = { if (showNavigationIcon) { Image( - painter = painterResource(R.drawable.ic_baseline_arrow_back_24), + imageVector = Icons.Filled.ArrowBack, contentDescription = null, colorFilter = ColorFilter.tint(color = MaterialTheme.colorScheme.onSurface), modifier = Modifier diff --git a/android-features/profile/src/main/kotlin/com/thomaskioko/tvmaniac/profile/ProfileScreen.kt b/android-features/profile/src/main/kotlin/com/thomaskioko/tvmaniac/profile/ProfileScreen.kt index 9eaf97e0e..e0e883317 100644 --- a/android-features/profile/src/main/kotlin/com/thomaskioko/tvmaniac/profile/ProfileScreen.kt +++ b/android-features/profile/src/main/kotlin/com/thomaskioko/tvmaniac/profile/ProfileScreen.kt @@ -63,7 +63,6 @@ import com.thomaskioko.tvmaniac.presentation.profile.LoggedOutContent import com.thomaskioko.tvmaniac.presentation.profile.ProfileState import com.thomaskioko.tvmaniac.presentation.profile.ProfileStats import com.thomaskioko.tvmaniac.presentation.profile.ShowTraktDialog -import com.thomaskioko.tvmaniac.resources.R import dev.chrisbanes.snapper.ExperimentalSnapperApi import dev.chrisbanes.snapper.SnapOffsets import dev.chrisbanes.snapper.rememberSnapperFlingBehavior @@ -167,8 +166,9 @@ fun LoggedOutUi( .fillMaxWidth() .padding(start = 16.dp, end = 16.dp), ) { + Icon( - painter = painterResource(id = R.drawable.trakt_icon_red), + painter = painterResource(id = MR.images.trakt_logo.drawableResId), tint = MaterialTheme.colorScheme.error, contentDescription = null, modifier = Modifier diff --git a/android-features/settings/src/main/kotlin/com/thomaskioko/tvmaniac/settings/SettingsScreen.kt b/android-features/settings/src/main/kotlin/com/thomaskioko/tvmaniac/settings/SettingsScreen.kt index 62a21773f..41e659dec 100644 --- a/android-features/settings/src/main/kotlin/com/thomaskioko/tvmaniac/settings/SettingsScreen.kt +++ b/android-features/settings/src/main/kotlin/com/thomaskioko/tvmaniac/settings/SettingsScreen.kt @@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Palette import androidx.compose.material.icons.filled.Person import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.Divider @@ -42,7 +43,6 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.PreviewParameter @@ -67,7 +67,6 @@ import com.thomaskioko.tvmaniac.presentation.settings.ShowTraktDialog import com.thomaskioko.tvmaniac.presentation.settings.ThemeSelected import com.thomaskioko.tvmaniac.presentation.settings.TraktLogoutClicked import com.thomaskioko.tvmaniac.presentation.settings.UserInfo -import com.thomaskioko.tvmaniac.resources.R import me.tatarka.inject.annotations.Assisted import me.tatarka.inject.annotations.Inject @@ -417,7 +416,7 @@ private fun SettingsThemeItem( horizontalArrangement = Arrangement.SpaceBetween, ) { Icon( - painter = painterResource(R.drawable.ic_palette_24), + imageVector = Icons.Filled.Palette, tint = MaterialTheme.colorScheme.secondary, contentDescription = null, modifier = Modifier diff --git a/android-features/show-details/src/main/kotlin/com/thomaskioko/showdetails/ShowDetailScreen.kt b/android-features/show-details/src/main/kotlin/com/thomaskioko/showdetails/ShowDetailScreen.kt index c372fc2a9..8ae3c8323 100644 --- a/android-features/show-details/src/main/kotlin/com/thomaskioko/showdetails/ShowDetailScreen.kt +++ b/android-features/show-details/src/main/kotlin/com/thomaskioko/showdetails/ShowDetailScreen.kt @@ -26,8 +26,10 @@ import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.LibraryAdd +import androidx.compose.material.icons.filled.LibraryAddCheck +import androidx.compose.material.icons.filled.Movie import androidx.compose.material.icons.filled.PlayCircle -import androidx.compose.material.icons.filled.Slideshow import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults @@ -58,7 +60,6 @@ import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.font.FontWeight @@ -94,7 +95,6 @@ import com.thomaskioko.tvmaniac.presentation.showdetails.WebViewError import com.thomaskioko.tvmaniac.presentation.showdetails.model.Season import com.thomaskioko.tvmaniac.presentation.showdetails.model.Show import com.thomaskioko.tvmaniac.presentation.showdetails.model.Trailer -import com.thomaskioko.tvmaniac.resources.R import dev.chrisbanes.snapper.ExperimentalSnapperApi import dev.chrisbanes.snapper.rememberSnapperFlingBehavior import me.tatarka.inject.annotations.Assisted @@ -555,7 +555,7 @@ fun ShowDetailButtons( TvManiacOutlinedButton( leadingIcon = { Image( - imageVector = Icons.Filled.Slideshow, + imageVector = Icons.Filled.Movie, contentDescription = null, colorFilter = ColorFilter.tint( MaterialTheme.colorScheme.secondary.copy( @@ -575,10 +575,10 @@ fun ShowDetailButtons( TvManiacOutlinedButton( leadingIcon = { Image( - painter = if (isFollowed) { - painterResource(id = R.drawable.ic_baseline_check_box_24) + imageVector = if (isFollowed) { + Icons.Filled.LibraryAddCheck } else { - painterResource(id = R.drawable.ic_baseline_add_box_24) + Icons.Filled.LibraryAdd }, contentDescription = null, colorFilter = ColorFilter.tint( diff --git a/android-features/watchlist/src/main/kotlin/com/thomaskioko/tvmaniac/watchlist/WatchlistScreen.kt b/android-features/watchlist/src/main/kotlin/com/thomaskioko/tvmaniac/watchlist/WatchlistScreen.kt index 7ad873990..f8b213312 100644 --- a/android-features/watchlist/src/main/kotlin/com/thomaskioko/tvmaniac/watchlist/WatchlistScreen.kt +++ b/android-features/watchlist/src/main/kotlin/com/thomaskioko/tvmaniac/watchlist/WatchlistScreen.kt @@ -5,13 +5,14 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.lazy.rememberLazyListState +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Inbox import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.lifecycle.compose.collectAsStateWithLifecycle @@ -30,7 +31,6 @@ import com.thomaskioko.tvmaniac.presentation.watchlist.ReloadWatchlist import com.thomaskioko.tvmaniac.presentation.watchlist.WatchlistContent import com.thomaskioko.tvmaniac.presentation.watchlist.WatchlistItem import com.thomaskioko.tvmaniac.presentation.watchlist.WatchlistState -import com.thomaskioko.tvmaniac.resources.R import me.tatarka.inject.annotations.Assisted import me.tatarka.inject.annotations.Inject @@ -98,7 +98,7 @@ private fun WatchlistScreen( is WatchlistContent -> { when { state.list.isEmpty() -> EmptyContent( - painter = painterResource(id = R.drawable.ic_watchlist_empty), + imageVector = Icons.Outlined.Inbox, message = stringResource(id = MR.strings.msg_empty_favorites.resourceId), )