Skip to content

Commit 21d70cc

Browse files
committed
Initial twig translation of KMP SDK
1 parent a9c3f60 commit 21d70cc

File tree

96 files changed

+5479
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+5479
-0
lines changed

src/SDK/Language/KMP.php

Lines changed: 588 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Auto-close External Pull Requests
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, reopened]
6+
7+
jobs:
8+
auto_close:
9+
uses: appwrite/.github/.github/workflows/autoclose.yml@main
10+
secrets:
11+
GH_AUTO_CLOSE_PR_TOKEN: ${{ secrets.GH_AUTO_CLOSE_PR_TOKEN }}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
release:
5+
types: [released]
6+
7+
jobs:
8+
publish:
9+
name: Release build and publish
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@v3
14+
15+
- name: Set up JDK 17
16+
uses: actions/setup-java@v3
17+
with:
18+
java-version: 17
19+
distribution: 'temurin'
20+
21+
- name: Prepare environment
22+
env:
23+
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }}
24+
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
25+
run: |
26+
git fetch --unshallow
27+
sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'"
28+
chmod +x ./gradlew
29+
30+
- name: Build Release Artifacts
31+
run: ./gradlew assemble
32+
33+
- name: Generate Documentation
34+
run: ./gradlew dokkaHtml
35+
36+
- name: Publish to Maven Central
37+
run: |
38+
if ${{ contains(github.event.release.tag_name, '-rc') }}; then
39+
echo "Publishing Snapshot Version ${{ github.event.release.tag_name}}"
40+
./gradlew publishAllPublicationsToSonatypeRepository
41+
else
42+
echo "Publishing Release Version ${{ github.event.release.tag_name}}"
43+
./gradlew publishAllPublicationsToSonatypeRepository closeAndReleaseSonatypeStagingRepository
44+
fi
45+
env:
46+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
47+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
48+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
49+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
50+
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
51+
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
52+
SDK_VERSION: ${{ github.event.release.tag_name }}

templates/kmp/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.iml
2+
.gradle
3+
.idea
4+
.DS_Store
5+
build
6+
captures
7+
.externalNativeBuild
8+
.cxx
9+
local.properties
10+
xcuserdata

templates/kmp/CHANGELOG.md.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{sdk.changelog}}

templates/kmp/LICENSE.md.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{sdk.licenseContent | raw}}

