Closed mahramane closed 3 months ago
I'm sorry, I'm having trouble understanding the question/issue.
Can you share a project that has the problem, and say the problem is / what you would like to happen?
I found a way for it. i write this code to gradle :
task("copy") {
val sourceDir = file("/.../app/src/main/java/ui")
val destinationDir = file("${project.projectDir.absolutePath}/composeApp/src/commonMain/kotlin/ui")
destinationDir.deleteRecursively()
sourceDir.copyRecursively(destinationDir)
FileUtils.listFiles(destinationDir, arrayOf("kt"), true)
.filter { it.isFile }
.forEach { file ->
var content = file.readText()
if (content.contains("@Preview")) {
//remove preview function
content = content.replace("import androidx.compose.ui.tooling.preview.PreviewScreenSizes", "")
content = content.replace("import androidx.compose.ui.tooling.preview.Preview", "")
val pattern = """@PreviewScreenSizes\n@Preview\n@Composable\nprivate fun (.+?)\(\) \{.+?\n}""".toRegex(RegexOption.DOT_MATCHES_ALL)
content = pattern.replace(content, "")
file.writeText(content)
}
}
println("copy kt files is done!")
}
I can't explain more than that, but I hope you understand what I mean.
Hi I moved all
jetpack-compose
codes to a directory withlayout
name incommonMain
directory and there isn't anyjetbrains-compose
codes in that So that when i copylayout
directory in anotherandroid studio jetpack compose
project, It works well. Now i want to userAndroid preview tools
because it's very easy to use and develop compose code.Is there a way to use the
android preview tools
feature without copying the layout directory inside anandroid jetpack compose project
?