Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Samples
| Sample | Description | Platforms |
| ------------------------------------ | -------------------------------------------------------------------------------------------- | --------------------- |
| [Imageviewer](imageviewer) | Image Viewer application | Android, iOS, Desktop |
| [Codeviewer](codeviewer) | File browser and code viewer application | Android, iOS, Desktop |
| [Chat](chat) | A simple chat | Android, iOS, Desktop |
| [Graphics2D](graphics-2d) | 2D Games and graphics examples | Android, iOS, Desktop |
| [Nav Cupcake](nav_cupcake) | Multiscreen app to demonstrate the use of Compose Navigation | Android, iOS, Desktop |
| [Issues tracker](issues) | GitHub issue tracker with an adaptive UI and ktor-client | Android, Desktop |
| [HTML based samples](html/README.md) | Examples written with Compose HTML Library |
| Sample | Description | Platforms |
| -------------------------------------- |:---------------------------------------------------------| -------------------------- |
| [Imageviewer](imageviewer) | Image Viewer | Android, iOS, Desktop, Web |
| [Codeviewer](codeviewer) | File browser and code viewer | Android, iOS, Desktop, Web |
| [Chat](chat) | A simple chat | Android, iOS, Desktop, Web |
| [Graphics2D](graphics-2d) | 2D Games and graphics examples | Android, iOS, Desktop, Web |
| [Nav Cupcake](nav_cupcake) | Multiscreen app using Compose Navigation 2 | Android, iOS, Desktop, Web |
| [Issues tracker](issues) | GitHub issue tracker with an adaptive UI and ktor-client | Android, Desktop |
| [Compose HTML samples](html/README.md) | Examples written with Compose HTML Library | Web |
56 changes: 56 additions & 0 deletions examples/buildWithKotlinToolchain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

# Script to build an example with the Kotlin Toolchain, optionally with the given Compose and Kotlin versions.
# The Kotlin Toolchain can't override versions from the command line, so in that case the example is copied
# to a temporary directory, and every module there applies a template with the versions and the dev maven repo.

set -euo pipefail

if [ "$#" -lt 2 ] || [ "$#" -gt 4 ]; then
echo "Specify the example, the platform and optionally Compose and Kotlin versions. For example: ./buildWithKotlinToolchain.sh codeviewer jvm 1.13.0-alpha03 2.3.20"
exit 1
fi

example="$1"
platform="$2"
compose_version="${3:-}"
kotlin_version="${4:-}"
build_dir="$example"

if [ -n "$compose_version" ]; then
temp_dir="$(mktemp -d)"
# Keep the copy if the build fails, so that its logs can be inspected
trap 'if [ "$?" -eq 0 ]; then rm -rf "$temp_dir"; else echo "Failed $example, its copy is kept in $temp_dir"; fi' EXIT

tar -C "$example" --exclude=./build -cf - . | tar -C "$temp_dir" -xf -
echo "Building a copy of $example in $temp_dir with Compose $compose_version${kotlin_version:+ and Kotlin $kotlin_version}"

template="validation-versions.module-template.yaml"
{
echo "repositories:"
echo " - https://packages.jetbrains.team/maven/p/cmp/dev"
echo
echo "settings:"
echo " compose:"
echo " version: $compose_version"
if [ -n "$kotlin_version" ]; then
echo " kotlin:"
echo " version: $kotlin_version"
fi
} > "$temp_dir/$template"

find "$temp_dir" -name module.yaml | while read -r module; do
{ printf 'apply:\n - //%s\n\n' "$template"; cat "$module"; } > "$module.tmp"
mv "$module.tmp" "$module"
done

if [ -f "$temp_dir/libs.versions.toml" ]; then
sed -E "s/^(compose-multiplatform[[:space:]]*=[[:space:]]*).*/\1\"$compose_version\"/" "$temp_dir/libs.versions.toml" > "$temp_dir/libs.versions.toml.tmp"
mv "$temp_dir/libs.versions.toml.tmp" "$temp_dir/libs.versions.toml"
fi

build_dir="$temp_dir"
fi

cd "$build_dir"
./kotlin build -p "$platform"
4 changes: 4 additions & 0 deletions examples/codeviewer/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.bat text eol=crlf

