Browse Source

Update README.md

pull/1777/head
Igor Demin 3 years ago committed by GitHub
parent
commit
b83d681c1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      tutorials/Window_API_new/README.md

6
tutorials/Window_API_new/README.md

@ -46,6 +46,8 @@ fun main() = application {
``` ```
<img alt="Window properties" src="window_properties.gif" height="260" /> <img alt="Window properties" src="window_properties.gif" height="260" />
## Open and close windows (conditionally)
You can also close/open windows using a simple `if` statement. You can also close/open windows using a simple `if` statement.
When the `Window` leaves the composition (`isPerformingTask` becomes `false`) – the native window automatically closes. When the `Window` leaves the composition (`isPerformingTask` becomes `false`) – the native window automatically closes.
@ -122,6 +124,8 @@ fun main() = application {
``` ```
<img alt="Ask to close" src="ask_to_close.gif" height="309" /> <img alt="Ask to close" src="ask_to_close.gif" height="309" />
## Hide the window into the tray
If you don't need to close the window and just need to hide it (for example to the tray), you can change the `windowState.isVisible` state: If you don't need to close the window and just need to hide it (for example to the tray), you can change the `windowState.isVisible` state:
```kotlin ```kotlin
import androidx.compose.material.Text import androidx.compose.material.Text
@ -179,6 +183,8 @@ object TrayIcon : Painter() {
``` ```
<img alt="Hide instead of closing" src="hide_instead_of_close.gif" height="308" /> <img alt="Hide instead of closing" src="hide_instead_of_close.gif" height="308" />
## Open and close multiple windows
If an application has multiple windows, then it is better to put its state into a separate class and open/close window in response to `mutableStateListOf` changes (see [notepad example](https://github.com/JetBrains/compose-jb/tree/master/examples/notepad) for more complex use cases): If an application has multiple windows, then it is better to put its state into a separate class and open/close window in response to `mutableStateListOf` changes (see [notepad example](https://github.com/JetBrains/compose-jb/tree/master/examples/notepad) for more complex use cases):
```kotlin ```kotlin
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable

Loading…
Cancel
Save