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

Make TextField.error/info slots non-nullable #455

Open
hrach opened this issue Jun 9, 2023 · 1 comment
Open

Make TextField.error/info slots non-nullable #455

hrach opened this issue Jun 9, 2023 · 1 comment
Assignees
Labels
feature New feature or request
Milestone

Comments

@hrach
Copy link
Contributor

hrach commented Jun 9, 2023

Currently, the only solution to this I have is to utilize SubcomposeLayout for rendering, that will make impossible intrinsic measuring on textfield.

But maybe it has its worth. When somebody needs intrinsic measuring, it is quite specific usecase that can be handled without this high-level component.

    SubcomposeLayout { constraints ->
        val errorPlaceable = subcompose("error") {
            error()
        }.firstOrNull()?.measure(constraints)
        val infoPlaceable = subcompose("info") {
            info()
        }.firstOrNull()?.measure(constraints)

        val hasError = errorPlaceable != null && errorPlaceable.height > 0
        val hasInfo = infoPlaceable != null && infoPlaceable.height > 0
        val state = when {
            hasError -> Message.Error(error)
            hasInfo -> Message.Info(info)
            else -> null
        }

        val messagePlaceable = subcompose("message") {
            AnimatedContent(state) { state -> ... }
        }.first().measure(constraints)

        layout(messagePlaceable.width, messagePlaceable.height) {
            messagePlaceable.placeRelative(0, 0)
        }
    }
@hrach hrach added the feature New feature or request label Jun 9, 2023
@hrach hrach self-assigned this Sep 19, 2023
@hrach hrach added this to the Q4/2023 milestone Sep 20, 2023
@hrach
Copy link
Contributor Author

hrach commented Oct 14, 2023

@hrach hrach modified the milestones: Q4/2023, Q1/2024 Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant