Skip to content

Commit 892ad49

Browse files
committed
Annotated text switch is now disabled when error is disabled in control item demo screens
1 parent f883fe1 commit 892ad49

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

app/src/main/java/com/orange/ouds/app/ui/components/controlitem/ControlItemDemoScreen.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ fun ControlItemAnnotatedTextCustomization(state: ControlItemDemoState) {
162162
CustomizationSwitchItem(
163163
label = stringResource(id = R.string.app_components_common_annotatedText_tech),
164164
checked = annotatedText,
165-
onCheckedChange = { annotatedText = it }
165+
onCheckedChange = { annotatedText = it },
166+
enabled = annotatedTextSwitchEnabled
166167
)
167168
}
168169
}

app/src/main/java/com/orange/ouds/app/ui/components/controlitem/ControlItemDemoState.kt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,7 @@ open class ControlItemDemoState(
8686
var label: String by mutableStateOf(label)
8787
var description: String? by mutableStateOf(description)
8888

89-
private var _annotatedText: Boolean by mutableStateOf(annotatedText)
90-
var annotatedText: Boolean
91-
get() = _annotatedText
92-
set(value) {
93-
_annotatedText = value
94-
if (value) {
95-
error = true
96-
}
97-
}
89+
var annotatedText: Boolean by mutableStateOf(annotatedText)
9890

9991
val enabledSwitchEnabled: Boolean
10092
get() = !error
@@ -108,6 +100,9 @@ open class ControlItemDemoState(
108100
val errorMessageTextInputEnabled: Boolean
109101
get() = error && !annotatedText
110102

103+
val annotatedTextSwitchEnabled: Boolean
104+
get() = error
105+
111106
enum class Icon(@StringRes val labelRes: Int) {
112107
None(R.string.app_components_common_none_tech),
113108
Tinted(R.string.app_components_common_tintedIcon_tech),

0 commit comments

Comments
 (0)