1 /*
2 * Copyright 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package androidx.wear.compose.material.samples
18
19 import androidx.annotation.Sampled
20 import androidx.compose.runtime.Composable
21 import androidx.compose.runtime.getValue
22 import androidx.compose.runtime.mutableStateOf
23 import androidx.compose.runtime.remember
24 import androidx.compose.runtime.setValue
25 import androidx.wear.compose.material.Icon
26 import androidx.wear.compose.material.InlineSlider
27 import androidx.wear.compose.material.InlineSliderDefaults
28
29 @Sampled
30 @Composable
InlineSliderSamplenull31 fun InlineSliderSample() {
32 var value by remember { mutableStateOf(4.5f) }
33 InlineSlider(
34 value = value,
35 onValueChange = { value = it },
36 increaseIcon = { Icon(InlineSliderDefaults.Increase, "Increase") },
37 decreaseIcon = { Icon(InlineSliderDefaults.Decrease, "Decrease") },
38 valueRange = 3f..6f,
39 steps = 5,
40 segmented = false
41 )
42 }
43
44 @Sampled
45 @Composable
InlineSliderSegmentedSamplenull46 fun InlineSliderSegmentedSample() {
47 var value by remember { mutableStateOf(2f) }
48 InlineSlider(
49 value = value,
50 onValueChange = { value = it },
51 increaseIcon = { Icon(InlineSliderDefaults.Increase, "Increase") },
52 decreaseIcon = { Icon(InlineSliderDefaults.Decrease, "Decrease") },
53 valueRange = 1f..4f,
54 steps = 7,
55 segmented = true
56 )
57 }
58
59 @Sampled
60 @Composable
InlineSliderWithIntegerSamplenull61 fun InlineSliderWithIntegerSample() {
62 var value by remember { mutableStateOf(4) }
63 InlineSlider(
64 value = value,
65 onValueChange = { value = it },
66 increaseIcon = { Icon(InlineSliderDefaults.Increase, "Increase") },
67 decreaseIcon = { Icon(InlineSliderDefaults.Decrease, "Decrease") },
68 valueProgression = 0..10,
69 segmented = false
70 )
71 }
72