Skip to content

Commit

Permalink
Replace painterResource with imageVector
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaskioko committed Nov 16, 2023
1 parent 48d085e commit 838d9a8
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -116,7 +116,7 @@ fun TvManiacOutlinedButton(
},
),

)
)
}

@Composable
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ 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
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,
) {
Expand All @@ -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,
Expand All @@ -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),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ 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
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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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),
)

Expand Down

0 comments on commit 838d9a8

Please sign in to comment.