-
Notifications
You must be signed in to change notification settings - Fork 60
🐛 Fix PlatformFile child resolution for non-web #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import androidx.compose.runtime.Composable | |
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.rememberCoroutineScope | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
|
|
@@ -23,9 +24,11 @@ import io.github.vinceglb.filekit.sample.shared.ui.components.AppScreenHeader | |
| import io.github.vinceglb.filekit.sample.shared.ui.components.AppScreenHeaderButtonState | ||
| import io.github.vinceglb.filekit.sample.shared.ui.icons.LucideIcons | ||
| import io.github.vinceglb.filekit.sample.shared.ui.icons.MessageCircleCode | ||
| import io.github.vinceglb.filekit.sample.shared.ui.screens.directorypicker.rememberDirectoryPickerLauncher | ||
| import io.github.vinceglb.filekit.sample.shared.ui.theme.AppMaxWidth | ||
| import io.github.vinceglb.filekit.sample.shared.ui.theme.AppTheme | ||
| import io.github.vinceglb.filekit.sample.shared.util.plus | ||
| import kotlinx.coroutines.launch | ||
|
|
||
| @Composable | ||
| internal fun DebugRoute( | ||
|
|
@@ -51,6 +54,15 @@ private fun DebugScreen( | |
| files = file?.let(::listOf) ?: emptyList() | ||
| } | ||
|
|
||
| val scope = rememberCoroutineScope() | ||
| val folderPicker = rememberDirectoryPickerLauncher(directory = null) { folder -> | ||
| scope.launch { | ||
| folder?.let { | ||
| debugPlatformTest(folder) | ||
| } | ||
|
Comment on lines
+58
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The debug screen now launches the directory picker, but the callback only runs Useful? React with 👍 / 👎. |
||
| } | ||
| } | ||
|
|
||
| Scaffold( | ||
| topBar = { | ||
| AppPickerTopBar( | ||
|
|
@@ -75,7 +87,8 @@ private fun DebugScreen( | |
| primaryButtonState = buttonState, | ||
| onPrimaryButtonClick = { | ||
| buttonState = AppScreenHeaderButtonState.Loading | ||
| picker.launch() | ||
| // picker.launch() | ||
| folderPicker.launch() | ||
| }, | ||
| modifier = Modifier.sizeIn(maxWidth = AppMaxWidth), | ||
| ) | ||
|
|
@@ -94,6 +107,8 @@ private fun DebugScreen( | |
| } | ||
| } | ||
|
|
||
| internal expect suspend fun debugPlatformTest(folder: PlatformFile) | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun DebugScreenPreview() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,10 @@ | ||
| package io.github.vinceglb.filekit.sample.shared.ui.screens.debug | ||
| package io.github.vinceglb.filekit.sample.shared.ui.screens.debug | ||
|
|
||
| import io.github.vinceglb.filekit.PlatformFile | ||
| import io.github.vinceglb.filekit.div | ||
| import io.github.vinceglb.filekit.writeString | ||
|
|
||
| internal actual suspend fun debugPlatformTest(folder: PlatformFile) { | ||
| val file = folder / "debug-test-file.txt" | ||
| file.writeString("Vince") | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
expect fun PlatformFile(base, child)is declared innonWebMain, but Android depends onnonWebMain(seebuild-logic/convention/ConfigureKotlinMultiplatform.ktwhereandroidMaindepends onnonWebMain) and there is no Androidactualimplementation. As a result, Android builds will fail with an “expected/actual mismatch” when compiling the Android target, and the/operator onPlatformFilecan’t be resolved for Android. This breaks./gradlew assemblefor Android consumers until an Androidactualis added.Useful? React with 👍 / 👎.