Skip to content

Commit 928cd65

Browse files
authored
🔀 Merge pull request #16 from vinceglb/kotlin-v2
⬆️ Kotlin 2.0.0-RC2
2 parents bf637be + 0c201d0 commit 928cd65

File tree

16 files changed

+512
-283
lines changed

16 files changed

+512
-283
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ With `Picker`, you can pick files, medias and folders on each target from your c
2828
val file = Picker.pickFile()
2929

3030
// Pick a directory
31-
val files = Picker.pickDirectory()
31+
val directory = Picker.pickDirectory()
3232

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

5050
```kotlin
51-
// Pick a file from Compose
51+
// Pick files from Compose
5252
val launcher = rememberFilePickerLauncher(PickerSelectionMode.Multiple) { files ->
5353
// Handle picked files
5454
}
@@ -72,7 +72,7 @@ dependencies {
7272
// Enables Picker without Compose dependencies
7373
implementation("io.github.vinceglb:picker-core:0.3.0")
7474
75-
// Enables Picker with rememberPickerLauncher Composable
75+
// Enables Picker with Composable utilities
7676
implementation("io.github.vinceglb:picker-compose:0.3.0")
7777
}
7878
```

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
plugins {
22
alias(libs.plugins.androidLibrary) apply false
33
alias(libs.plugins.androidApplication) apply false
4+
alias(libs.plugins.compose.compiler) apply false
45
alias(libs.plugins.jetbrainsCompose) apply false
56
alias(libs.plugins.kotlinMultiplatform) apply false
67
alias(libs.plugins.mavenPublishVanniktech) apply false
7-
alias(libs.plugins.skie) apply false
88
}

gradle/libs.versions.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ agp = "8.4.0"
33
android-activity-ktx = "1.9.0"
44
android-compose = "1.9.0"
55
coilCompose = "3.0.0-alpha06"
6-
compose-plugin = "1.6.2"
6+
compose-plugin = "1.6.10-rc01"
77
jna = "5.14.0"
8-
kmmViewmodel = "1.0.0-ALPHA-20"
8+
kmmViewmodel = "1.0.0-ALPHA-20-kotlin-2.0.0-RC2"
99
koinCompose = "1.2.0-alpha3"
10-
kotlin = "1.9.23"
10+
kotlin = "2.0.0-RC2"
1111
kotlinx-coroutines = "1.8.0"
1212
mavenPublishVanniktech = "0.28.0"
13-
skie = "0.6.4"
1413

1514
[libraries]
1615
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "android-compose" }
@@ -25,7 +24,7 @@ kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-
2524
[plugins]
2625
androidApplication = { id = "com.android.application", version.ref = "agp" }
2726
androidLibrary = { id = "com.android.library", version.ref = "agp" }
27+
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
2828
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
2929
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
3030
mavenPublishVanniktech = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublishVanniktech" }
31-
skie = { id = "co.touchlab.skie", version.ref = "skie" }

kotlin-js-store/yarn.lock

Lines changed: 381 additions & 175 deletions
Large diffs are not rendered by default.

picker-compose/build.gradle.kts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
22

