From b964b793e7a10558ad84756d780e40a5c76a203f Mon Sep 17 00:00:00 2001 From: "Danil.Pavlov" Date: Fri, 15 Sep 2023 14:56:42 +0200 Subject: [PATCH] update: review suggestions --- .../multiplatform-mobile-create-first-app.md | 19 ++++++++++++------- .../multiplatform-mobile-dependencies.md | 2 +- .../multiplatform-mobile-getting-started.md | 2 +- .../multiplatform-mobile-setup.md | 2 +- .../multiplatform-mobile-update-ui.md | 8 ++++---- .../multiplatform-mobile-upgrade-app.md | 4 ++-- .../multiplatform-mobile-wrap-up.md | 2 +- 7 files changed, 22 insertions(+), 17 deletions(-) diff --git a/docs/topics/multiplatform-mobile/multiplatform-mobile-create-first-app.md b/docs/topics/multiplatform-mobile/multiplatform-mobile-create-first-app.md index c38ed4ba5a2..3d02bac7df9 100644 --- a/docs/topics/multiplatform-mobile/multiplatform-mobile-create-first-app.md +++ b/docs/topics/multiplatform-mobile/multiplatform-mobile-create-first-app.md @@ -4,7 +4,7 @@

This is the second part of the Getting started with Kotlin Multiplatform for mobile tutorial. Before proceeding, make sure you've completed the previous step.

First step Set up an environment
Second step Create your first cross-platform app
- Third step Update UI
+ Third step Update the user interface
Fourth step Add dependencies
Fifth step Share more logic
Sixth step Wrap up your project

@@ -73,7 +73,7 @@ When it is built into an iOS framework, common Kotlin gets treated as Kotlin/Nat ![Common Kotlin, Kotlin/JVM, and Kotlin/Native](modules-structure.png) -### Writing common declarations +### Write common declarations The common source set contains shared code that can be used across multiple target platforms. It's designed to contain code that is platform-independent. If you try to use platform-specific APIs in the common source set, @@ -113,7 +113,7 @@ IDE will show a warning: Writing the code only in common Kotlin has obvious limitations because it can't use any platform specifics. Using interfaces and the [expect/actual](multiplatform-connect-to-apis.md) mechanism solves this. -### Adding platform-specific implementations +### Add platform-specific implementations The common source set can define an interface or an expected declaration. Then each platform source sets, in this case `androidMain` and `iosMain`, has to provide actual platform-specific implementations for the expected @@ -142,7 +142,9 @@ and generates a single declaration with actual implementations. override val name: String = "Android ${Build.VERSION.SDK_INT}" } - + ``` + + ```kotlin // Platform.kt in the iosMain module: import platform.UIKit.UIDevice @@ -151,7 +153,6 @@ and generates a single declaration with actual implementations. UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion } ``` - {validate="false"} * The `name` property implementation from `AndroidPlatform` uses the Android platform code, namely the `android.os.Build` dependency. This code is written in Kotlin/JVM. If you try to access `java.util.Random` here, this code will compile. @@ -165,10 +166,14 @@ and generates a single declaration with actual implementations. ```kotlin // Platform.kt in commonMain module: expect fun getPlatform(): Platform - + ``` + + ```kotlin // Platform.kt in androidMain module: actual fun getPlatform(): Platform = AndroidPlatform() - + ``` + + ```kotlin // Platform.kt in iosMain module: actual fun getPlatform(): Platform = IOSPlatform() ``` diff --git a/docs/topics/multiplatform-mobile/multiplatform-mobile-dependencies.md b/docs/topics/multiplatform-mobile/multiplatform-mobile-dependencies.md index 89db3f80d95..b9de0d3950e 100644 --- a/docs/topics/multiplatform-mobile/multiplatform-mobile-dependencies.md +++ b/docs/topics/multiplatform-mobile/multiplatform-mobile-dependencies.md @@ -4,7 +4,7 @@

This is the fourth part of the Getting started with Kotlin Multiplatform for mobile tutorial. Before proceeding, make sure you've completed previous steps.

First step Set up an environment
Second step Create your first cross-platform app
- Third step Update UI
+ Third step Update the user interface
Fourth step Add dependencies
Fifth step Share more logic
Sixth step Wrap up your project

diff --git a/docs/topics/multiplatform-mobile/multiplatform-mobile-getting-started.md b/docs/topics/multiplatform-mobile/multiplatform-mobile-getting-started.md index 8e25b0e6dbb..2103e499ddb 100644 --- a/docs/topics/multiplatform-mobile/multiplatform-mobile-getting-started.md +++ b/docs/topics/multiplatform-mobile/multiplatform-mobile-getting-started.md @@ -36,7 +36,7 @@ Get to know Kotlin Multiplatform and create a mobile app that works on both Andr ![Second step](icon-2.svg){width=25}{type="joined"} [Create your first app that works both on Android and iOS with the IDE](multiplatform-mobile-create-first-app.md) -![Third step](icon-3.svg){width=25}{type="joined"} [Update UI](multiplatform-mobile-update-ui.md) +![Third step](icon-3.svg){width=25}{type="joined"} [Update the user interface](multiplatform-mobile-update-ui.md) ![Fourth step](icon-4.svg){width=25}{type="joined"} [Add dependencies to your project](multiplatform-mobile-dependencies.md) diff --git a/docs/topics/multiplatform-mobile/multiplatform-mobile-setup.md b/docs/topics/multiplatform-mobile/multiplatform-mobile-setup.md index 64d3d4e9a3d..f5d678ae5eb 100644 --- a/docs/topics/multiplatform-mobile/multiplatform-mobile-setup.md +++ b/docs/topics/multiplatform-mobile/multiplatform-mobile-setup.md @@ -4,7 +4,7 @@

This is the first part of the Getting started with Kotlin Multiplatform for mobile tutorial:

First step Set up an environment
Second step Create your first cross-platform app
- Third step Update UI
+ Third step Update the user interface
Fourth step Add dependencies
Fifth step Share more logic
Sixth step Wrap up your project

diff --git a/docs/topics/multiplatform-mobile/multiplatform-mobile-update-ui.md b/docs/topics/multiplatform-mobile/multiplatform-mobile-update-ui.md index f30a4333836..52a3131427a 100644 --- a/docs/topics/multiplatform-mobile/multiplatform-mobile-update-ui.md +++ b/docs/topics/multiplatform-mobile/multiplatform-mobile-update-ui.md @@ -1,10 +1,10 @@ -[//]: # (title: Update UI) +[//]: # (title: Update the user interface)

This is the third part of the Getting started with Kotlin Multiplatform for mobile tutorial. Before proceeding, make sure you've completed previous steps.

First step Set up an environment
Second step Create your first cross-platform app
- Third step Update UI
+ Third step Update the user interface
Fourth step Add dependencies
Fifth step Share more logic
Sixth step Wrap up your project

@@ -15,7 +15,7 @@ for the Android part of your project and [SwiftUI](https://developer.apple.com/x These are both declarative UI frameworks, and you'll see similarities in the UI implementations. In both cases, you store the data in the `phrases` variable and later iterate over it to produce a list of `Text` items. -### The Android module +### Update the Android module The `androidApp` module contains an Android application, defines its main activity and the UI views, and uses the `shared` module as a regular Android library. The UI of the application uses the Jetpack Compose framework. @@ -73,7 +73,7 @@ Make some changes and see how it is reflected in the UI: ![Updated UI of Android multiplatform app](first-multiplatform-project-on-android-2.png){width=300} -### The iOS module +### Work with the iOS module in Xcode `iosApp` is an Xcode project that builds into an iOS application. It depends on and uses the `shared` module as an iOS framework. The UI of the app is written in Swift. diff --git a/docs/topics/multiplatform-mobile/multiplatform-mobile-upgrade-app.md b/docs/topics/multiplatform-mobile/multiplatform-mobile-upgrade-app.md index ae22dae27d1..6b61b800d53 100644 --- a/docs/topics/multiplatform-mobile/multiplatform-mobile-upgrade-app.md +++ b/docs/topics/multiplatform-mobile/multiplatform-mobile-upgrade-app.md @@ -1,10 +1,10 @@ -[//]: # (title: Share the logic) +[//]: # (title: Share more logic between iOS and Android)

This is the fifth part of the Getting started with Kotlin Multiplatform for mobile tutorial. Before proceeding, make sure you've completed previous steps.

First step Set up an environment
Second step Create your first cross-platform app
- Third step Update UI
+ Third step Update the user interface
Fourth step Add dependencies
Fifth step Share more logic
Sixth step Wrap up your project

diff --git a/docs/topics/multiplatform-mobile/multiplatform-mobile-wrap-up.md b/docs/topics/multiplatform-mobile/multiplatform-mobile-wrap-up.md index c419c7dae07..a6711dc151f 100644 --- a/docs/topics/multiplatform-mobile/multiplatform-mobile-wrap-up.md +++ b/docs/topics/multiplatform-mobile/multiplatform-mobile-wrap-up.md @@ -4,7 +4,7 @@

This is final part of the Getting started with Kotlin Multiplatform for mobile tutorial. Before proceeding, make sure you've completed previous steps.

First step Set up an environment
Second step Create your first cross-platform app
- Third step Update UI
+ Third step Update the user interface
Fourth step Add dependencies
Fifth step Share more logic
Sixth step Wrap up your project