templates/kmp/README.md.twig

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# {{ spec.title }} {{sdk.name}} SDK
2+
3+
![Maven Central](https://img.shields.io/maven-central/v/{{ sdk.namespace | caseDot }}/{{ sdk.gitRepoName | caseDash }}.svg?color=green&style=flat-square)
4+
![License](https://img.shields.io/github/license/{{ sdk.gitUserName|url_encode }}/{{ sdk.gitRepoName|url_encode }}.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-{{ spec.version|url_encode }}-blue.svg?style=flat-square)
6+
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
7+
{% if sdk.twitterHandle %}
8+
[![Twitter Account](https://img.shields.io/twitter/follow/{{ sdk.twitterHandle }}?color=00acee&label=twitter&style=flat-square)](https://twitter.com/{{ sdk.twitterHandle }})
9+
{% endif %}
10+
{% if sdk.discordChannel %}
11+
[![Discord](https://img.shields.io/discord/{{ sdk.discordChannel }}?label=discord&style=flat-square)]({{ sdk.discordUrl }})
12+
{% endif %}
13+
{% if sdk.warning %}
14+
15+
{{ sdk.warning|raw }}
16+
{% endif %}
17+
18+
{{ sdk.description }}
19+
20+
{% if sdk.logo %}
21+
![{{ spec.title }}]({{ sdk.logo }})
22+
{% endif %}
23+
24+
## Installation
25+
26+
### Gradle
27+
28+
Appwrite's Android SDK is hosted on Maven Central. In order to fetch the Appwrite SDK, add this to your root level `build.gradle(.kts)` file:
29+
30+
```groovy
31+
repositories {
32+
mavenCentral()
33+
}
34+
```
35+
36+
If you would like to fetch our SNAPSHOT releases, you need to add the SNAPSHOT maven repository to your `build.gradle(.kts)`:
37+
38+
```groovy
39+
repositories {
40+
maven {
41+
url "https://s01.oss.sonatype.org/content/repositories/snapshots/"
42+
}
43+
}
44+
```
45+
46+
Next, add the dependency to your project's `build.gradle(.kts)` file:
47+
48+
```groovy
49+
implementation("{{ sdk.namespace | caseDot }}:{{ sdk.gitRepoName | caseDash }}:{{ sdk.version }}")
50+
```
51+
52+
### Maven
53+
Add this to your project's `pom.xml` file:
54+
55+
```xml
56+
<dependencies>
57+
<dependency>
58+
<groupId>{{ sdk.namespace | caseDot }}</groupId>
59+
<artifactId>{{ sdk.gitRepoName | caseDash }}</artifactId>
60+
<version>{{sdk.version}}</version>
61+
</dependency>
62+
</dependencies>
63+
```
64+
65+
{% if sdk.gettingStarted %}
66+
67+
{{ sdk.gettingStarted|raw }}
68+
{% endif %}
69+
70+
## Contribution
71+
72+
This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.
73+
74+
## License
75+
76+
Please see the [{{spec.licenseName}} license]({{spec.licenseURL}}) file for more information.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
plugins {
2+
alias(libs.plugins.androidApplication)
3+
alias(libs.plugins.kotlinAndroid)
4+
alias(libs.plugins.compose.compiler)
5+
alias(libs.plugins.kotlinx.serialization)
6+
}
7+
8+
android {
9+
namespace = "io.appwrite.android"
10+
compileSdk = 35
11+
defaultConfig {
12+
applicationId = "io.appwrite.android"
13+
minSdk = 21
14+
targetSdk = 35
15+
versionCode = 1
16+
versionName = "1.0"
17+
}
18+
buildFeatures {
19+
compose = true
20+
}
21+
packaging {
22+
resources {
23+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
24+
}
25+
}
26+
buildTypes {
27+
getByName("release") {
28+
isMinifyEnabled = false
29+
}
30+
}
31+
compileOptions {
32+
sourceCompatibility = JavaVersion.VERSION_1_8
33+
targetCompatibility = JavaVersion.VERSION_1_8
34+
}
35+
kotlinOptions {
36+
jvmTarget = "1.8"
37+
}
38+
}
39+
40+
dependencies {
41+
implementation(projects.shared)
42+
implementation(libs.compose.ui)
43+
implementation(libs.compose.ui.tooling.preview)
44+
implementation(libs.compose.material3)
45+
implementation(libs.androidx.activity.compose)
46+
debugImplementation(libs.compose.ui.tooling)
47+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="io.appwrite.android">
4+
5+
<application
6+
android:allowBackup="false"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/Theme.AppwriteAndroidSDK"
12+
android:usesCleartextTraffic="true">
13+
14+
<activity android:name=".MainActivity" android:exported="true">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
<category android:name="android.intent.category.LAUNCHER" />
18+
</intent-filter>
19+
</activity>
20+
21+
<activity android:name="io.appwrite.views.CallbackActivity" android:exported="true">
22+
<intent-filter android:label="android_web_auth">
23+
<action android:name="android.intent.action.VIEW" />
24+
<category android:name="android.intent.category.DEFAULT" />
25+
<category android:name="android.intent.category.BROWSABLE" />
26+
<data android:scheme="appwrite-callback-6070749e6acd4" />
27+
</intent-filter>
28+
</activity>
29+
30+
<service android:name=".services.MessagingService" android:exported="false">
31+
<intent-filter>
32+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
33+
</intent-filter>
34+
</service>
35+
36+
</application>
37+
38+
</manifest>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package {{ sdk.namespace | caseDot }}.android
2+
3+
import androidx.appcompat.app.AppCompatActivity
4+
import android.os.Bundle
5+
import androidx.fragment.app.add
6+
import androidx.fragment.app.commit
7+
import {{ sdk.namespace | caseDot }}.android.ui.accounts.AccountsFragment
8+
import {{ sdk.namespace | caseDot }}.android.utils.Client
9+
10+
class MainActivity : AppCompatActivity() {
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
super.onCreate(savedInstanceState)
13+
setContentView(R.layout.activity_main)
14+
Client.create(applicationContext)
15+
16+
if (savedInstanceState == null) {
17+
supportFragmentManager.commit {
18+
setReorderingAllowed(true)
19+
add<AccountsFragment>(R.id.fragment_container_view)
20+
}
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)