Skip to content

Commit

Permalink
🔀 Merge pull request #16 from vinceglb/kotlin-v2
Browse files Browse the repository at this point in the history
⬆️ Kotlin 2.0.0-RC2
  • Loading branch information
vinceglb authored May 10, 2024
2 parents bf637be + 0c201d0 commit 928cd65
Show file tree
Hide file tree
Showing 16 changed files with 512 additions and 283 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ With `Picker`, you can pick files, medias and folders on each target from your c
val file = Picker.pickFile()

// Pick a directory
val files = Picker.pickDirectory()
val directory = Picker.pickDirectory()

// Save a file
val file = Picker.saveFile(
Expand All @@ -48,7 +48,7 @@ val bytes = file?.readBytes()
Compose Multiplatform integration made simple:

```kotlin
// Pick a file from Compose
// Pick files from Compose
val launcher = rememberFilePickerLauncher(PickerSelectionMode.Multiple) { files ->
// Handle picked files
}
Expand All @@ -72,7 +72,7 @@ dependencies {
// Enables Picker without Compose dependencies
implementation("io.github.vinceglb:picker-core:0.3.0")
// Enables Picker with rememberPickerLauncher Composable
// Enables Picker with Composable utilities
implementation("io.github.vinceglb:picker-compose:0.3.0")
}
```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.mavenPublishVanniktech) apply false
alias(libs.plugins.skie) apply false
}
9 changes: 4 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ agp = "8.4.0"
android-activity-ktx = "1.9.0"
android-compose = "1.9.0"
coilCompose = "3.0.0-alpha06"
compose-plugin = "1.6.2"
compose-plugin = "1.6.10-rc01"
jna = "5.14.0"
kmmViewmodel = "1.0.0-ALPHA-20"
kmmViewmodel = "1.0.0-ALPHA-20-kotlin-2.0.0-RC2"
koinCompose = "1.2.0-alpha3"
kotlin = "1.9.23"
kotlin = "2.0.0-RC2"
kotlinx-coroutines = "1.8.0"
mavenPublishVanniktech = "0.28.0"
skie = "0.6.4"

[libraries]
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "android-compose" }
Expand All @@ -25,7 +24,7 @@ kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-
[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
mavenPublishVanniktech = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublishVanniktech" }
skie = { id = "co.touchlab.skie", version.ref = "skie" }
556 changes: 381 additions & 175 deletions kotlin-js-store/yarn.lock

Large diffs are not rendered by default.

15 changes: 2 additions & 13 deletions picker-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.mavenPublishVanniktech)
Expand All @@ -13,23 +14,11 @@ kotlin {

// Android
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "17"
}
}
publishLibraryVariants("release")
}

// JVM / Desktop
jvmToolchain(17)
jvm {
compilations.all {
kotlinOptions {
jvmTarget = "17"
}
}
}
jvm()

// Wasm
@OptIn(ExperimentalWasmDsl::class)
Expand Down
22 changes: 1 addition & 21 deletions picker-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,11 @@ kotlin {

// Android
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "17"
}
}
publishLibraryVariants("release")
}

// JVM / Desktop
jvmToolchain(17)
jvm {
compilations.all {
kotlinOptions {
jvmTarget = "17"
}
}
}
jvm()

// JS / Web
@OptIn(ExperimentalWasmDsl::class)
Expand All @@ -53,14 +41,6 @@ kotlin {
}
}

targets.all {
compilations.all {
compilerOptions.configure {
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}
}

sourceSets {
commonMain.dependencies {
implementation(libs.kotlinx.coroutines.core)
Expand Down
11 changes: 3 additions & 8 deletions samples/sample-compose/composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig

plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidApplication)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.kotlinMultiplatform)
}

kotlin {
Expand All @@ -26,13 +27,7 @@ kotlin {
binaries.executable()
}

androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "11"
}
}
}
androidTarget()

jvm("desktop")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
BF104B0C2BED41390046917B /* KMMViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF104B0B2BED41390046917B /* KMMViewModel.swift */; };
BF104B0F2BED419D0046917B /* KMMViewModelSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = BF104B0E2BED419D0046917B /* KMMViewModelSwiftUI */; };
BF8748C82BBF4342003493D5 /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8748C72BBF4342003493D5 /* iOSApp.swift */; };
BF8748CA2BBF4342003493D5 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8748C92BBF4342003493D5 /* ContentView.swift */; };
BF8748CC2BBF4343003493D5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BF8748CB2BBF4343003493D5 /* Assets.xcassets */; };
Expand All @@ -19,9 +21,12 @@
BF8748F12BBF45B9003493D5 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8748F02BBF45B9003493D5 /* ContentView.swift */; };
BF8748F32BBF45BA003493D5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BF8748F22BBF45BA003493D5 /* Assets.xcassets */; };
BF8748F62BBF45BA003493D5 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BF8748F52BBF45BA003493D5 /* Preview Assets.xcassets */; };
BFCCCB632BEE1D7C00749584 /* KMMViewModelSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = BFCCCB622BEE1D7C00749584 /* KMMViewModelSwiftUI */; };
BFCCCB652BEE1E5B00749584 /* KMMViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFCCCB642BEE1E5B00749584 /* KMMViewModel.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
BF104B0B2BED41390046917B /* KMMViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMMViewModel.swift; sourceTree = "<group>"; };
BF8748C52BBF4342003493D5 /* iOSApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOSApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
BF8748C72BBF4342003493D5 /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };
BF8748C92BBF4342003493D5 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand All @@ -38,20 +43,23 @@
BF8748F02BBF45B9003493D5 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
BF8748F22BBF45BA003493D5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
BF8748F52BBF45BA003493D5 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
BFCCCB642BEE1E5B00749584 /* KMMViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMMViewModel.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
BF8748C22BBF4342003493D5 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
BFCCCB632BEE1D7C00749584 /* KMMViewModelSwiftUI in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
BF8748D52BBF44E4003493D5 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
BF104B0F2BED419D0046917B /* KMMViewModelSwiftUI in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -65,13 +73,21 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
BF104B0D2BED419D0046917B /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
BF8748A72BBF427F003493D5 = {
isa = PBXGroup;
children = (
BF8748D92BBF44E4003493D5 /* macOSApp */,
BF8748C62BBF4342003493D5 /* iOSApp */,
BF8748ED2BBF45B9003493D5 /* iOSAppCompose */,
BF8748B12BBF427F003493D5 /* Products */,
BF104B0D2BED419D0046917B /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -90,6 +106,7 @@
children = (
BF8748C72BBF4342003493D5 /* iOSApp.swift */,
BF8748C92BBF4342003493D5 /* ContentView.swift */,
BFCCCB642BEE1E5B00749584 /* KMMViewModel.swift */,
BF8748CB2BBF4343003493D5 /* Assets.xcassets */,
BF8748CD2BBF4343003493D5 /* Preview Content */,
);
Expand All @@ -109,6 +126,7 @@
children = (
BF8748DA2BBF44E4003493D5 /* macOSApp.swift */,
BF8748DC2BBF44E4003493D5 /* ContentView.swift */,
BF104B0B2BED41390046917B /* KMMViewModel.swift */,
BF8748DE2BBF44E6003493D5 /* Assets.xcassets */,
BF8748E32BBF44E6003493D5 /* macOSApp.entitlements */,
BF8748E02BBF44E6003493D5 /* Preview Content */,
Expand Down Expand Up @@ -160,6 +178,9 @@
dependencies = (
);
name = iOSApp;
packageProductDependencies = (
BFCCCB622BEE1D7C00749584 /* KMMViewModelSwiftUI */,
);
productName = iOSApp;
productReference = BF8748C52BBF4342003493D5 /* iOSApp.app */;
productType = "com.apple.product-type.application";
Expand All @@ -178,6 +199,9 @@
dependencies = (
);
name = macOSApp;
packageProductDependencies = (
BF104B0E2BED419D0046917B /* KMMViewModelSwiftUI */,
);
productName = macOSApp;
productReference = BF8748D82BBF44E4003493D5 /* macOSApp.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -230,6 +254,9 @@
Base,
);
mainGroup = BF8748A72BBF427F003493D5;
packageReferences = (
BF104B0A2BED40C40046917B /* XCRemoteSwiftPackageReference "KMM-ViewModel" */,
);
productRefGroup = BF8748B12BBF427F003493D5 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -330,6 +357,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BFCCCB652BEE1E5B00749584 /* KMMViewModel.swift in Sources */,
BF8748CA2BBF4342003493D5 /* ContentView.swift in Sources */,
BF8748C82BBF4342003493D5 /* iOSApp.swift in Sources */,
);
Expand All @@ -339,6 +367,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BF104B0C2BED41390046917B /* KMMViewModel.swift in Sources */,
BF8748DD2BBF44E4003493D5 /* ContentView.swift in Sources */,
BF8748DB2BBF44E4003493D5 /* macOSApp.swift in Sources */,
);
Expand Down Expand Up @@ -701,6 +730,30 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
BF104B0A2BED40C40046917B /* XCRemoteSwiftPackageReference "KMM-ViewModel" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/rickclephas/KMM-ViewModel.git";
requirement = {
kind = exactVersion;
version = "1.0.0-ALPHA-20";
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
BF104B0E2BED419D0046917B /* KMMViewModelSwiftUI */ = {
isa = XCSwiftPackageProductDependency;
package = BF104B0A2BED40C40046917B /* XCRemoteSwiftPackageReference "KMM-ViewModel" */;
productName = KMMViewModelSwiftUI;
};
BFCCCB622BEE1D7C00749584 /* KMMViewModelSwiftUI */ = {
isa = XCSwiftPackageProductDependency;
package = BF104B0A2BED40C40046917B /* XCRemoteSwiftPackageReference "KMM-ViewModel" */;
productName = KMMViewModelSwiftUI;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = BF8748A82BBF427F003493D5 /* Project object */;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"originHash" : "ad556088e5aec34cec10a7ca9ac4b521b542b15ac04d30f37ec7b0f6e795db36",
"pins" : [
{
"identity" : "kmm-viewmodel",
"kind" : "remoteSourceControl",
"location" : "https://github.com/rickclephas/KMM-ViewModel.git",
"state" : {
"revision" : "677d657ed678fadf50efac37b5d177170d6873a8",
"version" : "1.0.0-ALPHA-20"
}
}
],
"version" : 3
}
20 changes: 8 additions & 12 deletions samples/sample-core/appleApps/iOSApp/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
//

import SwiftUI
import KMMViewModelSwiftUI
import SamplePickerKt

struct ContentView: View {
let viewModel = MainViewModel()

@State
var uiState: MainUiState = MainUiState()
@StateViewModel
var viewModel = MainViewModel()

var body: some View {
let uiState = viewModel.uiState.value as? MainUiState

// Convert Set to Array
let files = Array(uiState.files)
let files = Array(uiState?.files ?? [])

VStack {
Image(systemName: "globe")
Expand Down Expand Up @@ -44,23 +45,18 @@ struct ContentView: View {
viewModel.pickDirectory()
}

if uiState.loading {
if uiState?.loading == true {
ProgressView()
}

Text("Directory: \(String(describing: uiState.directory?.path))")
Text("Directory: \(String(describing: uiState?.directory?.path))")

List(files, id: \.nsUrl) { file in
Text(file.name)
.onTapGesture { viewModel.saveFile(file: file) }
}
}
.padding()
.task {
for await state in viewModel.uiState {
uiState = state
}
}
}
}

Expand Down
Loading

0 comments on commit 928cd65

Please sign in to comment.