-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#141] Rename ComponentCustomizationChipRow to ComponentChipRow
- Loading branch information
1 parent
7847a0e
commit 389bd62
Showing
3 changed files
with
63 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
demo/src/main/java/com/orange/ods/demo/ui/components/utilities/ComponentChipRow.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* | ||
* Copyright 2021 Orange | ||
* | ||
* Use of this source code is governed by an MIT-style | ||
* license that can be found in the LICENSE file or at | ||
* https://opensource.org/licenses/MIT. | ||
* / | ||
*/ | ||
|
||
package com.orange.ods.demo.ui.components.utilities | ||
|
||
import androidx.annotation.StringRes | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.selection.selectableGroup | ||
import androidx.compose.material.ExperimentalMaterialApi | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.MutableState | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.dimensionResource | ||
import androidx.compose.ui.res.stringResource | ||
import com.google.accompanist.flowlayout.FlowRow | ||
import com.orange.ods.compose.component.chip.OdsChip | ||
import com.orange.ods.demo.R | ||
|
||
@Composable | ||
fun <T> ComponentChipRow(selectedChip: MutableState<T>, content: @Composable ComponentChipRowScope<T>.() -> Unit) { | ||
FlowRow( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.selectableGroup() | ||
.padding(horizontal = dimensionResource(id = R.dimen.ods_screen_horizontal_margin)), | ||
mainAxisSpacing = dimensionResource(id = R.dimen.spacing_s), | ||
content = { ComponentChipRowScope(selectedChip).content() } | ||
) | ||
} | ||
|
||
@ExperimentalMaterialApi | ||
@Composable | ||
fun <T> ComponentChipRowScope<T>.ComponentChip(@StringRes textRes: Int, value: T) { | ||
OdsChip( | ||
text = stringResource(id = textRes), | ||
selected = selectedChip.value == value, | ||
onClick = { selectedChip.value = value } | ||
) | ||
} | ||
|
||
data class ComponentChipRowScope<T>(val selectedChip: MutableState<T>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters