MrPowerGamerBR
08/02/2021, 12:57 AMMrPowerGamerBR
08/02/2021, 12:57 AM@Composable
fun Test(text: String, callback: @Composable (String) -> (Unit), customComposeKey: String, callback2: @Composable () -> (Unit)) {
val currentSection = StringBuilder()
val sectionName = StringBuilder()
var inSection = false
for (char in text) {
if (char == '}') {
inSection = false
val sectionNameAsString = sectionName.toString()
if (customComposeKey == sectionNameAsString) {
// Has a custom composable section!
callback.invoke(currentSection.toString()) // So first, we are going to append everything before this section
callback2.invoke() // And then we are going to call our custom composable section!
sectionName.clear()
} else {
// Doesn't has a custom composable section, just append the section as is and let the formatter do its thing
currentSection.append("{$sectionName}")
sectionName.clear()
}
continue
}
if (char == '{') {
inSection = true
continue
}
if (inSection)
sectionName.append(char)
else
currentSection.append(char)
}
// And now, invoke the left over section
callback.invoke(currentSection.toString())
}
Arslan Armanuly
08/02/2021, 2:03 AMMrPowerGamerBR
08/02/2021, 2:13 AMthis.is.a.key = If you want to know more, {0}
, where I want to replace the {0}
with a "click here" + href link. That's what the code does (which... well, should've worked if it didn't have that compiler error 😛)
An alternative would be storing the translations directly in Kotlin files, however this doesn't let me use Crowdin for translations (unless if I did a code generation task in Gradle to convert YAML files to Kotlin files? Maybe...)olonho
08/02/2021, 6:03 AMMrPowerGamerBR
08/02/2021, 4:33 PMbashor
08/02/2021, 5:10 PMbashor
08/02/2021, 5:54 PMbashor
08/02/2021, 5:54 PM@Composable
fun Test(text: String, callback: @Composable () -> Unit) {
for (char in text) {
if (char == '}') {
if (Random.nextBoolean()) {
callback()
} else {
println()
}
continue
}
}
}
bashor
08/02/2021, 5:55 PM@Composable
fun Test(text: String, callback: @Composable () -> Unit) {
for (char in text) {
if (char == '}') {
callback()
continue
}
}
}
MrPowerGamerBR
08/03/2021, 3:06 AMjim
08/03/2021, 3:28 AMMrPowerGamerBR
08/03/2021, 12:44 PMolonho
08/03/2021, 12:47 PMjim
08/04/2021, 10:30 AMlouiscad
08/04/2021, 10:52 AMjim
08/04/2021, 10:57 AMlouiscad
08/04/2021, 10:58 AM