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

Implement OptimisingLayout #29

Merged
merged 2 commits into from
Oct 16, 2023
Merged

Implement OptimisingLayout #29

merged 2 commits into from
Oct 16, 2023

Conversation

KovalevAndrey
Copy link
Collaborator

Implement OptimisingLayout which calculates scaling factor based on the optimal and available space

Box(modifier = modifier) {
BoxWithConstraints(
modifier = Modifier
.fillMaxSize(0.84f)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8% padding on each side instead of hardcoded padding values

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't hardcode it here (+ the alignment too), this should depend on the call site composable probably.

What if you wouldn't have Box + BoxWithConstraints but just the latter, then apply the incoming modifier to it rather than on the outer Box.

Box(modifier = modifier) {
BoxWithConstraints(
modifier = Modifier
.fillMaxSize(0.84f)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't hardcode it here (+ the alignment too), this should depend on the call site composable probably.

What if you wouldn't have Box + BoxWithConstraints but just the latter, then apply the incoming modifier to it rather than on the outer Box.

.align(Alignment.Center)
) {
ScaledLayout(
scale = ([email protected] / optimalWidth).coerceIn(0.1f, 1f),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why coerceIn(0.1f, 1f)?

I mean both: why these specific values + whether this could be a call site parameter.

Copy link
Collaborator Author

@KovalevAndrey KovalevAndrey Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't go above 1f, the lower value probably can be unrestricted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't be using it above 1f but I guess it can still make sense? Not too important though.

@KovalevAndrey KovalevAndrey merged commit 0983ca1 into main Oct 16, 2023
2 checks passed
@KovalevAndrey KovalevAndrey deleted the optimised-layout branch October 16, 2023 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants