Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Remove deprecated SunflowerImage Glide wrapper in favor of GlideImage #945

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
Expand All @@ -33,7 +32,6 @@ import androidx.compose.foundation.lazy.grid.rememberLazyGridState
import androidx.compose.material3.Button
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -49,15 +47,16 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.hilt.navigation.compose.hiltViewModel
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
import com.bumptech.glide.integration.compose.GlideImage
import com.google.samples.apps.sunflower.R
import com.google.samples.apps.sunflower.compose.utils.SunflowerImage
import com.google.samples.apps.sunflower.data.GardenPlanting
import com.google.samples.apps.sunflower.data.Plant
import com.google.samples.apps.sunflower.data.PlantAndGardenPlantings
import com.google.samples.apps.sunflower.ui.SunflowerTheme
import com.google.samples.apps.sunflower.viewmodels.GardenPlantingListViewModel
import com.google.samples.apps.sunflower.viewmodels.PlantAndGardenPlantingsViewModel
import java.util.*
import java.util.Calendar

@Composable
fun GardenScreen(
Expand Down Expand Up @@ -117,7 +116,7 @@ private fun GardenList(
}

@OptIn(
ExperimentalMaterial3Api::class
ExperimentalGlideComposeApi::class
)
@Composable
private fun GardenListItem(
Expand All @@ -140,7 +139,7 @@ private fun GardenListItem(
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.secondaryContainer)
) {
Column(Modifier.fillMaxWidth()) {
SunflowerImage(
GlideImage(
model = vm.imageUrl,
contentDescription = plant.plant.description,
Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Share
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FloatingActionButton
Expand Down Expand Up @@ -82,13 +82,14 @@ import androidx.compose.ui.viewinterop.AndroidViewBinding
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.core.text.HtmlCompat
import androidx.hilt.navigation.compose.hiltViewModel
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
import com.bumptech.glide.integration.compose.GlideImage
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import com.google.samples.apps.sunflower.R
import com.google.samples.apps.sunflower.compose.Dimens
import com.google.samples.apps.sunflower.compose.utils.SunflowerImage
import com.google.samples.apps.sunflower.compose.utils.TextSnackbarContainer
import com.google.samples.apps.sunflower.compose.visible
import com.google.samples.apps.sunflower.data.Plant
Expand Down Expand Up @@ -118,7 +119,7 @@ fun PlantDetailsScreen(
val isPlanted = plantDetailsViewModel.isPlanted.collectAsState(initial = false).value
val showSnackbar = plantDetailsViewModel.showSnackbar.observeAsState().value

if (plant != null && isPlanted != null && showSnackbar != null) {
if (plant != null && showSnackbar != null) {
Surface {
TextSnackbarContainer(
snackbarText = stringResource(R.string.added_plant_to_garden),
Expand Down Expand Up @@ -265,6 +266,7 @@ private fun PlantDetailsContent(
}
}

@OptIn(ExperimentalGlideComposeApi::class)
@Composable
private fun PlantImage(
imageUrl: String,
Expand All @@ -287,7 +289,7 @@ private fun PlantImage(
.background(placeholderColor)
)
}
SunflowerImage(
GlideImage(
model = imageUrl,
contentDescription = null,
modifier = Modifier
Expand Down Expand Up @@ -388,7 +390,7 @@ private fun PlantDetailsToolbar(
Modifier.align(Alignment.CenterVertically)
) {
Icon(
Icons.Filled.ArrowBack,
Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.a11y_back)
)
}
Expand Down Expand Up @@ -451,7 +453,7 @@ private fun PlantHeaderActions(
.then(iconModifier)
) {
Icon(
Icons.Filled.ArrowBack,
Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.a11y_back)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -33,8 +32,9 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
import com.bumptech.glide.integration.compose.GlideImage
import com.google.samples.apps.sunflower.R
import com.google.samples.apps.sunflower.compose.utils.SunflowerImage
import com.google.samples.apps.sunflower.data.Plant
import com.google.samples.apps.sunflower.data.UnsplashPhoto

Expand All @@ -48,7 +48,7 @@ fun PhotoListItem(photo: UnsplashPhoto, onClick: () -> Unit) {
ImageListItem(name = photo.user.name, imageUrl = photo.urls.small, onClick = onClick)
}

@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalGlideComposeApi::class)
@Composable
fun ImageListItem(name: String, imageUrl: String, onClick: () -> Unit) {
Card(
Expand All @@ -59,7 +59,7 @@ fun ImageListItem(name: String, imageUrl: String, onClick: () -> Unit) {
.padding(bottom = dimensionResource(id = R.dimen.card_bottom_margin))
) {
Column(Modifier.fillMaxWidth()) {
SunflowerImage(
GlideImage(
model = imageUrl,
contentDescription = stringResource(R.string.a11y_plant_item_image),
Modifier
Expand Down

This file was deleted.