|
|
|
@ -9,11 +9,12 @@ import androidx.compose.runtime.*
|
|
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
|
import androidx.compose.ui.unit.dp |
|
|
|
|
import components.resources.demo.shared.generated.resources.Res |
|
|
|
|
import kotlinx.io.* |
|
|
|
|
|
|
|
|
|
@Composable |
|
|
|
|
fun FileRes(paddingValues: PaddingValues) { |
|
|
|
|
Column( |
|
|
|
|
modifier = Modifier.padding(paddingValues) |
|
|
|
|
modifier = Modifier.padding(paddingValues).verticalScroll(rememberScrollState()) |
|
|
|
|
) { |
|
|
|
|
Text( |
|
|
|
|
modifier = Modifier.padding(16.dp), |
|
|
|
@ -50,7 +51,7 @@ fun FileRes(paddingValues: PaddingValues) {
|
|
|
|
|
) |
|
|
|
|
Text( |
|
|
|
|
modifier = Modifier.padding(16.dp), |
|
|
|
|
text = "File: 'files/platform-text.txt'", |
|
|
|
|
text = "File: 'files/icon.xml'", |
|
|
|
|
style = MaterialTheme.typography.titleLarge |
|
|
|
|
) |
|
|
|
|
OutlinedCard( |
|
|
|
@ -80,5 +81,50 @@ fun FileRes(paddingValues: PaddingValues) {
|
|
|
|
|
Text(bytes.decodeToString()) |
|
|
|
|
""".trimIndent() |
|
|
|
|
) |
|
|
|
|
Text( |
|
|
|
|
modifier = Modifier.padding(16.dp), |
|
|
|
|
text = "File: 'drawable/compose.png'", |
|
|
|
|
style = MaterialTheme.typography.titleLarge |
|
|
|
|
) |
|
|
|
|
OutlinedCard( |
|
|
|
|
modifier = Modifier.padding(horizontal = 16.dp), |
|
|
|
|
shape = RoundedCornerShape(4.dp), |
|
|
|
|
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.primaryContainer) |
|
|
|
|
) { |
|
|
|
|
var content by remember { mutableStateOf("") } |
|
|
|
|
LaunchedEffect(Unit) { |
|
|
|
|
@OptIn(ExperimentalStdlibApi::class) |
|
|
|
|
Buffer().use { buffer -> |
|
|
|
|
Res.getAsFlow("drawable/compose.png").collect { chunk -> |
|
|
|
|
buffer.write(chunk) |
|
|
|
|
} |
|
|
|
|
content = buffer.readByteArray().asList().toString() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Text( |
|
|
|
|
modifier = Modifier.padding(8.dp).height(200.dp).verticalScroll(rememberScrollState()), |
|
|
|
|
text = content, |
|
|
|
|
color = MaterialTheme.colorScheme.onPrimaryContainer, |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
Text( |
|
|
|
|
modifier = Modifier.padding(16.dp), |
|
|
|
|
text = """ |
|
|
|
|
import kotlinx.io.* |
|
|
|
|
|
|
|
|
|
var content by remember { |
|
|
|
|
mutableStateOf("") |
|
|
|
|
} |
|
|
|
|
LaunchedEffect(Unit) { |
|
|
|
|
Buffer().use { buffer -> |
|
|
|
|
Res.getAsFlow("drawable/compose.png").collect { chunk -> |
|
|
|
|
buffer.write(chunk) |
|
|
|
|
} |
|
|
|
|
content = buffer.readByteArray().asList().toString() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Text(content) |
|
|
|
|
""".trimIndent() |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |