Merge pull request #5 from SebastianAigner/aigner-update-readme

Update README images and code
This commit is contained in:
Nikita Lipsky 2023-04-03 15:40:17 +03:00 committed by GitHub
commit c005b55e42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 13 deletions

View file

@ -142,17 +142,27 @@ run configuration.
### Make your first changes ### Make your first changes
The common entry point for your Compose Multiplatform app is located in `shared/src/commonMain/kotlin/App.kt`. Here, you will see the code that is responsible for rendering the "Hello, World" button. If you make changes here, you will see them reflected on both Android and iOS: The common entry point for your Compose Multiplatform app is located in `shared/src/commonMain/kotlin/App.kt`. Here, you will see the code that is responsible for rendering the "Hello, World" button and the animated Compose Multplatform logo. If you make changes here, you will see them reflected on both Android and iOS:
```kotlin ```kotlin
@OptIn(ExperimentalResourceApi::class)
@Composable @Composable
internal fun App() { internal fun App() {
MaterialTheme { MaterialTheme {
var text by remember { mutableStateOf("Hello, World!") } var greetingText by remember { mutableStateOf("Hello, World!") }
var showImage by remember { mutableStateOf(false) }
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
Button(onClick = { Button(onClick = {
text = "Hello, ${getPlatformName()}" greetingText = "Hello, ${getPlatformName()}"
showImage = !showImage
}) { }) {
Text(text) Text(greetingText)
}
AnimatedVisibility(showImage) {
Image(
painterResource("compose-multiplatform.xml"),
null
)
}
} }
} }
} }
@ -160,18 +170,27 @@ internal fun App() {
Update the shared code by adding a text field that will update the name displayed on the button: Update the shared code by adding a text field that will update the name displayed on the button:
```kotlin ```diff
@OptIn(ExperimentalResourceApi::class)
@Composable @Composable
internal fun App() { internal fun App() {
MaterialTheme { MaterialTheme {
var text by remember { mutableStateOf("Hello, World!") } var greetingText by remember { mutableStateOf("Hello, World!") }
Column { var showImage by remember { mutableStateOf(false) }
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
Button(onClick = { Button(onClick = {
text = "Hello, ${getPlatformName()}" greetingText = "Hello, ${getPlatformName()}"
showImage = !showImage
}) { }) {
Text(text) Text(greetingText)
}
+ TextField(greetingText, onValueChange = { greetingText = it })
AnimatedVisibility(showImage) {
Image(
painterResource("compose-multiplatform.xml"),
null
)
} }
TextField(text, onValueChange = { text = it })
} }
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 KiB

After

Width:  |  Height:  |  Size: 292 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 93 KiB