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

Commit 64f7606

Browse files
sabiouarriolac
andauthored
Remove deprecated SunflowerImage Glide wrapper in favor of GlideImage composable. (#945)
The SunflowerImage() wrapper was introduced as a workaround for the issue bumptech/glide#4977, and now that the issue has been resolved, there is no need for this wrapper in the codebase. Others minor changes: - Simplified expression if (plant != null && isPlanted != null && showSnackbar != null) to if (plant != null && showSnackbar != null) as (isPlanted != null) is always true. - Replaced deprecated Icons.Filled.ArrowBack with Icons.AutoMirrored.Filled.ArrowBack. Co-authored-by: Chris Arriola <[email protected]>
1 parent 60a9daf commit 64f7606

File tree

4 files changed

+17
-88
lines changed

4 files changed

+17
-88
lines changed

app/src/main/java/com/google/samples/apps/sunflower/compose/garden/GardenScreen.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import androidx.compose.foundation.layout.PaddingValues
2424
import androidx.compose.foundation.layout.fillMaxWidth
2525
import androidx.compose.foundation.layout.height
2626
import androidx.compose.foundation.layout.imePadding
27-
import androidx.compose.foundation.layout.navigationBarsPadding
2827
import androidx.compose.foundation.layout.padding
2928
import androidx.compose.foundation.lazy.grid.GridCells
3029
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
@@ -33,7 +32,6 @@ import androidx.compose.foundation.lazy.grid.rememberLazyGridState
3332
import androidx.compose.material3.Button
3433
import androidx.compose.material3.CardDefaults
3534
import androidx.compose.material3.ElevatedCard
36-
import androidx.compose.material3.ExperimentalMaterial3Api
3735
import androidx.compose.material3.MaterialTheme
3836
import androidx.compose.material3.Text
3937
import androidx.compose.runtime.Composable
@@ -49,15 +47,16 @@ import androidx.compose.ui.tooling.preview.Preview
4947
import androidx.compose.ui.tooling.preview.PreviewParameter
5048
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
5149
import androidx.hilt.navigation.compose.hiltViewModel
50+
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
51+
import com.bumptech.glide.integration.compose.GlideImage
5252
import com.google.samples.apps.sunflower.R
53-
import com.google.samples.apps.sunflower.compose.utils.SunflowerImage
5453
import com.google.samples.apps.sunflower.data.GardenPlanting
5554
import com.google.samples.apps.sunflower.data.Plant
5655
import com.google.samples.apps.sunflower.data.PlantAndGardenPlantings
5756
import com.google.samples.apps.sunflower.ui.SunflowerTheme
5857
import com.google.samples.apps.sunflower.viewmodels.GardenPlantingListViewModel
5958
import com.google.samples.apps.sunflower.viewmodels.PlantAndGardenPlantingsViewModel
60-
import java.util.*
59+
import java.util.Calendar
6160

6261
@Composable
6362
fun GardenScreen(
@@ -117,7 +116,7 @@ private fun GardenList(
117116
}
118117

119118
@OptIn(
120-
ExperimentalMaterial3Api::class
119+
ExperimentalGlideComposeApi::class
121120
)
122121
@Composable
123122
private fun GardenListItem(
@@ -140,7 +139,7 @@ private fun GardenListItem(
140139
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.secondaryContainer)
141140
) {
142141
Column(Modifier.fillMaxWidth()) {
143-
SunflowerImage(
142+
GlideImage(
144143
model = vm.imageUrl,
145144
contentDescription = plant.plant.description,
146145
Modifier

app/src/main/java/com/google/samples/apps/sunflower/compose/plantdetail/PlantDetailView.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ import androidx.compose.foundation.rememberScrollState
4343
import androidx.compose.foundation.shape.CircleShape
4444
import androidx.compose.foundation.verticalScroll
4545
import androidx.compose.material.icons.Icons
46+
import androidx.compose.material.icons.automirrored.filled.ArrowBack
4647
import androidx.compose.material.icons.filled.Add
47-
import androidx.compose.material.icons.filled.ArrowBack
4848
import androidx.compose.material.icons.filled.Share
4949
import androidx.compose.material3.ExperimentalMaterial3Api
5050
import androidx.compose.material3.FloatingActionButton
@@ -82,13 +82,14 @@ import androidx.compose.ui.viewinterop.AndroidViewBinding
8282
import androidx.constraintlayout.compose.ConstraintLayout
8383
import androidx.core.text.HtmlCompat
8484
import androidx.hilt.navigation.compose.hiltViewModel
85+
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
86+
import com.bumptech.glide.integration.compose.GlideImage
8587
import com.bumptech.glide.load.DataSource
8688
import com.bumptech.glide.load.engine.GlideException
8789
import com.bumptech.glide.request.RequestListener
8890
import com.bumptech.glide.request.target.Target
8991
import com.google.samples.apps.sunflower.R
9092
import com.google.samples.apps.sunflower.compose.Dimens
91-
import com.google.samples.apps.sunflower.compose.utils.SunflowerImage
9293
import com.google.samples.apps.sunflower.compose.utils.TextSnackbarContainer
9394
import com.google.samples.apps.sunflower.compose.visible
9495
import com.google.samples.apps.sunflower.data.Plant
@@ -118,7 +119,7 @@ fun PlantDetailsScreen(
118119
val isPlanted = plantDetailsViewModel.isPlanted.collectAsState(initial = false).value
119120
val showSnackbar = plantDetailsViewModel.showSnackbar.observeAsState().value
120121

121-
if (plant != null && isPlanted != null && showSnackbar != null) {
122+
if (plant != null && showSnackbar != null) {
122123
Surface {
123124
TextSnackbarContainer(
124125
snackbarText = stringResource(R.string.added_plant_to_garden),
@@ -265,6 +266,7 @@ private fun PlantDetailsContent(
265266
}
266267
}
267268

269+
@OptIn(ExperimentalGlideComposeApi::class)
268270
@Composable
269271
private fun PlantImage(
270272
imageUrl: String,
@@ -287,7 +289,7 @@ private fun PlantImage(
287289
.background(placeholderColor)
288290
)
289291
}
290-
SunflowerImage(
292+
GlideImage(
291293
model = imageUrl,
292294
contentDescription = null,
293295
modifier = Modifier
@@ -388,7 +390,7 @@ private fun PlantDetailsToolbar(
388390
Modifier.align(Alignment.CenterVertically)
389391
) {
390392
Icon(
391-
Icons.Filled.ArrowBack,
393+
Icons.AutoMirrored.Filled.ArrowBack,
392394
contentDescription = stringResource(id = R.string.a11y_back)
393395
)
394396
}
@@ -451,7 +453,7 @@ private fun PlantHeaderActions(
451453
.then(iconModifier)
452454
) {
453455
Icon(
454-
Icons.Filled.ArrowBack,
456+
Icons.AutoMirrored.Filled.ArrowBack,
455457
contentDescription = stringResource(id = R.string.a11y_back)
456458
)
457459
}

app/src/main/java/com/google/samples/apps/sunflower/compose/plantlist/PlantListItemView.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.padding
2323
import androidx.compose.foundation.layout.wrapContentWidth
2424
import androidx.compose.material3.Card
2525
import androidx.compose.material3.CardDefaults
26-
import androidx.compose.material3.ExperimentalMaterial3Api
2726
import androidx.compose.material3.MaterialTheme
2827
import androidx.compose.material3.Text
2928
import androidx.compose.runtime.Composable
@@ -33,8 +32,9 @@ import androidx.compose.ui.layout.ContentScale
3332
import androidx.compose.ui.res.dimensionResource
3433
import androidx.compose.ui.res.stringResource
3534
import androidx.compose.ui.text.style.TextAlign
35+
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
36+
import com.bumptech.glide.integration.compose.GlideImage
3637
import com.google.samples.apps.sunflower.R
37-
import com.google.samples.apps.sunflower.compose.utils.SunflowerImage
3838
import com.google.samples.apps.sunflower.data.Plant
3939
import com.google.samples.apps.sunflower.data.UnsplashPhoto
4040

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

51-
@OptIn(ExperimentalMaterial3Api::class)
51+
@OptIn(ExperimentalGlideComposeApi::class)
5252
@Composable
5353
fun ImageListItem(name: String, imageUrl: String, onClick: () -> Unit) {
5454
Card(
@@ -59,7 +59,7 @@ fun ImageListItem(name: String, imageUrl: String, onClick: () -> Unit) {
5959
.padding(bottom = dimensionResource(id = R.dimen.card_bottom_margin))
6060
) {
6161
Column(Modifier.fillMaxWidth()) {
62-
SunflowerImage(
62+
GlideImage(
6363
model = imageUrl,
6464
contentDescription = stringResource(R.string.a11y_plant_item_image),
6565
Modifier

app/src/main/java/com/google/samples/apps/sunflower/compose/utils/SunflowerImage.kt

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)