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

Migrate GalleryFragment and GardenFragment to Compose #819

Merged
merged 9 commits into from
Jan 11, 2023
Merged

Conversation

arriolac
Copy link
Contributor

@arriolac arriolac commented Dec 22, 2022

Resolves #816 #814
Fixes #773

Change-Id: I0563a0ae66e807b0ddb6ed335adf619a0a21b9cf
@arriolac arriolac requested review from a team and JolandaVerhoef December 22, 2022 23:45
@arriolac arriolac marked this pull request as ready for review December 22, 2022 23:45
Change-Id: I9c36a93116944e1b504e42e6070743922d3f1bd7
Change-Id: I5e92ee75ec6d6982b4f48940fbc4d289a28f791d
Change-Id: Ia9a25082eca36f099c6416d0781c01fe7aed7dec
@arriolac arriolac changed the title Migrate GalleryFragment to Compose Migrate GalleryFragment and GardenFragment to Compose Jan 7, 2023
Change-Id: I0a10b9ab5515d380232cc173c962acc8c62aece4
Change-Id: I6d894646e8e7f266b72a8f49848e2c9c69de6efa
@arriolac arriolac requested a review from mlykotom January 9, 2023 18:49
@arriolac
Copy link
Contributor Author

arriolac commented Jan 9, 2023

@mlykotom am I using the ReportDrawnWhen correctly in 3903c31?

Copy link
Contributor

@mlykotom mlykotom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some comments/questions. ReportDrawn could be more readable. Thanks!

onAddPlantClick: () -> Unit,
onPlantClick: (PlantAndGardenPlantings) -> Unit
) {
val gardenPlants = viewModel.plantAndGardenPlantings.observeAsState().value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of directly using Flow in the viewmodel instead of mapping to LiveData?
This way we can skip one mapping, so instead of Flow -> LiveData -> State, we'd have just Flow -> State

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - agreed that's more straightforward

Comment on lines 90 to 92
ReportDrawnWhen {
gardenPlants != null
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could add a more comment that it covers both empty and not empty scenario.
Alternatively, you could also call it within the if to be more readable (that once it's reported when the list is empty and once when list is not empty)

text = vm.plantName,
Modifier
.padding(
top = dimensionResource(id = R.dimen.margin_normal),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be worth to extract the dimension into a variable to prevent parsing it multiple times?

@@ -315,7 +330,7 @@ private fun PlantImage(
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
target: com.bumptech.glide.request.target.Target<Drawable>?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we import the Target instead of the full qualifier here? (same 👇🏼 )

@@ -20,7 +20,8 @@
<style name="Base.Theme.Sunflower" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorPrimary">@color/sunflower_green_500</item>
<item name="colorPrimaryVariant">@color/sunflower_green_700</item>
<item name="colorOnPrimary">@color/sunflower_yellow_500</item>
<!-- <item name="colorOnPrimary">@color/sunflower_yellow_500</item>-->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

@@ -551,12 +584,14 @@ private fun PlantDescription(description: String) {
@Preview
@Composable
private fun PlantDetailContentPreview() {
// FIXME: Preview is broken because of GlideImage. See: https://github.com/bumptech/glide/issues/4977
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing we could do is wrap GlideImage in our own composable and use LocalInspectionMode to render e.g. red Box .. this way, the previews are working until the issue is resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Will create a wrapper for GlideImage

Change-Id: I6933ab8bdde68ad3adf1564ae7d4a59b0dac67be
@arriolac
Copy link
Contributor Author

I have some comments/questions. ReportDrawn could be more readable. Thanks!

Thanks for your review, @mlykotom ! I addressed your feedback in c6ae463

Copy link
Contributor

@mlykotom mlykotom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits, otherwise lgtm


@Composable
private fun GardenScreen(
gardenPlants: List<PlantAndGardenPlantings>?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this list won't be null anymore, right? because you pass initial = emptyList()

arriolac and others added 2 commits January 11, 2023 12:04
…rden/GardenScreen.kt

Co-authored-by: Tomáš Mlynarič <mlynarict@gmail.com>
Change-Id: I782e23956891540e72ffeae1923fe7445c36172f
@arriolac arriolac merged commit 59bdae9 into main Jan 11, 2023
@arriolac arriolac deleted the chris/feat/816 branch January 11, 2023 20:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate GalleryFragment's contents to Compose Add support to navigate to Gallery
2 participants