-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Paintable class to represent generic image #1868
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit concerned we are inventing an alternative Slot API....
...bles/src/main/java/com/google/android/horologist/auth/composables/chips/CreateAccountChip.kt
Outdated
Show resolved
Hide resolved
@@ -87,8 +87,8 @@ public fun ToggleButton( | |||
*/ | |||
@Composable | |||
public fun ToggleButton( | |||
checkedIcon: Any, | |||
notCheckedIcon: Any, | |||
checkedIcon: PaintableIcon, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be just Paintable, why this specific PaintableIcon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be surfacing the lack of implementation in the current code of ToggleButton and Button to also support Image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PaintableIcon
is a subtype used just to indicate "this could be used in an Icon
instead of an Image
". This is to keep compatibility with existing code that in some places uses Icon
or Image
and in some only Icon
(like here).
compose-material/src/main/java/com/google/android/horologist/compose/material/Paintable.kt
Show resolved
Hide resolved
contentScale = ContentScale.Crop, | ||
alpha = LocalContentAlpha.current, | ||
) | ||
if (it is PaintableIcon) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we avoid repeating this? pull it out somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the improvements, even though it might look like it is making the API a bit less convenient.
...omposables/src/main/java/com/google/android/horologist/auth/composables/chips/AccountChip.kt
Outdated
Show resolved
Hide resolved
compose-material/src/main/java/com/google/android/horologist/compose/material/Paintable.kt
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Stable | ||
public class CoilPaintable(private val model: Any?, private val placeholder: Painter? = null) : Paintable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to have "Coil" in the name, exposing the implementation details? ImageLoadingPaintable would be my suggestion but doesn't read great..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this get extracted to a separate module as previously suggested, then it should be fine to keep the name, and having "-coil" in the name of the lib.
Worth doing that extraction before next release (not necessarily in this PR) to avoid having 2 separated "big" API changes in the same area?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, moving this to a separate -coil
library will be a quick follow-up. I only added it here to stay backwards-compatible.
...ug/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipPreview.kt
Show resolved
Hide resolved
...n/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreen.kt
Show resolved
Hide resolved
...in/java/com/google/android/horologist/auth/composables/dialogs/SignedInConfirmationDialog.kt
Show resolved
Hide resolved
...aterial/src/main/java/com/google/android/horologist/compose/material/ChipIconWithProgress.kt
Show resolved
Hide resolved
ca8e0db
to
6daba44
Compare
WHAT
Adds a new
Paintable
interface that can be used to represent "any kind of image".WHY
This decouples most parts of the library from
coil
while making it trivial to still use it (seeCoilPaintable
) and removes the need to useAny
across the codebase.HOW
By replacing uses of
Any
withPaintable
in the codebase, which itself has only one method, which returns aPainter
that can be used inside bothIcon
andImage
elements. This logic previously lived in individual components (seeChip
delta) and is now encapsulated in the various implementations of this interface.Checklist 📋