33
plugins {
44
alias(libs.plugins.androidLibrary)
5+
alias(libs.plugins.compose.compiler)
56
alias(libs.plugins.kotlinMultiplatform)
67
alias(libs.plugins.jetbrainsCompose)
78
alias(libs.plugins.mavenPublishVanniktech)
@@ -13,23 +14,11 @@ kotlin {
1314

1415
// Android
1516
androidTarget {
16-
compilations.all {
17-
kotlinOptions {
18-
jvmTarget = "17"
19-
}
20-
}
2117
publishLibraryVariants("release")
2218
}
2319

2420
// JVM / Desktop
25-
jvmToolchain(17)
26-
jvm {
27-
compilations.all {
28-
kotlinOptions {
29-
jvmTarget = "17"
30-
}
31-
}
32-
}
21+
jvm()
3322

3423
// Wasm
3524
@OptIn(ExperimentalWasmDsl::class)

picker-core/build.gradle.kts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,11 @@ kotlin {
1111

1212
// Android
1313
androidTarget {
14-
compilations.all {
15-
kotlinOptions {
16-
jvmTarget = "17"
17-
}
18-
}
1914
publishLibraryVariants("release")
2015
}
2116

2217
// JVM / Desktop
23-
jvmToolchain(17)
24-
jvm {
25-
compilations.all {
26-
kotlinOptions {
27-
jvmTarget = "17"
28-
}
29-
}
30-
}
18+
jvm()
3119

3220
// JS / Web
3321
@OptIn(ExperimentalWasmDsl::class)
@@ -53,14 +41,6 @@ kotlin {
5341
}
5442
}
5543

56-
targets.all {
57-
compilations.all {
58-
compilerOptions.configure {
59-
freeCompilerArgs.add("-Xexpect-actual-classes")
60-
}
61-
}
62-
}
63-
6444
sourceSets {
6545
commonMain.dependencies {
6646
implementation(libs.kotlinx.coroutines.core)

samples/sample-compose/composeApp/build.gradle.kts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
33
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
44

55
plugins {
6-
alias(libs.plugins.kotlinMultiplatform)
76
alias(libs.plugins.androidApplication)
7+
alias(libs.plugins.compose.compiler)
88
alias(libs.plugins.jetbrainsCompose)
9+
alias(libs.plugins.kotlinMultiplatform)
910
}
1011

1112
kotlin {
@@ -26,13 +27,7 @@ kotlin {
2627
binaries.executable()
2728
}
2829

29-
androidTarget {
30-
compilations.all {
31-
kotlinOptions {
32-
jvmTarget = "11"
33-
}
34-
}
35-
}
30+
androidTarget()
3631

3732
jvm("desktop")
3833

samples/sample-core/appleApps/PickerKotlinSampleCore.xcodeproj/project.pbxproj

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
BF104B0C2BED41390046917B /* KMMViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF104B0B2BED41390046917B /* KMMViewModel.swift */; };
11+
BF104B0F2BED419D0046917B /* KMMViewModelSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = BF104B0E2BED419D0046917B /* KMMViewModelSwiftUI */; };
1012
BF8748C82BBF4342003493D5 /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8748C72BBF4342003493D5 /* iOSApp.swift */; };
1113
BF8748CA2BBF4342003493D5 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8748C92BBF4342003493D5 /* ContentView.swift */; };
1214
BF8748CC2BBF4343003493D5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BF8748CB2BBF4343003493D5 /* Assets.xcassets */; };
@@ -19,9 +21,12 @@
1921
BF8748F12BBF45B9003493D5 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8748F02BBF45B9003493D5 /* ContentView.swift */; };
2022
BF8748F32BBF45BA003493D5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BF8748F22BBF45BA003493D5 /* Assets.xcassets */; };
2123
BF8748F62BBF45BA003493D5 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BF8748F52BBF45BA003493D5 /* Preview Assets.xcassets */; };
24+
BFCCCB632BEE1D7C00749584 /* KMMViewModelSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = BFCCCB622BEE1D7C00749584 /* KMMViewModelSwiftUI */; };
25+
BFCCCB652BEE1E5B00749584 /* KMMViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFCCCB642BEE1E5B00749584 /* KMMViewModel.swift */; };
2226
/* End PBXBuildFile section */
2327

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

4349
/* Begin PBXFrameworksBuildPhase section */
4450
BF8748C22BBF4342003493D5 /* Frameworks */ = {
4551
isa = PBXFrameworksBuildPhase;
4652
buildActionMask = 2147483647;
4753
files = (
54+
BFCCCB632BEE1D7C00749584 /* KMMViewModelSwiftUI in Frameworks */,
4855
);
4956
runOnlyForDeploymentPostprocessing = 0;
5057
};
5158
BF8748D52BBF44E4003493D5 /* Frameworks */ = {
5259
isa = PBXFrameworksBuildPhase;
5360
buildActionMask = 2147483647;
5461
files = (
62+
BF104B0F2BED419D0046917B /* KMMViewModelSwiftUI in Frameworks */,
5563
);
5664
runOnlyForDeploymentPostprocessing = 0;
5765
};
@@ -65,13 +73,21 @@
6573
/* End PBXFrameworksBuildPhase section */
6674

6775
/* Begin PBXGroup section */
76+
BF104B0D2BED419D0046917B /* Frameworks */ = {
77+
isa = PBXGroup;
78+
children = (
79+
);
80+
name = Frameworks;
81+
sourceTree = "<group>";
82+
};
6883
BF8748A72BBF427F003493D5 = {
6984
isa = PBXGroup;
7085
children = (
7186
BF8748D92BBF44E4003493D5 /* macOSApp */,
7287
BF8748C62BBF4342003493D5 /* iOSApp */,
7388
BF8748ED2BBF45B9003493D5 /* iOSAppCompose */,
7489
BF8748B12BBF427F003493D5 /* Products */,
90+
BF104B0D2BED419D0046917B /* Frameworks */,
7591
);
7692
sourceTree = "<group>";
7793
};
@@ -90,6 +106,7 @@
90106
children = (
91107
BF8748C72BBF4342003493D5 /* iOSApp.swift */,
92108
BF8748C92BBF4342003493D5 /* ContentView.swift */,
109+
BFCCCB642BEE1E5B00749584 /* KMMViewModel.swift */,
93110
BF8748CB2BBF4343003493D5 /* Assets.xcassets */,
94111
BF8748CD2BBF4343003493D5 /* Preview Content */,
95112
);
@@ -109,6 +126,7 @@
109126
children = (
110127
BF8748DA2BBF44E4003493D5 /* macOSApp.swift */,
111128
BF8748DC2BBF44E4003493D5 /* ContentView.swift */,
129+
BF104B0B2BED41390046917B /* KMMViewModel.swift */,
112130
BF8748DE2BBF44E6003493D5 /* Assets.xcassets */,
113131
BF8748E32BBF44E6003493D5 /* macOSApp.entitlements */,
114132
BF8748E02BBF44E6003493D5 /* Preview Content */,
@@ -160,6 +178,9 @@
160178
dependencies = (
161179
);
162180
name = iOSApp;
181+
packageProductDependencies = (
182+
BFCCCB622BEE1D7C00749584 /* KMMViewModelSwiftUI */,
183+
);
163184
productName = iOSApp;
164185
productReference = BF8748C52BBF4342003493D5 /* iOSApp.app */;
165186
productType = "com.apple.product-type.application";
@@ -178,6 +199,9 @@
178199
dependencies = (
179200
);
180201
name = macOSApp;
202+
packageProductDependencies = (
203+
BF104B0E2BED419D0046917B /* KMMViewModelSwiftUI */,
204+
);
181205
productName = macOSApp;
182206
productReference = BF8748D82BBF44E4003493D5 /* macOSApp.app */;
183207
productType = "com.apple.product-type.application";
@@ -230,6 +254,9 @@
230254
Base,
231255
);
232256
mainGroup = BF8748A72BBF427F003493D5;
257+
packageReferences = (
258+
BF104B0A2BED40C40046917B /* XCRemoteSwiftPackageReference "KMM-ViewModel" */,
259+
);
233260
productRefGroup = BF8748B12BBF427F003493D5 /* Products */;
234261
projectDirPath = "";
235262
projectRoot = "";
@@ -330,6 +357,7 @@
330357
isa = PBXSourcesBuildPhase;
331358
buildActionMask = 2147483647;
332359
files = (
360+
BFCCCB652BEE1E5B00749584 /* KMMViewModel.swift in Sources */,
333361
BF8748CA2BBF4342003493D5 /* ContentView.swift in Sources */,
334362
BF8748C82BBF4342003493D5 /* iOSApp.swift in Sources */,
335363
);
@@ -339,6 +367,7 @@
339367
isa = PBXSourcesBuildPhase;
340368
buildActionMask = 2147483647;
341369
files = (
370+
BF104B0C2BED41390046917B /* KMMViewModel.swift in Sources */,
342371
BF8748DD2BBF44E4003493D5 /* ContentView.swift in Sources */,
343372
BF8748DB2BBF44E4003493D5 /* macOSApp.swift in Sources */,
344373
);
@@ -701,6 +730,30 @@
701730
defaultConfigurationName = Release;
702731
};
703732
/* End XCConfigurationList section */
733+
734+
/* Begin XCRemoteSwiftPackageReference section */
735+
BF104B0A2BED40C40046917B /* XCRemoteSwiftPackageReference "KMM-ViewModel" */ = {
736+
isa = XCRemoteSwiftPackageReference;
737+
repositoryURL = "https://github.com/rickclephas/KMM-ViewModel.git";
738+
requirement = {
739+
kind = exactVersion;
740+
version = "1.0.0-ALPHA-20";
741+
};
742+
};
743+
/* End XCRemoteSwiftPackageReference section */
744+
745+
/* Begin XCSwiftPackageProductDependency section */
746+
BF104B0E2BED419D0046917B /* KMMViewModelSwiftUI */ = {
747+
isa = XCSwiftPackageProductDependency;
748+
package = BF104B0A2BED40C40046917B /* XCRemoteSwiftPackageReference "KMM-ViewModel" */;
749+
productName = KMMViewModelSwiftUI;
750+
};
751+
BFCCCB622BEE1D7C00749584 /* KMMViewModelSwiftUI */ = {
752+
isa = XCSwiftPackageProductDependency;
753+
package = BF104B0A2BED40C40046917B /* XCRemoteSwiftPackageReference "KMM-ViewModel" */;
754+
productName = KMMViewModelSwiftUI;
755+
};
756+
/* End XCSwiftPackageProductDependency section */
704757
};
705758
rootObject = BF8748A82BBF427F003493D5 /* Project object */;
706759
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"originHash" : "ad556088e5aec34cec10a7ca9ac4b521b542b15ac04d30f37ec7b0f6e795db36",
3+
"pins" : [
4+
{
5+
"identity" : "kmm-viewmodel",
6+
"kind" : "remoteSourceControl",
7+
"location" : "https://github.com/rickclephas/KMM-ViewModel.git",
8+
"state" : {
9+
"revision" : "677d657ed678fadf50efac37b5d177170d6873a8",
10+
"version" : "1.0.0-ALPHA-20"
11+
}
12+
}
13+
],
14+
"version" : 3
15+
}

