Skip to content

Commit

Permalink
Merge pull request #397 from hieuwu/feature/set-up-ios-chat-demo
Browse files Browse the repository at this point in the history
Set up iOS for chat demo
  • Loading branch information
jan-tennert authored Dec 27, 2023
2 parents ac5e125 + d4174f3 commit 1ca6072
Show file tree
Hide file tree
Showing 45 changed files with 1,152 additions and 575 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added demos/.DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions demos/chat-demo-mpp/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ android {
}
namespace = "io.github.jan.supabase.android"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "11"
}
buildTypes {
getByName("release") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.MaterialTheme

import co.touchlab.kermit.Logger
import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.common.App
import io.github.jan.supabase.common.ChatViewModel
import io.github.jan.supabase.gotrue.handleDeeplinks
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 25 additions & 4 deletions demos/chat-demo-mpp/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@file:OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
import org.jetbrains.compose.compose

plugins {
kotlin("multiplatform")
Expand All @@ -14,11 +13,21 @@ version = "1.0-SNAPSHOT"
kotlin {
android()
jvm("desktop") {
jvmToolchain(8)
jvmToolchain(11)
}
js(IR) {
browser()
}

listOf(
iosArm64(),
iosSimulatorArm64(),
).forEach {
it.binaries.framework {
baseName = "common"
isStatic = true
}
}
sourceSets {
val commonMain by getting {
dependencies {
Expand Down Expand Up @@ -56,6 +65,18 @@ kotlin {
api(libs.ktor.js)
}
}
val iosArm64Main by getting {
dependsOn(commonMain)
dependencies {
api(libs.ktor.ios)
}
}
val iosSimulatorArm64Main by getting {
dependsOn(commonMain)
dependencies {
api(libs.ktor.ios)
}
}
}
}

Expand All @@ -67,7 +88,7 @@ android {
minSdk = 26
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.jan.supabase.common.di

import io.github.jan.supabase.common.ChatViewModel
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.core.module.Module

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ expect open class MPViewModel() {
val coroutineScope: CoroutineScope

}

class ChatViewModel(
val supabaseClient: SupabaseClient,
private val realtimeChannel: RealtimeChannel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.jan.supabase.common.di

import io.github.jan.supabase.common.ChatViewModel
import org.koin.core.module.Module

actual fun Module.viewModel() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.github.jan.supabase.common

import androidx.compose.ui.window.ComposeUIViewController
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import platform.UIKit.UIViewController


class RootComponent : KoinComponent {
private val viewModel: ChatViewModel by inject()
fun getViewModel(): ChatViewModel = viewModel
}

fun AppIos(viewModel: ChatViewModel): UIViewController = ComposeUIViewController {
App(viewModel = viewModel)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.github.jan.supabase.common

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers

actual open class MPViewModel actual constructor() {

actual val coroutineScope = CoroutineScope(Dispatchers.Default)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.github.jan.supabase.common.di

import io.github.jan.supabase.gotrue.GoTrueConfig

actual fun GoTrueConfig.platformGoTrueConfig() {
scheme = "io.jan.supabase"
host = "login"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.github.jan.supabase.common.di

import org.koin.core.module.Module

actual fun Module.viewModel() {
single { createViewModule() }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.github.jan.supabase.common.ui.components

import androidx.compose.runtime.Composable

@Composable
actual fun AlertDialog(text: String, close: () -> Unit) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.github.jan.supabase.common

import androidx.compose.ui.window.ComposeUIViewController
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import platform.UIKit.UIViewController

class RootComponent : KoinComponent {
private val viewModel: ChatViewModel by inject()
fun getViewModel(): ChatViewModel = viewModel
}

fun AppIos(viewModel: ChatViewModel): UIViewController = ComposeUIViewController {
App(viewModel = viewModel)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.github.jan.supabase.common

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers

actual open class MPViewModel actual constructor() {
actual val coroutineScope = CoroutineScope(Dispatchers.Default)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.github.jan.supabase.common.di

import io.github.jan.supabase.gotrue.GoTrueConfig

actual fun GoTrueConfig.platformGoTrueConfig() {
scheme = "io.jan.supabase"
host = "login"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.github.jan.supabase.common.di

import org.koin.core.module.Module

actual fun Module.viewModel() {
single { createViewModule() }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.github.jan.supabase.common.ui.components

import androidx.compose.runtime.Composable

@Composable
actual fun AlertDialog(text: String, close: () -> Unit) {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.jan.supabase.common.di

import io.github.jan.supabase.common.ChatViewModel
import org.koin.core.module.Module

actual fun Module.viewModel() {
Expand Down
4 changes: 2 additions & 2 deletions demos/chat-demo-mpp/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
kotlin.code.style=official
kotlin.native.enableDependencyPropagation=false
android.useAndroidX=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.gradle.jvmargs=-Xmx4096m
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.mpp.androidSourceSetLayoutVersion=2
org.jetbrains.compose.experimental.uikit.enabled=true
11 changes: 6 additions & 5 deletions demos/chat-demo-mpp/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
[versions]
kotlin = "1.8.20"
kotlin = "1.9.21"
agp = "8.0.2"
compose = "1.4.0"
compose = "1.5.11"
supabase = "1.1.0"
koin = "3.4.1"
ktor = "2.3.1"
koin = "3.4.3"
ktor = "2.3.7"

androidx-core = "1.10.1"
androidx-compat = "1.6.1"
androidx-lifecycle = "2.6.1"
androidx-activity = "1.7.2"

[plugins]
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
Expand All @@ -21,6 +20,7 @@ android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }

compose = { id = "org.jetbrains.compose", version.ref = "compose" }
org-jetbrains-kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

[libraries]
supabase-gotrue = { module = "io.github.jan-tennert.supabase:gotrue-kt", version.ref = "supabase" }
Expand All @@ -38,6 +38,7 @@ androidx-activity-compose = { module = "androidx.activity:activity-compose", ver

ktor-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
ktor-ios = { module = "io.ktor:ktor-client-ios", version.ref = "ktor" }

[bundles]
supabase = [ "supabase-gotrue", "supabase-realtime", "supabase-postgrest" ]
Binary file modified demos/chat-demo-mpp/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 4 additions & 3 deletions demos/chat-demo-mpp/gradlew
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
Loading

0 comments on commit 1ca6072

Please sign in to comment.