This commit is contained in:
AnranYus
2025-10-06 11:15:05 +08:00
commit 2afdf55341
79 changed files with 2763 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
*.iml
.kotlin
.gradle
**/build/
xcuserdata
!src/**/build/
local.properties
.idea
.DS_Store
captures
.externalNativeBuild
.cxx
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcodeproj/project.xcworkspace/
!*.xcworkspace/contents.xcworkspacedata
**/xcshareddata/WorkspaceSettings.xcsettings
node_modules/
+30
View File
@@ -0,0 +1,30 @@
# ComfyUI KMP Mobile
Kotlin Multiplatform (Android/iOS, ARM) App using Compose Multiplatform to connect to a remote ComfyUI server, import workflow JSON, edit existing nodes/params, run, and display generated images.
## Features
- Import ComfyUI workflow JSON (paste)
- Edit existing node parameters (string fields)
- Connect to remote ComfyUI server and run
- Poll history and fetch generated images
- Display images in a responsive grid (MD3)
## Setup
1. ComfyUI server: ensure reachable from device, default ports (e.g. `http://<ip>:8188`).
2. Android: INTERNET permission included.
3. iOS: ATS relaxed in `iosApp/iosApp/Info.plist` for dev. For production, configure proper HTTPS.
## Build
Android: run `:composeApp:assembleDebug` or use Android Studio run configuration.
iOS: open `iosApp/iosApp.xcodeproj`, run on a device/simulator.
## Usage
1. Open Settings, set Base URL of ComfyUI server.
2. Import a workflow JSON via Import page.
3. Edit string parameters in Editor page.
4. Run, wait for results, view images in Gallery.
## Notes
- Only editing of existing parameters is supported; adding nodes is not supported.
- Networking via Ktor; JSON via kotlinx.serialization.
- For non-ARM devices, compatibility is not targeted.
+10
View File
@@ -0,0 +1,10 @@
plugins {
// this is necessary to avoid the plugins to be loaded multiple times
// in each subproject's classloader
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.composeMultiplatform) apply false
alias(libs.plugins.composeCompiler) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.serialization) apply false
}
+92
View File
@@ -0,0 +1,92 @@
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidApplication)
alias(libs.plugins.composeMultiplatform)
alias(libs.plugins.composeCompiler)
alias(libs.plugins.serialization)
}
kotlin {
androidTarget {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
listOf(
iosArm64(),
iosSimulatorArm64()
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "ComposeApp"
isStatic = true
}
}
sourceSets {
androidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)
implementation(libs.ktor.client.okhttp)
}
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material3)
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(libs.androidx.lifecycle.viewmodelCompose)
implementation(libs.androidx.lifecycle.runtimeCompose)
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.logging)
implementation(libs.ktor.client.contentNegotiation)
implementation(libs.ktor.serialization.kotlinx.json)
implementation(libs.kotlinx.serialization.json)
implementation(libs.ktor.client.websockets)
implementation("co.touchlab:kermit:2.0.4") //Add latest version
implementation("br.com.devsrsouza.compose.icons:font-awesome:1.1.1")
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
iosMain.dependencies {
implementation(libs.ktor.client.darwin)
}
}
}
android {
namespace = "moe.uni.comfy.comfyuikmp"
compileSdk = libs.versions.android.compileSdk.get().toInt()
defaultConfig {
applicationId = "moe.uni.comfy.comfyuikmp"
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = 1
versionName = "1.0"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
dependencies {
debugImplementation(compose.uiTooling)
}
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@android:style/Theme.Material.Light.NoActionBar">
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<activity
android:exported="true"
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
@@ -0,0 +1,27 @@
package moe.uni.comfy.comfyuikmp
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import moe.uni.comfy.comfyuikmp.data.settings.KeyValueStore
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
KeyValueStore.init(this)
setContent {
App()
}
}
}
@Preview
@Composable
fun AppAndroidPreview() {
App()
}
@@ -0,0 +1,9 @@
package moe.uni.comfy.comfyuikmp
import android.os.Build
class AndroidPlatform : Platform {
override val name: String = "Android ${Build.VERSION.SDK_INT}"
}
actual fun getPlatform(): Platform = AndroidPlatform()
@@ -0,0 +1,31 @@
package moe.uni.comfy.comfyuikmp.data.network
import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.engine.okhttp.OkHttp
import io.ktor.client.plugins.HttpTimeout
import io.ktor.client.plugins.UserAgent
import io.ktor.client.plugins.defaultRequest
import io.ktor.http.URLProtocol
import moe.uni.comfy.comfyuikmp.data.network.createPlatformHttpClient
actual fun createPlatformHttpClient(configure: HttpClientConfig<*>.() -> Unit): HttpClient {
return HttpClient(OkHttp) {
install(HttpTimeout) {
requestTimeoutMillis = 60_000
connectTimeoutMillis = 30_000
socketTimeoutMillis = 60_000
}
install(UserAgent) {
agent = "ComfyUIKMP-Android"
}
defaultRequest {
url {
protocol = URLProtocol.HTTP
}
}
configure()
}
}
@@ -0,0 +1,23 @@
package moe.uni.comfy.comfyuikmp.data.settings
import android.content.Context
import android.content.SharedPreferences
private const val PREFS_NAME = "comfy_prefs"
private var sharedPrefs: SharedPreferences? = null
actual object KeyValueStore {
actual fun init(platformContext: Any?) {
val ctx = platformContext as? Context ?: return
sharedPrefs = ctx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
}
actual fun getString(key: String): String? = sharedPrefs?.getString(key, null)
actual fun setString(key: String, value: String) {
sharedPrefs?.edit()?.putString(key, value)?.apply()
}
}
@@ -0,0 +1,19 @@
package moe.uni.comfy.comfyuikmp.ui.importer
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import moe.uni.comfy.comfyuikmp.data.model.ComfyPrompt
import moe.uni.comfy.comfyuikmp.data.model.parsePromptJson
@Composable
actual fun FileImportFab(onImported: (ComfyPrompt) -> Unit, onError: (String) -> Unit) {
val pick = rememberJsonFilePicker { name: String, content: String ->
runCatching { parsePromptJson(content) }
.onSuccess { onImported(it) }
.onFailure { onError(it.message ?: "解析失败") }
}
ExtendedFloatingActionButton(text = { Text("从文件导入") }, icon = {}, onClick = { pick() })
}
@@ -0,0 +1,26 @@
package moe.uni.comfy.comfyuikmp.ui.importer
import android.content.Context
import android.net.Uri
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import java.io.BufferedReader
import androidx.compose.ui.platform.LocalContext
@Composable
actual fun rememberJsonFilePicker(onPicked: (name: String, content: String) -> Unit): () -> Unit {
val ctx = LocalContext.current
val launcher = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocument()) { uri: Uri? ->
if (uri != null) {
val name = uri.lastPathSegment?.substringAfterLast('/') ?: "import.json"
val text = ctx.contentResolver.openInputStream(uri)?.bufferedReader()?.use(BufferedReader::readText) ?: ""
onPicked(name, text)
}
}
return remember { { launcher.launch(arrayOf("application/json")) } }
}
@@ -0,0 +1,10 @@
package moe.uni.comfy.comfyuikmp.util
import android.graphics.BitmapFactory
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap
actual fun decodeImage(bytes: ByteArray): ImageBitmap? =
BitmapFactory.decodeByteArray(bytes, 0, bytes.size)?.asImageBitmap()
@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0"/>
<item
android:color="#00000000"
android:offset="1.0"/>
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000"/>
</vector>
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z"/>
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF"/>
</vector>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">comfyuikmp</string>
</resources>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
@@ -0,0 +1,44 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="450dp"
android:height="450dp"
android:viewportWidth="64"
android:viewportHeight="64">
<path
android:pathData="M56.25,18V46L32,60 7.75,46V18L32,4Z"
android:fillColor="#6075f2"/>
<path
android:pathData="m41.5,26.5v11L32,43V60L56.25,46V18Z"
android:fillColor="#6b57ff"/>
<path
android:pathData="m32,43 l-9.5,-5.5v-11L7.75,18V46L32,60Z">
<aapt:attr name="android:fillColor">
<gradient
android:centerX="23.131"
android:centerY="18.441"
android:gradientRadius="42.132"
android:type="radial">
<item android:offset="0" android:color="#FF5383EC"/>
<item android:offset="0.867" android:color="#FF7F52FF"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="M22.5,26.5 L32,21 41.5,26.5 56.25,18 32,4 7.75,18Z">
<aapt:attr name="android:fillColor">
<gradient
android:startX="44.172"
android:startY="4.377"
android:endX="17.973"
android:endY="34.035"
android:type="linear">
<item android:offset="0" android:color="#FF33C3FF"/>
<item android:offset="0.878" android:color="#FF5383EC"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="m32,21 l9.526,5.5v11L32,43 22.474,37.5v-11z"
android:fillColor="#000000"/>
</vector>
@@ -0,0 +1,9 @@
package moe.uni.comfy.comfyuikmp
import androidx.compose.runtime.Composable
import org.jetbrains.compose.ui.tooling.preview.Preview
import moe.uni.comfy.comfyuikmp.ui.AppRoot
@Composable
@Preview
fun App() { AppRoot() }
@@ -0,0 +1,9 @@
package moe.uni.comfy.comfyuikmp
class Greeting {
private val platform = getPlatform()
fun greet(): String {
return "Hello, ${platform.name}!"
}
}
@@ -0,0 +1,7 @@
package moe.uni.comfy.comfyuikmp
interface Platform {
val name: String
}
expect fun getPlatform(): Platform
@@ -0,0 +1,32 @@
package moe.uni.comfy.comfyuikmp.data.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonElement
/**
* 通用 ComfyUI 节点模型,尽量保持结构宽松以兼容不同节点类型与输入形态。
*/
@Serializable
data class ComfyNode(
@SerialName("class_type") val classType: String,
val inputs: Map<String, JsonElement> = emptyMap(),
@SerialName("_meta") val meta: ComfyNodeMeta? = null
)
@Serializable
data class ComfyNodeMeta(
val title: String? = null
)
/**
* API 交互所需的包裹结构:{"prompt": { "<nodeId>": ComfyNode, ... }, "client_id": "..."}
*/
@Serializable
data class ComfyPromptEnvelope(
val prompt: Map<String, ComfyNode>,
@SerialName("client_id") val clientId: String? = null
)
typealias ComfyPrompt = Map<String, ComfyNode>
@@ -0,0 +1,79 @@
package moe.uni.comfy.comfyuikmp.data.model
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.boolean
import kotlinx.serialization.json.decodeFromJsonElement
object ComfyJson {
val relaxed: Json = Json {
ignoreUnknownKeys = true
prettyPrint = false
isLenient = true
encodeDefaults = true
}
}
/**
* 从工作流 JSON 文本解析为 ComfyPrompt。
* 支持两种顶层结构:
* 1) 直接为 { nodeId: { class_type, inputs } }
* 2) 包裹为 { "prompt": { ... }, ... }
*/
fun parsePromptJson(text: String): ComfyPrompt {
val root = ComfyJson.relaxed.parseToJsonElement(text)
val map = when (root) {
is JsonObject -> {
if ("prompt" in root) {
val promptElement = root["prompt"]
(promptElement as? JsonObject)?.let {
ComfyJson.relaxed.decodeFromJsonElement<Map<String, ComfyNode>>(it)
} ?: emptyMap()
} else {
ComfyJson.relaxed.decodeFromJsonElement<Map<String, ComfyNode>>(root)
}
}
else -> emptyMap()
}
return map
}
/**
* 修改指定节点的字符串输入(如提示词)。仅当输入值为 JsonPrimitive 且为字符串时进行替换。
*/
fun updateNodeStringInput(
prompt: ComfyPrompt,
nodeId: String,
inputKey: String,
newValue: String
): ComfyPrompt {
val target = prompt[nodeId] ?: return prompt
val newInputs = target.inputs.mapValues { (k, v) ->
if (k == inputKey && v is JsonPrimitive && v.isString) JsonPrimitive(newValue) else v
}
return prompt.toMutableMap().apply {
this[nodeId] = target.copy(inputs = newInputs)
}
}
/**
* 修改指定节点的原始 JsonPrimitive(支持 number/boolean)。
*/
fun updateNodePrimitiveInput(
prompt: ComfyPrompt,
nodeId: String,
inputKey: String,
newValue: JsonPrimitive
): ComfyPrompt {
val target = prompt[nodeId] ?: return prompt
val newInputs = target.inputs.mapValues { (k, v) ->
if (k == inputKey && v is JsonPrimitive && !v.isString) newValue else v
}
return prompt.toMutableMap().apply {
this[nodeId] = target.copy(inputs = newInputs)
}
}
@@ -0,0 +1,55 @@
package moe.uni.comfy.comfyuikmp.data.model
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
@Serializable
data class ImageRef(
val filename: String,
val subfolder: String? = null,
val type: String? = null
)
/**
* 从 /history/{prompt_id} 宽松 JSON 结果中提取图片引用。
* 规则:深度遍历,找到形如 { images: [ { filename, subfolder?, type? }, ... ] } 的结构。
*/
fun extractImageRefsFromHistoryElement(root: JsonElement): List<ImageRef> {
val results = mutableListOf<ImageRef>()
fun visit(element: JsonElement) {
when (element) {
is JsonObject -> {
// 命中 images 字段
element["images"]?.let { imagesEl ->
val arr: JsonArray? = imagesEl as? JsonArray ?: imagesEl.jsonArray
arr?.forEach { imgEl ->
val obj: JsonObject? = imgEl as? JsonObject ?: runCatching { imgEl.jsonObject }.getOrNull()
if (obj != null) {
val filename = runCatching { obj["filename"]?.jsonPrimitive?.content }.getOrNull()
if (!filename.isNullOrEmpty()) {
val sub = runCatching { obj["subfolder"]?.jsonPrimitive?.content }.getOrNull()
val typ = runCatching { obj["type"]?.jsonPrimitive?.content }.getOrNull()
results.add(ImageRef(filename = filename, subfolder = sub, type = typ))
}
}
}
}
// 继续遍历子项
element.values.forEach { visit(it) }
}
is JsonArray -> element.forEach { visit(it) }
else -> {}
}
}
visit(root)
return results
}
@@ -0,0 +1,66 @@
package moe.uni.comfy.comfyuikmp.data.network
import co.touchlab.kermit.Logger
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.request.get
import io.ktor.client.request.parameter
import io.ktor.client.request.post
import io.ktor.client.request.setBody
import io.ktor.client.statement.HttpResponse
import io.ktor.http.ContentType
import io.ktor.http.contentType
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
import moe.uni.comfy.comfyuikmp.data.model.ComfyNode
import moe.uni.comfy.comfyuikmp.data.model.ComfyPrompt
import moe.uni.comfy.comfyuikmp.data.model.ComfyPromptEnvelope
class ComfyApi(private val baseUrl: String, private val httpClient: HttpClient) {
suspend fun submitPrompt(prompt: ComfyPrompt, clientId: String? = null): PromptSubmitResponse {
val envelope = ComfyPromptEnvelope(prompt = prompt, clientId = clientId)
val response: HttpResponse = httpClient.post("$baseUrl/prompt") {
contentType(ContentType.Application.Json)
setBody(envelope)
}
Logger.i { "Submitted envelope: $envelope" }
return response.body()
}
suspend fun getQueue(): QueueResponse = httpClient.get("$baseUrl/queue").body()
suspend fun getHistory(promptId: String): Map<String, JsonElement> =
httpClient.get("$baseUrl/history/$promptId").body()
suspend fun fetchImage(
filename: String,
subfolder: String? = null,
type: String? = null
): ByteArray {
val response = httpClient.get("$baseUrl/view") {
parameter("filename", filename)
if (subfolder != null) parameter("subfolder", subfolder)
if (type != null) parameter("type", type)
}
return response.body()
}
}
// 依 ComfyUI 官方 API 响应结构定义
@Serializable
data class PromptSubmitResponse(
@SerialName("prompt_id") val promptId: String
)
@Serializable
data class QueueResponse(
val queue_running: List<List<JsonElement>> = emptyList(),
val queue_pending: List<List<JsonElement>> = emptyList()
)
// /history/{prompt_id} 返回形如 { "<prompt_id>": { ... } }
@@ -0,0 +1,80 @@
package moe.uni.comfy.comfyuikmp.data.network
import io.ktor.client.HttpClient
import io.ktor.client.plugins.websocket.webSocket
import io.ktor.websocket.Frame
import io.ktor.websocket.readText
import kotlinx.coroutines.isActive
import kotlinx.coroutines.yield
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import moe.uni.comfy.comfyuikmp.data.model.ImageRef
import moe.uni.comfy.comfyuikmp.data.model.extractImageRefsFromHistoryElement
import kotlin.coroutines.cancellation.CancellationException
data class ProgressUpdate(
val fraction: Float?,
val message: String?
)
class ComfyWsClient(private val client: HttpClient) {
private val json = Json { ignoreUnknownKeys = true }
private fun toWsUrl(httpBase: String, clientId: String): String {
val base = httpBase.removeSuffix("/")
val wsBase = when {
base.startsWith("https://") -> base.replaceFirst("https://", "wss://")
base.startsWith("http://") -> base.replaceFirst("http://", "ws://")
else -> "ws://$base"
}
return "$wsBase/ws?clientId=$clientId"
}
suspend fun listen(
baseUrl: String,
clientId: String,
onUpdate: (ProgressUpdate) -> Unit,
onImages: (List<ImageRef>) -> Unit = {}
) {
val url = toWsUrl(baseUrl, clientId)
client.webSocket(urlString = url) {
try {
for (frame in incoming) {
val text = (frame as? Frame.Text)?.readText() ?: continue
val root = runCatching { json.parseToJsonElement(text) }.getOrNull() ?: continue
val obj: JsonObject = root as? JsonObject ?: continue
val type = obj["type"]?.jsonPrimitive?.content
when (type) {
"progress" -> {
val data = obj["data"]?.jsonObject
val value = data?.get("value")?.jsonPrimitive?.content?.toFloatOrNull()
val max = data?.get("max")?.jsonPrimitive?.content?.toFloatOrNull()
val frac = if (value != null && max != null && max > 0f) value / max else null
onUpdate(ProgressUpdate(frac, "生成中 ${(value ?: 0f).toInt()}/${(max ?: 0f).toInt()}"))
}
"executing" -> {
val node = obj["data"]?.jsonObject?.get("node")?.jsonPrimitive?.content
onUpdate(ProgressUpdate(null, "执行节点: ${node ?: ""}"))
}
"executed" -> {
val data: JsonElement = obj["data"] ?: continue
val refs = extractImageRefsFromHistoryElement(data)
if (refs.isNotEmpty()) onImages(refs)
}
else -> {
// ignore other types
}
}
if (!this@webSocket.isActive) break
yield()
}
} catch (_: CancellationException) {
}
}
}
}
@@ -0,0 +1,37 @@
package moe.uni.comfy.comfyuikmp.data.network
import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.plugins.DefaultRequest
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.plugins.logging.LogLevel
import io.ktor.client.plugins.logging.Logging
import io.ktor.client.plugins.websocket.WebSockets
import io.ktor.http.HttpHeaders
import kotlinx.serialization.json.Json
import io.ktor.serialization.kotlinx.json.json
/**
* 由平台提供具体引擎与基础设置。
*/
expect fun createPlatformHttpClient(configure: HttpClientConfig<*>.() -> Unit = {}): HttpClient
object NetworkDefaults {
val json: Json = Json {
ignoreUnknownKeys = true
isLenient = true
prettyPrint = false
encodeDefaults = true
}
}
fun createDefaultHttpClient(): HttpClient = createPlatformHttpClient {
install(ContentNegotiation) {
json(NetworkDefaults.json)
}
install(Logging) { level = LogLevel.INFO }
install(WebSockets)
install(DefaultRequest) { headers.append(HttpHeaders.Accept, "application/json") }
}
@@ -0,0 +1,56 @@
package moe.uni.comfy.comfyuikmp.data.repository
import co.touchlab.kermit.Logger
import io.ktor.client.HttpClient
import moe.uni.comfy.comfyuikmp.data.model.ComfyPrompt
import moe.uni.comfy.comfyuikmp.data.model.ImageRef
import moe.uni.comfy.comfyuikmp.data.model.extractImageRefsFromHistoryElement
import moe.uni.comfy.comfyuikmp.data.network.ComfyApi
import moe.uni.comfy.comfyuikmp.data.network.createDefaultHttpClient
import kotlinx.serialization.json.JsonElement
import kotlinx.coroutines.delay
import kotlinx.coroutines.withTimeout
class ComfyRepository(
private val settingsRepository: SettingsRepository,
private val httpClient: HttpClient = createDefaultHttpClient()
) {
private fun apiOrNull(): ComfyApi? {
val base = settingsRepository.getBaseUrl() ?: return null
return ComfyApi(baseUrl = base.trimEnd('/'), httpClient = httpClient)
}
suspend fun submit(prompt: ComfyPrompt, clientId: String? = null) =
apiOrNull()?.submitPrompt(prompt, clientId)
suspend fun queue() = apiOrNull()?.getQueue()
suspend fun history(promptId: String) = apiOrNull()?.getHistory(promptId)
suspend fun image(filename: String, subfolder: String? = null, type: String? = null) =
apiOrNull()?.fetchImage(filename, subfolder, type)
/**
* 提交并轮询直到历史中出现图片引用或超时。
*/
suspend fun runAndWaitImages(prompt: ComfyPrompt, clientId: String? = null, timeoutMs: Long = 120_000): List<ImageRef> {
val api = apiOrNull() ?: return emptyList()
val submit = api.submitPrompt(prompt, clientId)
Logger.i { "Submit result: $submit." }
return withTimeout(timeoutMs) {
while (true) {
val hist: Map<String, JsonElement> = api.getHistory(submit.promptId)
Logger.i { "History result: $hist." }
val merged = hist.values.firstOrNull()
if (merged != null) {
val refs = extractImageRefsFromHistoryElement(merged)
if (refs.isNotEmpty()) return@withTimeout refs
}
delay(1000)
}
emptyList()
}
}
}
@@ -0,0 +1,11 @@
package moe.uni.comfy.comfyuikmp.data.repository
import moe.uni.comfy.comfyuikmp.data.settings.KeyValueStore
import moe.uni.comfy.comfyuikmp.data.settings.PrefKeys
class SettingsRepository {
fun getBaseUrl(): String? = KeyValueStore.getString(PrefKeys.BASE_URL)
fun setBaseUrl(url: String) = KeyValueStore.setString(PrefKeys.BASE_URL, url)
}
@@ -0,0 +1,48 @@
package moe.uni.comfy.comfyuikmp.data.repository
import kotlinx.serialization.Serializable
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import moe.uni.comfy.comfyuikmp.data.model.ComfyPrompt
import moe.uni.comfy.comfyuikmp.data.settings.KeyValueStore
@Serializable
data class WorkflowItem(
val id: String,
val name: String,
val prompt: ComfyPrompt
)
class WorkflowRepository {
private val json = Json { ignoreUnknownKeys = true; encodeDefaults = true }
private val key = "workflows_json"
fun list(): List<WorkflowItem> {
val text = KeyValueStore.getString(key) ?: return emptyList()
return runCatching { json.decodeFromString<List<WorkflowItem>>(text) }.getOrDefault(emptyList())
}
fun saveOrUpdate(item: WorkflowItem) {
val current = list().toMutableList()
val idx = current.indexOfFirst { it.id == item.id }
if (idx >= 0) current[idx] = item else current.add(item)
KeyValueStore.setString(key, json.encodeToString(current))
}
fun delete(id: String) {
val next = list().filterNot { it.id == id }
KeyValueStore.setString(key, json.encodeToString(next))
}
fun rename(id: String, newName: String) {
val current = list().toMutableList()
val idx = current.indexOfFirst { it.id == id }
if (idx >= 0) {
current[idx] = current[idx].copy(name = newName)
KeyValueStore.setString(key, json.encodeToString(current))
}
}
}
@@ -0,0 +1,13 @@
package moe.uni.comfy.comfyuikmp.data.settings
object PrefKeys {
const val BASE_URL = "base_url"
}
expect object KeyValueStore {
fun init(platformContext: Any?)
fun getString(key: String): String?
fun setString(key: String, value: String)
}
@@ -0,0 +1,13 @@
package moe.uni.comfy.comfyuikmp.di
import moe.uni.comfy.comfyuikmp.data.repository.ComfyRepository
import moe.uni.comfy.comfyuikmp.data.repository.SettingsRepository
import moe.uni.comfy.comfyuikmp.data.repository.WorkflowRepository
object AppGraph {
val settings: SettingsRepository by lazy { SettingsRepository() }
val comfy: ComfyRepository by lazy { ComfyRepository(settings) }
val workflows: WorkflowRepository by lazy { WorkflowRepository() }
}
@@ -0,0 +1,161 @@
package moe.uni.comfy.comfyuikmp.ui
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import moe.uni.comfy.comfyuikmp.ui.navigation.Dest
import moe.uni.comfy.comfyuikmp.ui.settings.SettingsScreen
import moe.uni.comfy.comfyuikmp.ui.importer.ImportScreen
import moe.uni.comfy.comfyuikmp.ui.editor.EditorScreen
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import kotlinx.coroutines.launch
import moe.uni.comfy.comfyuikmp.data.model.ComfyPrompt
import moe.uni.comfy.comfyuikmp.ui.gallery.GalleryScreen
import moe.uni.comfy.comfyuikmp.util.decodeImage
import androidx.compose.ui.graphics.ImageBitmap
import moe.uni.comfy.comfyuikmp.di.AppGraph
import androidx.compose.material3.ExtendedFloatingActionButton
import co.touchlab.kermit.Logger
import moe.uni.comfy.comfyuikmp.ui.home.HomeScreen
import moe.uni.comfy.comfyuikmp.data.repository.WorkflowItem
import moe.uni.comfy.comfyuikmp.data.network.ComfyWsClient
import moe.uni.comfy.comfyuikmp.data.network.ProgressUpdate
import moe.uni.comfy.comfyuikmp.data.network.createDefaultHttpClient
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AppRoot() {
val hasSaved = remember { AppGraph.workflows.list().isNotEmpty() }
val current: MutableState<Dest> = remember { mutableStateOf(if (hasSaved) Dest.Home else Dest.Settings) }
MaterialTheme {
val snackbar = remember { SnackbarHostState() }
val scope = rememberCoroutineScope()
var promptState by remember { mutableStateOf<ComfyPrompt?>(null) }
var images by remember { mutableStateOf<List<ImageBitmap>>(emptyList()) }
var currentWorkflowId by remember { mutableStateOf<String?>(null) }
var currentWorkflowName by remember { mutableStateOf<String?>(null) }
var progress by remember { mutableStateOf<ProgressUpdate?>(null) }
val wsClient = remember { ComfyWsClient(createDefaultHttpClient()) }
Scaffold(
snackbarHost = { SnackbarHost(hostState = snackbar) },
topBar = {
TopAppBar(title = { Text(text = when (current.value) {
Dest.Home -> "工作流"
Dest.Settings -> "设置"
Dest.Import -> "导入工作流"
Dest.Editor -> "编辑工作流"
Dest.Gallery -> "结果"
}) })
},
floatingActionButton = {
if (current.value == Dest.Editor) {
ExtendedFloatingActionButton(
text = { Text("生成") },
icon = {},
onClick = {
val p = promptState ?: return@ExtendedFloatingActionButton
scope.launch {
val repo = AppGraph.comfy
snackbar.showSnackbar("提交中…")
val clientId = (currentWorkflowId ?: "client")
scope.launch {
runCatching {
wsClient.listen(
AppGraph.settings.getBaseUrl() ?: "",
clientId,
onUpdate = { progress = it },
onImages = { refs ->
scope.launch {
val imgs = refs.mapNotNull { ref ->
val bytes = repo.image(ref.filename, ref.subfolder, ref.type)
bytes?.let { decodeImage(it) }
}
images = imgs
progress = null
}
}
)
}
}
runCatching { repo.submit(p, clientId) }.onFailure { e ->
snackbar.showSnackbar(e.message ?: "运行失败")
}
}
}
)
}
}
) { padding ->
when (current.value) {
Dest.Home -> HomeScreen(
contentPadding = padding,
onPick = { item ->
currentWorkflowId = item.id
currentWorkflowName = item.name
promptState = item.prompt
current.value = Dest.Editor
},
onCreate = { current.value = Dest.Import }
)
Dest.Settings -> SettingsScreen(padding){
current.value = Dest.Import
}
Dest.Import -> ImportScreen(
contentPadding = padding,
onImported = {
val name = it.values.firstOrNull()?.meta?.title ?: "工作流"
val id = name + "_" + it.hashCode()
AppGraph.workflows.saveOrUpdate(
WorkflowItem(
id = id,
name = name,
prompt = it
)
)
currentWorkflowId = id
currentWorkflowName = name
promptState = it
current.value = Dest.Editor
},
onError = { msg -> scope.launch { snackbar.showSnackbar(msg) } }
)
Dest.Editor -> EditorScreen(
contentPadding = padding,
prompt = promptState ?: emptyMap(),
latestImage = images.firstOrNull(),
progress = progress,
onPromptChange = {
promptState = it
val name = currentWorkflowName ?: it.values.firstOrNull()?.meta?.title ?: "工作流"
val id = currentWorkflowId ?: (name + "_" + it.hashCode()).also { nid -> currentWorkflowId = nid }
currentWorkflowName = name
AppGraph.workflows.saveOrUpdate(
WorkflowItem(
id = id,
name = name,
prompt = it
)
)
}
)
Dest.Gallery -> GalleryScreen(contentPadding = padding, images = images)
else -> Text("占位页面:" + current.value.name, modifier = Modifier.fillMaxSize())
}
}
}
}
@@ -0,0 +1,157 @@
package moe.uni.comfy.comfyuikmp.ui.editor
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.BottomSheetScaffold
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.Button
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.ui.draw.clip
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.booleanOrNull
import kotlinx.serialization.json.doubleOrNull
import kotlinx.serialization.json.intOrNull
import kotlin.random.Random
import moe.uni.comfy.comfyuikmp.data.model.ComfyPrompt
import moe.uni.comfy.comfyuikmp.data.model.updateNodeStringInput
import moe.uni.comfy.comfyuikmp.data.model.updateNodePrimitiveInput
import moe.uni.comfy.comfyuikmp.di.AppGraph
import moe.uni.comfy.comfyuikmp.data.network.ProgressUpdate
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EditorScreen(
contentPadding: PaddingValues,
prompt: ComfyPrompt,
latestImage: ImageBitmap?,
progress: ProgressUpdate? = null,
onPromptChange: (ComfyPrompt) -> Unit,
) {
BottomSheetScaffold(
sheetPeekHeight = 56.dp,
sheetContent = {
LazyColumn(modifier = Modifier.padding(16.dp)) {
items(prompt.keys.toList()) { nodeId ->
val node = prompt[nodeId]
val title = node?.meta?.title ?: nodeId
Text(title, style = MaterialTheme.typography.titleMedium, modifier = Modifier.padding(top = 8.dp))
node?.inputs?.forEach { (key, value: JsonElement) ->
if (value is JsonPrimitive) {
when {
value.isString -> {
var field by remember(nodeId, key) { mutableStateOf(value.content) }
OutlinedTextField(
value = field,
onValueChange = {
field = it
onPromptChange(updateNodeStringInput(prompt, nodeId, key, it))
},
label = { Text(key) },
modifier = Modifier
.padding(top = 8.dp)
.fillMaxWidth()
)
}
value.booleanOrNull != null -> {
var checked by remember(nodeId, key) { mutableStateOf(value.booleanOrNull == true) }
androidx.compose.material3.Switch(
checked = checked,
onCheckedChange = {
checked = it
onPromptChange(updateNodePrimitiveInput(prompt, nodeId, key, JsonPrimitive(it)))
},
)
}
value.intOrNull != null || value.doubleOrNull != null -> {
var text by remember(nodeId, key) { mutableStateOf(value.toString()) }
OutlinedTextField(
value = text,
onValueChange = {
text = it
it.toIntOrNull()?.let { num ->
onPromptChange(updateNodePrimitiveInput(prompt, nodeId, key, JsonPrimitive(num)))
} ?: it.toDoubleOrNull()?.let { d ->
onPromptChange(updateNodePrimitiveInput(prompt, nodeId, key, JsonPrimitive(d)))
}
},
label = { Text(key) },
modifier = Modifier
.padding(top = 8.dp)
.fillMaxWidth()
)
if (key.equals("seed", ignoreCase = true)) {
Row(modifier = Modifier.padding(top = 8.dp)) {
Button(onClick = {
val rnd = Random.nextInt(0, Int.MAX_VALUE)
text = rnd.toString()
onPromptChange(updateNodePrimitiveInput(prompt, nodeId, key, JsonPrimitive(rnd)))
}) { Text("随机") }
Spacer(Modifier.width(8.dp))
Text("自动生成随机种子", style = MaterialTheme.typography.bodySmall)
}
}
}
else -> {
OutlinedTextField(
value = value.toString(),
onValueChange = {},
readOnly = true,
label = { Text(key) },
modifier = Modifier
.padding(top = 8.dp)
.fillMaxWidth()
)
}
}
} else {
OutlinedTextField(
value = value.toString(),
onValueChange = {},
readOnly = true,
label = { Text(key) },
modifier = Modifier
.padding(top = 8.dp)
.fillMaxWidth()
)
}
}
}
}
}
) { innerPadding ->
Column(modifier = Modifier.padding(contentPadding).padding(innerPadding).padding(16.dp)) {
val p = progress
if (p != null) {
LinearProgressIndicator(progress = { p.fraction ?: 0f }, modifier = Modifier.fillMaxWidth())
if (p.message != null) Text(p.message, style = MaterialTheme.typography.bodySmall)
}
if (latestImage != null) {
Image(bitmap = latestImage, contentDescription = null, modifier = Modifier.fillMaxSize().clip(
RoundedCornerShape(15.dp)
))
} else {
Text("暂无生成结果", style = MaterialTheme.typography.bodyMedium)
}
}
}
}
@@ -0,0 +1,40 @@
package moe.uni.comfy.comfyuikmp.ui.gallery
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.unit.dp
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun GalleryScreen(contentPadding: PaddingValues, images: List<ImageBitmap>) {
if (images.isEmpty()) {
Text("暂无图片", modifier = Modifier.padding(contentPadding).padding(16.dp))
return
}
LazyVerticalGrid(
columns = GridCells.Adaptive(minSize = 160.dp),
contentPadding = contentPadding
) {
items(images) { img ->
Image(
bitmap = img,
contentDescription = null,
modifier = Modifier
.padding(6.dp)
.aspectRatio(1f)
)
}
}
}
@@ -0,0 +1,85 @@
package moe.uni.comfy.comfyuikmp.ui.home
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Card
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import moe.uni.comfy.comfyuikmp.data.repository.WorkflowItem
import moe.uni.comfy.comfyuikmp.di.AppGraph
import androidx.compose.material3.IconButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Button
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Icon
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import compose.icons.FontAwesomeIcons
import compose.icons.fontawesomeicons.Brands
import compose.icons.fontawesomeicons.Regular
import compose.icons.fontawesomeicons.brands.FontAwesome
import compose.icons.fontawesomeicons.regular.Edit
import compose.icons.fontawesomeicons.regular.TrashAlt
@Composable
fun HomeScreen(
contentPadding: PaddingValues,
onPick: (WorkflowItem) -> Unit,
onCreate: () -> Unit
) {
val repo = remember { AppGraph.workflows }
val items = repo.list()
var renaming by remember { mutableStateOf<WorkflowItem?>(null) }
var newName by remember { mutableStateOf("") }
LazyColumn(contentPadding = contentPadding) {
item {
Card(modifier = Modifier
.padding(16.dp)
.fillMaxWidth()
.clickable { onCreate() }
) { Text("新建/导入工作流", modifier = Modifier.padding(16.dp), style = MaterialTheme.typography.titleMedium) }
}
items(items) { w ->
Card(modifier = Modifier
.padding(horizontal = 16.dp, vertical = 8.dp)
.fillMaxWidth()
.clickable { onPick(w) }
) {
Text(w.name, modifier = Modifier.padding(16.dp), style = MaterialTheme.typography.titleMedium)
Row(modifier = Modifier.padding(horizontal = 8.dp)) {
IconButton(onClick = { renaming = w; newName = w.name }) { Icon(FontAwesomeIcons.Regular.Edit, contentDescription = null,
Modifier.size(24.dp)) }
IconButton(onClick = { AppGraph.workflows.delete(w.id) }) { Icon(FontAwesomeIcons.Regular.TrashAlt, contentDescription = null,
Modifier.size(24.dp)) }
}
}
}
}
val r = renaming
if (r != null) {
AlertDialog(onDismissRequest = { renaming = null }, confirmButton = {
Button(onClick = {
AppGraph.workflows.rename(r.id, newName.ifBlank { r.name })
renaming = null
}) { Text("确定") }
}, dismissButton = {
Button(onClick = { renaming = null }) { Text("取消") }
}, title = { Text("重命名") }, text = {
OutlinedTextField(value = newName, onValueChange = { newName = it }, label = { Text("名称") })
})
}
}
@@ -0,0 +1,9 @@
package moe.uni.comfy.comfyuikmp.ui.importer
import androidx.compose.runtime.Composable
import moe.uni.comfy.comfyuikmp.data.model.ComfyPrompt
@Composable
expect fun FileImportFab(onImported: (ComfyPrompt) -> Unit, onError: (String) -> Unit)
@@ -0,0 +1,8 @@
package moe.uni.comfy.comfyuikmp.ui.importer
import androidx.compose.runtime.Composable
@Composable
expect fun rememberJsonFilePicker(onPicked: (name: String, content: String) -> Unit): () -> Unit
@@ -0,0 +1,54 @@
package moe.uni.comfy.comfyuikmp.ui.importer
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Scaffold
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.max
import moe.uni.comfy.comfyuikmp.data.model.ComfyPrompt
import moe.uni.comfy.comfyuikmp.data.model.parsePromptJson
import org.jetbrains.compose.ui.tooling.preview.Preview
@Composable
@Preview
fun ImportScreen(
contentPadding: PaddingValues,
onImported: (ComfyPrompt) -> Unit,
onError: (String) -> Unit
) {
var text by remember { mutableStateOf("") }
Scaffold(
floatingActionButton = {
FileImportFab(onImported = onImported, onError = onError)
}
) { inner ->
Column(Modifier.padding(contentPadding).padding(inner).padding(16.dp)) {
OutlinedTextField(
value = text,
onValueChange = { text = it },
label = { Text("粘贴 ComfyUI 工作流 JSON") },
modifier = Modifier.fillMaxWidth(),
minLines = 8,
maxLines = 8,
)
Button(
onClick = {
runCatching { parsePromptJson(text) }
.onSuccess { onImported(it) }
.onFailure { onError(it.message ?: "解析失败") }
},
modifier = Modifier.padding(top = 12.dp)
) { Text("导入") }
}
}
}
@@ -0,0 +1,11 @@
package moe.uni.comfy.comfyuikmp.ui.navigation
enum class Dest {
Home,
Settings,
Import,
Editor,
Gallery
}
@@ -0,0 +1,35 @@
package moe.uni.comfy.comfyuikmp.ui.settings
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import moe.uni.comfy.comfyuikmp.di.AppGraph
@Composable
fun SettingsScreen(contentPadding: PaddingValues, onSave: () -> Unit) {
val repo = remember { AppGraph.settings }
var baseUrl by remember { mutableStateOf(repo.getBaseUrl().orEmpty()) }
Column(Modifier.padding(contentPadding).padding(16.dp)) {
OutlinedTextField(
value = baseUrl,
onValueChange = { baseUrl = it },
label = { Text("ComfyUI Base URL") },
modifier = Modifier.fillMaxWidth()
)
Button(onClick = {
repo.setBaseUrl(baseUrl.trim())
onSave.invoke()
}, modifier = Modifier.padding(top = 12.dp)) {
Text("保存")
}
}
}
@@ -0,0 +1,7 @@
package moe.uni.comfy.comfyuikmp.util
import androidx.compose.ui.graphics.ImageBitmap
expect fun decodeImage(bytes: ByteArray): ImageBitmap?
@@ -0,0 +1,12 @@
package moe.uni.comfy.comfyuikmp
import kotlin.test.Test
import kotlin.test.assertEquals
class ComposeAppCommonTest {
@Test
fun example() {
assertEquals(3, 1 + 2)
}
}
@@ -0,0 +1,9 @@
package moe.uni.comfy.comfyuikmp
import androidx.compose.ui.window.ComposeUIViewController
import moe.uni.comfy.comfyuikmp.data.settings.KeyValueStore
fun MainViewController() = ComposeUIViewController {
KeyValueStore.init(platformContext = null)
App()
}
@@ -0,0 +1,9 @@
package moe.uni.comfy.comfyuikmp
import platform.UIKit.UIDevice
class IOSPlatform : Platform {
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
}
actual fun getPlatform(): Platform = IOSPlatform()
@@ -0,0 +1,31 @@
package moe.uni.comfy.comfyuikmp.data.network
import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.engine.darwin.Darwin
import io.ktor.client.plugins.HttpTimeout
import io.ktor.client.plugins.UserAgent
import io.ktor.client.plugins.defaultRequest
import io.ktor.http.URLProtocol
import moe.uni.comfy.comfyuikmp.data.network.createPlatformHttpClient
actual fun createPlatformHttpClient(configure: HttpClientConfig<*>.() -> Unit): HttpClient {
return HttpClient(Darwin) {
install(HttpTimeout) {
requestTimeoutMillis = 60_000
connectTimeoutMillis = 30_000
socketTimeoutMillis = 60_000
}
install(UserAgent) {
agent = "ComfyUIKMP-iOS"
}
defaultRequest {
url {
protocol = URLProtocol.HTTP
}
}
configure()
}
}
@@ -0,0 +1,18 @@
package moe.uni.comfy.comfyuikmp.data.settings
import platform.Foundation.NSUserDefaults
actual object KeyValueStore {
private val defaults: NSUserDefaults = NSUserDefaults.standardUserDefaults()
actual fun init(platformContext: Any?) { /* no-op */ }
actual fun getString(key: String): String? = defaults.stringForKey(key)
actual fun setString(key: String, value: String) {
defaults.setObject(value, forKey = key)
defaults.synchronize()
}
}
@@ -0,0 +1,19 @@
package moe.uni.comfy.comfyuikmp.ui.importer
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import moe.uni.comfy.comfyuikmp.data.model.ComfyPrompt
import moe.uni.comfy.comfyuikmp.data.model.parsePromptJson
@Composable
actual fun FileImportFab(onImported: (ComfyPrompt) -> Unit, onError: (String) -> Unit) {
val pick = rememberJsonFilePicker { name: String, content: String ->
runCatching { parsePromptJson(content) }
.onSuccess { onImported(it) }
.onFailure { onError(it.message ?: "解析失败") }
}
ExtendedFloatingActionButton(text = { Text("从文件导入") }, icon = {}, onClick = { pick() })
}
@@ -0,0 +1,57 @@
package moe.uni.comfy.comfyuikmp.ui.importer
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import kotlinx.cinterop.BetaInteropApi
import kotlinx.cinterop.ExperimentalForeignApi
import platform.Foundation.NSString
import platform.Foundation.NSUTF8StringEncoding
import platform.Foundation.create
import platform.UniformTypeIdentifiers.UTTypeJSON
import platform.UIKit.UIApplication
import platform.UIKit.UIDocumentPickerDelegateProtocol
import platform.UIKit.UIDocumentPickerViewController
import platform.UIKit.UIViewController
import platform.darwin.NSObject
import platform.Foundation.NSURL
@OptIn(ExperimentalForeignApi::class, BetaInteropApi::class)
@Composable
actual fun rememberJsonFilePicker(onPicked: (name: String, content: String) -> Unit): () -> Unit {
val presenter = remember { findTopController() }
return remember {
{
val types = listOf(UTTypeJSON)
val picker = UIDocumentPickerViewController(forOpeningContentTypes = types)
picker.allowsMultipleSelection = false
val delegate = PickerDelegate { url ->
if (url == null) return@PickerDelegate
url.startAccessingSecurityScopedResource()
val name = url.lastPathComponent ?: "import.json"
val text = NSString.create(contentsOfURL = url, encoding = NSUTF8StringEncoding, error = null) as String?
url.stopAccessingSecurityScopedResource()
if (text != null) onPicked(name, text)
}
picker.delegate = delegate
presenter?.presentViewController(picker, animated = true, completion = null)
}
}
}
private fun findTopController(): UIViewController? {
val windows = UIApplication.sharedApplication.windows
val window = windows.firstOrNull() as? platform.UIKit.UIWindow
var top = window?.rootViewController
while (top?.presentedViewController != null) top = top.presentedViewController
return top
}
private class PickerDelegate(val onPicked: (NSURL?) -> Unit) : NSObject(), UIDocumentPickerDelegateProtocol {
override fun documentPicker(controller: UIDocumentPickerViewController, didPickDocumentsAtURLs: kotlin.collections.List<*>) {
val url = didPickDocumentsAtURLs.firstOrNull() as? NSURL
onPicked(url)
}
override fun documentPickerWasCancelled(controller: UIDocumentPickerViewController) { onPicked(null) }
}
@@ -0,0 +1,10 @@
package moe.uni.comfy.comfyuikmp.util
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.toComposeImageBitmap
import org.jetbrains.skia.Image
actual fun decodeImage(bytes: ByteArray): ImageBitmap? =
runCatching { Image.makeFromEncoded(bytes).toComposeImageBitmap() }.getOrNull()
+10
View File
@@ -0,0 +1,10 @@
#Kotlin
kotlin.code.style=official
kotlin.daemon.jvmargs=-Xmx3072M
#Gradle
org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8
org.gradle.configuration-cache=true
org.gradle.caching=true
#Android
android.nonTransitiveRClass=true
android.useAndroidX=true
+44
View File
@@ -0,0 +1,44 @@
[versions]
agp = "8.11.2"
android-compileSdk = "36"
android-minSdk = "24"
android-targetSdk = "36"
androidx-activity = "1.11.0"
androidx-appcompat = "1.7.1"
androidx-core = "1.17.0"
androidx-espresso = "3.7.0"
androidx-lifecycle = "2.9.4"
androidx-testExt = "1.3.0"
composeMultiplatform = "1.9.0"
junit = "4.13.2"
kotlin = "2.2.20"
ktor = "3.0.0"
serialization = "1.7.3"
[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlin-testJunit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
junit = { module = "junit:junit", version.ref = "junit" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
androidx-testExt-junit = { module = "androidx.test.ext:junit", version.ref = "androidx-testExt" }
androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidx-espresso" }
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
androidx-lifecycle-viewmodelCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" }
androidx-lifecycle-runtimeCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
ktor-client-contentNegotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" }
composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored Executable
+251
View File
@@ -0,0 +1,251 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
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 optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+94
View File
@@ -0,0 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+7
View File
@@ -0,0 +1,7 @@
TEAM_ID=
PRODUCT_NAME=comfyuikmp
PRODUCT_BUNDLE_IDENTIFIER=moe.uni.comfy.comfyuikmp.comfyuikmp$(TEAM_ID)
CURRENT_PROJECT_VERSION=1
MARKETING_VERSION=1.0
+373
View File
@@ -0,0 +1,373 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 77;
objects = {
/* Begin PBXFileReference section */
435B55A05ECBD4CEAE2F09AD /* comfyuikmp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = comfyuikmp.app; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
B01123528DA2C99F4406326A /* Exceptions for "iosApp" folder in "iosApp" target */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
Info.plist,
);
target = 671EC8C79CF41832257DB504 /* iosApp */;
};
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
/* Begin PBXFileSystemSynchronizedRootGroup section */
095711F5F622F4B5BE3EFA75 /* iosApp */ = {
isa = PBXFileSystemSynchronizedRootGroup;
exceptions = (
B01123528DA2C99F4406326A /* Exceptions for "iosApp" folder in "iosApp" target */,
);
path = iosApp;
sourceTree = "<group>";
};
CF9414654D7F1C0CBABF3105 /* Configuration */ = {
isa = PBXFileSystemSynchronizedRootGroup;
path = Configuration;
sourceTree = "<group>";
};
/* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */
B71AFF3DCC23BD5407D22B38 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
29C6B5D2F626DF40395C6557 = {
isa = PBXGroup;
children = (
CF9414654D7F1C0CBABF3105 /* Configuration */,
095711F5F622F4B5BE3EFA75 /* iosApp */,
DA1F75C1411A89854FC8C509 /* Products */,
);
sourceTree = "<group>";
};
DA1F75C1411A89854FC8C509 /* Products */ = {
isa = PBXGroup;
children = (
435B55A05ECBD4CEAE2F09AD /* comfyuikmp.app */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
671EC8C79CF41832257DB504 /* iosApp */ = {
isa = PBXNativeTarget;
buildConfigurationList = C5F0489CAF21F1B9DDCDE9EC /* Build configuration list for PBXNativeTarget "iosApp" */;
buildPhases = (
A0119CA2D4876DB056AE6971 /* Compile Kotlin Framework */,
39A2B2F6404A1B5A7EE4FEF9 /* Sources */,
B71AFF3DCC23BD5407D22B38 /* Frameworks */,
866772473E7501B461EB8A6F /* Resources */,
);
buildRules = (
);
dependencies = (
);
fileSystemSynchronizedGroups = (
095711F5F622F4B5BE3EFA75 /* iosApp */,
);
name = iosApp;
packageProductDependencies = (
);
productName = iosApp;
productReference = 435B55A05ECBD4CEAE2F09AD /* comfyuikmp.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
D3A0FA2F57232E5614C0AC86 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1620;
LastUpgradeCheck = 1620;
TargetAttributes = {
671EC8C79CF41832257DB504 = {
CreatedOnToolsVersion = 16.2;
};
};
};
buildConfigurationList = CE072D131AB21E31A22C0C65 /* Build configuration list for PBXProject "iosApp" */;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 29C6B5D2F626DF40395C6557;
minimizedProjectReferenceProxies = 1;
preferredProjectObjectVersion = 77;
productRefGroup = DA1F75C1411A89854FC8C509 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
671EC8C79CF41832257DB504 /* iosApp */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
866772473E7501B461EB8A6F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
A0119CA2D4876DB056AE6971 /* Compile Kotlin Framework */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Compile Kotlin Framework";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ \"YES\" = \"$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED\" ]; then\n echo \"Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \\\"YES\\\"\"\n exit 0\nfi\ncd \"$SRCROOT/..\"\n./gradlew :composeApp:embedAndSignAppleFrameworkForXcode\n";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
39A2B2F6404A1B5A7EE4FEF9 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
B418F86C9121F76AC29E0C68 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReferenceAnchor = CF9414654D7F1C0CBABF3105 /* Configuration */;
baseConfigurationReferenceRelativePath = Config.xcconfig;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.2;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
35E05C7FC47D3052DBB14A86 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReferenceAnchor = CF9414654D7F1C0CBABF3105 /* Configuration */;
baseConfigurationReferenceRelativePath = Config.xcconfig;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.2;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
1421DB7F95CDAE57944E10C9 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = "${TEAM_ID}";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = iosApp/Info.plist;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
CF145A26F4A0096FF05CC5ED /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = "${TEAM_ID}";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = iosApp/Info.plist;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
CE072D131AB21E31A22C0C65 /* Build configuration list for PBXProject "iosApp" */ = {
isa = XCConfigurationList;
buildConfigurations = (
B418F86C9121F76AC29E0C68 /* Debug */,
35E05C7FC47D3052DBB14A86 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C5F0489CAF21F1B9DDCDE9EC /* Build configuration list for PBXNativeTarget "iosApp" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1421DB7F95CDAE57944E10C9 /* Debug */,
CF145A26F4A0096FF05CC5ED /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = D3A0FA2F57232E5614C0AC86 /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
@@ -0,0 +1,11 @@
{
"colors": [
{
"idiom": "universal"
}
],
"info": {
"author": "xcode",
"version": 1
}
}
@@ -0,0 +1,36 @@
{
"images": [
{
"filename": "app-icon-1024.png",
"idiom": "universal",
"platform": "ios",
"size": "1024x1024"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"idiom": "universal",
"platform": "ios",
"size": "1024x1024"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "tinted"
}
],
"idiom": "universal",
"platform": "ios",
"size": "1024x1024"
}
],
"info": {
"author": "xcode",
"version": 1
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

@@ -0,0 +1,6 @@
{
"info": {
"author": "xcode",
"version": 1
}
}
+22
View File
@@ -0,0 +1,22 @@
import UIKit
import SwiftUI
import ComposeApp
struct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
MainViewControllerKt.MainViewController()
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
}
}
struct ContentView: View {
var body: some View {
ComposeView()
.ignoresSafeArea()
}
}
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
</dict>
</plist>
@@ -0,0 +1,6 @@
{
"info": {
"author": "xcode",
"version": 1
}
}
+10
View File
@@ -0,0 +1,10 @@
import SwiftUI
@main
struct iOSApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
+31
View File
@@ -0,0 +1,31 @@
rootProject.name = "comfyuikmp"
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
pluginManagement {
repositories {
google {
mavenContent {
includeGroupAndSubgroups("androidx")
includeGroupAndSubgroups("com.android")
includeGroupAndSubgroups("com.google")
}
}
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositories {
google {
mavenContent {
includeGroupAndSubgroups("androidx")
includeGroupAndSubgroups("com.android")
includeGroupAndSubgroups("com.google")
}
}
mavenCentral()
}
}
include(":composeApp")