Skip to content

Commit 3b5587f

Browse files
authored
Merge pull request #112 from NordicPlayground/feature/slider
Disabled slider added to sample app
2 parents 9b762df + 9662fde commit 3b5587f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

app/src/main/java/no/nordicsemi/android/common/test/main/page/BasicViewsPage.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private fun OtherWidgets() {
178178

179179
var sliderValue by rememberSaveable { mutableFloatStateOf(5.0f) }
180180
Text(
181-
text = stringResource(id = R.string.slider, sliderValue.toInt()),
181+
text = stringResource(id = R.string.slider_int, sliderValue.toInt()),
182182
)
183183
Slider(
184184
value = sliderValue,
@@ -187,6 +187,18 @@ private fun OtherWidgets() {
187187
steps = 9,
188188
colors = NordicSliderDefaults.colors()
189189
)
190+
191+
var disabledSliderValue by rememberSaveable { mutableFloatStateOf(5.0f) }
192+
Text(
193+
text = stringResource(id = R.string.slider_float, disabledSliderValue),
194+
)
195+
Slider(
196+
value = disabledSliderValue,
197+
valueRange = 0.0f..10.0f,
198+
onValueChange = { disabledSliderValue = it },
199+
enabled = checkedSwitch,
200+
colors = NordicSliderDefaults.colors()
201+
)
190202
}
191203
}
192204

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
<string name="action_dialog">Open Dialog</string>
7171

7272
<string name="option">Important option</string>
73-
<string name="slider">Value: %d</string>
73+
<string name="slider_int">Value: %d</string>
74+
<string name="slider_float">Value: %2.2f</string>
7475

7576
<string name="hello">Hello!</string>
7677
<string name="hello_param">Param: %d</string>

0 commit comments

Comments
 (0)