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

Add WindowInfo.containerSize #785

Merged
merged 8 commits into from
Sep 5, 2023
Merged

Conversation

MatkovIvan
Copy link
Member

@MatkovIvan MatkovIvan commented Sep 1, 2023

Proposed Changes

  • Add WindowInfo.containerSize public API

It requires for max available space calculation in some material components.

Testing

Test: Try to get window size via LocalWindowInfo.current

@m-sasha
Copy link

m-sasha commented Sep 1, 2023

Consider adding a (skiko) unit test.

@m-sasha
Copy link

m-sasha commented Sep 1, 2023

Maybe also add WindowInfo.position? See my request from 2022: JetBrains/compose-multiplatform#1873

@MatkovIvan MatkovIvan changed the title Add WindowInfo.size Add WindowInfo.containerSize Sep 4, 2023
Copy link
Collaborator

@igordmn igordmn left a comment

Choose a reason for hiding this comment

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

Let's wait for @m-sasha approval

Comment on lines +155 to +160

assertThat(window.scene.platform.windowInfo.containerSize)
.isEqualTo(IntSize(
width = (234 * window.density.density).toInt(),
height = (345 * window.density.density).toInt(),
))
Copy link

Choose a reason for hiding this comment

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

I think it's better to test WindowInfo separately from other things. A good test should validate one thing.

Also, don't you want to test it inside the composition (i.e. with LocalWindow.current.containerSize?

@MatkovIvan MatkovIvan merged commit d073850 into jb-main Sep 5, 2023
3 checks passed
@MatkovIvan MatkovIvan deleted the ivan.matkov/windowinfo-size branch September 5, 2023 10:41
igordmn added a commit that referenced this pull request Sep 14, 2023
Fixes a CI fail:
https://teamcity.jetbrains.com/buildConfiguration/JetBrainsPublicProjects_Compose_Publish_2_AllGitHubRelease/4313900?buildTab=dependencies&mode=list&state=failed&type=snapshot&hideProblemsFromDependencies=false&hideTestsFromDependencies=false&expandBuildProblemsSection=true&showLog=4313895_245_235.297&logFilter=debug&logView=flowAware#4313895

As it was before #785

Also:
- add default getters for source compatibility
- add JvmDefaultWithCompatibility to keep binary compatibility on JVM

## Test
```
import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.window.singleWindowApplication

fun main() = singleWindowApplication {
    val modifiers = LocalWindowInfo.current.keyboardModifiers
}

```
This shouldn't require OptIn
igordmn added a commit that referenced this pull request Sep 14, 2023
Fixes a CI fail:

https://teamcity.jetbrains.com/buildConfiguration/JetBrainsPublicProjects_Compose_Publish_2_AllGitHubRelease/4313900?buildTab=dependencies&mode=list&state=failed&type=snapshot&hideProblemsFromDependencies=false&hideTestsFromDependencies=false&expandBuildProblemsSection=true&showLog=4313895_245_235.297&logFilter=debug&logView=flowAware#4313895

As it was before
#785

Also:
- add default getters for source compatibility
- add JvmDefaultWithCompatibility to keep binary compatibility on JVM

## Testing
```
import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.window.singleWindowApplication

fun main() = singleWindowApplication {
    val modifiers = LocalWindowInfo.current.keyboardModifiers
}

```
This shouldn't require OptIn
igordmn added a commit that referenced this pull request Sep 14, 2023
Fixes a CI fail:

https://teamcity.jetbrains.com/buildConfiguration/JetBrainsPublicProjects_Compose_Publish_2_AllGitHubRelease/4313900?buildTab=dependencies&mode=list&state=failed&type=snapshot&hideProblemsFromDependencies=false&hideTestsFromDependencies=false&expandBuildProblemsSection=true&showLog=4313895_245_235.297&logFilter=debug&logView=flowAware#4313895

As it was before
#785

Also:
- add default getters for source compatibility
- add JvmDefaultWithCompatibility to keep binary compatibility on JVM

## Testing
```
import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.window.singleWindowApplication

fun main() = singleWindowApplication {
    val modifiers = LocalWindowInfo.current.keyboardModifiers
}

```
This shouldn't require OptIn
igordmn pushed a commit that referenced this pull request Nov 15, 2023
* Add WindowInfo.size

* Address feedback

* Use delegated property in WindowInfoImpl

* Revert size rounding

* Rename to containerSize

* Add windowInfo.containerSize checks

* Address feedback

* Provide LocalWindowInfo in tests
igordmn added a commit that referenced this pull request Nov 15, 2023
#818)

Fixes a CI fail:

https://teamcity.jetbrains.com/buildConfiguration/JetBrainsPublicProjects_Compose_Publish_2_AllGitHubRelease/4313900?buildTab=dependencies&mode=list&state=failed&type=snapshot&hideProblemsFromDependencies=false&hideTestsFromDependencies=false&expandBuildProblemsSection=true&showLog=4313895_245_235.297&logFilter=debug&logView=flowAware#4313895

As it was before
#785

Also:
- add default getters for source compatibility
- add JvmDefaultWithCompatibility to keep binary compatibility on JVM

## Testing
```
import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.window.singleWindowApplication

fun main() = singleWindowApplication {
    val modifiers = LocalWindowInfo.current.keyboardModifiers
}

```
This shouldn't require OptIn
igordmn pushed a commit that referenced this pull request Nov 16, 2023
…rdModifiers (#818)

Fixes a CI fail:

https://teamcity.jetbrains.com/buildConfiguration/JetBrainsPublicProjects_Compose_Publish_2_AllGitHubRelease/4313900?buildTab=dependencies&mode=list&state=failed&type=snapshot&hideProblemsFromDependencies=false&hideTestsFromDependencies=false&expandBuildProblemsSection=true&showLog=4313895_245_235.297&logFilter=debug&logView=flowAware#4313895

As it was before
#785

Also:
- add default getters for source compatibility
- add JvmDefaultWithCompatibility to keep binary compatibility on JVM

## Testing
```
import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.window.singleWindowApplication

fun main() = singleWindowApplication {
    val modifiers = LocalWindowInfo.current.keyboardModifiers
}

```
This shouldn't require OptIn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants