The Multipicker library features a collection of easily implementable composable pickers.
Current pickers:
- TextPicker
- NumberPicker
- TimePicker
- Add it in root build.gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {url = uri("https://jitpack.io")}
}
}
- Add the dependency
implementation ("com.github.returdev:multipickers:$version")
Short Picker |
Long Picker |
Time Picker |
Picker with colorful selection |
@Composable
fun TextPicker() {
val textList = listOf("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten")
val pickerState = rememberSaveablePickerState(
itemsCount = textList.size
)
TextPicker(items = textList, pickerState = pickerState)
}
@Composable
fun NumberPicker() {
val numberList = (0..100).toList()
val pickerState = rememberSaveablePickerState(
itemsCount = numberList.size,
pickerLength = PickerLength.Long
)
TimePicker(pickerState = pickerState)
}
@Composable
fun TimePickerPreview() {
val pickerState = rememberTimePickerState(
initialHour = 12,
initialMinute = 30,
initialSecond = 0,
pickerLength = PickerLength.LONG
)
NumberPicker(items = numberList, pickerState = pickerState)
}
Copyright 2024 ReturDev
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.