samples/sample-core/appleApps/iOSApp/ContentView.swift

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@
66
//
77

88
import SwiftUI
9+
import KMMViewModelSwiftUI
910
import SamplePickerKt
1011

1112
struct ContentView: View {
12-
let viewModel = MainViewModel()
13-
14-
@State
15-
var uiState: MainUiState = MainUiState()
13+
@StateViewModel
14+
var viewModel = MainViewModel()
1615

1716
var body: some View {
17+
let uiState = viewModel.uiState.value as? MainUiState
18+
1819
// Convert Set to Array
19-
let files = Array(uiState.files)
20+
let files = Array(uiState?.files ?? [])
2021

2122
VStack {
2223
Image(systemName: "globe")
@@ -44,23 +45,18 @@ struct ContentView: View {
4445
viewModel.pickDirectory()
4546
}
4647

47-
if uiState.loading {
48+
if uiState?.loading == true {
4849
ProgressView()
4950
}
5051

51-
Text("Directory: \(String(describing: uiState.directory?.path))")
52+
Text("Directory: \(String(describing: uiState?.directory?.path))")
5253

5354
List(files, id: \.nsUrl) { file in
5455
Text(file.name)
5556
.onTapGesture { viewModel.saveFile(file: file) }
5657
}
5758
}
5859
.padding()
59-
.task {
60-
for await state in viewModel.uiState {
61-
uiState = state
62-
}
63-
}
6460
}
6561
}
6662

0 commit comments

Comments
 (0)