Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WheelTextPicker: startIndex positions element askew #37

Open
midenok opened this issue Jul 7, 2023 · 0 comments
Open

WheelTextPicker: startIndex positions element askew #37

midenok opened this issue Jul 7, 2023 · 0 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@midenok
Copy link

midenok commented Jul 7, 2023

@Composable
fun WheelPicker()
{
    // FIXME: meaningless mutable state for output only?
    var snappedDT:LocalDateTime by remember { mutableStateOf(LocalDateTime.MIN) }
    var snappedD:LocalDate by remember { mutableStateOf(LocalDate.MIN) }
    var snappedT:LocalTime by remember { mutableStateOf(LocalTime.MIN) }

    Column {
        WheelDateTimePicker(
            startDateTime = LocalDateTime.of(
                2025, 10, 20, 5, 30
            ),
            minDateTime = LocalDateTime.now(),
            maxDateTime = LocalDateTime.of(
                2025, 10, 20, 5, 30
            ),
            timeFormat = TimeFormat.AM_PM,
            size = DpSize(200.dp, 100.dp),
            rowCount = 5,
            textStyle = MaterialTheme.typography.titleSmall,
            textColor = Color(0xFFffc300),
            selectorProperties = WheelPickerDefaults.selectorProperties(
                enabled = true,
                shape = RoundedCornerShape(0.dp),
                color = Color(0xFFf1faee).copy(alpha = 0.2f),
                border = BorderStroke(2.dp, Color(0xFFf1faee))
            )
        ) { snappedDateTime -> snappedDT = snappedDateTime }

        WheelDateTimePicker { snappedDateTime -> snappedDT = snappedDateTime}

        WheelDatePicker { snappedDate -> snappedD = snappedDate }

        WheelTimePicker { snappedTime -> snappedT = snappedTime }

        WheelTimePicker(timeFormat = TimeFormat.AM_PM) { snappedTime -> snappedT = snappedTime }

        WheelTextPicker(texts = (0..99).toList().map { it.toString() }, rowCount = 5, startIndex = 21)
    }
}

It positions the element like that:

image

After touching it with mouse it repositions it properly:

image

@commandiron commandiron added bug Something isn't working enhancement New feature or request labels Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants