shim/app/src/main/kotlin/com/vgmlr/shim/ShimItem.kt (1.7 kb)
Modified: 02:30:09 66 026 (20 May 026) - 4 Days Ago
Download
package com.vgmlr.shim

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
fun ShimItem(
    shim: ShimClass,
    onHashtagClick: (String) -> Unit
) {
    Column(
        modifier = Modifier
            .fillMaxWidth()
    ) {
        Text(
            text = shim.shimtext,
            style = MaterialTheme.typography.bodyLarge
        )

        if (shim.shimhash.isNotEmpty()) {
            val tags = shim.shimhash.split(" ").filter { it.isNotBlank() }
            Row(
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(vertical = 2.dp),
                horizontalArrangement = Arrangement.Start
            ) {
                tags.forEach { tag ->
                    val cleanTag = if (tag.startsWith("#")) tag else "#$tag"
                    Text(
                        text = cleanTag,
                        style = MaterialTheme.typography.labelLarge,
                        modifier = Modifier
                            .padding(end = 8.dp)
                            .clickable { onHashtagClick(cleanTag) }
                    )
                }
            }
        }

        Text(
            text = shim.shimtime,
            style = MaterialTheme.typography.bodyLarge.copy(
                fontSize = (MaterialTheme.typography.bodyLarge.fontSize.value * 0.85).sp,
                color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.6f)
            )
        )
    }
}