Skip to content

Commit

Permalink
Merge pull request #646 from Orange-OpenSource/develop
Browse files Browse the repository at this point in the history
Release 0.15.1
  • Loading branch information
florentmaitre committed Sep 28, 2023
2 parents 9f7ecce + 87c6d06 commit 9ed3317
Show file tree
Hide file tree
Showing 252 changed files with 5,051 additions and 711 deletions.
2 changes: 1 addition & 1 deletion DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repositories {

```groovy
dependencies {
implementation 'com.orange.ods.android:ods-lib:0.15.0'
implementation 'com.orange.ods.android:ods-lib:0.15.1'
}
```

Expand Down
3 changes: 1 addition & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ android {
minSdk = Versions.minSdk
targetSdk = Versions.targetSdk
val versionCodeProperty = project.findTypedProperty<String>("versionCode")
versionCode = versionCodeProperty?.toInt() ?: 6
versionCode = versionCodeProperty?.toInt() ?: 7
versionName = version.toString()
val versionNameSuffixProperty = project.findTypedProperty<String>("versionNameSuffix")
versionNameSuffix = versionNameSuffixProperty
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/orange/ods/app/ui/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ fun MainScreen(themeConfigurations: Set<OdsThemeConfigurationContract>, mainView

Scaffold(
modifier = modifier,
backgroundColor = OdsTheme.colors.background,
topBar = {
Surface(elevation = if (isSystemInDarkTheme()) 0.dp else AppBarDefaults.TopAppBarElevation) {
Column {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.ui.res.stringResource
import com.orange.ods.app.R
import com.orange.ods.app.ui.LocalMainTopAppBarManager
import com.orange.ods.app.ui.utilities.DrawableManager
import com.orange.ods.compose.component.card.OdsCardImage
import com.orange.ods.compose.component.card.OdsSmallCard
import com.orange.ods.extension.orElse

Expand Down Expand Up @@ -67,12 +68,13 @@ private fun RowScope.ComponentCard(component: Component, onComponentClick: (Long
OdsSmallCard(
modifier = Modifier.weight(0.5f),
title = stringResource(id = component.titleRes),
image = painterResource(id = smallImageResId.orElse { imageResId }),
imageBackgroundColor = Color(Component.ImageBackgroundColor),
imageContentScale = ContentScale.Fit,
imageAlignment = component.imageAlignment,
onCardClick = {
onComponentClick(component.id)
},
image = OdsCardImage(
painterResource(id = smallImageResId.orElse { imageResId }),
"",
component.imageAlignment,
ContentScale.Fit,
Color(Component.ImageBackgroundColor)
),
onClick = { onComponentClick(component.id) },
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ fun ComponentTopAppBar(variant: Variant) {
title(context.getString(R.string.component_app_bars_top_regular))

if (isNavigationIconEnabled) {
classInstance("navigationIcon", OdsTopAppBarNavigationIcon::class.java) {
simple("imageVector", "<image vector>")
classInstance<OdsTopAppBarNavigationIcon>("navigationIcon") {
imageVector()
contentDescription(context.getString(R.string.top_app_bar_back_icon_desc))
}
}

list("actions") {
repeat(actionCount.value) {
classInstance(OdsTopAppBarActionButton::class.java) {
classInstance<OdsTopAppBarActionButton> {
onClick()
painter()
contentDescription("icon description")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,18 @@ fun ComponentBanners() {
exhaustiveParameters = false,
parameters = {
string("message", if (hasTwoTextLines) recipe.description else recipe.title)
classInstance("firstButton", OdsBannerButton::class.java) {
classInstance<OdsBannerButton>("firstButton") {
text(context.getString(R.string.component_banner_dismiss))
onClick()
}
if (hasImage) {
classInstance("image", OdsBannerImage::class.java) {
classInstance<OdsBannerImage>("image") {
painter()
contentDescription("")
}
}
if (hasSecondButton) {
classInstance("secondButton", OdsBannerButton::class.java) {
classInstance<OdsBannerButton>("secondButton") {
text(context.getString(R.string.component_banner_detail))
onClick()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ fun ComponentBottomNavigation() {
parameters = {
list("items") {
navigationItems.take(selectedNavigationItemCount.value).forEach { item ->
classInstance(OdsBottomNavigationItem::class.java) {
classInstance("icon", OdsBottomNavigationItemIcon::class.java) {
classInstance<OdsBottomNavigationItem> {
classInstance<OdsBottomNavigationItemIcon>("icon") {
painter()
contentDescription("")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import com.orange.ods.compose.component.button.OdsButton
import com.orange.ods.compose.component.button.OdsButtonIcon
import com.orange.ods.compose.component.button.OdsButtonStyle
import com.orange.ods.compose.theme.OdsDisplaySurface
import com.orange.ods.extension.fullName

@Composable
fun ButtonsContained(customizationState: ButtonCustomizationState) {
Expand Down Expand Up @@ -84,10 +83,10 @@ fun ButtonsContained(customizationState: ButtonCustomizationState) {
name = OdsComposable.OdsButton.name,
exhaustiveParameters = false,
parameters = {
simple("style", buttonStyle.value.fullName)
enum("style", buttonStyle.value)
if (hasFullScreenWidth) fillMaxWidth()
if (hasLeadingIcon) {
classInstance("icon", OdsButtonIcon::class.java) {
classInstance<OdsButtonIcon>("icon") {
painter()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fun ButtonsOutlined(customizationState: ButtonCustomizationState) {
parameters = {
if (hasFullScreenWidth) fillMaxWidth()
if (hasLeadingIcon) {
classInstance("icon", OdsButtonIcon::class.java) {
classInstance<OdsButtonIcon>("icon") {
painter()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import com.orange.ods.compose.component.button.OdsButtonIcon
import com.orange.ods.compose.component.button.OdsTextButton
import com.orange.ods.compose.component.button.OdsTextButtonStyle
import com.orange.ods.compose.theme.OdsDisplaySurface
import com.orange.ods.extension.fullName

@Composable
fun ButtonsText(customizationState: ButtonCustomizationState) {
Expand Down Expand Up @@ -79,10 +78,10 @@ fun ButtonsText(customizationState: ButtonCustomizationState) {
name = OdsComposable.OdsTextButton.name,
exhaustiveParameters = false,
parameters = {
simple("style", textButtonStyle.value.fullName)
enum("style", textButtonStyle.value)
if (hasFullScreenWidth) fillMaxWidth()
if (hasLeadingIcon) {
classInstance("icon", OdsButtonIcon::class.java) {
classInstance<OdsButtonIcon>("icon") {
painter()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fun ButtonsTextToggleButtonsRow(customizationState: ButtonCustomizationState) {
parameters = {
list("textToggleButtons") {
textToggleButtons.take(toggleCount.value).forEach { item ->
classInstance(OdsTextToggleButtonsRowItem::class.java) {
classInstance<OdsTextToggleButtonsRowItem> {
text(item.text)
enabled(customizationState.isEnabled)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fun ButtonsIcon(customizationState: ButtonIconCustomizationState) {
name = OdsComposable.OdsIconButton.name,
exhaustiveParameters = false,
parameters = {
classInstance("icon", OdsIconButtonIcon::class.java) {
classInstance<OdsIconButtonIcon>("icon") {
painter()
contentDescription("")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ fun ButtonsIconToggle(customizationState: ButtonIconCustomizationState) {
name = OdsComposable.OdsIconToggleButton.name,
exhaustiveParameters = false,
parameters = {
classInstance("uncheckedIcon", OdsIconButtonIcon::class.java) {
classInstance<OdsIconButtonIcon>("uncheckedIcon") {
painter()
contentDescription("")
}
classInstance("checkedIcon", OdsIconButtonIcon::class.java) {
classInstance<OdsIconButtonIcon>("checkedIcon") {
painter()
contentDescription("")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fun ButtonsIconToggleGroup(customizationState: ButtonIconCustomizationState) {
parameters = {
list("icons") {
repeat(toggleCount.value) {
classInstance(OdsIconToggleButtonsRowIcon::class.java) {
classInstance<OdsIconToggleButtonsRowIcon> {
painter()
contentDescription("")
if (!isEnabled) enabled(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ fun rememberCardCustomizationState(
thumbnailChecked: MutableState<Boolean> = rememberSaveable { mutableStateOf(true) },
textChecked: MutableState<Boolean> = rememberSaveable { mutableStateOf(true) },
subtitleChecked: MutableState<Boolean> = rememberSaveable { mutableStateOf(true) },
actionButtonCount: MutableState<Int> = rememberSaveable { mutableStateOf(CardCustomizationState.MinActionButtonCount) },
buttonCount: MutableState<Int> = rememberSaveable { mutableStateOf(CardCustomizationState.MinButtonCount) },
dividerChecked: MutableState<Boolean> = rememberSaveable { mutableStateOf(true) },
imagePosition: MutableState<OdsHorizontalCardImagePosition> = rememberSaveable { mutableStateOf(OdsHorizontalCardImagePosition.Start) }
) =
remember(clickable, thumbnailChecked, textChecked, subtitleChecked, actionButtonCount, dividerChecked, imagePosition) {
CardCustomizationState(clickable, thumbnailChecked, textChecked, subtitleChecked, actionButtonCount, dividerChecked, imagePosition)
remember(clickable, thumbnailChecked, textChecked, subtitleChecked, buttonCount, dividerChecked, imagePosition) {
CardCustomizationState(clickable, thumbnailChecked, textChecked, subtitleChecked, buttonCount, dividerChecked, imagePosition)
}

class CardCustomizationState(
val clickable: MutableState<Boolean>,
val thumbnailChecked: MutableState<Boolean>,
val textChecked: MutableState<Boolean>,
val subtitleChecked: MutableState<Boolean>,
val actionButtonCount: MutableState<Int>,
val buttonCount: MutableState<Int>,
val dividerChecked: MutableState<Boolean>,
val imagePosition: MutableState<OdsHorizontalCardImagePosition>
) {

companion object {
const val MinActionButtonCount = 0
const val MaxActionButtonCount = 2
const val MinButtonCount = 0
const val MaxButtonCount = 2
}

val isClickable
Expand All @@ -58,12 +58,12 @@ class CardCustomizationState(
val hasSubtitle
get() = subtitleChecked.value

val hasButton1
get() = actionButtonCount.value > 0
val hasFirstButton
get() = buttonCount.value > 0

val hasButton2
get() = actionButtonCount.value > 1
val hasSecondButton
get() = buttonCount.value > 1

val hasDivider
get() = if (!hasButton1) false else dividerChecked.value
get() = if (!hasFirstButton) false else dividerChecked.value
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
package com.orange.ods.app.ui.components.cards

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
Expand All @@ -31,67 +30,78 @@ import com.orange.ods.app.ui.utilities.DrawableManager
import com.orange.ods.app.ui.utilities.composable.CodeImplementationColumn
import com.orange.ods.app.ui.utilities.composable.FunctionCallCode
import com.orange.ods.compose.OdsComposable
import com.orange.ods.compose.component.card.OdsCardButton
import com.orange.ods.compose.component.card.OdsCardImage
import com.orange.ods.compose.component.card.OdsHorizontalCard

@Composable
fun CardHorizontal(customizationState: CardCustomizationState) {
val context = LocalContext.current
val recipes = LocalRecipes.current
val recipe = rememberSaveable { recipes.filter { it.description.isNotBlank() }.random() }

with(customizationState) {
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(state = rememberScrollState())
.padding(dimensionResource(id = com.orange.ods.R.dimen.spacing_m))
.verticalScroll(state = rememberScrollState()),
) {
val button1Text = stringResource(id = R.string.component_element_first_button)
val button2Text = stringResource(id = R.string.component_element_second_button)
val firstButtonText = stringResource(id = R.string.component_element_first_button)
val secondButtonText = stringResource(id = R.string.component_element_second_button)
val cardText = stringResource(id = R.string.component_card_element_card)

OdsHorizontalCard(
title = recipe.title,
image = rememberAsyncImagePainter(
model = recipe.imageUrl,
placeholder = painterResource(id = DrawableManager.getPlaceholderResId()),
error = painterResource(id = DrawableManager.getPlaceholderResId(error = true))
image = OdsCardImage(
rememberAsyncImagePainter(
model = recipe.imageUrl,
placeholder = painterResource(id = DrawableManager.getPlaceholderResId()),
error = painterResource(id = DrawableManager.getPlaceholderResId(error = true))
),
""
),
subtitle = if (hasSubtitle) recipe.subtitle else null,
text = if (hasText) recipe.description else null,
onCardClick = if (isClickable) {
onClick = if (isClickable) {
{ clickOnElement(context, cardText) }
} else null,
button1Text = if (hasButton1) button1Text else null,
onButton1Click = { clickOnElement(context, button1Text) },
button2Text = if (hasButton2) button2Text else null,
onButton2Click = { clickOnElement(context, button2Text) },
firstButton = if (hasFirstButton) OdsCardButton(firstButtonText) { clickOnElement(context, firstButtonText) } else null,
secondButton = if (hasSecondButton) OdsCardButton(secondButtonText) { clickOnElement(context, secondButtonText) } else null,
imagePosition = imagePosition.value,
dividerEnabled = hasDivider
divider = hasDivider
)

Spacer(modifier = Modifier.padding(top = dimensionResource(com.orange.ods.R.dimen.spacing_s)))

CodeImplementationColumn {
CodeImplementationColumn(
modifier = Modifier.padding(top = dimensionResource(com.orange.ods.R.dimen.spacing_s))
) {
FunctionCallCode(
name = OdsComposable.OdsHorizontalCard.name,
exhaustiveParameters = false,
parameters = {
simple("imagePosition", imagePosition.value.name)
enum("imagePosition", imagePosition.value)
title(recipe.title)
image()
classInstance("image", OdsCardImage::class.java) {
painter()
contentDescription("")
}
if (hasSubtitle) subtitle(recipe.subtitle)
if (hasText) cardText()
if (isClickable) onCardClick()
if (hasButton1) {
button1Text(button1Text)
onButton1Click()
if (isClickable) onClick()
if (hasFirstButton) {
classInstance("firstButton", OdsCardButton::class.java) {
text(firstButtonText)
onClick()
}
}
if (hasButton2) {
button2Text(button2Text)
onButton2Click()
if (hasSecondButton) {
classInstance("secondButton", OdsCardButton::class.java) {
text(secondButtonText)
onClick()
}
}
if (!hasDivider && (hasButton1 || hasButton2)) stringRepresentation("dividerEnabled", hasDivider)
simple("imagePosition", imagePosition.value.name)
if (!hasDivider && (hasFirstButton || hasSecondButton)) stringRepresentation("divider", hasDivider)
}
)
}
Expand Down
Loading

0 comments on commit 9ed3317

Please sign in to comment.