diff --git a/app/build.gradle.kts b/app/build.gradle.kts index be50e43a5..a6e3c1d1f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -128,7 +128,6 @@ dependencies { implementation(project(":lib-xml")) implementation(project(":theme-innovation-cup")) - implementation(Dependencies.accompanistFlowLayout) implementation(Dependencies.accompanistSystemUiController) implementation(Dependencies.activityCompose) implementation(Dependencies.appCompat) diff --git a/app/src/main/java/com/orange/ods/app/ui/components/chips/ChipFilter.kt b/app/src/main/java/com/orange/ods/app/ui/components/chips/ChipFilter.kt index 1d7cfb0e3..5a802cefc 100644 --- a/app/src/main/java/com/orange/ods/app/ui/components/chips/ChipFilter.kt +++ b/app/src/main/java/com/orange/ods/app/ui/components/chips/ChipFilter.kt @@ -10,6 +10,9 @@ package com.orange.ods.app.ui.components.chips +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.ExperimentalLayoutApi +import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding @@ -25,7 +28,6 @@ import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import coil.compose.rememberAsyncImagePainter -import com.google.accompanist.flowlayout.FlowRow import com.orange.ods.app.R import com.orange.ods.app.domain.recipes.LocalRecipes import com.orange.ods.app.ui.components.utilities.ComponentCustomizationBottomSheetScaffold @@ -41,7 +43,7 @@ import com.orange.ods.compose.component.chip.OdsFilterChip import com.orange.ods.compose.component.list.OdsListItem import com.orange.ods.compose.component.list.OdsSwitchTrailing -@OptIn(ExperimentalMaterialApi::class) +@OptIn(ExperimentalMaterialApi::class, ExperimentalLayoutApi::class) @Composable fun ChipFilter() { val chipCustomizationState = rememberChipCustomizationState(chipType = rememberSaveable { mutableStateOf(ChipCustomizationState.ChipType.Filter) }) @@ -73,7 +75,10 @@ fun ChipFilter() { }) { var selectedChipIndexes by rememberSaveable { mutableStateOf(emptySet()) } ChipTypeDemo(chipType = chipType.value) { - FlowRow(modifier = Modifier.fillMaxWidth(), mainAxisSpacing = dimensionResource(id = com.orange.ods.R.dimen.spacing_s)) { + FlowRow( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(dimensionResource(id = com.orange.ods.R.dimen.spacing_s)) + ) { recipe.ingredients.forEachIndexed { index, ingredient -> OdsFilterChip( text = ingredient.food.name, diff --git a/app/src/main/java/com/orange/ods/app/ui/guidelines/color/GuidelineColorScreen.kt b/app/src/main/java/com/orange/ods/app/ui/guidelines/color/GuidelineColorScreen.kt index 507171b53..fac456abe 100644 --- a/app/src/main/java/com/orange/ods/app/ui/guidelines/color/GuidelineColorScreen.kt +++ b/app/src/main/java/com/orange/ods/app/ui/guidelines/color/GuidelineColorScreen.kt @@ -29,7 +29,6 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.material.Colors import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateOf @@ -57,15 +56,10 @@ import com.orange.ods.compose.text.OdsTextCaption import com.orange.ods.compose.text.OdsTextH5 import com.orange.ods.compose.text.OdsTextH6 import com.orange.ods.compose.theme.OdsTheme -import com.orange.ods.theme.colors.OdsColors -import com.orange.ods.theme.colors.OdsFunctionalColors import com.orange.ods.theme.guideline.GuidelineColor import com.orange.ods.theme.guideline.GuidelineColorType import com.orange.ods.theme.guideline.toHexString import com.orange.ods.theme.guideline.toRgbString -import kotlin.reflect.KProperty -import kotlin.reflect.full.extensionReceiverParameter -import kotlin.reflect.full.memberProperties @Composable fun GuidelineColorScreen() { @@ -147,7 +141,7 @@ private fun RowScope.SmallColorItem(color: GuidelineColor) { val openDialog = remember { mutableStateOf(false) } val context = LocalContext.current val clipboardManager = LocalClipboardManager.current - val colorValue = color.getValue() + val colorValue = color.getValue(OdsTheme.colors) Column( modifier = Modifier .weight(0.33f) @@ -179,7 +173,7 @@ private fun RowScope.BigColorItem(color: GuidelineColor) { val openDialog = remember { mutableStateOf(false) } val context = LocalContext.current val clipboardManager = LocalClipboardManager.current - val colorValue = color.getValue() + val colorValue = color.getValue(OdsTheme.colors) Column( modifier = Modifier .weight(0.5f) @@ -203,7 +197,7 @@ private fun RowScope.BigColorItem(color: GuidelineColor) { text = color.getName(), modifier = Modifier.padding(top = dimensionResource(id = com.orange.ods.R.dimen.spacing_xs)) ) - OdsTextBody1(text = color.callable.name) + OdsTextBody1(text = color.callableName) OdsTextCaption( modifier = Modifier.padding(top = dimensionResource(id = com.orange.ods.R.dimen.spacing_xs)), text = colorValue.toHexString() @@ -221,7 +215,7 @@ private fun RowScope.BigColorItem(color: GuidelineColor) { fun DialogColor(color: GuidelineColor, openDialog: MutableState) { val context = LocalContext.current val clipboardManager = LocalClipboardManager.current - val colorValue = color.getValue() + val colorValue = color.getValue(OdsTheme.colors) Dialog( onDismissRequest = { openDialog.value = false }, ) { @@ -244,7 +238,7 @@ fun DialogColor(color: GuidelineColor, openDialog: MutableState) { OdsTextH5(text = color.getName()) OdsTextBody1( modifier = Modifier.padding(top = dimensionResource(id = com.orange.ods.R.dimen.spacing_xs)), - text = color.callable.name + text = color.callableName ) OdsTextBody1( modifier = Modifier.padding(top = dimensionResource(id = com.orange.ods.R.dimen.spacing_s)), @@ -279,16 +273,3 @@ private fun copyColorToClipboard(context: Context, color: Color, clipboardManage .makeText(context, text, Toast.LENGTH_SHORT) .show() } - -@Composable -fun GuidelineColor.getValue(): Color { - val isColorsProperty = OdsColors::class.memberProperties.filterIsInstance>().contains(callable) - val isFunctionalColorsProperty = OdsFunctionalColors::class.memberProperties.filterIsInstance>().contains(callable) - val isColorsExtensionProperty = callable.extensionReceiverParameter?.type?.classifier == Colors::class - - return when { - isColorsProperty || isColorsExtensionProperty -> callable.call(OdsTheme.colors) - isFunctionalColorsProperty -> callable.call(OdsTheme.colors.functional) - else -> callable.call() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/orange/ods/app/ui/search/SearchScreen.kt b/app/src/main/java/com/orange/ods/app/ui/search/SearchScreen.kt index a9d463c38..ef8ed9921 100644 --- a/app/src/main/java/com/orange/ods/app/ui/search/SearchScreen.kt +++ b/app/src/main/java/com/orange/ods/app/ui/search/SearchScreen.kt @@ -40,13 +40,13 @@ import com.orange.ods.app.ui.components.Component import com.orange.ods.app.ui.components.Variant import com.orange.ods.app.ui.components.components import com.orange.ods.app.ui.guidelines.color.DialogColor -import com.orange.ods.app.ui.guidelines.color.getValue import com.orange.ods.app.ui.guidelines.spacing.Spacing import com.orange.ods.app.ui.utilities.DrawableManager import com.orange.ods.compose.component.list.OdsListItem import com.orange.ods.compose.component.list.OdsListItemIcon import com.orange.ods.compose.component.list.OdsListItemIconType import com.orange.ods.compose.component.list.iconType +import com.orange.ods.compose.theme.OdsTheme import com.orange.ods.extension.orElse import com.orange.ods.theme.guideline.GuidelineColor import com.orange.ods.theme.guideline.toHexString @@ -107,12 +107,13 @@ fun SearchScreen( ) } .plus(filteredGuidelineColors.map { guidelineColor -> + val color = guidelineColor.getValue(OdsTheme.colors) SearchResult( guidelineColor.getName(), 0, image = null, - color = guidelineColor.getValue(), - subtitle = guidelineColor.getValue().toHexString(), + color = color, + subtitle = color.toHexString(), data = guidelineColor ) }) @@ -162,7 +163,7 @@ fun SearchScreen( items(searchResults) { item -> val openDialog = remember { mutableStateOf(false) } val guidelineColor = filteredGuidelineColors.firstOrNull { guidelineColor -> - guidelineColor.getName() == item.title && guidelineColor.getValue() == item.color + guidelineColor.getName() == item.title && guidelineColor.getValue(OdsTheme.colors) == item.color } OdsListItem( text = item.title, diff --git a/buildSrc/src/main/kotlin/com/orange/ods/gradle/Dependencies.kt b/buildSrc/src/main/kotlin/com/orange/ods/gradle/Dependencies.kt index 771133430..f616aa0e7 100644 --- a/buildSrc/src/main/kotlin/com/orange/ods/gradle/Dependencies.kt +++ b/buildSrc/src/main/kotlin/com/orange/ods/gradle/Dependencies.kt @@ -13,9 +13,6 @@ package com.orange.ods.gradle object Dependencies { const val accompanistDrawablePainter = "com.google.accompanist:accompanist-drawablepainter:${Versions.accompanist}" - const val accompanistFlowLayout = "com.google.accompanist:accompanist-flowlayout:${Versions.accompanist}" - const val accompanistPager = "com.google.accompanist:accompanist-pager:${Versions.accompanist}" - const val accompanistPagerIndicators = "com.google.accompanist:accompanist-pager-indicators:${Versions.accompanist}" const val accompanistSystemUiController = "com.google.accompanist:accompanist-systemuicontroller:${Versions.accompanist}" const val activityCompose = "androidx.activity:activity-compose:${Versions.activity}" const val androidGradlePlugin = "com.android.tools.build:gradle:${Versions.androidGradlePlugin}" diff --git a/changelog.md b/changelog.md index 783bcc4eb..1d54eb9cc 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - \[Lib\] Update `OdsHorizontalCard`, `OdsSmallCard`, `OdsVerticalHeaderFirstCard` and `OdsVerticalImageFirstCard` APIs ([#597](https://github.com/Orange-OpenSource/ods-android/issues/597)) +- \[Lib\] Remove several dependencies to reduce consumer app size ([#623](https://github.com/Orange-OpenSource/ods-android/issues/623)) ### Fixed diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 1dcd2e0f1..5b588389f 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -52,7 +52,6 @@ dependencies { api(project(":theme-contract")) api(project(":theme-orange")) - implementation(Dependencies.accompanistFlowLayout) implementation(Dependencies.appCompat) implementation(platform(Dependencies.composeBom)) api(Dependencies.composeMaterial) @@ -63,7 +62,6 @@ dependencies { implementation(Dependencies.constraintLayoutCompose) implementation(Dependencies.coreKtx) implementation(Dependencies.customViewPoolingContainer) // This dependency is needed otherwise the compose preview does not work properly - implementation(Dependencies.kotlinReflect) implementation(Dependencies.lifecycleRuntimeKtx) testImplementation(Dependencies.jUnit) diff --git a/lib/src/main/java/com/orange/ods/compose/component/button/OdsButton.kt b/lib/src/main/java/com/orange/ods/compose/component/button/OdsButton.kt index 13a5b04ba..b45b15ce2 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/button/OdsButton.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/button/OdsButton.kt @@ -161,4 +161,4 @@ private fun PreviewOdsButton(@PreviewParameter(OdsButtonPreviewParameterProvider OdsButton(text = "Text", onClick = {}, style = style) } -private class OdsButtonPreviewParameterProvider : EnumPreviewParameterProvider(OdsButtonStyle::class) +private class OdsButtonPreviewParameterProvider : EnumPreviewParameterProvider(OdsButtonStyle::class.java) diff --git a/lib/src/main/java/com/orange/ods/compose/component/button/OdsTextButton.kt b/lib/src/main/java/com/orange/ods/compose/component/button/OdsTextButton.kt index b46857c17..fdae998c5 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/button/OdsTextButton.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/button/OdsTextButton.kt @@ -135,4 +135,4 @@ private fun PreviewOdsTextButton(@PreviewParameter(OdsTextButtonPreviewParameter OdsTextButton(text = "Text", maxLines = 1, overflow = TextOverflow.Clip, onClick = {}, style = style) } -private class OdsTextButtonPreviewParameterProvider : EnumPreviewParameterProvider(OdsTextButtonStyle::class) +private class OdsTextButtonPreviewParameterProvider : EnumPreviewParameterProvider(OdsTextButtonStyle::class.java) diff --git a/lib/src/main/java/com/orange/ods/compose/component/chip/OdsChoiceChipsFlowRow.kt b/lib/src/main/java/com/orange/ods/compose/component/chip/OdsChoiceChipsFlowRow.kt index 667742eab..f3ffd42bb 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/chip/OdsChoiceChipsFlowRow.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/chip/OdsChoiceChipsFlowRow.kt @@ -10,6 +10,9 @@ package com.orange.ods.compose.component.chip +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.ExperimentalLayoutApi +import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.selection.selectableGroup @@ -23,7 +26,6 @@ import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.semantics.SemanticsPropertyReceiver import androidx.compose.ui.semantics.semantics import androidx.compose.ui.semantics.stateDescription -import com.google.accompanist.flowlayout.FlowRow import com.orange.ods.R import com.orange.ods.compose.component.OdsComposable import com.orange.ods.compose.component.utilities.Preview @@ -42,6 +44,7 @@ import com.orange.ods.compose.theme.OdsTheme * @param modifier Modifier to be applied to the flow row. * @param chips The list of [OdsChoiceChip]s displayed inside this OdsChoiceChipsFlowRow. */ +@OptIn(ExperimentalLayoutApi::class) @Composable @OdsComposable fun OdsChoiceChipsFlowRow( @@ -56,7 +59,7 @@ fun OdsChoiceChipsFlowRow( modifier = modifier .fillMaxWidth() .selectableGroup(), - mainAxisSpacing = dimensionResource(id = R.dimen.spacing_s), + horizontalArrangement = Arrangement.spacedBy(dimensionResource(id = R.dimen.spacing_s)), content = { chips.forEachIndexed { index, odsChoiceChip -> odsChoiceChip.Content(selected = selectedChipValue == odsChoiceChip.value) { selected -> diff --git a/lib/src/main/java/com/orange/ods/compose/component/list/OdsListItem.kt b/lib/src/main/java/com/orange/ods/compose/component/list/OdsListItem.kt index cd8ce68d0..b2826ad51 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/list/OdsListItem.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/list/OdsListItem.kt @@ -65,7 +65,6 @@ import com.orange.ods.compose.theme.OdsTheme import com.orange.ods.compose.utilities.extension.getElementOfType import com.orange.ods.extension.isNotNullOrBlank import com.orange.ods.extension.orElse -import kotlin.reflect.KClass /** * ODS Lists. @@ -505,14 +504,14 @@ private fun getTrailingPreview(parameter: OdsListItemPreviewParameter): @Composa val checkedState = remember { mutableStateOf(false) } val selectedRadio = remember { mutableStateOf(0) } val trailing = when (parameter.previewTrailingType) { - OdsCheckboxTrailing::class -> OdsCheckboxTrailing(checked = checkedState, enabled = true) - OdsSwitchTrailing::class -> OdsSwitchTrailing(checked = checkedState) - OdsRadioButtonTrailing::class -> OdsRadioButtonTrailing(selectedRadio = selectedRadio, currentRadio = 0) - OdsIconTrailing::class -> OdsIconTrailing( + OdsCheckboxTrailing::class.java -> OdsCheckboxTrailing(checked = checkedState, enabled = true) + OdsSwitchTrailing::class.java -> OdsSwitchTrailing(checked = checkedState) + OdsRadioButtonTrailing::class.java -> OdsRadioButtonTrailing(selectedRadio = selectedRadio, currentRadio = 0) + OdsIconTrailing::class.java -> OdsIconTrailing( painter = painterResource(id = android.R.drawable.ic_dialog_info), contentDescription = null ) - OdsCaptionTrailing::class -> OdsCaptionTrailing(text = "caption") + OdsCaptionTrailing::class.java -> OdsCaptionTrailing(text = "caption") else -> null } @@ -560,7 +559,7 @@ internal data class OdsListItemPreviewParameter( val secondaryText: String?, val singleLineSecondaryText: Boolean, val iconType: OdsListItemIconType?, - val previewTrailingType: KClass? + val previewTrailingType: Class? ) private class OdsListItemPreviewParameterProvider : BasicPreviewParameterProvider(*previewParameterValues.toTypedArray()) @@ -572,10 +571,10 @@ private val previewParameterValues: List return listOf( OdsListItemPreviewParameter(null, true, null, null), - OdsListItemPreviewParameter(longSecondaryText, true, null, OdsCheckboxTrailing::class), - OdsListItemPreviewParameter(shortSecondaryText, true, OdsListItemIconType.Icon, OdsIconTrailing::class), - OdsListItemPreviewParameter(longSecondaryText, false, OdsListItemIconType.SquareImage, OdsSwitchTrailing::class), - OdsListItemPreviewParameter(longSecondaryText, false, OdsListItemIconType.WideImage, OdsCaptionTrailing::class), - OdsListItemPreviewParameter(shortSecondaryText, true, OdsListItemIconType.CircularImage, OdsRadioButtonTrailing::class) + OdsListItemPreviewParameter(longSecondaryText, true, null, OdsCheckboxTrailing::class.java), + OdsListItemPreviewParameter(shortSecondaryText, true, OdsListItemIconType.Icon, OdsIconTrailing::class.java), + OdsListItemPreviewParameter(longSecondaryText, false, OdsListItemIconType.SquareImage, OdsSwitchTrailing::class.java), + OdsListItemPreviewParameter(longSecondaryText, false, OdsListItemIconType.WideImage, OdsCaptionTrailing::class.java), + OdsListItemPreviewParameter(shortSecondaryText, true, OdsListItemIconType.CircularImage, OdsRadioButtonTrailing::class.java) ) } \ No newline at end of file diff --git a/lib/src/main/java/com/orange/ods/compose/component/textfield/OdsTextFieldsCommon.kt b/lib/src/main/java/com/orange/ods/compose/component/textfield/OdsTextFieldsCommon.kt index 55a3df33a..86b61fe67 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/textfield/OdsTextFieldsCommon.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/textfield/OdsTextFieldsCommon.kt @@ -33,7 +33,6 @@ import com.orange.ods.compose.component.utilities.BasicPreviewParameterProvider import com.orange.ods.compose.component.utilities.DisabledInteractionSource import com.orange.ods.compose.text.OdsTextCaption import com.orange.ods.compose.theme.OdsTheme -import kotlin.reflect.KClass /** * A character counter to display below the text field @@ -135,9 +134,9 @@ private fun OdsTextFieldErrorText(message: String) { @Composable internal fun getTrailingPreview(parameter: OdsTextFieldPreviewParameter, value: String): @Composable (() -> Unit)? { val trailing = when (parameter.previewTrailingType) { - OdsTextTrailing::class -> OdsTextTrailing(text = "units") - OdsIconTrailing::class -> OdsIconTrailing(painter = painterResource(id = android.R.drawable.ic_input_add)) - OdsExposedDropdownMenuTrailing::class -> OdsExposedDropdownMenuTrailing(expanded = false, enabled = true) + OdsTextTrailing::class.java -> OdsTextTrailing(text = "units") + OdsIconTrailing::class.java -> OdsIconTrailing(painter = painterResource(id = android.R.drawable.ic_input_add)) + OdsExposedDropdownMenuTrailing::class.java -> OdsExposedDropdownMenuTrailing(expanded = false, enabled = true) else -> null } @@ -148,7 +147,7 @@ internal data class OdsTextFieldPreviewParameter( val hasCounter: Boolean, val hasErrorMessage: Boolean, val isVeryLongErrorMessage: Boolean, - val previewTrailingType: KClass? + val previewTrailingType: Class? ) internal class OdsTextFieldPreviewParameterProvider : BasicPreviewParameterProvider(*previewParameterValues.toTypedArray()) @@ -156,7 +155,7 @@ internal class OdsTextFieldPreviewParameterProvider : BasicPreviewParameterProvi private val previewParameterValues: List get() { val booleanValues = listOf(true, false) - val trailings = listOf(null, OdsTextTrailing::class, OdsIconTrailing::class, OdsExposedDropdownMenuTrailing::class) + val trailings = listOf(null, OdsTextTrailing::class.java, OdsIconTrailing::class.java, OdsExposedDropdownMenuTrailing::class.java) return booleanValues.flatMap { hasCounter -> booleanValues.flatMap { hasErrorMessage -> diff --git a/lib/src/main/java/com/orange/ods/compose/component/utilities/Preview.kt b/lib/src/main/java/com/orange/ods/compose/component/utilities/Preview.kt index 09e428838..970ff1fe6 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/utilities/Preview.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/utilities/Preview.kt @@ -16,7 +16,6 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameterProvider import com.orange.ods.BuildConfig import com.orange.ods.compose.theme.OdsTheme -import kotlin.reflect.KClass /** * Configures the Compose preview environment in Android Studio. @@ -44,7 +43,7 @@ internal open class BasicPreviewParameterProvider(vararg values: T) : Preview * * @param clazz The enum class. */ -internal open class EnumPreviewParameterProvider(clazz: KClass>) : BasicPreviewParameterProvider>(*clazz.java.enumConstants) +internal open class EnumPreviewParameterProvider(clazz: Class>) : BasicPreviewParameterProvider>(*clazz.enumConstants) /** * Multipreview annotation classes used to display both light and dark mode previews. diff --git a/theme-contract/build.gradle.kts b/theme-contract/build.gradle.kts index 7aa66c846..673cb4e34 100644 --- a/theme-contract/build.gradle.kts +++ b/theme-contract/build.gradle.kts @@ -30,6 +30,5 @@ android { dependencies { implementation(platform(Dependencies.composeBom)) implementation(Dependencies.composeMaterial) - implementation(Dependencies.kotlinReflect) implementation(Dependencies.material) } \ No newline at end of file diff --git a/theme-contract/src/main/java/com/orange/ods/theme/guideline/GuidelineEntities.kt b/theme-contract/src/main/java/com/orange/ods/theme/guideline/GuidelineEntities.kt index 342e65613..8920a9190 100644 --- a/theme-contract/src/main/java/com/orange/ods/theme/guideline/GuidelineEntities.kt +++ b/theme-contract/src/main/java/com/orange/ods/theme/guideline/GuidelineEntities.kt @@ -16,7 +16,7 @@ import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.TextStyle -import kotlin.reflect.KCallable +import com.orange.ods.theme.colors.OdsColors /** * A color displayed in the guideline color part of the ODS application @@ -28,11 +28,12 @@ import kotlin.reflect.KCallable * @property xmlResource Optional resource used to use this color in XML */ data class GuidelineColor( - val callable: KCallable, + val callableName: String, val type: GuidelineColorType, val lightThemeName: String, val darkThemeName: String = lightThemeName, - @ColorRes @AttrRes val xmlResource: Int? = null + @ColorRes @AttrRes val xmlResource: Int? = null, + val getValue: (OdsColors) -> Color ) { /** diff --git a/theme-contract/src/main/java/com/orange/ods/theme/guideline/OdsGuideline.kt b/theme-contract/src/main/java/com/orange/ods/theme/guideline/OdsGuideline.kt index 587be3be8..aebd42673 100644 --- a/theme-contract/src/main/java/com/orange/ods/theme/guideline/OdsGuideline.kt +++ b/theme-contract/src/main/java/com/orange/ods/theme/guideline/OdsGuideline.kt @@ -53,7 +53,7 @@ open class OdsGuideline(private val typography: Typography) { if (name != null && xmlResource != null) { GuidelineTextStyle( name = name, - textStyle = property.call(), + textStyle = property(), composeStyle = "OdsTheme.typography.${property.name}", xmlResource = xmlResource ) diff --git a/theme-innovation-cup/src/main/java/com/orange/ods/theme/innovationcup/guideline/InnovationCupGuidelineColors.kt b/theme-innovation-cup/src/main/java/com/orange/ods/theme/innovationcup/guideline/InnovationCupGuidelineColors.kt index b7414a414..a1423204c 100644 --- a/theme-innovation-cup/src/main/java/com/orange/ods/theme/innovationcup/guideline/InnovationCupGuidelineColors.kt +++ b/theme-innovation-cup/src/main/java/com/orange/ods/theme/innovationcup/guideline/InnovationCupGuidelineColors.kt @@ -16,13 +16,12 @@ import com.orange.ods.theme.guideline.GuidelineColor import com.orange.ods.theme.guideline.GuidelineColorType val InnovationCupGuidelineColors = listOf( - GuidelineColor(OdsColors::primary, GuidelineColorType.Core, "Orange 100", "Orange 200"), - GuidelineColor(OdsColors::primaryVariant, GuidelineColorType.Core, "Orange 100", "Orange 200"), - GuidelineColor(OdsColors::background, GuidelineColorType.Core, "White 100", "Black 900"), - GuidelineColor(OdsColors::surface, GuidelineColorType.Core, "White 100", "Secondary Background"), - - GuidelineColor(OdsFunctionalColors::positive, GuidelineColorType.Functional, "Green"), - GuidelineColor(OdsColors::error, GuidelineColorType.Functional, "Red"), - GuidelineColor(OdsFunctionalColors::info, GuidelineColorType.Functional, "Info"), - GuidelineColor(OdsFunctionalColors::alert, GuidelineColorType.Functional, "Yellow") -) \ No newline at end of file + GuidelineColor(OdsColors::primary.name, GuidelineColorType.Core, "Orange 100", "Orange 200") { it.primary }, + GuidelineColor(OdsColors::primaryVariant.name, GuidelineColorType.Core, "Orange 100", "Orange 200") { it.primaryVariant }, + GuidelineColor(OdsColors::background.name, GuidelineColorType.Core, "White 100", "Black 900") { it.background }, + GuidelineColor(OdsColors::surface.name, GuidelineColorType.Core, "White 100", "Secondary Background") { it.surface }, + GuidelineColor(OdsFunctionalColors::positive.name, GuidelineColorType.Functional, "Green") { it.functional.positive }, + GuidelineColor(OdsColors::error.name, GuidelineColorType.Functional, "Red") { it.error }, + GuidelineColor(OdsFunctionalColors::info.name, GuidelineColorType.Functional, "Info") { it.functional.info }, + GuidelineColor(OdsFunctionalColors::alert.name, GuidelineColorType.Functional, "Yellow") { it.functional.alert } +) diff --git a/theme-orange/src/main/java/com/orange/ods/theme/orange/guideline/OrangeGuidelineColors.kt b/theme-orange/src/main/java/com/orange/ods/theme/orange/guideline/OrangeGuidelineColors.kt index 6b1cbec7e..1d7651dcd 100644 --- a/theme-orange/src/main/java/com/orange/ods/theme/orange/guideline/OrangeGuidelineColors.kt +++ b/theme-orange/src/main/java/com/orange/ods/theme/orange/guideline/OrangeGuidelineColors.kt @@ -33,29 +33,59 @@ import com.orange.ods.theme.orange.Yellow200 import com.orange.ods.theme.orange.Yellow300 val OrangeGuidelineColors = listOf( - GuidelineColor(OdsColors::primary, GuidelineColorType.Core, "Orange 100", "Orange 200", com.google.android.material.R.attr.colorPrimary), - GuidelineColor(OdsColors::background, GuidelineColorType.Core, "White 100", "Black 900", com.google.android.material.R.attr.backgroundColor), - GuidelineColor(OdsColors::surface, GuidelineColorType.Core, "White 100", "Secondary Background", com.google.android.material.R.attr.colorSurface), - GuidelineColor(::ObsGrey700, GuidelineColorType.Core, "OBS Grey 700", xmlResource = R.color.core_obsgrey_700), + GuidelineColor( + OdsColors::primary.name, + GuidelineColorType.Core, + "Orange 100", + "Orange 200", + com.google.android.material.R.attr.colorPrimary + ) { it.primary }, + GuidelineColor( + OdsColors::background.name, + GuidelineColorType.Core, + "White 100", + "Black 900", + com.google.android.material.R.attr.backgroundColor + ) { it.background }, + GuidelineColor( + OdsColors::surface.name, + GuidelineColorType.Core, + "White 100", + "Secondary Background", + com.google.android.material.R.attr.colorSurface + ) { it.surface }, + GuidelineColor(::ObsGrey700.name, GuidelineColorType.Core, "OBS Grey 700", xmlResource = R.color.core_obsgrey_700) { ObsGrey700 }, - GuidelineColor(OdsFunctionalColors::positive, GuidelineColorType.Functional, "Positive 200", "Positive 100", R.attr.functionalPositive), - GuidelineColor(OdsColors::error, GuidelineColorType.Functional, "Negative 200", "Negative 100", com.google.android.material.R.attr.colorError), - GuidelineColor(OdsFunctionalColors::info, GuidelineColorType.Functional, "Info 200", "Info 100", R.attr.functionalInfo), - GuidelineColor(OdsFunctionalColors::alert, GuidelineColorType.Functional, "Alert 200", "Alert 100", R.attr.functionalAlert), + GuidelineColor( + OdsFunctionalColors::positive.name, + GuidelineColorType.Functional, + "Positive 200", + "Positive 100", + R.attr.functionalPositive + ) { it.functional.positive }, + GuidelineColor( + OdsColors::error.name, + GuidelineColorType.Functional, + "Negative 200", + "Negative 100", + com.google.android.material.R.attr.colorError + ) { it.error }, + GuidelineColor(OdsFunctionalColors::info.name, GuidelineColorType.Functional, "Info 200", "Info 100", R.attr.functionalInfo) { it.functional.info }, + GuidelineColor(OdsFunctionalColors::alert.name, GuidelineColorType.Functional, "Alert 200", "Alert 100", R.attr.functionalAlert) { it.functional.alert }, - GuidelineColor(::Blue100, GuidelineColorType.Supporting, "Blue 100", xmlResource = R.color.supporting_blue_100), - GuidelineColor(::Blue200, GuidelineColorType.Supporting, "Blue 200", xmlResource = R.color.supporting_blue_200), - GuidelineColor(::Blue300, GuidelineColorType.Supporting, "Blue 300", xmlResource = R.color.supporting_blue_300), - GuidelineColor(::Green100, GuidelineColorType.Supporting, "Green 100", xmlResource = R.color.supporting_green_100), - GuidelineColor(::Green200, GuidelineColorType.Supporting, "Green 200", xmlResource = R.color.supporting_green_200), - GuidelineColor(::Green300, GuidelineColorType.Supporting, "Green 300", xmlResource = R.color.supporting_green_300), - GuidelineColor(::Pink100, GuidelineColorType.Supporting, "Pink 100", xmlResource = R.color.supporting_pink_100), - GuidelineColor(::Pink200, GuidelineColorType.Supporting, "Pink 200", xmlResource = R.color.supporting_pink_200), - GuidelineColor(::Pink300, GuidelineColorType.Supporting, "Pink 300", xmlResource = R.color.supporting_pink_300), - GuidelineColor(::Purple100, GuidelineColorType.Supporting, "Purple 100", xmlResource = R.color.supporting_purple_100), - GuidelineColor(::Purple200, GuidelineColorType.Supporting, "Purple 200", xmlResource = R.color.supporting_purple_200), - GuidelineColor(::Purple300, GuidelineColorType.Supporting, "Purple 300", xmlResource = R.color.supporting_purple_300), - GuidelineColor(::Yellow100, GuidelineColorType.Supporting, "Yellow 100", xmlResource = R.color.supporting_yellow_100), - GuidelineColor(::Yellow200, GuidelineColorType.Supporting, "Yellow 200", xmlResource = R.color.supporting_yellow_200), - GuidelineColor(::Yellow300, GuidelineColorType.Supporting, "Yellow 300", xmlResource = R.color.supporting_yellow_300) + GuidelineColor(::Blue100.name, GuidelineColorType.Supporting, "Blue 100", xmlResource = R.color.supporting_blue_100) { Blue100 }, + GuidelineColor(::Blue200.name, GuidelineColorType.Supporting, "Blue 200", xmlResource = R.color.supporting_blue_200) { Blue200 }, + GuidelineColor(::Blue300.name, GuidelineColorType.Supporting, "Blue 300", xmlResource = R.color.supporting_blue_300) { Blue300 }, + GuidelineColor(::Green100.name, GuidelineColorType.Supporting, "Green 100", xmlResource = R.color.supporting_green_100) { Green100 }, + GuidelineColor(::Green200.name, GuidelineColorType.Supporting, "Green 200", xmlResource = R.color.supporting_green_200) { Green200 }, + GuidelineColor(::Green300.name, GuidelineColorType.Supporting, "Green 300", xmlResource = R.color.supporting_green_300) { Green300 }, + GuidelineColor(::Pink100.name, GuidelineColorType.Supporting, "Pink 100", xmlResource = R.color.supporting_pink_100) { Pink100 }, + GuidelineColor(::Pink200.name, GuidelineColorType.Supporting, "Pink 200", xmlResource = R.color.supporting_pink_200) { Pink200 }, + GuidelineColor(::Pink300.name, GuidelineColorType.Supporting, "Pink 300", xmlResource = R.color.supporting_pink_300) { Pink300 }, + GuidelineColor(::Purple100.name, GuidelineColorType.Supporting, "Purple 100", xmlResource = R.color.supporting_purple_100) { Purple100 }, + GuidelineColor(::Purple200.name, GuidelineColorType.Supporting, "Purple 200", xmlResource = R.color.supporting_purple_200) { Purple200 }, + GuidelineColor(::Purple300.name, GuidelineColorType.Supporting, "Purple 300", xmlResource = R.color.supporting_purple_300) { Purple300 }, + GuidelineColor(::Yellow100.name, GuidelineColorType.Supporting, "Yellow 100", xmlResource = R.color.supporting_yellow_100) { Yellow100 }, + GuidelineColor(::Yellow200.name, GuidelineColorType.Supporting, "Yellow 200", xmlResource = R.color.supporting_yellow_200) { Yellow200 }, + GuidelineColor(::Yellow300.name, GuidelineColorType.Supporting, "Yellow 300", xmlResource = R.color.supporting_yellow_300) { Yellow300 } ) \ No newline at end of file