Skip to content

Commit

Permalink
[#83] Review: Remove Companion from TextFieldCustomizationState and r…
Browse files Browse the repository at this point in the history
…ename enabled by isEnabled
  • Loading branch information
paulinea authored and florentmaitre committed May 16, 2022
1 parent 501a4e0 commit d54b40b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ fun SubComponentTextField(subComponent: SubComponent) {
) {
LabelledRadioButton(
selectedRadio = customizationState.selectedState,
currentRadio = TextFieldCustomizationState.Companion.DisplayType.DEFAULT,
currentRadio = TextFieldCustomizationState.DisplayType.DEFAULT,
label = stringResource(id = R.string.component_state_default)
)
LabelledRadioButton(
selectedRadio = customizationState.selectedState,
currentRadio = TextFieldCustomizationState.Companion.DisplayType.ERROR,
currentRadio = TextFieldCustomizationState.DisplayType.ERROR,
label = stringResource(id = R.string.component_state_error)
)
LabelledRadioButton(
selectedRadio = customizationState.selectedState,
currentRadio = TextFieldCustomizationState.Companion.DisplayType.DISABLED,
currentRadio = TextFieldCustomizationState.DisplayType.DISABLED,
label = stringResource(id = R.string.component_state_disabled)
)
}
Expand All @@ -71,17 +71,17 @@ fun SubComponentTextField(subComponent: SubComponent) {
) {
LabelledRadioButton(
selectedRadio = customizationState.selectedTrailingElement,
currentRadio = TextFieldCustomizationState.Companion.TrailingElement.NONE,
currentRadio = TextFieldCustomizationState.TrailingElement.NONE,
label = stringResource(id = R.string.component_element_none)
)
LabelledRadioButton(
selectedRadio = customizationState.selectedTrailingElement,
currentRadio = TextFieldCustomizationState.Companion.TrailingElement.ICON,
currentRadio = TextFieldCustomizationState.TrailingElement.ICON,
label = stringResource(id = R.string.component_element_icon)
)
LabelledRadioButton(
selectedRadio = customizationState.selectedTrailingElement,
currentRadio = TextFieldCustomizationState.Companion.TrailingElement.TEXT,
currentRadio = TextFieldCustomizationState.TrailingElement.TEXT,
label = stringResource(id = R.string.component_element_text)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun TextFieldFilledContent(customizationState: TextFieldCustomizationState) {
.fillMaxWidth()
.padding(top = dimensionResource(id = R.dimen.ods_spacing_xs)),
leadingIcon = if (customizationState.leadingIconChecked.value) painterResource(id = R.drawable.ic_heart) else null,
enabled = customizationState.enabled,
enabled = customizationState.isEnabled,
isError = customizationState.isError,
value = text,
onValueChange = { text = it },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fun TextFieldOutlinedContent(customizationState: TextFieldCustomizationState) {
.fillMaxWidth()
.padding(top = dimensionResource(id = R.dimen.ods_spacing_xs)),
leadingIcon = if (customizationState.leadingIconChecked.value) painterResource(id = R.drawable.ic_heart) else null,
enabled = customizationState.enabled,
enabled = customizationState.isEnabled,
isError = customizationState.isError,
value = text,
onValueChange = { text = it },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import com.orange.ods.demo.ui.components.textfields.TextFieldCustomizationState.Companion.DisplayType
import com.orange.ods.demo.ui.components.textfields.TextFieldCustomizationState.Companion.TrailingElement
import com.orange.ods.demo.ui.components.textfields.TextFieldCustomizationState.DisplayType
import com.orange.ods.demo.ui.components.textfields.TextFieldCustomizationState.TrailingElement

@Composable
fun rememberTextFieldCustomizationState(
Expand All @@ -33,17 +33,15 @@ class TextFieldCustomizationState(
val selectedState: MutableState<DisplayType>,
val selectedTrailingElement: MutableState<TrailingElement>
) {
companion object {
enum class DisplayType {
DEFAULT, ERROR, DISABLED
}

enum class TrailingElement {
NONE, ICON, TEXT
}
enum class DisplayType {
DEFAULT, ERROR, DISABLED
}

val enabled
enum class TrailingElement {
NONE, ICON, TEXT
}

val isEnabled
get() = selectedState.value != DisplayType.DISABLED

val isError
Expand Down

0 comments on commit d54b40b

Please sign in to comment.