You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: topics/compose-onboard/compose-multiplatform-new-project.md
+26-22Lines changed: 26 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,8 @@ To get started, implement a new `App` composable:
68
68
69
69
When you run your application and click the button, the hardcoded time is displayed.
70
70
71
-
3. Run the application on the desktop. It works, but the window is clearly too large for the UI:
71
+
3. Run the application on the desktop (with the **composeApp [jvm]** run configuration).
72
+
It works, but the window is clearly too large for the UI:
72
73
73
74
{width=400}
74
75
@@ -77,7 +78,7 @@ To get started, implement a new `App` composable:
77
78
```kotlin
78
79
funmain() = application {
79
80
val state = rememberWindowState(
80
-
size =DpSize(400.dp, 250.dp),
81
+
size =DpSize(400.dp, 350.dp),
81
82
position =WindowPosition(300.dp, 300.dp)
82
83
)
83
84
Window(
@@ -94,22 +95,22 @@ To get started, implement a new `App` composable:
94
95
Here, you set the title of the window and use the `WindowState` type to give the window an initial size and position on
95
96
the screen.
96
97
97
-
>To see your changes in real time in the desktop app, use [ComposeHotReload](compose-hot-reload.md):
98
-
>1. In the `main.kt` file, click the **Run** icon in the gutter.
99
-
>2. Select**Run'composeApp [hotRunJvm]' with ComposeHotReload (Beta)**.
100
-
>{width=350}
101
-
>
102
-
>To see the app automatically update, save any modified files (<shortcut>⌘ S</shortcut>/<shortcut>Ctrl+S</shortcut>).
103
-
>
104
-
>ComposeHotReloadis currently in [Beta](https://kotlinlang.org/components-stability.html#stability-levels-explained) so its functionality is subject to change.
105
-
>
106
-
{style="tip"}
107
-
108
98
5. Follow the IDE's instructions to import the missing dependencies.
109
99
6. Run the desktop application again. Its appearance should improve:
110
100
111
101
{width=350}
112
102
103
+
> To see your changes in real time in the desktop app, use [Compose Hot Reload](compose-hot-reload.md):
104
+
> 1. In the `main.kt` file, click the **Run** icon in the gutter.
105
+
> 2. Select **Run 'composeApp [hotRunJvm]' with Compose Hot Reload (Beta)**.
106
+
> {width=350}
107
+
>
108
+
> To see the app automatically update, save any modified files (<shortcut>⌘ S</shortcut> / <shortcut>Ctrl+S</shortcut>).
109
+
>
110
+
> Compose Hot Reload is currently in [Beta](https://kotlinlang.org/components-stability.html#stability-levels-explained) so its functionality is subject to change.
111
+
>
112
+
{style="tip"}
113
+
113
114
<!--
114
115
### Compose Hot Reload demo {initial-collapse-state="collapsed" collapsible="true"}
115
116
@@ -121,7 +122,7 @@ To get started, implement a new `App` composable:
121
122
Now let users enter the name of a city to see the time at that location. The simplest way to achieve this is by adding
122
123
a `TextField` composable:
123
124
124
-
1. Replace the current implementation of `App` with the one below:
125
+
1. Replace the current implementation of `App()` in `commonMain/kotlin/compose.project.demo/App.kt` with the one below:
125
126
126
127
```kotlin
127
128
@Composable
@@ -168,7 +169,8 @@ The next step is to use the given input to calculate time. To do this, create a
168
169
1. Return to the `App.kt` file and add the following function:
169
170
170
171
```kotlin
171
-
fun currentTimeAt(location: String): String? {
172
+
@OptIn(ExperimentalTime::class)
173
+
fun currentTimeAt(location: String): String? {
172
174
fun LocalTime.formatted() = "$hour:$minute:$second"
173
175
174
176
return try {
@@ -300,6 +302,7 @@ list.
300
302
```kotlin
301
303
data class Country(val name: String, val zone: TimeZone)
302
304
305
+
@OptIn(ExperimentalTime::class)
303
306
fun currentTimeAt(location: String, zone: TimeZone): String {
304
307
fun LocalTime.formatted() = "$hour:$minute:$second"
305
308
@@ -405,7 +408,7 @@ modify the build file.
405
408
To support images in your project, you'll need to download image files, store them in the correct directory, and add
406
409
code to load and display them:
407
410
408
-
1. Using an external resource, such as[FlagCDN](https://flagcdn.com/), download flags to match the list of countries
411
+
1. Download flag images from [FlagCDN](https://flagcdn.com/) to match the list of countries
409
412
you have already created. Inthis case, these
410
413
are [Japan](https://flagcdn.com/w320/jp.png), [France](https://flagcdn.com/w320/fr.png), [Mexico](https://flagcdn.com/w320/mx.png), [Indonesia](https://flagcdn.com/w320/id.png),
411
414
and [Egypt](https://flagcdn.com/w320/eg.png).
@@ -419,14 +422,15 @@ code to load and display them:
419
422
4. Update the code in the `commonMain/kotlin/.../App.kt` file to support images:
0 commit comments