From 6daba44c70f34ebe2eb1b84f6b448bf65d520f74 Mon Sep 17 00:00:00 2001 From: Filip Stanis Date: Tue, 12 Dec 2023 17:05:57 +0000 Subject: [PATCH] Adds Paintable class to represent generic image --- auth/composables/api/current.api | 18 ++-- .../auth/composables/chips/AccountChip.kt | 13 +-- .../composables/chips/CreateAccountChip.kt | 3 +- .../auth/composables/chips/GuestModeChip.kt | 3 +- .../composables/chips/OtherOptionsChip.kt | 3 +- .../auth/composables/chips/SignInChip.kt | 3 +- .../dialogs/SignedInConfirmationDialog.kt | 11 +-- .../auth/composables/model/AccountUiModel.kt | 4 +- .../screens/SelectAccountScreen.kt | 4 +- .../dialogs/SignedInConfirmationDialogTest.kt | 11 ++- .../screens/SelectAccountScreenTest.kt | 3 +- .../mapper/AccountUiModelMapper.kt | 3 +- .../auth/ui/mapper/AccountUiModelMapper.kt | 3 +- compose-material/api/current.api | 67 ++++++++++--- .../material/ChipIconWithProgressPreview.kt | 6 +- .../compose/material/ChipPreview.kt | 16 ++-- .../compose/material/CompactChipPreview.kt | 4 +- .../compose/material/IconPreview.kt | 4 +- .../compose/material/OutlinedChipPreview.kt | 10 +- .../material/OutlinedCompactChipPreview.kt | 4 +- .../compose/material/ToggleButtonPreview.kt | 33 +++---- .../horologist/compose/material/Button.kt | 8 +- .../horologist/compose/material/Chip.kt | 53 ++++------- .../compose/material/ChipIconWithProgress.kt | 61 +++++------- .../compose/material/CompactChip.kt | 62 ++++-------- .../horologist/compose/material/Icon.kt | 71 +------------- .../compose/material/OutlinedChip.kt | 53 ++++------- .../compose/material/OutlinedCompactChip.kt | 61 ++++-------- .../horologist/compose/material/Paintable.kt | 95 +++++++++++++++++++ .../compose/material/SplitToggleChip.kt | 5 +- .../horologist/compose/material/Stepper.kt | 9 +- .../horologist/compose/material/Title.kt | 3 +- .../compose/material/ToggleButton.kt | 6 +- .../horologist/compose/material/ToggleChip.kt | 7 +- .../compose/material/ChipA11yTest.kt | 5 +- .../material/ChipIconWithProgressTest.kt | 7 +- .../horologist/compose/material/ChipTest.kt | 51 +++++----- .../compose/material/CompactChipA11yTest.kt | 7 +- .../compose/material/CompactChipTest.kt | 37 ++++---- .../horologist/compose/material/IconTest.kt | 21 ++-- .../compose/material/OutlinedChipA11yTest.kt | 5 +- .../compose/material/OutlinedChipTest.kt | 59 ++++++------ .../material/OutlinedCompactChipA11yTest.kt | 7 +- .../material/OutlinedCompactChipTest.kt | 37 ++++---- .../compose/material/ToggleButtonA11yTest.kt | 21 ++-- .../compose/material/ToggleButtonTest.kt | 61 ++++++------ .../horologist/audio/ui/VolumeScreen.kt | 7 +- .../ui/components/actions/SettingsButton.kt | 3 +- media/ui/api/current.api | 4 +- .../actions/ShowPlaylistChipPreview.kt | 39 ++++---- .../ui/screens/browse/BrowseScreenPreview.kt | 5 +- .../media/ui/components/MediaArtwork.kt | 11 +-- .../media/ui/components/MediaChip.kt | 4 +- .../ui/components/actions/ShowPlaylistChip.kt | 10 +- .../media/ui/screens/browse/BrowseScreen.kt | 5 +- .../browse/PlaylistDownloadBrowseScreen.kt | 8 +- .../screens/entity/PlaylistDownloadScreen.kt | 17 ++-- .../screens/entity/PlaylistStreamingScreen.kt | 3 +- .../ui/screens/playlists/PlaylistsScreen.kt | 4 +- .../actions/ShowPlaylistChipA11yTest.kt | 3 +- .../actions/ShowPlaylistChipTest.kt | 9 +- .../materialcomponents/SampleChipScreen.kt | 17 ++-- .../SampleCompactChipScreen.kt | 5 +- .../materialcomponents/SampleIconScreen.kt | 3 +- .../SampleOutlinedChipScreen.kt | 11 ++- .../SampleOutlinedCompactChipScreen.kt | 5 +- .../SampleToggleButtonScreen.kt | 17 ++-- .../sectionedlist/SectionedListMenuScreen.kt | 3 +- .../stateful/SectionedListStatefulScreen.kt | 9 +- .../stateless/SectionedListStatelessScreen.kt | 9 +- 70 files changed, 637 insertions(+), 612 deletions(-) create mode 100644 compose-material/src/main/java/com/google/android/horologist/compose/material/Paintable.kt diff --git a/auth/composables/api/current.api b/auth/composables/api/current.api index 5d104e8495..057e1de92d 100644 --- a/auth/composables/api/current.api +++ b/auth/composables/api/current.api @@ -2,8 +2,8 @@ package com.google.android.horologist.auth.composables.chips { public final class AccountChipKt { - method @androidx.compose.runtime.Composable public static void AccountChip(com.google.android.horologist.auth.composables.model.AccountUiModel account, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional Object? defaultAvatar, optional boolean largeAvatar, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); - method @androidx.compose.runtime.Composable public static void AccountChip(String email, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional Object? avatar, optional Object? defaultAvatar, optional boolean largeAvatar, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); + method @androidx.compose.runtime.Composable public static void AccountChip(com.google.android.horologist.auth.composables.model.AccountUiModel account, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.Paintable? defaultAvatar, optional boolean largeAvatar, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); + method @androidx.compose.runtime.Composable public static void AccountChip(String email, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.Paintable? avatar, optional com.google.android.horologist.compose.material.Paintable? defaultAvatar, optional boolean largeAvatar, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); } public final class CreateAccountChipKt { @@ -27,7 +27,7 @@ package com.google.android.horologist.auth.composables.chips { package com.google.android.horologist.auth.composables.dialogs { public final class SignedInConfirmationDialogKt { - method @androidx.compose.runtime.Composable public static void SignedInConfirmationDialog(kotlin.jvm.functions.Function0 onDismissOrTimeout, optional androidx.compose.ui.Modifier modifier, optional String? name, optional String? email, optional Object? avatar, optional java.time.Duration duration); + method @androidx.compose.runtime.Composable public static void SignedInConfirmationDialog(kotlin.jvm.functions.Function0 onDismissOrTimeout, optional androidx.compose.ui.Modifier modifier, optional String? name, optional String? email, optional com.google.android.horologist.compose.material.Paintable? avatar, optional java.time.Duration duration); method @androidx.compose.runtime.Composable public static void SignedInConfirmationDialog(kotlin.jvm.functions.Function0 onDismissOrTimeout, optional androidx.compose.ui.Modifier modifier, com.google.android.horologist.auth.composables.model.AccountUiModel accountUiModel, optional java.time.Duration duration); } @@ -36,15 +36,15 @@ package com.google.android.horologist.auth.composables.dialogs { package com.google.android.horologist.auth.composables.model { public final class AccountUiModel { - ctor public AccountUiModel(String email, optional String? name, optional Object? avatar); + ctor public AccountUiModel(String email, optional String? name, optional com.google.android.horologist.compose.material.Paintable? avatar); method public String component1(); method public String? component2(); - method public Object? component3(); - method public com.google.android.horologist.auth.composables.model.AccountUiModel copy(String email, String? name, Object? avatar); - method public Object? getAvatar(); + method public com.google.android.horologist.compose.material.Paintable? component3(); + method public com.google.android.horologist.auth.composables.model.AccountUiModel copy(String email, String? name, com.google.android.horologist.compose.material.Paintable? avatar); + method public com.google.android.horologist.compose.material.Paintable? getAvatar(); method public String getEmail(); method public String? getName(); - property public final Object? avatar; + property public final com.google.android.horologist.compose.material.Paintable? avatar; property public final String email; property public final String? name; } @@ -63,7 +63,7 @@ package com.google.android.horologist.auth.composables.screens { } public final class SelectAccountScreenKt { - method @androidx.compose.runtime.Composable public static void SelectAccountScreen(java.util.List accounts, kotlin.jvm.functions.Function2 onAccountClicked, com.google.android.horologist.compose.layout.ScalingLazyColumnState columnState, optional androidx.compose.ui.Modifier modifier, optional String title, optional Object? defaultAvatar); + method @androidx.compose.runtime.Composable public static void SelectAccountScreen(java.util.List accounts, kotlin.jvm.functions.Function2 onAccountClicked, com.google.android.horologist.compose.layout.ScalingLazyColumnState columnState, optional androidx.compose.ui.Modifier modifier, optional String title, optional com.google.android.horologist.compose.material.Paintable? defaultAvatar); } public final class SignInPlaceholderScreenKt { diff --git a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/AccountChip.kt b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/AccountChip.kt index 89d4fa7500..fe3aef1e67 100644 --- a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/AccountChip.kt +++ b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/AccountChip.kt @@ -20,13 +20,14 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.AccountCircle import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.text.style.LineBreak import androidx.wear.compose.material.ChipColors import androidx.wear.compose.material.ChipDefaults import androidx.wear.compose.material.MaterialTheme import com.google.android.horologist.auth.composables.model.AccountUiModel import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable +import com.google.android.horologist.compose.material.Paintable /** * A [Chip] to display the [AccountUiModel]'s email address and avatar. @@ -38,9 +39,8 @@ public fun AccountChip( account: AccountUiModel, onClick: () -> Unit, modifier: Modifier = Modifier, - defaultAvatar: Any? = Icons.Default.AccountCircle, + defaultAvatar: Paintable? = Icons.Default.AccountCircle.asPaintable(), largeAvatar: Boolean = true, - placeholder: Painter? = null, colors: ChipColors = ChipDefaults.primaryChipColors(), enabled: Boolean = true, ) { @@ -51,7 +51,6 @@ public fun AccountChip( avatar = account.avatar, defaultAvatar = defaultAvatar, largeAvatar = largeAvatar, - placeholder = placeholder, colors = colors, enabled = enabled, ) @@ -67,10 +66,9 @@ public fun AccountChip( email: String, onClick: () -> Unit, modifier: Modifier = Modifier, - avatar: Any? = null, - defaultAvatar: Any? = Icons.Default.AccountCircle, + avatar: Paintable? = null, + defaultAvatar: Paintable? = Icons.Default.AccountCircle.asPaintable(), largeAvatar: Boolean = true, - placeholder: Painter? = null, colors: ChipColors = ChipDefaults.primaryChipColors(), enabled: Boolean = true, ) { @@ -91,7 +89,6 @@ public fun AccountChip( modifier = modifier, icon = avatar ?: defaultAvatar, largeIcon = largeAvatar, - placeholder = placeholder, colors = colors, enabled = enabled, ) diff --git a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/CreateAccountChip.kt b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/CreateAccountChip.kt index f12a0e713f..104b049853 100644 --- a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/CreateAccountChip.kt +++ b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/CreateAccountChip.kt @@ -29,6 +29,7 @@ import androidx.wear.compose.material.ChipDefaults import androidx.wear.compose.material.Icon import com.google.android.horologist.auth.composables.R import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.util.DECORATIVE_ELEMENT_CONTENT_DESCRIPTION /** @@ -71,7 +72,7 @@ public fun CreateAccountChip( label = label, onClick = onClick, modifier = modifier, - icon = Icons.AutoMirrored.Outlined.SendToMobile, + icon = Icons.AutoMirrored.Outlined.SendToMobile.asPaintable(), colors = colors, enabled = enabled, ) diff --git a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/GuestModeChip.kt b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/GuestModeChip.kt index 6e778b36e2..0cc5cbb0ab 100644 --- a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/GuestModeChip.kt +++ b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/GuestModeChip.kt @@ -25,6 +25,7 @@ import androidx.wear.compose.material.ChipColors import androidx.wear.compose.material.ChipDefaults import com.google.android.horologist.auth.composables.R import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable /** * An opinionated [Chip] to represent the "Guest mode" action. @@ -45,7 +46,7 @@ public fun GuestModeChip( label = label, onClick = onClick, modifier = modifier, - icon = Icons.AutoMirrored.Default.ArrowForward, + icon = Icons.AutoMirrored.Default.ArrowForward.asPaintable(), colors = colors, enabled = enabled, ) diff --git a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/OtherOptionsChip.kt b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/OtherOptionsChip.kt index 87acf7e59d..1851135b42 100644 --- a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/OtherOptionsChip.kt +++ b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/OtherOptionsChip.kt @@ -25,6 +25,7 @@ import androidx.wear.compose.material.ChipColors import androidx.wear.compose.material.ChipDefaults import com.google.android.horologist.auth.composables.R import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable /** * An opinionated [Chip] to represent the "Other options to authentication" action. @@ -43,7 +44,7 @@ public fun OtherOptionsChip( label = label, onClick = onClick, modifier = modifier, - icon = Icons.AutoMirrored.Outlined.SendToMobile, + icon = Icons.AutoMirrored.Outlined.SendToMobile.asPaintable(), colors = colors, enabled = enabled, ) diff --git a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/SignInChip.kt b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/SignInChip.kt index 72ff1f0d70..30cdd896a0 100644 --- a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/SignInChip.kt +++ b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/chips/SignInChip.kt @@ -25,6 +25,7 @@ import androidx.wear.compose.material.ChipColors import androidx.wear.compose.material.ChipDefaults import com.google.android.horologist.auth.composables.R import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable /** * An opinionated [Chip] to represent the "Sign in" action. @@ -45,7 +46,7 @@ public fun SignInChip( label = label, onClick = onClick, modifier = modifier, - icon = Icons.Default.AccountCircle, + icon = Icons.Default.AccountCircle.asPaintable(), colors = colors, enabled = enabled, ) diff --git a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/dialogs/SignedInConfirmationDialog.kt b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/dialogs/SignedInConfirmationDialog.kt index 66362a7666..37cd419f03 100644 --- a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/dialogs/SignedInConfirmationDialog.kt +++ b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/dialogs/SignedInConfirmationDialog.kt @@ -41,10 +41,10 @@ import androidx.compose.ui.unit.sp import androidx.wear.compose.material.MaterialTheme import androidx.wear.compose.material.Text import androidx.wear.compose.material.dialog.DialogDefaults -import coil.compose.rememberAsyncImagePainter import com.google.android.horologist.auth.composables.R import com.google.android.horologist.auth.composables.model.AccountUiModel import com.google.android.horologist.compose.material.Confirmation +import com.google.android.horologist.compose.material.Paintable import com.google.android.horologist.compose.material.util.DECORATIVE_ELEMENT_CONTENT_DESCRIPTION import java.time.Duration @@ -63,7 +63,7 @@ public fun SignedInConfirmationDialog( modifier: Modifier = Modifier, name: String? = null, email: String? = null, - avatar: Any? = null, + avatar: Paintable? = null, duration: Duration = Duration.ofMillis(DialogDefaults.ShortDurationMillis), ) { Confirmation( @@ -108,7 +108,7 @@ private fun SignedInConfirmationDialogContent( modifier: Modifier = Modifier, name: String? = null, email: String? = null, - avatar: Any? = null, + avatar: Paintable? = null, ) { val configuration = LocalConfiguration.current val horizontalPadding = (configuration.screenWidthDp * HORIZONTAL_PADDING_SCREEN_PERCENTAGE).dp @@ -121,7 +121,6 @@ private fun SignedInConfirmationDialogContent( horizontalAlignment = Alignment.CenterHorizontally, ) { val hasName = !name.isNullOrEmpty() - val hasAvatar = avatar != null Box( modifier = Modifier @@ -129,10 +128,10 @@ private fun SignedInConfirmationDialogContent( .background(color = Color(AVATAR_BACKGROUND_COLOR), shape = CircleShape), contentAlignment = Alignment.Center, ) { - if (hasAvatar) { + if (avatar != null) { Image( modifier = Modifier.clip(CircleShape), - painter = rememberAsyncImagePainter(model = avatar), + painter = avatar.rememberPainter(), contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, contentScale = ContentScale.Fit, ) diff --git a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/model/AccountUiModel.kt b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/model/AccountUiModel.kt index e9b0c6ffd0..2692bacef4 100644 --- a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/model/AccountUiModel.kt +++ b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/model/AccountUiModel.kt @@ -16,11 +16,13 @@ package com.google.android.horologist.auth.composables.model +import com.google.android.horologist.compose.material.Paintable + /** * A UI model to represent an account. */ public data class AccountUiModel( val email: String, val name: String? = null, - val avatar: Any? = null, + val avatar: Paintable? = null, ) diff --git a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/screens/SelectAccountScreen.kt b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/screens/SelectAccountScreen.kt index 07709b1554..e8a57d62fc 100644 --- a/auth/composables/src/main/java/com/google/android/horologist/auth/composables/screens/SelectAccountScreen.kt +++ b/auth/composables/src/main/java/com/google/android/horologist/auth/composables/screens/SelectAccountScreen.kt @@ -33,6 +33,8 @@ import com.google.android.horologist.auth.composables.chips.AccountChip import com.google.android.horologist.auth.composables.model.AccountUiModel import com.google.android.horologist.compose.layout.ScalingLazyColumn import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable +import com.google.android.horologist.compose.material.Paintable import com.google.android.horologist.compose.material.Title private const val HORIZONTAL_PADDING_SCREEN_PERCENTAGE = 0.052 @@ -49,7 +51,7 @@ public fun SelectAccountScreen( columnState: ScalingLazyColumnState, modifier: Modifier = Modifier, title: String = stringResource(id = R.string.horologist_select_account_title), - defaultAvatar: Any? = Icons.Default.AccountCircle, + defaultAvatar: Paintable? = Icons.Default.AccountCircle.asPaintable(), ) { val configuration = LocalConfiguration.current val horizontalPadding = (configuration.screenWidthDp * HORIZONTAL_PADDING_SCREEN_PERCENTAGE).dp diff --git a/auth/composables/src/test/java/com/google/android/horologist/auth/composables/dialogs/SignedInConfirmationDialogTest.kt b/auth/composables/src/test/java/com/google/android/horologist/auth/composables/dialogs/SignedInConfirmationDialogTest.kt index 6b3ca21f8d..f9eb378734 100644 --- a/auth/composables/src/test/java/com/google/android/horologist/auth/composables/dialogs/SignedInConfirmationDialogTest.kt +++ b/auth/composables/src/test/java/com/google/android/horologist/auth/composables/dialogs/SignedInConfirmationDialogTest.kt @@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import com.google.android.horologist.compose.material.DrawableResPaintable import com.google.android.horologist.compose.tools.coil.FakeImageLoader import com.google.android.horologist.screenshots.ScreenshotBaseTest import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams @@ -46,7 +47,7 @@ class SignedInConfirmationDialogTest : ScreenshotBaseTest( onDismissOrTimeout = {}, name = "Maggie", email = "maggie@example.com", - avatar = android.R.drawable.sym_def_app_icon, + avatar = DrawableResPaintable(android.R.drawable.sym_def_app_icon), ) } } @@ -61,7 +62,7 @@ class SignedInConfirmationDialogTest : ScreenshotBaseTest( SignedInConfirmationDialog( onDismissOrTimeout = {}, email = "maggie@example.com", - avatar = android.R.drawable.sym_def_app_icon, + avatar = DrawableResPaintable(android.R.drawable.sym_def_app_icon), ) } } @@ -76,7 +77,7 @@ class SignedInConfirmationDialogTest : ScreenshotBaseTest( onDismissOrTimeout = {}, name = "", email = "maggie@example.com", - avatar = android.R.drawable.sym_def_app_icon, + avatar = DrawableResPaintable(android.R.drawable.sym_def_app_icon), ) } } @@ -100,7 +101,7 @@ class SignedInConfirmationDialogTest : ScreenshotBaseTest( SignedInConfirmationDialog( onDismissOrTimeout = {}, name = "Maggie", - avatar = android.R.drawable.sym_def_app_icon, + avatar = DrawableResPaintable(android.R.drawable.sym_def_app_icon), ) } } @@ -122,7 +123,7 @@ class SignedInConfirmationDialogTest : ScreenshotBaseTest( onDismissOrTimeout = {}, name = "Wolfeschlegelsteinhausenbergerdorff", email = "wolfeschlegelsteinhausenbergerdorff@example.com", - avatar = android.R.drawable.sym_def_app_icon, + avatar = DrawableResPaintable(android.R.drawable.sym_def_app_icon), ) } } diff --git a/auth/composables/src/test/java/com/google/android/horologist/auth/composables/screens/SelectAccountScreenTest.kt b/auth/composables/src/test/java/com/google/android/horologist/auth/composables/screens/SelectAccountScreenTest.kt index 30a356c8c2..af02620ba4 100644 --- a/auth/composables/src/test/java/com/google/android/horologist/auth/composables/screens/SelectAccountScreenTest.kt +++ b/auth/composables/src/test/java/com/google/android/horologist/auth/composables/screens/SelectAccountScreenTest.kt @@ -20,6 +20,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Face import com.google.android.horologist.auth.composables.model.AccountUiModel import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.screenshots.ScreenshotBaseTest import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams import org.junit.Test @@ -37,7 +38,7 @@ class SelectAccountScreenTest : ScreenshotBaseTest( accounts = listOf( AccountUiModel( email = "maggie@example.com", - avatar = Icons.Default.Face, + avatar = Icons.Default.Face.asPaintable(), ), AccountUiModel(email = "thisisaverylongemail@example.com"), ), diff --git a/auth/ui/src/main/java/com/google/android/horologist/auth/ui/googlesignin/mapper/AccountUiModelMapper.kt b/auth/ui/src/main/java/com/google/android/horologist/auth/ui/googlesignin/mapper/AccountUiModelMapper.kt index 8147475cc6..aa5e7e96bb 100644 --- a/auth/ui/src/main/java/com/google/android/horologist/auth/ui/googlesignin/mapper/AccountUiModelMapper.kt +++ b/auth/ui/src/main/java/com/google/android/horologist/auth/ui/googlesignin/mapper/AccountUiModelMapper.kt @@ -18,6 +18,7 @@ package com.google.android.horologist.auth.ui.googlesignin.mapper import com.google.android.gms.auth.api.signin.GoogleSignInAccount import com.google.android.horologist.auth.composables.model.AccountUiModel +import com.google.android.horologist.compose.material.CoilPaintable /** * Functions to map models from Google Sign In into a [AccountUiModel]. @@ -33,6 +34,6 @@ public object AccountUiModelMapper { ): AccountUiModel = AccountUiModel( email = account.email ?: defaultEmail, name = account.displayName, - avatar = account.photoUrl, + avatar = CoilPaintable(account.photoUrl), ) } diff --git a/auth/ui/src/main/java/com/google/android/horologist/auth/ui/mapper/AccountUiModelMapper.kt b/auth/ui/src/main/java/com/google/android/horologist/auth/ui/mapper/AccountUiModelMapper.kt index b069da8d9a..bd528573ce 100644 --- a/auth/ui/src/main/java/com/google/android/horologist/auth/ui/mapper/AccountUiModelMapper.kt +++ b/auth/ui/src/main/java/com/google/android/horologist/auth/ui/mapper/AccountUiModelMapper.kt @@ -18,6 +18,7 @@ package com.google.android.horologist.auth.ui.mapper import com.google.android.horologist.auth.composables.model.AccountUiModel import com.google.android.horologist.auth.data.common.model.AuthUser +import com.google.android.horologist.compose.material.CoilPaintable /** * Functions to map models from other layers and / or packages into a [AccountUiModel]. @@ -30,6 +31,6 @@ public object AccountUiModelMapper { public fun map(authUser: AuthUser, defaultEmail: String = ""): AccountUiModel = AccountUiModel( email = authUser.email ?: defaultEmail, name = authUser.displayName, - avatar = authUser.avatarUri, + avatar = CoilPaintable(authUser.avatarUri), ) } diff --git a/compose-material/api/current.api b/compose-material/api/current.api index b5727559e8..f81c24561f 100644 --- a/compose-material/api/current.api +++ b/compose-material/api/current.api @@ -5,6 +5,17 @@ package com.google.android.horologist.compose.material { method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void AlertDialog(String message, kotlin.jvm.functions.Function0 onCancelButtonClick, kotlin.jvm.functions.Function0 onOKButtonClick, boolean showDialog, androidx.wear.compose.foundation.lazy.ScalingLazyListState scalingLazyListState, optional androidx.compose.ui.Modifier modifier, optional String title, optional String okButtonContentDescription, optional String cancelButtonContentDescription); } + @kotlin.jvm.JvmInline public final value class BitmapPaintable implements com.google.android.horologist.compose.material.Paintable { + ctor public BitmapPaintable(androidx.compose.ui.graphics.ImageBitmap bitmap); + method @androidx.compose.runtime.Composable public androidx.compose.ui.graphics.painter.Painter rememberPainter(); + field public static final com.google.android.horologist.compose.material.BitmapPaintable.Companion Companion; + } + + public static final class BitmapPaintable.Companion { + method public androidx.compose.ui.graphics.ImageBitmap asPaintable(androidx.compose.ui.graphics.ImageBitmap); + method public androidx.compose.ui.graphics.ImageBitmap asPaintable(android.graphics.Bitmap); + } + public final class ButtonKt { method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void Button(androidx.compose.ui.graphics.vector.ImageVector imageVector, String contentDescription, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional androidx.wear.compose.material.ButtonColors colors, optional com.google.android.horologist.compose.material.ButtonSize buttonSize, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional boolean enabled); method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void Button(@DrawableRes int id, String contentDescription, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional androidx.wear.compose.material.ButtonColors colors, optional com.google.android.horologist.compose.material.ButtonSize buttonSize, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional boolean enabled); @@ -41,29 +52,38 @@ package com.google.android.horologist.compose.material { } public final class ChipIconWithProgressKt { - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void ChipIconWithProgress(optional androidx.compose.ui.Modifier modifier, optional Object? icon, optional boolean largeIcon, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional long progressIndicatorColor, optional long progressTrackColor); - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void ChipIconWithProgress(float progress, optional androidx.compose.ui.Modifier modifier, optional Object? icon, optional boolean largeIcon, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional long progressIndicatorColor, optional long progressTrackColor); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void ChipIconWithProgress(optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.Paintable? icon, optional boolean largeIcon, optional long progressIndicatorColor, optional long progressTrackColor); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void ChipIconWithProgress(float progress, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.Paintable? icon, optional boolean largeIcon, optional long progressIndicatorColor, optional long progressTrackColor); } public final class ChipKt { - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void Chip(String label, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional String? secondaryLabel, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional Object? icon, optional boolean largeIcon, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void Chip(@StringRes int labelId, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional @StringRes Integer? secondaryLabel, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional Object? icon, optional boolean largeIcon, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void Chip(String label, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional String? secondaryLabel, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional com.google.android.horologist.compose.material.Paintable? icon, optional boolean largeIcon, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void Chip(@StringRes int labelId, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional @StringRes Integer? secondaryLabel, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional com.google.android.horologist.compose.material.Paintable? icon, optional boolean largeIcon, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void Chip(String label, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional String? secondaryLabel, optional kotlin.jvm.functions.Function1? icon, optional boolean largeIcon, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); } + @androidx.compose.runtime.Stable public final class CoilPaintable implements com.google.android.horologist.compose.material.Paintable { + ctor public CoilPaintable(Object? model, optional androidx.compose.ui.graphics.painter.Painter? placeholder); + method @androidx.compose.runtime.Composable public androidx.compose.ui.graphics.painter.Painter rememberPainter(); + } + public final class CompactChipKt { - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void CompactChip(String label, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional Object? icon, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.wear.compose.material.ChipBorder border); - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void CompactChip(@StringRes int labelId, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional Object? icon, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.wear.compose.material.ChipBorder border); - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void CompactChip(Object icon, String contentDescription, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.wear.compose.material.ChipBorder border); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void CompactChip(String label, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.Paintable? icon, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.wear.compose.material.ChipBorder border); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void CompactChip(@StringRes int labelId, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.Paintable? icon, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.wear.compose.material.ChipBorder border); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void CompactChip(com.google.android.horologist.compose.material.Paintable icon, String contentDescription, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.wear.compose.material.ChipBorder border); } public final class ConfirmationKt { method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void Confirmation(kotlin.jvm.functions.Function0 onTimeout, optional androidx.compose.ui.Modifier modifier, optional kotlin.jvm.functions.Function1? icon, optional androidx.wear.compose.foundation.lazy.ScalingLazyListState scrollState, optional long durationMillis, optional long backgroundColor, optional long contentColor, optional long iconColor, optional androidx.compose.foundation.layout.Arrangement.Vertical verticalArrangement, optional androidx.compose.foundation.layout.PaddingValues contentPadding, kotlin.jvm.functions.Function1 content); } + @kotlin.jvm.JvmInline public final value class DrawableResPaintable implements com.google.android.horologist.compose.material.PaintableIcon { + ctor public DrawableResPaintable(@DrawableRes int id); + method @androidx.compose.runtime.Composable public androidx.compose.ui.graphics.painter.Painter rememberPainter(); + } + public final class IconKt { - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void Icon(androidx.compose.ui.graphics.vector.ImageVector imageVector, String? contentDescription, optional androidx.compose.ui.Modifier modifier, optional long tint, optional com.google.android.horologist.compose.material.IconRtlMode rtlMode); - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void Icon(@DrawableRes int id, String? contentDescription, optional androidx.compose.ui.Modifier modifier, optional long tint, optional com.google.android.horologist.compose.material.IconRtlMode rtlMode); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void Icon(com.google.android.horologist.compose.material.PaintableIcon paintable, String? contentDescription, optional androidx.compose.ui.Modifier modifier, optional long tint, optional com.google.android.horologist.compose.material.IconRtlMode rtlMode); } @com.google.android.horologist.annotations.ExperimentalHorologistApi public enum IconRtlMode { @@ -73,16 +93,33 @@ package com.google.android.horologist.compose.material { enum_constant public static final com.google.android.horologist.compose.material.IconRtlMode Mirrored; } + @kotlin.jvm.JvmInline public final value class ImageVectorPaintable implements com.google.android.horologist.compose.material.PaintableIcon { + ctor public ImageVectorPaintable(androidx.compose.ui.graphics.vector.ImageVector imageVector); + method @androidx.compose.runtime.Composable public androidx.compose.ui.graphics.painter.Painter rememberPainter(); + field public static final com.google.android.horologist.compose.material.ImageVectorPaintable.Companion Companion; + } + + public static final class ImageVectorPaintable.Companion { + method public androidx.compose.ui.graphics.vector.ImageVector asPaintable(androidx.compose.ui.graphics.vector.ImageVector); + } + public final class OutlinedChipKt { - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void OutlinedChip(String label, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional String? secondaryLabel, optional Object? icon, optional boolean largeIcon, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void OutlinedChip(@StringRes int labelId, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional @StringRes Integer? secondaryLabel, optional Object? icon, optional boolean largeIcon, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void OutlinedChip(String label, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional String? secondaryLabel, optional com.google.android.horologist.compose.material.Paintable? icon, optional boolean largeIcon, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void OutlinedChip(@StringRes int labelId, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional @StringRes Integer? secondaryLabel, optional com.google.android.horologist.compose.material.Paintable? icon, optional boolean largeIcon, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void OutlinedChip(String label, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional String? secondaryLabel, optional kotlin.jvm.functions.Function1? icon, optional boolean largeIcon, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled); } public final class OutlinedCompactChipKt { - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void OutlinedCompactChip(String label, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional Object? icon, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.wear.compose.material.ChipBorder border); - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void OutlinedCompactChip(@StringRes int labelId, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional Object? icon, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.wear.compose.material.ChipBorder border); - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void OutlinedCompactChip(Object icon, String contentDescription, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional androidx.compose.ui.graphics.painter.Painter? placeholder, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.wear.compose.material.ChipBorder border); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void OutlinedCompactChip(String label, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.Paintable? icon, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.wear.compose.material.ChipBorder border); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void OutlinedCompactChip(@StringRes int labelId, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.Paintable? icon, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.wear.compose.material.ChipBorder border); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void OutlinedCompactChip(com.google.android.horologist.compose.material.Paintable icon, String contentDescription, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional androidx.wear.compose.material.ChipColors colors, optional boolean enabled, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.wear.compose.material.ChipBorder border); + } + + @androidx.compose.runtime.Stable public interface Paintable { + method @androidx.compose.runtime.Composable public androidx.compose.ui.graphics.painter.Painter rememberPainter(); + } + + @androidx.compose.runtime.Stable public interface PaintableIcon extends com.google.android.horologist.compose.material.Paintable { } public final class SplitToggleChipKt { @@ -108,7 +145,7 @@ package com.google.android.horologist.compose.material { public final class ToggleButtonKt { method @androidx.compose.runtime.Composable public static void ToggleButton(String text, kotlin.jvm.functions.Function1 onCheckedChanged, optional androidx.compose.ui.Modifier modifier, optional boolean checked, optional boolean enabled, optional androidx.wear.compose.material.ToggleButtonColors colors, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.compose.ui.graphics.Shape shape, optional int role, optional boolean smallSize); - method @androidx.compose.runtime.Composable public static void ToggleButton(Object checkedIcon, Object notCheckedIcon, String contentDescription, kotlin.jvm.functions.Function1 onCheckedChanged, optional androidx.compose.ui.Modifier modifier, optional boolean checked, optional boolean enabled, optional androidx.wear.compose.material.ToggleButtonColors colors, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.compose.ui.graphics.Shape shape, optional int role, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional boolean smallSize); + method @androidx.compose.runtime.Composable public static void ToggleButton(com.google.android.horologist.compose.material.PaintableIcon checkedIcon, com.google.android.horologist.compose.material.PaintableIcon notCheckedIcon, String contentDescription, kotlin.jvm.functions.Function1 onCheckedChanged, optional androidx.compose.ui.Modifier modifier, optional boolean checked, optional boolean enabled, optional androidx.wear.compose.material.ToggleButtonColors colors, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.compose.ui.graphics.Shape shape, optional int role, optional com.google.android.horologist.compose.material.IconRtlMode iconRtlMode, optional boolean smallSize); } public final class ToggleChipKt { diff --git a/compose-material/src/debug/java/com/google/android/horologist/compose/material/ChipIconWithProgressPreview.kt b/compose-material/src/debug/java/com/google/android/horologist/compose/material/ChipIconWithProgressPreview.kt index fbddb8e07d..39b77307f4 100644 --- a/compose-material/src/debug/java/com/google/android/horologist/compose/material/ChipIconWithProgressPreview.kt +++ b/compose-material/src/debug/java/com/google/android/horologist/compose/material/ChipIconWithProgressPreview.kt @@ -51,7 +51,7 @@ fun ChipIconWithProgressInProgressPreview() { fun ChipIconWithProgressInProgressLargeIconPreview() { ChipIconWithProgress( progress = 75f, - icon = Icon48dp, + icon = ImageVectorPaintable(Icon48dp), largeIcon = true, ) } @@ -63,7 +63,7 @@ fun ChipIconWithProgressInProgressLargeIconPreview() { ) @Composable fun ChipIconWithProgressInProgressMediumIconPreview() { - ChipIconWithProgress(progress = 75f, icon = Icon32dp) + ChipIconWithProgress(progress = 75f, icon = ImageVectorPaintable(Icon32dp)) } @Preview( @@ -73,7 +73,7 @@ fun ChipIconWithProgressInProgressMediumIconPreview() { ) @Composable fun ChipIconWithProgressInProgressSmallIconPreview() { - ChipIconWithProgress(progress = 75f, icon = Icon12dp) + ChipIconWithProgress(progress = 75f, icon = ImageVectorPaintable(Icon12dp)) } private val Icon12dp: ImageVector diff --git a/compose-material/src/debug/java/com/google/android/horologist/compose/material/ChipPreview.kt b/compose-material/src/debug/java/com/google/android/horologist/compose/material/ChipPreview.kt index 19aed2810d..e932ab5e41 100644 --- a/compose-material/src/debug/java/com/google/android/horologist/compose/material/ChipPreview.kt +++ b/compose-material/src/debug/java/com/google/android/horologist/compose/material/ChipPreview.kt @@ -62,7 +62,7 @@ fun ChipPreviewWithIcon() { Chip( label = "Primary label", onClick = { }, - icon = Icons.Default.Image, + icon = ImageVectorPaintable(Icons.Default.Image), ) } @@ -76,7 +76,7 @@ fun ChipPreviewWithLargeIcon() { Chip( label = "Primary label", onClick = { }, - icon = Icon32dp, + icon = ImageVectorPaintable(Icon32dp), largeIcon = true, ) } @@ -92,7 +92,7 @@ fun ChipPreviewWithSecondaryLabelAndIcon() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = ImageVectorPaintable(Icons.Default.Image), ) } @@ -107,7 +107,7 @@ fun ChipPreviewWithSecondaryLabelAndLargeIcon() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icon32dp, + icon = ImageVectorPaintable(Icon32dp), largeIcon = true, ) } @@ -123,7 +123,7 @@ fun ChipPreviewDisabled() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = ImageVectorPaintable(Icons.Default.Image), enabled = false, ) } @@ -139,7 +139,7 @@ fun ChipPreviewWithSecondaryChipColors() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = ImageVectorPaintable(Icons.Default.Image), colors = ChipDefaults.secondaryChipColors(), ) } @@ -155,7 +155,7 @@ fun ChipPreviewWithGradientBackgroundChipColors() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = ImageVectorPaintable(Icons.Default.Image), colors = ChipDefaults.gradientBackgroundChipColors(), ) } @@ -171,7 +171,7 @@ fun ChipPreviewWithImageBackgroundChipColors() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = ImageVectorPaintable(Icons.Default.Image), colors = ChipDefaults.imageBackgroundChipColors( backgroundImagePainter = painterResource(id = android.R.drawable.ic_dialog_alert), ), diff --git a/compose-material/src/debug/java/com/google/android/horologist/compose/material/CompactChipPreview.kt b/compose-material/src/debug/java/com/google/android/horologist/compose/material/CompactChipPreview.kt index 35578057bc..0ff1525970 100644 --- a/compose-material/src/debug/java/com/google/android/horologist/compose/material/CompactChipPreview.kt +++ b/compose-material/src/debug/java/com/google/android/horologist/compose/material/CompactChipPreview.kt @@ -36,7 +36,7 @@ fun CompactChipPreviewWithIcon() { CompactChip( label = "Primary label", onClick = { }, - icon = Icons.Filled.Add, + icon = ImageVectorPaintable(Icons.Filled.Add), ) } @@ -45,7 +45,7 @@ fun CompactChipPreviewWithIcon() { fun CompactChipPreviewIconOnly() { CompactChip( onClick = { }, - icon = Icons.Filled.Add, + icon = ImageVectorPaintable(Icons.Filled.Add), contentDescription = "contentDescription", ) } diff --git a/compose-material/src/debug/java/com/google/android/horologist/compose/material/IconPreview.kt b/compose-material/src/debug/java/com/google/android/horologist/compose/material/IconPreview.kt index 157ade95ec..4341f0b8e3 100644 --- a/compose-material/src/debug/java/com/google/android/horologist/compose/material/IconPreview.kt +++ b/compose-material/src/debug/java/com/google/android/horologist/compose/material/IconPreview.kt @@ -28,7 +28,7 @@ import com.google.android.horologist.compose.tools.WearPreview @Composable fun IconPreview() { Icon( - imageVector = Icons.AutoMirrored.Outlined.VolumeDown, + paintable = ImageVectorPaintable(Icons.AutoMirrored.Outlined.VolumeDown), contentDescription = "contentDescription", ) } @@ -38,7 +38,7 @@ fun IconPreview() { fun IconPreviewMirrored() { CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) { Icon( - imageVector = Icons.AutoMirrored.Outlined.VolumeDown, + paintable = ImageVectorPaintable(Icons.AutoMirrored.Outlined.VolumeDown), contentDescription = "contentDescription", rtlMode = IconRtlMode.Mirrored, ) diff --git a/compose-material/src/debug/java/com/google/android/horologist/compose/material/OutlinedChipPreview.kt b/compose-material/src/debug/java/com/google/android/horologist/compose/material/OutlinedChipPreview.kt index cd70e3542d..443ab1f63c 100644 --- a/compose-material/src/debug/java/com/google/android/horologist/compose/material/OutlinedChipPreview.kt +++ b/compose-material/src/debug/java/com/google/android/horologist/compose/material/OutlinedChipPreview.kt @@ -60,7 +60,7 @@ fun OutlinedChipPreviewWithIcon() { OutlinedChip( label = "Primary label", onClick = { }, - icon = Icons.Default.Image, + icon = ImageVectorPaintable(Icons.Default.Image), ) } @@ -74,7 +74,7 @@ fun OutlinedChipPreviewWithLargeIcon() { OutlinedChip( label = "Primary label", onClick = { }, - icon = Icon32dp, + icon = ImageVectorPaintable(Icon32dp), largeIcon = true, ) } @@ -90,7 +90,7 @@ fun OutlinedChipPreviewWithSecondaryLabelAndIcon() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = ImageVectorPaintable(Icons.Default.Image), ) } @@ -105,7 +105,7 @@ fun OutlinedChipPreviewWithSecondaryLabelAndLargeIcon() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icon32dp, + icon = ImageVectorPaintable(Icon32dp), largeIcon = true, ) } @@ -121,7 +121,7 @@ fun OutlinedChipPreviewDisabled() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = ImageVectorPaintable(Icons.Default.Image), enabled = false, ) } diff --git a/compose-material/src/debug/java/com/google/android/horologist/compose/material/OutlinedCompactChipPreview.kt b/compose-material/src/debug/java/com/google/android/horologist/compose/material/OutlinedCompactChipPreview.kt index df6ad26cb7..7245d7ee32 100644 --- a/compose-material/src/debug/java/com/google/android/horologist/compose/material/OutlinedCompactChipPreview.kt +++ b/compose-material/src/debug/java/com/google/android/horologist/compose/material/OutlinedCompactChipPreview.kt @@ -36,7 +36,7 @@ fun OutlinedCompactChipPreviewWithIcon() { OutlinedCompactChip( onClick = { }, label = "Primary label", - icon = Icons.Filled.Add, + icon = ImageVectorPaintable(Icons.Filled.Add), ) } @@ -45,7 +45,7 @@ fun OutlinedCompactChipPreviewWithIcon() { fun OutlinedCompactChipPreviewIconOnly() { OutlinedCompactChip( onClick = { }, - icon = Icons.Filled.Add, + icon = ImageVectorPaintable(Icons.Filled.Add), contentDescription = "contentDescription", ) } diff --git a/compose-material/src/debug/java/com/google/android/horologist/compose/material/ToggleButtonPreview.kt b/compose-material/src/debug/java/com/google/android/horologist/compose/material/ToggleButtonPreview.kt index 80be674424..806dbb4810 100644 --- a/compose-material/src/debug/java/com/google/android/horologist/compose/material/ToggleButtonPreview.kt +++ b/compose-material/src/debug/java/com/google/android/horologist/compose/material/ToggleButtonPreview.kt @@ -21,6 +21,7 @@ import androidx.compose.material.icons.filled.AirplanemodeActive import androidx.compose.material.icons.filled.AirplanemodeInactive import androidx.compose.runtime.Composable import androidx.compose.ui.tooling.preview.Preview +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable @Preview( backgroundColor = 0xff000000, @@ -29,8 +30,8 @@ import androidx.compose.ui.tooling.preview.Preview @Composable fun ToggleButtonPreview() { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, ) @@ -43,8 +44,8 @@ fun ToggleButtonPreview() { @Composable fun ToggleButtonPreviewNotChecked() { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, @@ -58,8 +59,8 @@ fun ToggleButtonPreviewNotChecked() { @Composable fun ToggleButtonPreviewDisabled() { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, enabled = false, @@ -73,8 +74,8 @@ fun ToggleButtonPreviewDisabled() { @Composable fun ToggleButtonPreviewNotCheckedDisabled() { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, @@ -114,8 +115,8 @@ fun ToggleButtonPreviewTextNotChecked() { @Composable fun ToggleButtonPreviewSmall() { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, smallSize = true, @@ -129,8 +130,8 @@ fun ToggleButtonPreviewSmall() { @Composable fun ToggleButtonPreviewSmallNotChecked() { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, @@ -145,8 +146,8 @@ fun ToggleButtonPreviewSmallNotChecked() { @Composable fun ToggleButtonPreviewIconOnly() { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, colors = ToggleButtonDefaults.iconOnlyColors(), @@ -161,8 +162,8 @@ fun ToggleButtonPreviewIconOnly() { @Composable fun ToggleButtonPreviewIconOnlyNotChecked() { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, diff --git a/compose-material/src/main/java/com/google/android/horologist/compose/material/Button.kt b/compose-material/src/main/java/com/google/android/horologist/compose/material/Button.kt index fce9c4b4aa..8e4536d72f 100644 --- a/compose-material/src/main/java/com/google/android/horologist/compose/material/Button.kt +++ b/compose-material/src/main/java/com/google/android/horologist/compose/material/Button.kt @@ -52,7 +52,7 @@ public fun Button( enabled: Boolean = true, ) { Button( - icon = imageVector, + icon = ImageVectorPaintable(imageVector), contentDescription = contentDescription, onClick = onClick, modifier = modifier, @@ -81,7 +81,7 @@ public fun Button( enabled: Boolean = true, ) { Button( - icon = id, + icon = DrawableResPaintable(id), contentDescription = contentDescription, onClick = onClick, modifier = modifier, @@ -95,7 +95,7 @@ public fun Button( @OptIn(ExperimentalHorologistApi::class) @Composable internal fun Button( - icon: Any, + icon: PaintableIcon, contentDescription: String, onClick: () -> Unit, modifier: Modifier = Modifier, @@ -115,7 +115,7 @@ internal fun Button( .align(Alignment.Center) Icon( - icon = icon, + paintable = icon, contentDescription = contentDescription, modifier = iconModifier, rtlMode = iconRtlMode, diff --git a/compose-material/src/main/java/com/google/android/horologist/compose/material/Chip.kt b/compose-material/src/main/java/com/google/android/horologist/compose/material/Chip.kt index 8842de7c28..a23bee0705 100644 --- a/compose-material/src/main/java/com/google/android/horologist/compose/material/Chip.kt +++ b/compose-material/src/main/java/com/google/android/horologist/compose/material/Chip.kt @@ -28,8 +28,6 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.painter.Painter -import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign @@ -40,7 +38,6 @@ import androidx.wear.compose.material.ChipColors import androidx.wear.compose.material.ChipDefaults import androidx.wear.compose.material.LocalContentAlpha import androidx.wear.compose.material.Text -import coil.compose.rememberAsyncImagePainter import com.google.android.horologist.annotations.ExperimentalHorologistApi import com.google.android.horologist.compose.material.util.DECORATIVE_ELEMENT_CONTENT_DESCRIPTION @@ -58,9 +55,8 @@ public fun Chip( modifier: Modifier = Modifier, secondaryLabel: String? = null, iconRtlMode: IconRtlMode = IconRtlMode.Default, - icon: Any? = null, + icon: Paintable? = null, largeIcon: Boolean = false, - placeholder: Painter? = null, colors: ChipColors = ChipDefaults.primaryChipColors(), enabled: Boolean = true, ) { @@ -77,34 +73,21 @@ public fun Chip( val iconModifier = Modifier .size(iconSize) .clip(CircleShape) - when (icon) { - is ImageVector -> - Icon( - imageVector = icon, - contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, - modifier = iconModifier, - rtlMode = iconRtlMode, - ) - - is Int -> - Icon( - id = icon, - contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, - modifier = iconModifier, - rtlMode = iconRtlMode, - ) - - else -> - Image( - painter = rememberAsyncImagePainter( - model = icon, - placeholder = placeholder, - ), - contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, - modifier = iconModifier, - contentScale = ContentScale.Crop, - alpha = LocalContentAlpha.current, - ) + if (it is PaintableIcon) { + Icon( + paintable = it, + contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, + modifier = iconModifier, + rtlMode = iconRtlMode, + ) + } else { + Image( + painter = it.rememberPainter(), + contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, + modifier = iconModifier, + contentScale = ContentScale.Crop, + alpha = LocalContentAlpha.current, + ) } } } @@ -136,9 +119,8 @@ public fun Chip( modifier: Modifier = Modifier, @StringRes secondaryLabel: Int? = null, iconRtlMode: IconRtlMode = IconRtlMode.Default, - icon: Any? = null, + icon: Paintable? = null, largeIcon: Boolean = false, - placeholder: Painter? = null, colors: ChipColors = ChipDefaults.primaryChipColors(), enabled: Boolean = true, ) { @@ -149,7 +131,6 @@ public fun Chip( secondaryLabel = secondaryLabel?.let { stringResource(id = it) }, icon = icon, largeIcon = largeIcon, - placeholder = placeholder, colors = colors, enabled = enabled, iconRtlMode = iconRtlMode, diff --git a/compose-material/src/main/java/com/google/android/horologist/compose/material/ChipIconWithProgress.kt b/compose-material/src/main/java/com/google/android/horologist/compose/material/ChipIconWithProgress.kt index 2dbc431836..cf8ea46350 100644 --- a/compose-material/src/main/java/com/google/android/horologist/compose/material/ChipIconWithProgress.kt +++ b/compose-material/src/main/java/com/google/android/horologist/compose/material/ChipIconWithProgress.kt @@ -26,15 +26,12 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.painter.Painter -import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.unit.dp import androidx.wear.compose.material.ChipDefaults import androidx.wear.compose.material.CircularProgressIndicator -import androidx.wear.compose.material.Icon import androidx.wear.compose.material.LocalContentAlpha import androidx.wear.compose.material.MaterialTheme -import coil.compose.rememberAsyncImagePainter import com.google.android.horologist.annotations.ExperimentalHorologistApi import com.google.android.horologist.compose.material.util.DECORATIVE_ELEMENT_CONTENT_DESCRIPTION @@ -57,9 +54,8 @@ private val progressBarStrokeWidth = 2.dp @Composable public fun ChipIconWithProgress( modifier: Modifier = Modifier, - icon: Any? = null, + icon: Paintable? = null, largeIcon: Boolean = false, - placeholder: Painter? = null, progressIndicatorColor: Color = MaterialTheme.colors.primary, progressTrackColor: Color = MaterialTheme.colors.onSurface.copy(alpha = 0.10f), ) { @@ -67,7 +63,6 @@ public fun ChipIconWithProgress( progress = null, icon = icon, largeIcon = largeIcon, - placeholder = placeholder, progressIndicatorColor = progressIndicatorColor, progressTrackColor = progressTrackColor, modifier = modifier, @@ -93,9 +88,8 @@ public fun ChipIconWithProgress( public fun ChipIconWithProgress( progress: Float, modifier: Modifier = Modifier, - icon: Any? = null, + icon: Paintable? = null, largeIcon: Boolean = false, - placeholder: Painter? = null, progressIndicatorColor: Color = MaterialTheme.colors.primary, progressTrackColor: Color = MaterialTheme.colors.onSurface.copy(alpha = 0.10f), ) { @@ -103,7 +97,6 @@ public fun ChipIconWithProgress( progress = progress, icon = icon, largeIcon = largeIcon, - placeholder = placeholder, progressIndicatorColor = progressIndicatorColor, progressTrackColor = progressTrackColor, modifier = modifier, @@ -113,9 +106,8 @@ public fun ChipIconWithProgress( @Composable private fun ChipIconWithProgressInternal( progress: Float?, - icon: Any?, + icon: Paintable?, largeIcon: Boolean, - placeholder: Painter?, progressIndicatorColor: Color, progressTrackColor: Color, modifier: Modifier = Modifier, @@ -150,32 +142,27 @@ private fun ChipIconWithProgressInternal( ) } - when (icon) { - is ImageVector -> { - Icon( - imageVector = icon, - contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, - modifier = Modifier - .align(Alignment.Center) - .size(iconSize - indicatorPadding) - .clip(CircleShape), - ) - } - else -> { - Image( - painter = rememberAsyncImagePainter( - model = icon, - placeholder = placeholder, - ), - contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, - modifier = Modifier - .align(Alignment.Center) - .size(iconSize - indicatorPadding) - .clip(CircleShape), - contentScale = ContentScale.Crop, - alpha = LocalContentAlpha.current, - ) - } + icon ?: return + if (icon is PaintableIcon) { + Icon( + paintable = icon, + contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, + modifier = Modifier + .align(Alignment.Center) + .size(iconSize - indicatorPadding) + .clip(CircleShape), + ) + } else { + Image( + painter = icon.rememberPainter(), + contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, + modifier = Modifier + .align(Alignment.Center) + .size(iconSize - indicatorPadding) + .clip(CircleShape), + contentScale = ContentScale.Crop, + alpha = LocalContentAlpha.current, + ) } } } diff --git a/compose-material/src/main/java/com/google/android/horologist/compose/material/CompactChip.kt b/compose-material/src/main/java/com/google/android/horologist/compose/material/CompactChip.kt index 0a544f856d..7b696cf52a 100644 --- a/compose-material/src/main/java/com/google/android/horologist/compose/material/CompactChip.kt +++ b/compose-material/src/main/java/com/google/android/horologist/compose/material/CompactChip.kt @@ -27,8 +27,6 @@ import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.painter.Painter -import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign @@ -39,7 +37,6 @@ import androidx.wear.compose.material.ChipDefaults import androidx.wear.compose.material.CompactChip import androidx.wear.compose.material.LocalContentAlpha import androidx.wear.compose.material.Text -import coil.compose.rememberAsyncImagePainter import com.google.android.horologist.annotations.ExperimentalHorologistApi import com.google.android.horologist.compose.material.util.DECORATIVE_ELEMENT_CONTENT_DESCRIPTION @@ -54,9 +51,8 @@ public fun CompactChip( label: String, onClick: () -> Unit, modifier: Modifier = Modifier, - icon: Any? = null, + icon: Paintable? = null, iconRtlMode: IconRtlMode = IconRtlMode.Default, - placeholder: Painter? = null, colors: ChipColors = ChipDefaults.primaryChipColors(), enabled: Boolean = true, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, @@ -68,7 +64,6 @@ public fun CompactChip( label = label, icon = icon, iconRtlMode = iconRtlMode, - placeholder = placeholder, contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, colors = colors, enabled = enabled, @@ -88,9 +83,8 @@ public fun CompactChip( @StringRes labelId: Int, onClick: () -> Unit, modifier: Modifier = Modifier, - icon: Any? = null, + icon: Paintable? = null, iconRtlMode: IconRtlMode = IconRtlMode.Default, - placeholder: Painter? = null, colors: ChipColors = ChipDefaults.primaryChipColors(), enabled: Boolean = true, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, @@ -102,7 +96,6 @@ public fun CompactChip( modifier = modifier, icon = icon, iconRtlMode = iconRtlMode, - placeholder = placeholder, colors = colors, enabled = enabled, interactionSource = interactionSource, @@ -117,12 +110,11 @@ public fun CompactChip( @ExperimentalHorologistApi @Composable public fun CompactChip( - icon: Any, + icon: Paintable, contentDescription: String, onClick: () -> Unit, modifier: Modifier = Modifier, iconRtlMode: IconRtlMode = IconRtlMode.Default, - placeholder: Painter? = null, colors: ChipColors = ChipDefaults.primaryChipColors(), enabled: Boolean = true, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, @@ -134,7 +126,6 @@ public fun CompactChip( label = null, icon = icon, iconRtlMode = iconRtlMode, - placeholder = placeholder, contentDescription = contentDescription, colors = colors, enabled = enabled, @@ -148,9 +139,8 @@ internal fun CompactChip( onClick: () -> Unit, modifier: Modifier = Modifier, label: String? = null, - icon: Any? = null, + icon: Paintable? = null, iconRtlMode: IconRtlMode = IconRtlMode.Default, - placeholder: Painter? = null, contentDescription: String? = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, colors: ChipColors = ChipDefaults.primaryChipColors(), enabled: Boolean = true, @@ -161,35 +151,21 @@ internal fun CompactChip( { Row { val iconModifier = Modifier.size(ChipDefaults.SmallIconSize) - - when (icon) { - is ImageVector -> - Icon( - imageVector = icon, - contentDescription = contentDescription, - modifier = iconModifier, - rtlMode = iconRtlMode, - ) - - is Int -> - Icon( - id = icon, - contentDescription = contentDescription, - modifier = iconModifier, - rtlMode = iconRtlMode, - ) - - else -> - Image( - painter = rememberAsyncImagePainter( - model = icon, - placeholder = placeholder, - ), - contentDescription = contentDescription, - modifier = iconModifier, - contentScale = ContentScale.Crop, - alpha = LocalContentAlpha.current, - ) + if (it is PaintableIcon) { + Icon( + paintable = it, + contentDescription = contentDescription, + modifier = iconModifier, + rtlMode = iconRtlMode, + ) + } else { + Image( + painter = it.rememberPainter(), + contentDescription = contentDescription, + modifier = iconModifier, + contentScale = ContentScale.Crop, + alpha = LocalContentAlpha.current, + ) } } } diff --git a/compose-material/src/main/java/com/google/android/horologist/compose/material/Icon.kt b/compose-material/src/main/java/com/google/android/horologist/compose/material/Icon.kt index 4a4b441e77..4bd7e9ad0a 100644 --- a/compose-material/src/main/java/com/google/android/horologist/compose/material/Icon.kt +++ b/compose-material/src/main/java/com/google/android/horologist/compose/material/Icon.kt @@ -16,14 +16,11 @@ package com.google.android.horologist.compose.material -import androidx.annotation.DrawableRes import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.scale import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.platform.LocalLayoutDirection -import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.LayoutDirection import androidx.wear.compose.material.Icon import androidx.wear.compose.material.LocalContentAlpha @@ -37,33 +34,7 @@ import com.google.android.horologist.annotations.ExperimentalHorologistApi @ExperimentalHorologistApi @Composable public fun Icon( - imageVector: ImageVector, - contentDescription: String?, - modifier: Modifier = Modifier, - tint: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current), - rtlMode: IconRtlMode = IconRtlMode.Default, -) { - val shouldMirror = - rtlMode == IconRtlMode.Mirrored && LocalLayoutDirection.current == LayoutDirection.Rtl - Icon( - modifier = modifier.scale( - scaleX = if (shouldMirror) -1f else 1f, - scaleY = 1f, - ), - imageVector = imageVector, - contentDescription = contentDescription, - tint = tint, - ) -} - -/** - * This component is an alternative to [Icon], providing the following: - * - a convenient way of setting the icon to be mirrored in RTL mode; - */ -@ExperimentalHorologistApi -@Composable -public fun Icon( - @DrawableRes id: Int, + paintable: PaintableIcon, contentDescription: String?, modifier: Modifier = Modifier, tint: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current), @@ -73,7 +44,7 @@ public fun Icon( rtlMode == IconRtlMode.Mirrored && LocalLayoutDirection.current == LayoutDirection.Rtl Icon( - painter = painterResource(id = id), + painter = paintable.rememberPainter(), contentDescription = contentDescription, modifier = modifier.scale( scaleX = if (shouldMirror) -1f else 1f, @@ -83,44 +54,6 @@ public fun Icon( ) } -@Composable -internal fun Icon( - icon: Any, - contentDescription: String?, - modifier: Modifier = Modifier, - tint: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current), - rtlMode: IconRtlMode = IconRtlMode.Default, -) { - val shouldMirror = - rtlMode == IconRtlMode.Mirrored && LocalLayoutDirection.current == LayoutDirection.Rtl - - val iconModifier = modifier.scale( - scaleX = if (shouldMirror) -1f else 1f, - scaleY = 1f, - ) - when (icon) { - is ImageVector -> { - Icon( - imageVector = icon, - modifier = iconModifier, - contentDescription = contentDescription, - tint = tint, - ) - } - - is Int -> { - Icon( - painter = painterResource(id = icon), - contentDescription = contentDescription, - modifier = iconModifier, - tint = tint, - ) - } - - else -> throw IllegalArgumentException("Type not supported.") - } -} - @ExperimentalHorologistApi public enum class IconRtlMode { Default, diff --git a/compose-material/src/main/java/com/google/android/horologist/compose/material/OutlinedChip.kt b/compose-material/src/main/java/com/google/android/horologist/compose/material/OutlinedChip.kt index d87ea3ba9d..84f2685974 100644 --- a/compose-material/src/main/java/com/google/android/horologist/compose/material/OutlinedChip.kt +++ b/compose-material/src/main/java/com/google/android/horologist/compose/material/OutlinedChip.kt @@ -28,8 +28,6 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.painter.Painter -import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign @@ -40,7 +38,6 @@ import androidx.wear.compose.material.ChipDefaults import androidx.wear.compose.material.LocalContentAlpha import androidx.wear.compose.material.OutlinedChip import androidx.wear.compose.material.Text -import coil.compose.rememberAsyncImagePainter import com.google.android.horologist.annotations.ExperimentalHorologistApi import com.google.android.horologist.compose.material.util.DECORATIVE_ELEMENT_CONTENT_DESCRIPTION @@ -58,9 +55,8 @@ public fun OutlinedChip( modifier: Modifier = Modifier, iconRtlMode: IconRtlMode = IconRtlMode.Default, secondaryLabel: String? = null, - icon: Any? = null, + icon: Paintable? = null, largeIcon: Boolean = false, - placeholder: Painter? = null, colors: ChipColors = ChipDefaults.outlinedChipColors(), enabled: Boolean = true, ) { @@ -77,34 +73,21 @@ public fun OutlinedChip( val iconModifier = Modifier .size(iconSize) .clip(CircleShape) - when (icon) { - is ImageVector -> - Icon( - imageVector = icon, - rtlMode = iconRtlMode, - contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, - modifier = iconModifier, - ) - - is Int -> - Icon( - id = icon, - rtlMode = iconRtlMode, - contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, - modifier = iconModifier, - ) - - else -> - Image( - painter = rememberAsyncImagePainter( - model = icon, - placeholder = placeholder, - ), - contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, - modifier = iconModifier, - contentScale = ContentScale.Crop, - alpha = LocalContentAlpha.current, - ) + if (it is PaintableIcon) { + Icon( + paintable = it, + rtlMode = iconRtlMode, + contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, + modifier = iconModifier, + ) + } else { + Image( + painter = it.rememberPainter(), + contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, + modifier = iconModifier, + contentScale = ContentScale.Crop, + alpha = LocalContentAlpha.current, + ) } } } @@ -136,9 +119,8 @@ public fun OutlinedChip( modifier: Modifier = Modifier, iconRtlMode: IconRtlMode = IconRtlMode.Default, @StringRes secondaryLabel: Int? = null, - icon: Any? = null, + icon: Paintable? = null, largeIcon: Boolean = false, - placeholder: Painter? = null, colors: ChipColors = ChipDefaults.outlinedChipColors(), enabled: Boolean = true, ) { @@ -149,7 +131,6 @@ public fun OutlinedChip( secondaryLabel = secondaryLabel?.let { stringResource(id = it) }, icon = icon, largeIcon = largeIcon, - placeholder = placeholder, iconRtlMode = iconRtlMode, colors = colors, enabled = enabled, diff --git a/compose-material/src/main/java/com/google/android/horologist/compose/material/OutlinedCompactChip.kt b/compose-material/src/main/java/com/google/android/horologist/compose/material/OutlinedCompactChip.kt index 8bbed859eb..4226b5bd04 100644 --- a/compose-material/src/main/java/com/google/android/horologist/compose/material/OutlinedCompactChip.kt +++ b/compose-material/src/main/java/com/google/android/horologist/compose/material/OutlinedCompactChip.kt @@ -27,8 +27,6 @@ import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.painter.Painter -import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign @@ -39,7 +37,6 @@ import androidx.wear.compose.material.ChipDefaults import androidx.wear.compose.material.LocalContentAlpha import androidx.wear.compose.material.OutlinedCompactChip import androidx.wear.compose.material.Text -import coil.compose.rememberAsyncImagePainter import com.google.android.horologist.annotations.ExperimentalHorologistApi import com.google.android.horologist.compose.material.util.DECORATIVE_ELEMENT_CONTENT_DESCRIPTION @@ -54,9 +51,8 @@ public fun OutlinedCompactChip( label: String, onClick: () -> Unit, modifier: Modifier = Modifier, - icon: Any? = null, + icon: Paintable? = null, iconRtlMode: IconRtlMode = IconRtlMode.Default, - placeholder: Painter? = null, colors: ChipColors = ChipDefaults.outlinedChipColors(), enabled: Boolean = true, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, @@ -68,7 +64,6 @@ public fun OutlinedCompactChip( label = label, icon = icon, iconRtlMode = iconRtlMode, - placeholder = placeholder, contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, colors = colors, enabled = enabled, @@ -88,9 +83,8 @@ public fun OutlinedCompactChip( @StringRes labelId: Int, onClick: () -> Unit, modifier: Modifier = Modifier, - icon: Any? = null, + icon: Paintable? = null, iconRtlMode: IconRtlMode = IconRtlMode.Default, - placeholder: Painter? = null, colors: ChipColors = ChipDefaults.outlinedChipColors(), enabled: Boolean = true, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, @@ -102,7 +96,6 @@ public fun OutlinedCompactChip( label = stringResource(id = labelId), icon = icon, iconRtlMode = iconRtlMode, - placeholder = placeholder, colors = colors, enabled = enabled, interactionSource = interactionSource, @@ -118,12 +111,11 @@ public fun OutlinedCompactChip( @ExperimentalHorologistApi @Composable public fun OutlinedCompactChip( - icon: Any, + icon: Paintable, contentDescription: String, onClick: () -> Unit, modifier: Modifier = Modifier, iconRtlMode: IconRtlMode = IconRtlMode.Default, - placeholder: Painter? = null, colors: ChipColors = ChipDefaults.outlinedChipColors(), enabled: Boolean = true, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, @@ -135,7 +127,6 @@ public fun OutlinedCompactChip( label = null, icon = icon, iconRtlMode = iconRtlMode, - placeholder = placeholder, contentDescription = contentDescription, colors = colors, enabled = enabled, @@ -149,9 +140,8 @@ internal fun OutlinedCompactChip( onClick: () -> Unit, modifier: Modifier = Modifier, label: String? = null, - icon: Any? = null, + icon: Paintable? = null, iconRtlMode: IconRtlMode = IconRtlMode.Default, - placeholder: Painter? = null, contentDescription: String? = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, colors: ChipColors = ChipDefaults.outlinedChipColors(), enabled: Boolean = true, @@ -163,34 +153,21 @@ internal fun OutlinedCompactChip( Row { val iconModifier = Modifier.size(ChipDefaults.SmallIconSize) - when (icon) { - is ImageVector -> - Icon( - imageVector = icon, - contentDescription = contentDescription, - modifier = iconModifier, - rtlMode = iconRtlMode, - ) - - is Int -> - Icon( - id = icon, - contentDescription = contentDescription, - modifier = iconModifier, - rtlMode = iconRtlMode, - ) - - else -> - Image( - painter = rememberAsyncImagePainter( - model = icon, - placeholder = placeholder, - ), - contentDescription = contentDescription, - modifier = iconModifier, - contentScale = ContentScale.Crop, - alpha = LocalContentAlpha.current, - ) + if (it is PaintableIcon) { + Icon( + paintable = it, + contentDescription = contentDescription, + modifier = iconModifier, + rtlMode = iconRtlMode, + ) + } else { + Image( + painter = it.rememberPainter(), + contentDescription = contentDescription, + modifier = iconModifier, + contentScale = ContentScale.Crop, + alpha = LocalContentAlpha.current, + ) } } } diff --git a/compose-material/src/main/java/com/google/android/horologist/compose/material/Paintable.kt b/compose-material/src/main/java/com/google/android/horologist/compose/material/Paintable.kt new file mode 100644 index 0000000000..6cdd5ad308 --- /dev/null +++ b/compose-material/src/main/java/com/google/android/horologist/compose/material/Paintable.kt @@ -0,0 +1,95 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.android.horologist.compose.material + +import android.graphics.Bitmap +import androidx.annotation.DrawableRes +import androidx.compose.runtime.Composable +import androidx.compose.runtime.Stable +import androidx.compose.runtime.remember +import androidx.compose.ui.graphics.ImageBitmap +import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.graphics.painter.BitmapPainter +import androidx.compose.ui.graphics.painter.Painter +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.graphics.vector.rememberVectorPainter +import androidx.compose.ui.res.painterResource +import coil.compose.rememberAsyncImagePainter + +/** Represents an image or graphic that can be displayed in a compose context via a [Painter]. */ +@Stable +public interface Paintable { + @Composable + public fun rememberPainter(): Painter +} + +/** + * Represents an image or graphic that can be displayed in a compose context via a [Painter], but + * that should be treated as an icon rather than an image (for example, tinting can be applied). + **/ +@Stable +public interface PaintableIcon : Paintable + +/** An [ImageVector] that can be represented as a [Painter]. */ +@JvmInline +public value class ImageVectorPaintable(private val imageVector: ImageVector) : + PaintableIcon { + + @Composable + override fun rememberPainter(): Painter = rememberVectorPainter(imageVector) + + public companion object { + public fun ImageVector.asPaintable(): ImageVectorPaintable = ImageVectorPaintable( + this, + ) + } + } + +/** An drawable resource ID that can be represented as a [Painter]. */ +@JvmInline +public value class DrawableResPaintable( + @DrawableRes private val id: Int, +) : PaintableIcon { + + @Composable + override fun rememberPainter(): Painter = painterResource(id = id) +} + +/** A [Bitmap] that can be represented as a [Painter]. */ +@JvmInline +public value class BitmapPaintable(private val bitmap: ImageBitmap) : Paintable { + + @Composable + override fun rememberPainter(): Painter = remember { BitmapPainter(bitmap) } + + public companion object { + public fun ImageBitmap.asPaintable(): BitmapPaintable = BitmapPaintable(this) + public fun Bitmap.asPaintable(): BitmapPaintable = this.asImageBitmap().asPaintable() + } +} + +/** A wrapper around a coil-compatible model that can be represented as a [Painter]. */ +@Stable +public class CoilPaintable(private val model: Any?, private val placeholder: Painter? = null) : + Paintable { + + @Composable + override fun rememberPainter(): Painter = rememberAsyncImagePainter( + model = model, + placeholder = placeholder, + ) + } diff --git a/compose-material/src/main/java/com/google/android/horologist/compose/material/SplitToggleChip.kt b/compose-material/src/main/java/com/google/android/horologist/compose/material/SplitToggleChip.kt index 3a04d65781..60aea555f6 100644 --- a/compose-material/src/main/java/com/google/android/horologist/compose/material/SplitToggleChip.kt +++ b/compose-material/src/main/java/com/google/android/horologist/compose/material/SplitToggleChip.kt @@ -34,6 +34,7 @@ import androidx.wear.compose.material.SplitToggleChipColors import androidx.wear.compose.material.Text import androidx.wear.compose.material.ToggleChipDefaults import com.google.android.horologist.annotations.ExperimentalHorologistApi +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.util.DECORATIVE_ELEMENT_CONTENT_DESCRIPTION /** @@ -91,11 +92,11 @@ public fun SplitToggleChip( }, ) Icon( - imageVector = when (toggleControl) { + paintable = when (toggleControl) { ToggleChipToggleControl.Switch -> ToggleChipDefaults.switchIcon(checked) ToggleChipToggleControl.Radio -> ToggleChipDefaults.radioIcon(checked) ToggleChipToggleControl.Checkbox -> ToggleChipDefaults.checkboxIcon(checked) - }, + }.asPaintable(), contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, modifier = Modifier.semantics { stateDescription = stateDescriptionSemantics diff --git a/compose-material/src/main/java/com/google/android/horologist/compose/material/Stepper.kt b/compose-material/src/main/java/com/google/android/horologist/compose/material/Stepper.kt index f8ccffe3ba..2d5e059c15 100644 --- a/compose-material/src/main/java/com/google/android/horologist/compose/material/Stepper.kt +++ b/compose-material/src/main/java/com/google/android/horologist/compose/material/Stepper.kt @@ -26,6 +26,7 @@ import androidx.compose.ui.util.lerp import androidx.wear.compose.material.MaterialTheme import androidx.wear.compose.material.StepperDefaults import androidx.wear.compose.material.contentColorFor +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.rotaryinput.RotaryDefaults import com.google.android.horologist.compose.rotaryinput.onRotaryInputAccumulatedWithFocus import kotlin.math.roundToInt @@ -43,13 +44,13 @@ public fun Stepper( modifier: Modifier = Modifier, decreaseIcon: @Composable () -> Unit = { Icon( - StepperDefaults.Decrease, + StepperDefaults.Decrease.asPaintable(), stringResource(R.string.horologist_stepper_decrease_content_description), ) }, increaseIcon: @Composable () -> Unit = { Icon( - StepperDefaults.Increase, + StepperDefaults.Increase.asPaintable(), stringResource(R.string.horologist_stepper_increase_content_description), ) }, @@ -110,13 +111,13 @@ public fun Stepper( modifier: Modifier = Modifier, decreaseIcon: @Composable () -> Unit = { Icon( - StepperDefaults.Decrease, + StepperDefaults.Decrease.asPaintable(), stringResource(R.string.horologist_stepper_decrease_content_description), ) }, increaseIcon: @Composable () -> Unit = { Icon( - StepperDefaults.Increase, + StepperDefaults.Increase.asPaintable(), stringResource(R.string.horologist_stepper_increase_content_description), ) }, diff --git a/compose-material/src/main/java/com/google/android/horologist/compose/material/Title.kt b/compose-material/src/main/java/com/google/android/horologist/compose/material/Title.kt index 448939b915..6b06f4390d 100644 --- a/compose-material/src/main/java/com/google/android/horologist/compose/material/Title.kt +++ b/compose-material/src/main/java/com/google/android/horologist/compose/material/Title.kt @@ -38,6 +38,7 @@ import androidx.compose.ui.unit.dp import androidx.wear.compose.material.MaterialTheme import androidx.wear.compose.material.Text import com.google.android.horologist.annotations.ExperimentalHorologistApi +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.util.DECORATIVE_ELEMENT_CONTENT_DESCRIPTION /** @@ -119,7 +120,7 @@ public fun SecondaryTitle( ) { icon?.let { Icon( - imageVector = icon, + paintable = icon.asPaintable(), contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, modifier = Modifier .size(iconSize), diff --git a/compose-material/src/main/java/com/google/android/horologist/compose/material/ToggleButton.kt b/compose-material/src/main/java/com/google/android/horologist/compose/material/ToggleButton.kt index 5a09999902..d307008c50 100644 --- a/compose-material/src/main/java/com/google/android/horologist/compose/material/ToggleButton.kt +++ b/compose-material/src/main/java/com/google/android/horologist/compose/material/ToggleButton.kt @@ -87,8 +87,8 @@ public fun ToggleButton( */ @Composable public fun ToggleButton( - checkedIcon: Any, - notCheckedIcon: Any, + checkedIcon: PaintableIcon, + notCheckedIcon: PaintableIcon, contentDescription: String, onCheckedChanged: (Boolean) -> Unit, modifier: Modifier = Modifier, @@ -126,7 +126,7 @@ public fun ToggleButton( role = role, ) { Icon( - icon = if (checked) { + paintable = if (checked) { checkedIcon } else { notCheckedIcon diff --git a/compose-material/src/main/java/com/google/android/horologist/compose/material/ToggleChip.kt b/compose-material/src/main/java/com/google/android/horologist/compose/material/ToggleChip.kt index bb9571e851..c59292342d 100644 --- a/compose-material/src/main/java/com/google/android/horologist/compose/material/ToggleChip.kt +++ b/compose-material/src/main/java/com/google/android/horologist/compose/material/ToggleChip.kt @@ -40,6 +40,7 @@ import androidx.wear.compose.material.ToggleChip import androidx.wear.compose.material.ToggleChipColors import androidx.wear.compose.material.ToggleChipDefaults import com.google.android.horologist.annotations.ExperimentalHorologistApi +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.util.DECORATIVE_ELEMENT_CONTENT_DESCRIPTION /** @@ -91,11 +92,11 @@ public fun ToggleChip( val toggleControlParam: (@Composable () -> Unit) = { Icon( - imageVector = when (toggleControl) { + paintable = when (toggleControl) { ToggleChipToggleControl.Switch -> ToggleChipDefaults.switchIcon(checked) ToggleChipToggleControl.Radio -> ToggleChipDefaults.radioIcon(checked) ToggleChipToggleControl.Checkbox -> ToggleChipDefaults.checkboxIcon(checked) - }, + }.asPaintable(), contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, // This potentially be removed once this issue is addressed: // https://issuetracker.google.com/issues/287087138 @@ -108,7 +109,7 @@ public fun ToggleChip( { Row { Icon( - imageVector = icon, + paintable = it.asPaintable(), contentDescription = DECORATIVE_ELEMENT_CONTENT_DESCRIPTION, modifier = Modifier .size(ChipDefaults.IconSize) diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipA11yTest.kt index 8ff5068b8a..7764d11951 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipA11yTest.kt @@ -22,6 +22,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Image import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.screenshots.ScreenshotBaseTest import com.google.android.horologist.screenshots.ScreenshotTestRule import org.junit.Test @@ -41,7 +42,7 @@ class ChipA11yTest : ScreenshotBaseTest( label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } } @@ -55,7 +56,7 @@ class ChipA11yTest : ScreenshotBaseTest( label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), enabled = false, ) } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipIconWithProgressTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipIconWithProgressTest.kt index e31211f367..aab7b58e39 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipIconWithProgressTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipIconWithProgressTest.kt @@ -19,6 +19,7 @@ package com.google.android.horologist.compose.material import androidx.compose.material.icons.materialPath import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.unit.dp +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.tools.coil.FakeImageLoader import com.google.android.horologist.screenshots.ScreenshotBaseTest import org.junit.Test @@ -39,14 +40,14 @@ class ChipIconWithProgressTest : ScreenshotBaseTest() { @Test fun withProgressSmallIcon() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { - ChipIconWithProgress(progress = 75f, icon = Icon12dp) + ChipIconWithProgress(progress = 75f, icon = Icon12dp.asPaintable()) } } @Test fun withProgressMediumIcon() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { - ChipIconWithProgress(progress = 75f, icon = Icon32dp) + ChipIconWithProgress(progress = 75f, icon = Icon32dp.asPaintable()) } } @@ -55,7 +56,7 @@ class ChipIconWithProgressTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ChipIconWithProgress( progress = 75f, - icon = Icon48dp, + icon = Icon48dp.asPaintable(), largeIcon = true, ) } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipTest.kt index 2145343c6f..e2e50cff4d 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipTest.kt @@ -32,6 +32,7 @@ import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp import androidx.wear.compose.material.ChipDefaults import com.google.accompanist.testharness.TestHarness +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.util.rememberVectorPainter import com.google.android.horologist.compose.tools.coil.FakeImageLoader import com.google.android.horologist.screenshots.ScreenshotBaseTest @@ -66,7 +67,7 @@ class ChipTest : ScreenshotBaseTest() { Chip( label = "Primary label", onClick = { }, - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } } @@ -77,7 +78,7 @@ class ChipTest : ScreenshotBaseTest() { Chip( label = "Primary label", onClick = { }, - icon = Icon32dp, + icon = Icon32dp.asPaintable(), largeIcon = true, ) } @@ -90,7 +91,7 @@ class ChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } } @@ -102,7 +103,7 @@ class ChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icon32dp, + icon = Icon32dp.asPaintable(), largeIcon = true, ) } @@ -115,7 +116,7 @@ class ChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), enabled = false, ) } @@ -162,7 +163,7 @@ class ChipTest : ScreenshotBaseTest() { label = "Primary label very very very very very very very very long text", onClick = { }, secondaryLabel = "Secondary label very very very very very very very very very long text", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } } @@ -175,7 +176,7 @@ class ChipTest : ScreenshotBaseTest() { label = "Primary label very very very very very very very very long text", onClick = { }, secondaryLabel = "Secondary label very very very very very very very very very long text", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } } @@ -188,7 +189,7 @@ class ChipTest : ScreenshotBaseTest() { label = "Primary label very very very very very very very very long text", onClick = { }, secondaryLabel = "Secondary label very very very very very very very very very long text", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), largeIcon = true, ) } @@ -202,7 +203,7 @@ class ChipTest : ScreenshotBaseTest() { label = "Primary label very very very very very very very very long text", onClick = { }, secondaryLabel = "Secondary label very very very very very very very very very long text", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), largeIcon = true, ) } @@ -215,7 +216,7 @@ class ChipTest : ScreenshotBaseTest() { Chip( label = "Primary label", onClick = { }, - icon = Icon12dp, + icon = Icon12dp.asPaintable(), ) } } @@ -226,7 +227,7 @@ class ChipTest : ScreenshotBaseTest() { Chip( label = "Primary label", onClick = { }, - icon = android.R.drawable.ic_delete, + icon = DrawableResPaintable(android.R.drawable.ic_delete), ) } } @@ -237,7 +238,7 @@ class ChipTest : ScreenshotBaseTest() { Chip( label = "Primary label", onClick = { }, - icon = Icon12dp, + icon = Icon12dp.asPaintable(), largeIcon = true, ) } @@ -249,7 +250,7 @@ class ChipTest : ScreenshotBaseTest() { Chip( label = "Primary label", onClick = { }, - icon = Icon48dp, + icon = Icon48dp.asPaintable(), ) } } @@ -260,7 +261,7 @@ class ChipTest : ScreenshotBaseTest() { Chip( label = "Primary label", onClick = { }, - icon = Icon48dp, + icon = Icon48dp.asPaintable(), largeIcon = true, ) } @@ -272,7 +273,7 @@ class ChipTest : ScreenshotBaseTest() { Chip( label = "Primary label", onClick = { }, - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } } @@ -290,10 +291,12 @@ class ChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = "iconUri", - placeholder = rememberVectorPainter( - image = Icons.Default.Image, - tintColor = Color.Black, + icon = CoilPaintable( + "iconUri", + placeholder = rememberVectorPainter( + image = Icons.Default.Image, + tintColor = Color.Black, + ), ), enabled = false, ) @@ -309,7 +312,7 @@ class ChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } } @@ -322,7 +325,7 @@ class ChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) } @@ -335,7 +338,7 @@ class ChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), colors = ChipDefaults.gradientBackgroundChipColors(), ) } @@ -348,7 +351,7 @@ class ChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), colors = ChipDefaults.imageBackgroundChipColors( backgroundImagePainter = painterResource(id = R.drawable.ic_dialog_alert), ), @@ -365,7 +368,7 @@ class ChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Outlined.VolumeDown, + icon = Icons.Outlined.VolumeDown.asPaintable(), iconRtlMode = IconRtlMode.Mirrored, ) } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/CompactChipA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/CompactChipA11yTest.kt index d78480e088..d46a6b7e50 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/CompactChipA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/CompactChipA11yTest.kt @@ -22,6 +22,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.screenshots.ScreenshotBaseTest import com.google.android.horologist.screenshots.ScreenshotTestRule import org.junit.Test @@ -42,7 +43,7 @@ class CompactChipA11yTest : ScreenshotBaseTest( CompactChip( label = "Primary label", onClick = { }, - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), ) } } @@ -58,7 +59,7 @@ class CompactChipA11yTest : ScreenshotBaseTest( CompactChip( label = "Primary label", onClick = { }, - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), enabled = false, ) } @@ -74,7 +75,7 @@ class CompactChipA11yTest : ScreenshotBaseTest( ) { CompactChip( onClick = { }, - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), contentDescription = "contentDescription", ) } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/CompactChipTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/CompactChipTest.kt index af0eaa0593..cd871201f5 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/CompactChipTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/CompactChipTest.kt @@ -27,6 +27,7 @@ import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.unit.LayoutDirection import androidx.wear.compose.material.MaterialTheme import com.google.accompanist.testharness.TestHarness +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.util.rememberVectorPainter import com.google.android.horologist.compose.tools.coil.FakeImageLoader import com.google.android.horologist.screenshots.ScreenshotBaseTest @@ -50,7 +51,7 @@ class CompactChipTest : ScreenshotBaseTest() { CompactChip( label = "Primary label", onClick = { }, - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), ) } } @@ -60,7 +61,7 @@ class CompactChipTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { CompactChip( onClick = { }, - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), contentDescription = "Add Icon", ) } @@ -72,7 +73,7 @@ class CompactChipTest : ScreenshotBaseTest() { CompactChip( label = "Primary label", onClick = { }, - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), enabled = false, ) } @@ -106,7 +107,7 @@ class CompactChipTest : ScreenshotBaseTest() { CompactChip( label = "Primary label", onClick = { }, - icon = R.drawable.ic_delete, + icon = DrawableResPaintable(R.drawable.ic_delete), ) } } @@ -122,10 +123,12 @@ class CompactChipTest : ScreenshotBaseTest() { CompactChip( label = "Primary label", onClick = { }, - icon = "iconUri", - placeholder = rememberVectorPainter( - image = Icons.Filled.Image, - tintColor = Color.Black, + icon = CoilPaintable( + "iconUri", + placeholder = rememberVectorPainter( + image = Icons.Filled.Image, + tintColor = Color.Black, + ), ), ) } @@ -144,10 +147,12 @@ class CompactChipTest : ScreenshotBaseTest() { CompactChip( label = "Primary label", onClick = { }, - icon = "iconUri", - placeholder = rememberVectorPainter( - image = Icons.Default.Image, - tintColor = MaterialTheme.colors.primary, + icon = CoilPaintable( + "iconUri", + placeholder = rememberVectorPainter( + image = Icons.Default.Image, + tintColor = MaterialTheme.colors.primary, + ), ), enabled = false, ) @@ -162,7 +167,7 @@ class CompactChipTest : ScreenshotBaseTest() { CompactChip( label = "Primary label", onClick = { }, - icon = Icons.AutoMirrored.Default.DirectionsBike, + icon = Icons.AutoMirrored.Default.DirectionsBike.asPaintable(), ) } } @@ -174,7 +179,7 @@ class CompactChipTest : ScreenshotBaseTest() { CompactChip( label = "Primary label", onClick = { }, - icon = Icons.AutoMirrored.Default.DirectionsBike, + icon = Icons.AutoMirrored.Default.DirectionsBike.asPaintable(), iconRtlMode = IconRtlMode.Mirrored, ) } @@ -187,7 +192,7 @@ class CompactChipTest : ScreenshotBaseTest() { CompactChip( label = "Primary label", onClick = { }, - icon = Icons.AutoMirrored.Default.DirectionsBike, + icon = Icons.AutoMirrored.Default.DirectionsBike.asPaintable(), iconRtlMode = IconRtlMode.Mirrored, ) } @@ -201,7 +206,7 @@ class CompactChipTest : ScreenshotBaseTest() { CompactChip( label = "Primary label", onClick = { }, - icon = R.drawable.ic_media_play, + icon = DrawableResPaintable(R.drawable.ic_media_play), iconRtlMode = IconRtlMode.Mirrored, ) } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/IconTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/IconTest.kt index 31f43aee2d..53b8267286 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/IconTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/IconTest.kt @@ -21,6 +21,7 @@ import androidx.compose.material.icons.automirrored.outlined.VolumeDown import androidx.compose.material.icons.outlined.Abc import androidx.compose.ui.unit.LayoutDirection import com.google.accompanist.testharness.TestHarness +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.screenshots.ScreenshotBaseTest import org.junit.Test @@ -30,7 +31,7 @@ class IconTest : ScreenshotBaseTest() { fun default() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { Icon( - imageVector = Icons.Outlined.Abc, + paintable = Icons.Outlined.Abc.asPaintable(), contentDescription = "contentDescription", ) } @@ -41,7 +42,7 @@ class IconTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { TestHarness(layoutDirection = LayoutDirection.Rtl) { Icon( - imageVector = Icons.Outlined.Abc, + paintable = Icons.Outlined.Abc.asPaintable(), contentDescription = "contentDescription", ) } @@ -52,7 +53,7 @@ class IconTest : ScreenshotBaseTest() { fun mirrored() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { Icon( - imageVector = Icons.Outlined.Abc, + paintable = Icons.Outlined.Abc.asPaintable(), contentDescription = "contentDescription", rtlMode = IconRtlMode.Mirrored, ) @@ -64,7 +65,7 @@ class IconTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { TestHarness(layoutDirection = LayoutDirection.Rtl) { Icon( - imageVector = Icons.Outlined.Abc, + paintable = Icons.Outlined.Abc.asPaintable(), contentDescription = "contentDescription", rtlMode = IconRtlMode.Mirrored, ) @@ -76,7 +77,7 @@ class IconTest : ScreenshotBaseTest() { fun autoMirroredLTR() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { Icon( - imageVector = Icons.AutoMirrored.Outlined.VolumeDown, + paintable = Icons.AutoMirrored.Outlined.VolumeDown.asPaintable(), contentDescription = "contentDescription", ) } @@ -87,7 +88,7 @@ class IconTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { TestHarness(layoutDirection = LayoutDirection.Rtl) { Icon( - imageVector = Icons.AutoMirrored.Outlined.VolumeDown, + paintable = Icons.AutoMirrored.Outlined.VolumeDown.asPaintable(), contentDescription = "contentDescription", ) } @@ -98,7 +99,7 @@ class IconTest : ScreenshotBaseTest() { fun usingDrawableResAsIcon() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { Icon( - id = android.R.drawable.ic_media_play, + paintable = DrawableResPaintable(android.R.drawable.ic_media_play), contentDescription = "contentDescription", ) } @@ -109,7 +110,7 @@ class IconTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { TestHarness(layoutDirection = LayoutDirection.Rtl) { Icon( - id = android.R.drawable.ic_media_play, + paintable = DrawableResPaintable(android.R.drawable.ic_media_play), contentDescription = "contentDescription", ) } @@ -120,7 +121,7 @@ class IconTest : ScreenshotBaseTest() { fun usingDrawableResAsIconMirrored() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { Icon( - id = android.R.drawable.ic_media_play, + paintable = DrawableResPaintable(android.R.drawable.ic_media_play), contentDescription = "contentDescription", rtlMode = IconRtlMode.Mirrored, ) @@ -132,7 +133,7 @@ class IconTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { TestHarness(layoutDirection = LayoutDirection.Rtl) { Icon( - id = android.R.drawable.ic_media_play, + paintable = DrawableResPaintable(android.R.drawable.ic_media_play), contentDescription = "contentDescription", rtlMode = IconRtlMode.Mirrored, ) diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedChipA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedChipA11yTest.kt index 154cc0e65e..9555d20c9f 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedChipA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedChipA11yTest.kt @@ -22,6 +22,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Image import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.screenshots.ScreenshotBaseTest import com.google.android.horologist.screenshots.ScreenshotTestRule import org.junit.Test @@ -41,7 +42,7 @@ class OutlinedChipA11yTest : ScreenshotBaseTest( label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } } @@ -55,7 +56,7 @@ class OutlinedChipA11yTest : ScreenshotBaseTest( label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), enabled = false, ) } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedChipTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedChipTest.kt index 7e2b8080b6..241460388a 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedChipTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedChipTest.kt @@ -31,6 +31,7 @@ import androidx.compose.ui.unit.dp import androidx.wear.compose.material.ChipDefaults import androidx.wear.compose.material.MaterialTheme import com.google.accompanist.testharness.TestHarness +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.util.rememberVectorPainter import com.google.android.horologist.compose.tools.coil.FakeImageLoader import com.google.android.horologist.screenshots.ScreenshotBaseTest @@ -65,7 +66,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { OutlinedChip( label = "Primary label", onClick = { }, - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } } @@ -76,7 +77,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { OutlinedChip( label = "Primary label", onClick = { }, - icon = Icon32dp, + icon = Icon32dp.asPaintable(), largeIcon = true, ) } @@ -89,7 +90,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } } @@ -101,7 +102,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icon32dp, + icon = Icon32dp.asPaintable(), largeIcon = true, ) } @@ -114,7 +115,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), enabled = false, ) } @@ -161,7 +162,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label very very very very very very very very long text", onClick = { }, secondaryLabel = "Secondary label very very very very very very very very very long text", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } } @@ -174,7 +175,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label very very very very very very very very long text", onClick = { }, secondaryLabel = "Secondary label very very very very very very very very very long text", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } } @@ -187,7 +188,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label very very very very very very very very long text", onClick = { }, secondaryLabel = "Secondary label very very very very very very very very very long text", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), largeIcon = true, ) } @@ -201,7 +202,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label very very very very very very very very long text", onClick = { }, secondaryLabel = "Secondary label very very very very very very very very very long text", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), largeIcon = true, ) } @@ -214,7 +215,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { OutlinedChip( label = "Primary label", onClick = { }, - icon = Icon12dp, + icon = Icon12dp.asPaintable(), ) } } @@ -225,7 +226,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { OutlinedChip( label = "Primary label", onClick = { }, - icon = android.R.drawable.ic_delete, + icon = DrawableResPaintable(android.R.drawable.ic_delete), ) } } @@ -236,7 +237,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { OutlinedChip( label = "Primary label", onClick = { }, - icon = Icon12dp, + icon = Icon12dp.asPaintable(), largeIcon = true, ) } @@ -248,7 +249,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { OutlinedChip( label = "Primary label", onClick = { }, - icon = Icon48dp, + icon = Icon48dp.asPaintable(), ) } } @@ -259,7 +260,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { OutlinedChip( label = "Primary label", onClick = { }, - icon = Icon48dp, + icon = Icon48dp.asPaintable(), largeIcon = true, ) } @@ -273,10 +274,12 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = "iconUri", - placeholder = rememberVectorPainter( - image = Icons.Default.Image, - tintColor = MaterialTheme.colors.primary, + icon = CoilPaintable( + "iconUri", + placeholder = rememberVectorPainter( + image = Icons.Default.Image, + tintColor = MaterialTheme.colors.primary, + ), ), ) } @@ -296,10 +299,12 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = "iconUri", - placeholder = rememberVectorPainter( - image = Icons.Default.Image, - tintColor = MaterialTheme.colors.primary, + icon = CoilPaintable( + "iconUri", + placeholder = rememberVectorPainter( + image = Icons.Default.Image, + tintColor = MaterialTheme.colors.primary, + ), ), enabled = false, ) @@ -315,7 +320,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } } @@ -328,7 +333,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) } @@ -341,7 +346,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), colors = ChipDefaults.gradientBackgroundChipColors(), ) } @@ -354,7 +359,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), colors = ChipDefaults.imageBackgroundChipColors( backgroundImagePainter = painterResource(id = R.drawable.ic_dialog_alert), ), @@ -371,7 +376,7 @@ class OutlinedChipTest : ScreenshotBaseTest() { label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Outlined.VolumeDown, + icon = Icons.Outlined.VolumeDown.asPaintable(), iconRtlMode = IconRtlMode.Mirrored, colors = ChipDefaults.imageBackgroundChipColors( backgroundImagePainter = painterResource(id = R.drawable.ic_dialog_alert), diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedCompactChipA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedCompactChipA11yTest.kt index 1f33551d71..e2807c1c44 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedCompactChipA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedCompactChipA11yTest.kt @@ -22,6 +22,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.screenshots.ScreenshotBaseTest import com.google.android.horologist.screenshots.ScreenshotTestRule import org.junit.Test @@ -42,7 +43,7 @@ class OutlinedCompactChipA11yTest : ScreenshotBaseTest( OutlinedCompactChip( onClick = { }, label = "Primary label", - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), ) } } @@ -58,7 +59,7 @@ class OutlinedCompactChipA11yTest : ScreenshotBaseTest( OutlinedCompactChip( onClick = { }, label = "Primary label", - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), enabled = false, ) } @@ -74,7 +75,7 @@ class OutlinedCompactChipA11yTest : ScreenshotBaseTest( ) { OutlinedCompactChip( onClick = { }, - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), contentDescription = "contentDescription", ) } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedCompactChipTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedCompactChipTest.kt index ecd0203be4..4648aacb29 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedCompactChipTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedCompactChipTest.kt @@ -26,6 +26,7 @@ import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.unit.LayoutDirection import androidx.wear.compose.material.MaterialTheme import com.google.accompanist.testharness.TestHarness +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.util.rememberVectorPainter import com.google.android.horologist.compose.tools.coil.FakeImageLoader import com.google.android.horologist.screenshots.ScreenshotBaseTest @@ -49,7 +50,7 @@ class OutlinedCompactChipTest : ScreenshotBaseTest() { OutlinedCompactChip( onClick = { }, label = "Primary label", - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), ) } } @@ -59,7 +60,7 @@ class OutlinedCompactChipTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { OutlinedCompactChip( onClick = { }, - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), ) } } @@ -70,7 +71,7 @@ class OutlinedCompactChipTest : ScreenshotBaseTest() { OutlinedCompactChip( onClick = { }, label = "Primary label", - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), enabled = false, ) } @@ -104,7 +105,7 @@ class OutlinedCompactChipTest : ScreenshotBaseTest() { OutlinedCompactChip( onClick = { }, label = "Primary label", - icon = R.drawable.ic_delete, + icon = DrawableResPaintable(R.drawable.ic_delete), ) } } @@ -117,10 +118,12 @@ class OutlinedCompactChipTest : ScreenshotBaseTest() { OutlinedCompactChip( onClick = { }, label = "Primary label", - icon = "iconUri", - placeholder = rememberVectorPainter( - image = Icons.Default.Image, - tintColor = MaterialTheme.colors.primary, + icon = CoilPaintable( + "iconUri", + placeholder = rememberVectorPainter( + image = Icons.Default.Image, + tintColor = MaterialTheme.colors.primary, + ), ), ) } @@ -139,10 +142,12 @@ class OutlinedCompactChipTest : ScreenshotBaseTest() { OutlinedCompactChip( onClick = { }, label = "Primary label", - icon = "iconUri", - placeholder = rememberVectorPainter( - image = Icons.Default.Image, - tintColor = MaterialTheme.colors.primary, + icon = CoilPaintable( + "iconUri", + placeholder = rememberVectorPainter( + image = Icons.Default.Image, + tintColor = MaterialTheme.colors.primary, + ), ), enabled = false, ) @@ -157,7 +162,7 @@ class OutlinedCompactChipTest : ScreenshotBaseTest() { OutlinedCompactChip( onClick = { }, label = "Primary label", - icon = Icons.AutoMirrored.Default.DirectionsBike, + icon = Icons.AutoMirrored.Default.DirectionsBike.asPaintable(), ) } } @@ -169,7 +174,7 @@ class OutlinedCompactChipTest : ScreenshotBaseTest() { OutlinedCompactChip( onClick = { }, label = "Primary label", - icon = Icons.AutoMirrored.Default.DirectionsBike, + icon = Icons.AutoMirrored.Default.DirectionsBike.asPaintable(), iconRtlMode = IconRtlMode.Mirrored, ) } @@ -182,7 +187,7 @@ class OutlinedCompactChipTest : ScreenshotBaseTest() { OutlinedCompactChip( onClick = { }, label = "Primary label", - icon = Icons.AutoMirrored.Default.DirectionsBike, + icon = Icons.AutoMirrored.Default.DirectionsBike.asPaintable(), iconRtlMode = IconRtlMode.Mirrored, ) } @@ -196,7 +201,7 @@ class OutlinedCompactChipTest : ScreenshotBaseTest() { OutlinedCompactChip( onClick = { }, label = "Primary label", - icon = R.drawable.ic_media_play, + icon = DrawableResPaintable(R.drawable.ic_media_play), iconRtlMode = IconRtlMode.Mirrored, ) } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleButtonA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleButtonA11yTest.kt index 853174aa7a..7f02ca8f3c 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleButtonA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleButtonA11yTest.kt @@ -23,6 +23,7 @@ import androidx.compose.material.icons.filled.AirplanemodeActive import androidx.compose.material.icons.filled.AirplanemodeInactive import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.screenshots.ScreenshotBaseTest import com.google.android.horologist.screenshots.ScreenshotTestRule import org.junit.Test @@ -40,8 +41,8 @@ class ToggleButtonA11yTest : screenshotTestRule.setContent(takeScreenshot = true) { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, ) @@ -54,8 +55,8 @@ class ToggleButtonA11yTest : screenshotTestRule.setContent(takeScreenshot = true) { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, @@ -69,8 +70,8 @@ class ToggleButtonA11yTest : screenshotTestRule.setContent(takeScreenshot = true) { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, enabled = false, @@ -84,8 +85,8 @@ class ToggleButtonA11yTest : screenshotTestRule.setContent(takeScreenshot = true) { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, @@ -112,8 +113,8 @@ class ToggleButtonA11yTest : screenshotTestRule.setContent(takeScreenshot = true) { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, colors = ToggleButtonDefaults.iconOnlyColors(), diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleButtonTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleButtonTest.kt index 2b8d23c879..2ab34fa86c 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleButtonTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleButtonTest.kt @@ -23,6 +23,7 @@ import androidx.compose.material.icons.filled.AirplanemodeActive import androidx.compose.material.icons.filled.AirplanemodeInactive import androidx.compose.ui.unit.LayoutDirection import com.google.accompanist.testharness.TestHarness +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.screenshots.ScreenshotBaseTest import org.junit.Test @@ -32,8 +33,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { fun default() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, ) @@ -44,8 +45,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { fun notChecked() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, @@ -57,8 +58,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { fun disabled() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, enabled = false, @@ -70,8 +71,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { fun notCheckedDisabled() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, @@ -128,8 +129,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { fun small() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, smallSize = true, @@ -141,8 +142,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { fun smallNotChecked() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, @@ -155,8 +156,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { fun smallDisabled() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, enabled = false, @@ -168,8 +169,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { fun smallNotCheckedDisabled() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, @@ -182,8 +183,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { fun iconOnly() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, colors = ToggleButtonDefaults.iconOnlyColors(), @@ -195,8 +196,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { fun iconOnlyNotChecked() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, @@ -209,8 +210,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { fun iconOnlyDisabled() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, enabled = false, @@ -223,8 +224,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { fun iconOnlyNotCheckedDisabled() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, @@ -240,8 +241,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { TestHarness(layoutDirection = LayoutDirection.Rtl) { ToggleButton( - checkedIcon = Icons.AutoMirrored.Filled.VolumeUp, - notCheckedIcon = Icons.AutoMirrored.Filled.VolumeOff, + checkedIcon = Icons.AutoMirrored.Filled.VolumeUp.asPaintable(), + notCheckedIcon = Icons.AutoMirrored.Filled.VolumeOff.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, ) @@ -253,8 +254,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { fun mirrored() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { ToggleButton( - checkedIcon = Icons.AutoMirrored.Filled.VolumeUp, - notCheckedIcon = Icons.AutoMirrored.Filled.VolumeOff, + checkedIcon = Icons.AutoMirrored.Filled.VolumeUp.asPaintable(), + notCheckedIcon = Icons.AutoMirrored.Filled.VolumeOff.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, iconRtlMode = IconRtlMode.Mirrored, @@ -267,8 +268,8 @@ class ToggleButtonTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { TestHarness(layoutDirection = LayoutDirection.Rtl) { ToggleButton( - checkedIcon = Icons.AutoMirrored.Filled.VolumeUp, - notCheckedIcon = Icons.AutoMirrored.Filled.VolumeOff, + checkedIcon = Icons.AutoMirrored.Filled.VolumeUp.asPaintable(), + notCheckedIcon = Icons.AutoMirrored.Filled.VolumeOff.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, iconRtlMode = IconRtlMode.Mirrored, diff --git a/media/audio-ui/src/main/java/com/google/android/horologist/audio/ui/VolumeScreen.kt b/media/audio-ui/src/main/java/com/google/android/horologist/audio/ui/VolumeScreen.kt index 272ced9c92..f96c28cf9d 100644 --- a/media/audio-ui/src/main/java/com/google/android/horologist/audio/ui/VolumeScreen.kt +++ b/media/audio-ui/src/main/java/com/google/android/horologist/audio/ui/VolumeScreen.kt @@ -45,6 +45,7 @@ import com.google.android.horologist.audio.ui.components.DeviceChip import com.google.android.horologist.audio.ui.components.toAudioOutputUi import com.google.android.horologist.compose.material.Icon import com.google.android.horologist.compose.material.IconRtlMode +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.rotaryinput.RotaryDefaults.isLowResInput /** @@ -115,7 +116,7 @@ public fun VolumeScreen( deviceName = audioOutputUi.displayName, icon = { Icon( - imageVector = audioOutputUi.imageVector, + paintable = audioOutputUi.imageVector.asPaintable(), contentDescription = audioOutputUi.displayName, tint = MaterialTheme.colors.onSurfaceVariant, ) @@ -207,7 +208,7 @@ public object VolumeScreenDefaults { public fun IncreaseIcon() { Icon( modifier = Modifier.size(26.dp), - imageVector = Icons.AutoMirrored.Outlined.VolumeUp, + paintable = Icons.AutoMirrored.Outlined.VolumeUp.asPaintable(), contentDescription = stringResource(id = R.string.horologist_volume_screen_volume_up_content_description), rtlMode = IconRtlMode.Mirrored, ) @@ -217,7 +218,7 @@ public object VolumeScreenDefaults { public fun DecreaseIcon() { Icon( modifier = Modifier.size(26.dp), - imageVector = Icons.AutoMirrored.Outlined.VolumeDown, + paintable = Icons.AutoMirrored.Outlined.VolumeDown.asPaintable(), contentDescription = stringResource(id = R.string.horologist_volume_screen_volume_down_content_description), rtlMode = IconRtlMode.Mirrored, ) diff --git a/media/audio-ui/src/main/java/com/google/android/horologist/audio/ui/components/actions/SettingsButton.kt b/media/audio-ui/src/main/java/com/google/android/horologist/audio/ui/components/actions/SettingsButton.kt index 00d8f9bda7..67af54b9bc 100644 --- a/media/audio-ui/src/main/java/com/google/android/horologist/audio/ui/components/actions/SettingsButton.kt +++ b/media/audio-ui/src/main/java/com/google/android/horologist/audio/ui/components/actions/SettingsButton.kt @@ -30,6 +30,7 @@ import androidx.wear.compose.material.MaterialTheme import com.google.android.horologist.audio.VolumeState import com.google.android.horologist.compose.material.Icon import com.google.android.horologist.compose.material.IconRtlMode +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable /** * Button to launch a screen to control the system volume. @@ -58,7 +59,7 @@ public fun SettingsButton( enabled = enabled, ) { Icon( - imageVector = imageVector, + paintable = imageVector.asPaintable(), contentDescription = contentDescription, modifier = Modifier .size(iconSize) diff --git a/media/ui/api/current.api b/media/ui/api/current.api index 77bafd0c64..0f8fc015fe 100644 --- a/media/ui/api/current.api +++ b/media/ui/api/current.api @@ -54,7 +54,7 @@ package com.google.android.horologist.media.ui.components { public final class MediaArtworkKt { method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void MediaArtwork(com.google.android.horologist.media.ui.state.model.MediaUiModel media, optional androidx.compose.ui.Modifier modifier, optional androidx.compose.ui.graphics.painter.Painter? placeholder); - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void MediaArtwork(Object? artworkUri, String? contentDescription, optional androidx.compose.ui.Modifier modifier, optional androidx.compose.ui.graphics.painter.Painter? placeholder); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void MediaArtwork(com.google.android.horologist.compose.material.Paintable artworkPaintable, String? contentDescription, optional androidx.compose.ui.Modifier modifier); } public final class MediaChipKt { @@ -87,7 +87,7 @@ package com.google.android.horologist.media.ui.components { package com.google.android.horologist.media.ui.components.actions { public final class ShowPlaylistChipKt { - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void ShowPlaylistChip(Object? artworkUri, String? name, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier, optional androidx.compose.ui.graphics.painter.Painter? placeholder); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void ShowPlaylistChip(com.google.android.horologist.compose.material.Paintable? artworkPaintable, String? name, kotlin.jvm.functions.Function0 onClick, optional androidx.compose.ui.Modifier modifier); } } diff --git a/media/ui/src/debug/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipPreview.kt b/media/ui/src/debug/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipPreview.kt index 87f836fac5..3ec7dcee06 100644 --- a/media/ui/src/debug/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipPreview.kt +++ b/media/ui/src/debug/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipPreview.kt @@ -21,6 +21,7 @@ import androidx.compose.material.icons.automirrored.filled.FeaturedPlayList import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview +import com.google.android.horologist.compose.material.CoilPaintable import com.google.android.horologist.compose.material.util.rememberVectorPainter import com.google.android.horologist.compose.tools.WearPreview @@ -28,13 +29,15 @@ import com.google.android.horologist.compose.tools.WearPreview @Composable fun ShowPlaylistChipPreview() { ShowPlaylistChip( - artworkUri = "artworkUri", + artworkPaintable = CoilPaintable( + "artworkUri", + rememberVectorPainter( + image = Icons.AutoMirrored.Default.FeaturedPlayList, + tintColor = Color.Green, + ), + ), name = "Playlists", onClick = {}, - placeholder = rememberVectorPainter( - image = Icons.AutoMirrored.Default.FeaturedPlayList, - tintColor = Color.Green, - ), ) } @@ -46,7 +49,7 @@ fun ShowPlaylistChipPreview() { @Composable fun ShowPlaylistChipPreviewNoArtwork() { ShowPlaylistChip( - artworkUri = null, + artworkPaintable = null, name = "Playlists", onClick = {}, ) @@ -60,13 +63,15 @@ fun ShowPlaylistChipPreviewNoArtwork() { @Composable fun ShowPlaylistChipPreviewNoName() { ShowPlaylistChip( - artworkUri = "artworkUri", + artworkPaintable = CoilPaintable( + "artworkUri", + rememberVectorPainter( + image = Icons.AutoMirrored.Default.FeaturedPlayList, + tintColor = Color.Green, + ), + ), name = null, onClick = {}, - placeholder = rememberVectorPainter( - image = Icons.AutoMirrored.Default.FeaturedPlayList, - tintColor = Color.Green, - ), ) } @@ -78,12 +83,14 @@ fun ShowPlaylistChipPreviewNoName() { @Composable fun ShowPlaylistChipPreviewVeryLongName() { ShowPlaylistChip( - artworkUri = "artworkUri", + artworkPaintable = CoilPaintable( + "artworkUri", + rememberVectorPainter( + image = Icons.AutoMirrored.Default.FeaturedPlayList, + tintColor = Color.Green, + ), + ), name = "Very very very very very very very very very very very very very very very very very very very long title", onClick = {}, - placeholder = rememberVectorPainter( - image = Icons.AutoMirrored.Default.FeaturedPlayList, - tintColor = Color.Green, - ), ) } diff --git a/media/ui/src/debug/java/com/google/android/horologist/media/ui/screens/browse/BrowseScreenPreview.kt b/media/ui/src/debug/java/com/google/android/horologist/media/ui/screens/browse/BrowseScreenPreview.kt index 09a86b430b..cfdf6cb696 100644 --- a/media/ui/src/debug/java/com/google/android/horologist/media/ui/screens/browse/BrowseScreenPreview.kt +++ b/media/ui/src/debug/java/com/google/android/horologist/media/ui/screens/browse/BrowseScreenPreview.kt @@ -30,6 +30,7 @@ import com.google.android.horologist.composables.PlaceholderChip import com.google.android.horologist.composables.Section import com.google.android.horologist.compose.layout.belowTimeTextPreview import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.media.ui.R @WearPreviewDevices @@ -90,7 +91,7 @@ private fun BrowseScreenPreviewSample( Chip( label = item, onClick = { }, - icon = Icons.Default.Person, + icon = Icons.Default.Person.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) } @@ -108,7 +109,7 @@ private fun BrowseScreenPreviewSample( label = item.first, onClick = { }, secondaryLabel = item.second, - icon = Icons.Default.MusicNote, + icon = Icons.Default.MusicNote.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) } diff --git a/media/ui/src/main/java/com/google/android/horologist/media/ui/components/MediaArtwork.kt b/media/ui/src/main/java/com/google/android/horologist/media/ui/components/MediaArtwork.kt index e3264482e7..0ea40e2bf9 100644 --- a/media/ui/src/main/java/com/google/android/horologist/media/ui/components/MediaArtwork.kt +++ b/media/ui/src/main/java/com/google/android/horologist/media/ui/components/MediaArtwork.kt @@ -21,8 +21,9 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.layout.ContentScale -import coil.compose.rememberAsyncImagePainter import com.google.android.horologist.annotations.ExperimentalHorologistApi +import com.google.android.horologist.compose.material.CoilPaintable +import com.google.android.horologist.compose.material.Paintable import com.google.android.horologist.media.ui.state.model.MediaUiModel @ExperimentalHorologistApi @@ -33,24 +34,22 @@ public fun MediaArtwork( placeholder: Painter? = null, ) { MediaArtwork( - artworkUri = media.artworkUri, + artworkPaintable = CoilPaintable(media.artworkUri, placeholder), contentDescription = media.title, modifier = modifier, - placeholder = placeholder, ) } @ExperimentalHorologistApi @Composable public fun MediaArtwork( - artworkUri: Any?, + artworkPaintable: Paintable, contentDescription: String?, modifier: Modifier = Modifier, - placeholder: Painter? = null, ) { Image( modifier = modifier, - painter = rememberAsyncImagePainter(model = artworkUri, placeholder = placeholder), + painter = artworkPaintable.rememberPainter(), contentDescription = contentDescription, contentScale = ContentScale.Fit, ) diff --git a/media/ui/src/main/java/com/google/android/horologist/media/ui/components/MediaChip.kt b/media/ui/src/main/java/com/google/android/horologist/media/ui/components/MediaChip.kt index b3230796f4..f8a4b9a8b5 100644 --- a/media/ui/src/main/java/com/google/android/horologist/media/ui/components/MediaChip.kt +++ b/media/ui/src/main/java/com/google/android/horologist/media/ui/components/MediaChip.kt @@ -29,6 +29,7 @@ import androidx.wear.compose.material.Chip import androidx.wear.compose.material.ChipDefaults import androidx.wear.compose.material.Text import com.google.android.horologist.annotations.ExperimentalHorologistApi +import com.google.android.horologist.compose.material.CoilPaintable import com.google.android.horologist.media.ui.state.model.MediaUiModel /** @@ -80,8 +81,7 @@ public fun MediaChip( MediaArtwork( modifier = Modifier.size(ChipDefaults.LargeIconSize), contentDescription = title, - artworkUri = artworkUri, - placeholder = placeholder, + artworkPaintable = CoilPaintable(artworkUri, placeholder), ) } } diff --git a/media/ui/src/main/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChip.kt b/media/ui/src/main/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChip.kt index 6b680df30c..4a606fe7fb 100644 --- a/media/ui/src/main/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChip.kt +++ b/media/ui/src/main/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChip.kt @@ -20,10 +20,10 @@ import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.painter.Painter import androidx.wear.compose.material.ChipDefaults import com.google.android.horologist.annotations.ExperimentalHorologistApi import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.Paintable import com.google.android.horologist.media.ui.components.MediaArtwork /** @@ -32,19 +32,17 @@ import com.google.android.horologist.media.ui.components.MediaArtwork @ExperimentalHorologistApi @Composable public fun ShowPlaylistChip( - artworkUri: Any?, + artworkPaintable: Paintable?, name: String?, onClick: () -> Unit, modifier: Modifier = Modifier, - placeholder: Painter? = null, ) { - val appIcon: (@Composable BoxScope.() -> Unit)? = artworkUri?.let { + val appIcon: (@Composable BoxScope.() -> Unit)? = artworkPaintable?.let { { MediaArtwork( modifier = Modifier.size(ChipDefaults.LargeIconSize), contentDescription = name, - artworkUri = artworkUri, - placeholder = placeholder, + artworkPaintable = it, ) } } diff --git a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/BrowseScreen.kt b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/BrowseScreen.kt index 3cbf16a5bc..decd80f012 100644 --- a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/BrowseScreen.kt +++ b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/BrowseScreen.kt @@ -35,6 +35,7 @@ import com.google.android.horologist.composables.SectionContentScope import com.google.android.horologist.composables.SectionedList import com.google.android.horologist.compose.layout.ScalingLazyColumnState import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.Title import com.google.android.horologist.media.ui.R import com.google.android.horologist.media.ui.state.model.PlaylistDownloadUiModel @@ -163,7 +164,7 @@ public class BrowseScreenScope { Chip( labelId = item.textId, onClick = item.onClick, - icon = item.icon, + icon = item.icon.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) }, @@ -180,7 +181,7 @@ public class BrowseScreenScope { Chip( labelId = item.textId, onClick = item.onClick, - icon = item.icon, + icon = item.icon.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) }, diff --git a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreen.kt b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreen.kt index a98a6a2a6f..10232de29a 100644 --- a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreen.kt +++ b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreen.kt @@ -32,6 +32,8 @@ import com.google.android.horologist.composables.PlaceholderChip import com.google.android.horologist.composables.Section import com.google.android.horologist.compose.layout.ScalingLazyColumnState import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.CoilPaintable +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.media.ui.R import com.google.android.horologist.media.ui.state.model.PlaylistDownloadUiModel @@ -81,9 +83,8 @@ public fun PlaylistDownloadBrowseScreen( Chip( label = download.playlistUiModel.title, onClick = { onDownloadItemClick(download) }, - icon = download.playlistUiModel.artworkUri, + icon = CoilPaintable(download.playlistUiModel.artworkUri, downloadItemArtworkPlaceholder), largeIcon = true, - placeholder = downloadItemArtworkPlaceholder, colors = ChipDefaults.secondaryChipColors(), ) } @@ -106,8 +107,7 @@ public fun PlaylistDownloadBrowseScreen( id = R.string.horologist_browse_downloads_progress, download.percentage, ), - icon = Icons.Default.Downloading, - placeholder = downloadItemArtworkPlaceholder, + icon = Icons.Default.Downloading.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) } diff --git a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/PlaylistDownloadScreen.kt b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/PlaylistDownloadScreen.kt index 8fca410bca..850536a638 100644 --- a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/PlaylistDownloadScreen.kt +++ b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/PlaylistDownloadScreen.kt @@ -60,6 +60,8 @@ import com.google.android.horologist.compose.material.Button import com.google.android.horologist.compose.material.ButtonSize import com.google.android.horologist.compose.material.Chip import com.google.android.horologist.compose.material.ChipIconWithProgress +import com.google.android.horologist.compose.material.CoilPaintable +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.media.ui.R import com.google.android.horologist.media.ui.screens.entity.PlaylistDownloadScreenState.Loaded.DownloadsProgress import com.google.android.horologist.media.ui.state.model.DownloadMediaUiModel @@ -179,9 +181,8 @@ private fun MediaContent( label = mediaTitle, onClick = { onDownloadItemClick(downloadMediaUiModel) }, secondaryLabel = secondaryLabel, - icon = downloadMediaUiModel.artworkUri, + icon = CoilPaintable(downloadMediaUiModel.artworkUri, downloadItemArtworkPlaceholder), largeIcon = true, - placeholder = downloadItemArtworkPlaceholder, colors = ChipDefaults.secondaryChipColors(), enabled = downloadMediaUiModel !is DownloadMediaUiModel.NotDownloaded, ) @@ -200,9 +201,8 @@ private fun MediaContent( ChipIconWithProgress( progress = progress, modifier = Modifier.clearAndSetSemantics { }, - icon = downloadMediaUiModel.artworkUri, + icon = CoilPaintable(downloadMediaUiModel.artworkUri, downloadItemArtworkPlaceholder), largeIcon = true, - placeholder = downloadItemArtworkPlaceholder, ) } } @@ -211,9 +211,8 @@ private fun MediaContent( { ChipIconWithProgress( modifier = Modifier.clearAndSetSemantics { }, - icon = downloadMediaUiModel.artworkUri, + icon = CoilPaintable(downloadMediaUiModel.artworkUri, downloadItemArtworkPlaceholder), largeIcon = true, - placeholder = downloadItemArtworkPlaceholder, ) } } @@ -265,7 +264,7 @@ private fun ButtonsContent( label = stringResource(id = R.string.horologist_playlist_download_button_download), onClick = { /* do nothing */ }, modifier = Modifier.padding(bottom = 16.dp), - icon = Icons.Default.Download, + icon = Icons.Default.Download.asPaintable(), enabled = false, ) } @@ -277,14 +276,14 @@ private fun ButtonsContent( label = stringResource(id = R.string.horologist_playlist_download_button_cancel), onClick = { onCancelDownloadButtonClick(state.collectionModel) }, modifier = Modifier.padding(bottom = 16.dp), - icon = Icons.Default.Close, + icon = Icons.Default.Close.asPaintable(), ) } else { Chip( label = stringResource(id = R.string.horologist_playlist_download_button_download), onClick = { onDownloadButtonClick(state.collectionModel) }, modifier = Modifier.padding(bottom = 16.dp), - icon = Icons.Default.Download, + icon = Icons.Default.Download.asPaintable(), ) } } else { diff --git a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/PlaylistStreamingScreen.kt b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/PlaylistStreamingScreen.kt index 1c7f9ac8df..c55f80833c 100644 --- a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/PlaylistStreamingScreen.kt +++ b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/PlaylistStreamingScreen.kt @@ -33,6 +33,7 @@ import com.google.android.horologist.composables.PlaceholderChip import com.google.android.horologist.compose.layout.ScalingLazyColumnState import com.google.android.horologist.compose.material.Button import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.CoilPaintable import com.google.android.horologist.media.ui.R import com.google.android.horologist.media.ui.state.model.DownloadMediaUiModel import com.google.android.horologist.media.ui.state.model.PlaylistUiModel @@ -73,7 +74,7 @@ public fun PlaylistStreamingScreen( Chip( label = mediaTitle, onClick = { onPlayItemClick(mediaUiModel) }, - icon = mediaUiModel.artworkUri, + icon = CoilPaintable(mediaUiModel.artworkUri), largeIcon = true, colors = ChipDefaults.secondaryChipColors(), ) diff --git a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/playlists/PlaylistsScreen.kt b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/playlists/PlaylistsScreen.kt index 7a195249bc..961d02ca0e 100644 --- a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/playlists/PlaylistsScreen.kt +++ b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/playlists/PlaylistsScreen.kt @@ -29,6 +29,7 @@ import com.google.android.horologist.composables.Section import com.google.android.horologist.composables.SectionedList import com.google.android.horologist.compose.layout.ScalingLazyColumnState import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.CoilPaintable import com.google.android.horologist.compose.material.Title import com.google.android.horologist.media.ui.R import com.google.android.horologist.media.ui.state.model.PlaylistUiModel @@ -102,9 +103,8 @@ public fun PlaylistsScreen( Chip( label = playlist.title, onClick = { onPlaylistItemClick(playlist) }, - icon = playlist.artworkUri, + icon = CoilPaintable(playlist.artworkUri, playlistItemArtworkPlaceholder), largeIcon = true, - placeholder = playlistItemArtworkPlaceholder, colors = ChipDefaults.secondaryChipColors(), ) } diff --git a/media/ui/src/test/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipA11yTest.kt b/media/ui/src/test/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipA11yTest.kt index a8adf5d72a..5a75b967a3 100644 --- a/media/ui/src/test/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipA11yTest.kt +++ b/media/ui/src/test/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipA11yTest.kt @@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import com.google.android.horologist.compose.material.DrawableResPaintable import com.google.android.horologist.compose.tools.coil.FakeImageLoader import com.google.android.horologist.logo.R import com.google.android.horologist.screenshots.ScreenshotBaseTest @@ -41,7 +42,7 @@ class ShowPlaylistChipA11yTest : ScreenshotBaseTest( ) { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { ShowPlaylistChip( - artworkUri = R.drawable.horologist_logo, + artworkPaintable = DrawableResPaintable(R.drawable.horologist_logo), name = "Playlists", onClick = {}, ) diff --git a/media/ui/src/test/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipTest.kt b/media/ui/src/test/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipTest.kt index acedbe0d4e..b9c25104aa 100644 --- a/media/ui/src/test/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipTest.kt +++ b/media/ui/src/test/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipTest.kt @@ -16,6 +16,7 @@ package com.google.android.horologist.media.ui.components.actions +import com.google.android.horologist.compose.material.DrawableResPaintable import com.google.android.horologist.compose.tools.coil.FakeImageLoader import com.google.android.horologist.logo.R import com.google.android.horologist.screenshots.ScreenshotBaseTest @@ -28,7 +29,7 @@ class ShowPlaylistChipTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { FakeImageLoader.Resources.override { ShowPlaylistChip( - artworkUri = R.drawable.horologist_logo, + artworkPaintable = DrawableResPaintable(R.drawable.horologist_logo), name = "Playlists", onClick = {}, ) @@ -41,7 +42,7 @@ class ShowPlaylistChipTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { FakeImageLoader.Resources.override { ShowPlaylistChip( - artworkUri = null, + artworkPaintable = null, name = "Playlists", onClick = {}, ) @@ -54,7 +55,7 @@ class ShowPlaylistChipTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { FakeImageLoader.Resources.override { ShowPlaylistChip( - artworkUri = R.drawable.horologist_logo, + artworkPaintable = DrawableResPaintable(R.drawable.horologist_logo), name = null, onClick = {}, ) @@ -67,7 +68,7 @@ class ShowPlaylistChipTest : ScreenshotBaseTest() { screenshotTestRule.setContent(isComponent = true, takeScreenshot = true) { FakeImageLoader.Resources.override { ShowPlaylistChip( - artworkUri = R.drawable.horologist_logo, + artworkPaintable = DrawableResPaintable(R.drawable.horologist_logo), name = "Very very very very very very very very very very very very very very very very very very very long title", onClick = {}, ) diff --git a/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleChipScreen.kt b/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleChipScreen.kt index 06be8981ef..8060ab2456 100644 --- a/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleChipScreen.kt +++ b/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleChipScreen.kt @@ -30,6 +30,7 @@ import androidx.wear.compose.material.ChipDefaults import com.google.android.horologist.compose.layout.ScalingLazyColumn import com.google.android.horologist.compose.layout.ScalingLazyColumnState import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable @Composable internal fun SampleChipScreen( @@ -50,14 +51,14 @@ internal fun SampleChipScreen( Chip( label = "Primary label", onClick = { }, - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } item { Chip( label = "Primary label", onClick = { }, - icon = Icon32dp, + icon = Icon32dp.asPaintable(), largeIcon = true, ) } @@ -66,7 +67,7 @@ internal fun SampleChipScreen( label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } item { @@ -74,7 +75,7 @@ internal fun SampleChipScreen( label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icon32dp, + icon = Icon32dp.asPaintable(), largeIcon = true, ) } @@ -83,7 +84,7 @@ internal fun SampleChipScreen( label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), enabled = false, ) } @@ -92,7 +93,7 @@ internal fun SampleChipScreen( label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) } @@ -101,7 +102,7 @@ internal fun SampleChipScreen( label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), colors = ChipDefaults.gradientBackgroundChipColors(), ) } @@ -110,7 +111,7 @@ internal fun SampleChipScreen( label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), colors = ChipDefaults.imageBackgroundChipColors( backgroundImagePainter = painterResource(id = R.drawable.ic_dialog_alert), ), diff --git a/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleCompactChipScreen.kt b/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleCompactChipScreen.kt index ea15a39338..d897bcfec2 100644 --- a/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleCompactChipScreen.kt +++ b/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleCompactChipScreen.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.Modifier import com.google.android.horologist.compose.layout.ScalingLazyColumn import com.google.android.horologist.compose.layout.ScalingLazyColumnState import com.google.android.horologist.compose.material.CompactChip +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable @Composable internal fun SampleCompactChipScreen( @@ -44,13 +45,13 @@ internal fun SampleCompactChipScreen( CompactChip( label = "Primary label", onClick = { }, - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), ) } item { CompactChip( onClick = { }, - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), contentDescription = "contentDescription", ) } diff --git a/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleIconScreen.kt b/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleIconScreen.kt index d8db854f0d..1bd2cc9958 100644 --- a/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleIconScreen.kt +++ b/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleIconScreen.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.Modifier import com.google.android.horologist.compose.layout.ScalingLazyColumn import com.google.android.horologist.compose.layout.ScalingLazyColumnState import com.google.android.horologist.compose.material.Icon +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable @Composable internal fun SampleIconScreen( @@ -36,7 +37,7 @@ internal fun SampleIconScreen( ) { item { Icon( - imageVector = Icons.AutoMirrored.Outlined.VolumeDown, + paintable = Icons.AutoMirrored.Outlined.VolumeDown.asPaintable(), contentDescription = "contentDescription", ) } diff --git a/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleOutlinedChipScreen.kt b/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleOutlinedChipScreen.kt index c059464533..fce7c85dce 100644 --- a/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleOutlinedChipScreen.kt +++ b/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleOutlinedChipScreen.kt @@ -26,6 +26,7 @@ import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.unit.dp import com.google.android.horologist.compose.layout.ScalingLazyColumn import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.OutlinedChip @Composable @@ -41,14 +42,14 @@ internal fun SampleOutlinedChipScreen( OutlinedChip( label = "Primary label", onClick = { }, - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } item { OutlinedChip( label = "Primary label", onClick = { }, - icon = Icon32dp, + icon = Icon32dp.asPaintable(), largeIcon = true, ) } @@ -57,7 +58,7 @@ internal fun SampleOutlinedChipScreen( label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), ) } item { @@ -65,7 +66,7 @@ internal fun SampleOutlinedChipScreen( label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icon32dp, + icon = Icon32dp.asPaintable(), largeIcon = true, ) } @@ -74,7 +75,7 @@ internal fun SampleOutlinedChipScreen( label = "Primary label", onClick = { }, secondaryLabel = "Secondary label", - icon = Icons.Default.Image, + icon = Icons.Default.Image.asPaintable(), enabled = false, ) } diff --git a/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleOutlinedCompactChipScreen.kt b/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleOutlinedCompactChipScreen.kt index 226f823012..7e0e765634 100644 --- a/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleOutlinedCompactChipScreen.kt +++ b/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleOutlinedCompactChipScreen.kt @@ -23,6 +23,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.google.android.horologist.compose.layout.ScalingLazyColumn import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.OutlinedCompactChip @Composable @@ -44,13 +45,13 @@ internal fun SampleOutlinedCompactChipScreen( OutlinedCompactChip( onClick = { }, label = "Primary label", - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), ) } item { OutlinedCompactChip( onClick = { }, - icon = Icons.Filled.Add, + icon = Icons.Filled.Add.asPaintable(), contentDescription = "contentDescription", ) } diff --git a/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleToggleButtonScreen.kt b/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleToggleButtonScreen.kt index 9e8b00082e..33e3430209 100644 --- a/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleToggleButtonScreen.kt +++ b/sample/src/main/java/com/google/android/horologist/materialcomponents/SampleToggleButtonScreen.kt @@ -24,6 +24,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.google.android.horologist.compose.layout.ScalingLazyColumn import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.ToggleButton import com.google.android.horologist.compose.material.ToggleButtonDefaults @@ -51,8 +52,8 @@ internal fun SampleToggleButtonScreen( } item { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, smallSize = true, @@ -60,8 +61,8 @@ internal fun SampleToggleButtonScreen( } item { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, @@ -70,8 +71,8 @@ internal fun SampleToggleButtonScreen( } item { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, colors = ToggleButtonDefaults.iconOnlyColors(), @@ -80,8 +81,8 @@ internal fun SampleToggleButtonScreen( } item { ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive, - notCheckedIcon = Icons.Filled.AirplanemodeInactive, + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), contentDescription = "contentDescription", onCheckedChanged = {}, checked = false, diff --git a/sample/src/main/java/com/google/android/horologist/sectionedlist/SectionedListMenuScreen.kt b/sample/src/main/java/com/google/android/horologist/sectionedlist/SectionedListMenuScreen.kt index 31500c24f9..0db4eec3f5 100644 --- a/sample/src/main/java/com/google/android/horologist/sectionedlist/SectionedListMenuScreen.kt +++ b/sample/src/main/java/com/google/android/horologist/sectionedlist/SectionedListMenuScreen.kt @@ -30,6 +30,7 @@ import com.google.android.horologist.composables.SectionedList import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults import com.google.android.horologist.compose.layout.ScalingLazyColumnState import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.Title import com.google.android.horologist.sample.R import com.google.android.horologist.sample.Screen @@ -70,7 +71,7 @@ fun SectionedListMenuScreen( loaded { item -> Chip( label = stringResource(id = item.first), - icon = Icons.AutoMirrored.Default.FormatListBulleted, + icon = Icons.AutoMirrored.Default.FormatListBulleted.asPaintable(), onClick = { navigateToRoute(item.second) }, colors = ChipDefaults.primaryChipColors(), ) diff --git a/sample/src/main/java/com/google/android/horologist/sectionedlist/stateful/SectionedListStatefulScreen.kt b/sample/src/main/java/com/google/android/horologist/sectionedlist/stateful/SectionedListStatefulScreen.kt index 0ae09eb653..393e5cffb5 100644 --- a/sample/src/main/java/com/google/android/horologist/sectionedlist/stateful/SectionedListStatefulScreen.kt +++ b/sample/src/main/java/com/google/android/horologist/sectionedlist/stateful/SectionedListStatefulScreen.kt @@ -52,6 +52,7 @@ import com.google.android.horologist.composables.SectionedListScope import com.google.android.horologist.compose.layout.ScalingLazyColumnState import com.google.android.horologist.compose.layout.belowTimeTextPreview import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.Title import com.google.android.horologist.compose.material.util.DECORATIVE_ELEMENT_CONTENT_DESCRIPTION import com.google.android.horologist.sample.R @@ -93,7 +94,7 @@ private fun SectionedListScope.topMenuSection() { Chip( label = stringResource(stringResId), onClick = { }, - icon = icon, + icon = icon.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) } @@ -126,7 +127,7 @@ private fun SectionedListScope.recommendationsSection( Chip( label = recommendation.playlistName, onClick = { }, - icon = recommendation.icon, + icon = recommendation.icon.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) } @@ -178,7 +179,7 @@ private fun SectionedListScope.trendingSection( label = trending.name, onClick = { }, secondaryLabel = trending.artist, - icon = Icons.Default.MusicNote, + icon = Icons.Default.MusicNote.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) } @@ -211,7 +212,7 @@ private fun SectionedListScope.bottomMenuSection() { Chip( label = stringResource(R.string.sectionedlist_settings_button), onClick = { }, - icon = Icons.Default.Settings, + icon = Icons.Default.Settings.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) } diff --git a/sample/src/main/java/com/google/android/horologist/sectionedlist/stateless/SectionedListStatelessScreen.kt b/sample/src/main/java/com/google/android/horologist/sectionedlist/stateless/SectionedListStatelessScreen.kt index dede06721d..e651bc4992 100644 --- a/sample/src/main/java/com/google/android/horologist/sectionedlist/stateless/SectionedListStatelessScreen.kt +++ b/sample/src/main/java/com/google/android/horologist/sectionedlist/stateless/SectionedListStatelessScreen.kt @@ -36,6 +36,7 @@ import com.google.android.horologist.composables.SectionedListScope import com.google.android.horologist.compose.layout.ScalingLazyColumnState import com.google.android.horologist.compose.layout.belowTimeTextPreview import com.google.android.horologist.compose.material.Chip +import com.google.android.horologist.compose.material.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.compose.material.Title import com.google.android.horologist.sample.R @@ -70,7 +71,7 @@ private fun SectionedListScope.topMenuSection() { Chip( label = stringResource(label), onClick = { }, - icon = icon, + icon = icon.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) } @@ -97,7 +98,7 @@ private fun SectionedListScope.recommendationsSection() { Chip( label = label, onClick = { }, - icon = icon, + icon = icon.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) } @@ -133,7 +134,7 @@ private fun SectionedListScope.trendingSection() { label = title, onClick = { }, secondaryLabel = artist, - icon = Icons.Default.MusicNote, + icon = Icons.Default.MusicNote.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) } @@ -155,7 +156,7 @@ private fun SectionedListScope.bottomMenuSection() { Chip( label = stringResource(R.string.sectionedlist_settings_button), onClick = { }, - icon = Icons.Default.Settings, + icon = Icons.Default.Settings.asPaintable(), colors = ChipDefaults.secondaryChipColors(), ) }