Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ kotlin {

### SwiftUI ###

You need add the following file [Observer.kt](./mobk-swift/Observer.kt) to your
You need add the following file [Observer.swift](./mobk-swift/Observer.swift) to your
Xcode project. Be sure to replace the import line with the name of your Kotlin
framework.

Expand Down
32 changes: 0 additions & 32 deletions build.gradle

This file was deleted.

27 changes: 27 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
buildscript {
repositories {
google()
mavenCentral()
}

dependencies {
classpath("com.android.tools.build:gradle:8.1.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21")
classpath("org.jetbrains.compose:compose-gradle-plugin:1.5.1")
}
}

plugins {
kotlin("multiplatform") version "1.9.10"
}

allprojects {
repositories {
google()
mavenCentral()
}
}

kotlin {
jvm()
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
android.useAndroidX=true
android.useAndroidX=true
org.jetbrains.compose.experimental.uikit.enabled=true
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Aug 11 10:48:24 CEST 2021
#Wed Sep 20 20:55:00 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
73 changes: 0 additions & 73 deletions mobk-compose/build.gradle

This file was deleted.

57 changes: 0 additions & 57 deletions mobk-core/build.gradle

This file was deleted.

74 changes: 74 additions & 0 deletions mobk-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
plugins {
kotlin("multiplatform")
id("com.android.library")
id("org.jetbrains.compose")
id("maven-publish")
}

group = "io.monkeypatch"
version = "0.0.11"

@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default()

androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}

publishLibraryVariants("release")
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
}

}
sourceSets {
val commonMain by getting{
dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation("org.jetbrains.kotlinx:atomicfu:0.21.0")
}

}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val iosMain by getting
val iosTest by getting
}
}

android {
namespace = "io.monkeypatch.mobk.core"
compileSdk = 34
defaultConfig {
minSdk = 24
}
}



publishing {
repositories {
maven{
url = uri("https://api.bintray.com/maven/alexandre-delattre/MonkeyPatchLibs/mobk-core/;publish=1")
credentials {
username = project.findProperty("bintrayUsername") as String? ?: ""
password = project.findProperty("bintrayPassword") as String? ?: ""
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<manifest package="io.monkeypatch.mobk.ui"
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

Expand Down
39 changes: 39 additions & 0 deletions mobk-swift/Observer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Observer.swift
//

import SwiftUI
import <y>

struct ObserverView<V: View> : View {
@ObservedObject var reactionObservable: ReactionObservable<V>

var body: some View {
self.reactionObservable.view
}
}

func Observer<V: View>(@ViewBuilder f: @escaping () -> V) -> some View {
let reactionObservable = ReactionObservable(f: f)
return ObserverView(reactionObservable: reactionObservable)
}

class ReactionObservable<V>: ObservableObject {
@Published var view: V? = nil
var disposer: ReactionDisposer? = nil

init(f: @escaping () -> V) {
disposer = ApiKt.autorun { [weak self] in
self?.view = f()
}
}

deinit {
let d = disposer
disposer = nil
DispatchQueue.main.async {
d?.invoke()
}
}

}
2 changes: 0 additions & 2 deletions settings.gradle

This file was deleted.

2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rootProject.name = "mobk"
include(":mobk-core")