# Kotlin CLI wrapper without extension
kotlin text eol=lf
22 changes: 9 additions & 13 deletions examples/codeviewer/.gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
build/
.kotlin/
.idea/
*.iml
.gradle
/local.properties
/.idea
.DS_Store
build/
/captures
.externalNativeBuild
.cxx
iosApp/Podfile.lock
iosApp/Pods/*
iosApp/iosApp.xcworkspace/*
iosApp/iosApp.xcodeproj/*
!iosApp/iosApp.xcodeproj/project.pbxproj
shared/shared.podspec
**/module.xcodeproj/*
!**/module.xcodeproj/project.pbxproj
!**/module.xcodeproj/xcshareddata/
!**/module.xcodeproj/project.xcworkspace/
**/xcshareddata/WorkspaceSettings.xcsettings
xcuserdata
28 changes: 0 additions & 28 deletions examples/codeviewer/.run/desktopApp.run.xml

This file was deleted.

35 changes: 22 additions & 13 deletions examples/codeviewer/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
# Code Viewer
Code Viewer example for Desktop, Android and iOS written in Compose Multiplatform.
Code Viewer example for Desktop, Android, iOS, and Web written in Compose Multiplatform.

The project is built with the [Kotlin Toolchain](https://github.com/JetBrains/kotlin-toolchain).

## Setting up your development environment

To setup the environment, please consult these [instructions](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-multiplatform-setup.html).
To set up the environment, please consult these [instructions](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-multiplatform-setup.html).

Open the project in IntelliJ IDEA with the Kotlin Toolchain plugin and use the run gutter icons or run configurations
to launch the app on the target of your choice.

## Run desktop app

`./kotlin run -m desktopApp`

## Run Android app

`./kotlin run -m androidApp`

## How to run
## Run iOS app

Choose a run configuration for an appropriate target in Android Studio and run it.
`./kotlin run -m iosApp`

![run-configurations.png](run-configurations.png)
or open `iosApp/module.xcodeproj` in Xcode.

## Run desktop via Gradle
## Run web app

`./gradlew desktopApp:run`
`./kotlin run -m webApp`

### Building native desktop distribution
```
./gradlew :desktop:packageDistributionForCurrentOS
# outputs are written to desktop/build/compose/binaries
```
and open the printed URL in a browser that supports [Wasm GC](https://kotl.in/wasm-help).

![Desktop](screenshots/codeviewer.png)
![Desktop](screenshots/codeviewer.png)
35 changes: 0 additions & 35 deletions examples/codeviewer/androidApp/build.gradle.kts

This file was deleted.

17 changes: 17 additions & 0 deletions examples/codeviewer/androidApp/module.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
product: android/app

dependencies:
- //shared
- $libs.androidx.activity.compose

settings:
compose: enabled
android:
namespace: org.jetbrains.codeviewer
applicationId: org.jetbrains.Codeviewer
minSdk: 26
compileSdk:
apiLevel: 37
minorApiLevel: 1
versionCode: 1
versionName: "1.0"
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:theme="@style/Theme.Application">
<activity
android:exported="true"
android:name="MainActivity"
android:name="org.jetbrains.codeviewer.MainActivity"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
10 changes: 0 additions & 10 deletions examples/codeviewer/build.gradle.kts

This file was deleted.

41 changes: 0 additions & 41 deletions examples/codeviewer/desktopApp/build.gradle.kts

This file was deleted.

11 changes: 11 additions & 0 deletions examples/codeviewer/desktopApp/module.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
product: jvm/app

dependencies:
- //shared
- $libs.compose.runtime
- $libs.compose.ui

settings:
compose: enabled
jvm:
mainClass: org.jetbrains.codeviewer.MainKt
10 changes: 0 additions & 10 deletions examples/codeviewer/gradle.properties

This file was deleted.

27 changes: 0 additions & 27 deletions examples/codeviewer/gradle/libs.versions.toml

This file was deleted.

Binary file not shown.
8 changes: 0 additions & 8 deletions examples/codeviewer/gradle/wrapper/gradle-wrapper.properties

This file was deleted.

Loading
Loading