Skip to content
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.orange.ouds.core.component.OudsButton
import com.orange.ouds.core.component.OudsButtonAppearance
import com.orange.ouds.core.component.OudsButtonIcon
import com.orange.ouds.core.component.OudsButtonLoader
import com.orange.ouds.core.component.OudsSmallButton
import com.orange.ouds.theme.OudsVersion

@Composable
Expand Down Expand Up @@ -81,6 +82,13 @@ private fun ButtonDemoBottomSheetContent(state: ButtonDemoState) {
onCheckedChange = { hasLoader = it },
enabled = loaderSwitchEnabled
)
CustomizationFilterChips(
applyTopPadding = true,
label = stringResource(R.string.app_components_common_size_tech),
chipLabels = ButtonDemoState.Size.entries.map { stringResource(it.labelRes) },
selectedChipIndex = ButtonDemoState.Size.entries.indexOf(size),
onSelectionChange = { index -> size = ButtonDemoState.Size.entries[index] }
)
CustomizationFilterChips(
applyTopPadding = true,
label = stringResource(R.string.app_components_common_layout_tech),
Expand Down Expand Up @@ -118,28 +126,49 @@ private fun ButtonDemoContent(state: ButtonDemoState) {
tinted = icon == ButtonDemoState.Icon.Tinted
)
val loader = if (hasLoader) OudsButtonLoader(null) else null
when (layout) {
ButtonDemoState.Layout.TextOnly -> {
OudsButton(

when (size) {
ButtonDemoState.Size.Default -> when (layout) {
ButtonDemoState.Layout.TextOnly -> OudsButton(
label = label,
onClick = {},
enabled = enabled,
loader = loader,
appearance = appearance
)
}
ButtonDemoState.Layout.TextAndIcon -> {
OudsButton(
ButtonDemoState.Layout.TextAndIcon -> OudsButton(
icon = buttonIcon,
label = label,
onClick = {},
enabled = enabled,
loader = loader,
appearance = appearance
)
ButtonDemoState.Layout.IconOnly -> OudsButton(
icon = buttonIcon,
onClick = {},
enabled = enabled,
loader = loader,
appearance = appearance
)
}
ButtonDemoState.Layout.IconOnly -> {
OudsButton(
ButtonDemoState.Size.Small -> when (layout) {
ButtonDemoState.Layout.TextOnly -> OudsSmallButton(
label = label,
onClick = {},
enabled = enabled,
loader = loader,
appearance = appearance
)
ButtonDemoState.Layout.TextAndIcon -> OudsSmallButton(
icon = buttonIcon,
label = label,
onClick = {},
enabled = enabled,
loader = loader,
appearance = appearance
)
ButtonDemoState.Layout.IconOnly -> OudsSmallButton(
icon = buttonIcon,
onClick = {},
enabled = enabled,
Expand All @@ -154,9 +183,18 @@ private fun ButtonDemoContent(state: ButtonDemoState) {
private fun Code.Builder.buttonDemoCodeSnippet(state: ButtonDemoState, themeDrawableResources: ThemeDrawableResources) {
with(state) {
coloredBoxCall(onColoredBox) {
functionCall("OudsButton") {
val functionName = when (size) {
ButtonDemoState.Size.Default -> "OudsButton"
ButtonDemoState.Size.Small -> "OudsSmallButton"
}
functionCall(functionName) {
if (layout in listOf(ButtonDemoState.Layout.IconOnly, ButtonDemoState.Layout.TextAndIcon)) {
iconArgument<OudsButtonIcon>("icon", themeDrawableResources.tipsAndTricks, R.string.app_components_common_icon_a11y, icon == ButtonDemoState.Icon.Tinted)
iconArgument<OudsButtonIcon>(
"icon",
themeDrawableResources.tipsAndTricks,
R.string.app_components_common_icon_a11y,
icon == ButtonDemoState.Icon.Tinted
)
}
if (layout in listOf(ButtonDemoState.Layout.TextOnly, ButtonDemoState.Layout.TextAndIcon)) {
labelArgument(label)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ fun rememberButtonDemoState(
onColoredBox: Boolean = false,
hasLoader: Boolean = false,
appearance: OudsButtonAppearance = OudsButtonDefaults.Appearance,
size: ButtonDemoState.Size = ButtonDemoState.Size.entries.first(),
layout: ButtonDemoState.Layout = ButtonDemoState.Layout.entries.first(),
icon: ButtonDemoState.Icon = ButtonDemoState.Icon.Tinted
) = rememberSaveable(label, enabled, onColoredBox, hasLoader, appearance, layout, icon, saver = ButtonDemoState.Saver) {
ButtonDemoState(label, enabled, onColoredBox, hasLoader, appearance, layout, icon)
) = rememberSaveable(label, enabled, onColoredBox, hasLoader, appearance, size, layout, icon, saver = ButtonDemoState.Saver) {
ButtonDemoState(label, enabled, onColoredBox, hasLoader, appearance, size, layout, icon)
}

class ButtonDemoState(
Expand All @@ -43,6 +44,7 @@ class ButtonDemoState(
onColoredBox: Boolean,
hasLoader: Boolean,
appearance: OudsButtonAppearance,
size: Size,
layout: Layout,
icon: Icon
) : BaseButtonDemoState(enabled, onColoredBox, hasLoader) {
Expand All @@ -56,25 +58,27 @@ class ButtonDemoState(
save = { state ->
with(state) {
listOf(
with(BaseButtonDemoState.Saver) { save(state) },
label,
appearance,
size,
layout,
icon,
with(BaseButtonDemoState.Saver) { save(state) },
icon
)
}
},
restore = { list: List<Any?> ->
val baseButtonDemoState = list[4]?.let { BaseButtonDemoState.Saver.restore(it) }
val baseButtonDemoState = list[0]?.let { BaseButtonDemoState.Saver.restore(it) }
baseButtonDemoState?.run {
ButtonDemoState(
list[0] as String,
list[1] as String,
enabled,
onColoredBox,
hasLoader,
list[1] as OudsButtonAppearance,
list[2] as Layout,
list[3] as Icon
list[2] as OudsButtonAppearance,
list[3] as Size,
list[4] as Layout,
list[5] as Icon
)
}
}
Expand All @@ -83,6 +87,8 @@ class ButtonDemoState(

var label: String by mutableStateOf(label)

var size: Size by mutableStateOf(size)

var layout: Layout by mutableStateOf(layout)

private var _appearance: OudsButtonAppearance by mutableStateOf(appearance)
Expand All @@ -106,6 +112,11 @@ class ButtonDemoState(
val enabledIcons: List<Icon>
get() = if (layout != Layout.TextOnly) Icon.entries else emptyList()

enum class Size(@StringRes val labelRes: Int) {
Default(R.string.app_components_button_button_defaultSize_tech),
Small(R.string.app_components_common_smallSize_tech)
}

enum class Layout(@StringRes val labelRes: Int) {
TextOnly(R.string.app_components_common_textOnlyLayout_tech),
TextAndIcon(R.string.app_components_common_textAndIconLayout_tech),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,47 +110,35 @@ private fun FloatingActionButtonDemoContent(state: FloatingActionButtonDemoState
tinted = icon == FloatingActionButtonDemoState.Icon.Tinted
)
when (size) {
FloatingActionButtonDemoState.Size.Small -> {
OudsSmallFloatingActionButton(
FloatingActionButtonDemoState.Size.Small -> OudsSmallFloatingActionButton(
icon = floatingActionButtonIcon,
onClick = {},
appearance = appearance
)
FloatingActionButtonDemoState.Size.Medium -> when (layout) {
FloatingActionButtonDemoState.Layout.IconOnly -> OudsFloatingActionButton(
icon = floatingActionButtonIcon,
onClick = {},
appearance = appearance
)
}
FloatingActionButtonDemoState.Size.Medium -> {
when (layout) {
FloatingActionButtonDemoState.Layout.IconOnly -> {
OudsFloatingActionButton(
icon = floatingActionButtonIcon,
onClick = {},
appearance = appearance
)
}
FloatingActionButtonDemoState.Layout.TextAndIcon -> {
OudsExtendedFloatingActionButton(
label = label,
icon = floatingActionButtonIcon,
onClick = {},
expanded = expanded,
appearance = appearance
)
}
FloatingActionButtonDemoState.Layout.TextOnly -> {
OudsExtendedFloatingActionButton(
label = label,
onClick = {},
appearance = appearance
)
}
}
}
FloatingActionButtonDemoState.Size.Large -> {
OudsLargeFloatingActionButton(
FloatingActionButtonDemoState.Layout.TextAndIcon -> OudsExtendedFloatingActionButton(
label = label,
icon = floatingActionButtonIcon,
onClick = {},
expanded = expanded,
appearance = appearance
)
FloatingActionButtonDemoState.Layout.TextOnly -> OudsExtendedFloatingActionButton(
label = label,
onClick = {},
appearance = appearance
)
}
FloatingActionButtonDemoState.Size.Large -> OudsLargeFloatingActionButton(
icon = floatingActionButtonIcon,
onClick = {},
appearance = appearance
)
}
}
}
Expand All @@ -167,7 +155,12 @@ private fun Code.Builder.floatingActionButtonDemoCodeSnippet(state: FloatingActi
labelArgument(label)
}
if (layout != FloatingActionButtonDemoState.Layout.TextOnly) {
iconArgument<OudsFloatingActionButtonIcon>("icon", themeDrawableResources.tipsAndTricks, R.string.app_components_common_icon_a11y, icon == FloatingActionButtonDemoState.Icon.Tinted)
iconArgument<OudsFloatingActionButtonIcon>(
"icon",
themeDrawableResources.tipsAndTricks,
R.string.app_components_common_icon_a11y,
icon == FloatingActionButtonDemoState.Icon.Tinted
)
}
if (layout == FloatingActionButtonDemoState.Layout.TextAndIcon && !expanded) {
typedArgument("expanded", expanded)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
<string name="app_components_button_tech" translatable="false">Button</string>
<string name="app_components_button_description_text">Button is a UI element that triggers an action or event, and is used to initiate tasks or confirming an action.</string>
<string name="app_components_button_button_tech" translatable="false">Button</string>
<string name="app_components_button_button_defaultSize_tech" translatable="false">Default</string>
<string name="app_components_button_navigationButton_tech" translatable="false">Navigation button</string>
<string name="app_components_button_navigationButton_chevron_tech" translatable="false">Chevron</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,39 @@
package com.orange.ouds.core.test

import com.orange.ouds.core.utilities.OudsPreviewableComponent
import org.junit.experimental.runners.Enclosed
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

@RunWith(Parameterized::class)
internal class OudsCircularProgressIndicatorTest(parameter: Any) : OudsComponentSnapshotTest(
OudsPreviewableComponent.CircularProgressIndicator,
parameter,
OudsComponentTestSuite.theme
) {

companion object {
@JvmStatic
@Parameterized.Parameters
internal fun data() = OudsPreviewableComponent.CircularProgressIndicator.parameters
@RunWith(Enclosed::class)
internal class OudsCircularProgressIndicatorTest {

@RunWith(Parameterized::class)
class Default(parameter: Any) : OudsComponentSnapshotTest(
OudsPreviewableComponent.CircularProgressIndicator.Default,
parameter,
OudsComponentTestSuite.theme
) {

companion object {
@JvmStatic
@Parameterized.Parameters
internal fun data() = OudsPreviewableComponent.CircularProgressIndicator.Default.parameters
}
}


@RunWith(Parameterized::class)
class Sized(parameter: Any) : OudsComponentSnapshotTest(
OudsPreviewableComponent.CircularProgressIndicator.Sized,
parameter,
OudsComponentTestSuite.theme
) {

companion object {
@JvmStatic
@Parameterized.Parameters
internal fun data() = OudsPreviewableComponent.CircularProgressIndicator.Sized.parameters
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import org.junit.runners.Suite
OudsPinCodeInputTest::class,
OudsRadioButtonItemTest::class,
OudsRadioButtonTest::class,
OudsSmallButtonTest::class,
OudsSuggestionChipTest::class,
OudsSwitchItemTest::class,
OudsSwitchTest::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ internal class OudsNavigationButtonTest {
}
}

class WithRoundedCorners : OudsComponentSnapshotTest(
OudsPreviewableComponent.NavigationButton.WithRoundedCorners,
parameter = null,
OudsComponentTestSuite.theme
)

class OnTwoLines : OudsComponentSnapshotTest(
OudsPreviewableComponent.NavigationButton.OnTwoLines,
parameter = null,
OudsComponentTestSuite.theme
)
}
}
Loading