79252974

Date: 2024-12-04 23:12:50
Score: 0.5
Natty:
Report link

Not Sure this one can help you. Please take a look. IntrinsicSize.Max can cause unintended behavior in layout calculation, especially with the combination of fillMaxHeight().

@Composable
fun WeatherCardWithTopBar(title: String, text: String, icon: ImageVector) {
    Card(
        modifier = Modifier.padding(8.dp) // External padding to adjust card spacing
    ) {
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(8.dp), // Internal padding for Row
        ) {
            // Left side column with background and centered content
            Column(
                modifier = Modifier
                    .fillMaxWidth(0.20f)
                    .background(MaterialTheme.colorScheme.secondary)
                    .padding(8.dp),
                horizontalAlignment = Alignment.CenterHorizontally,
                verticalArrangement = Arrangement.Center, // Center content vertically
            ) {
                Icon(
                    imageVector = icon,
                    modifier = Modifier.size(48.dp),
                    contentDescription = "Weather",
                    tint = MaterialTheme.colorScheme.onSecondary,
                )
                Text(
                    text = title,
                    modifier = Modifier.padding(top = 8.dp), // Adjusted padding for text
                    style = MaterialTheme.typography.titleLarge,
                    color = MaterialTheme.colorScheme.onSecondary,
                )
            }
            // Right side column for additional text
            Column(
                modifier = Modifier
                    .weight(1f) // Fills the remaining width of the Row
                    .padding(start = 16.dp) // Padding between columns
            ) {
                Text(
                    text = text,
                    style = MaterialTheme.typography.bodyMedium,
                )
            }
        }
    }
}

Result: enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Gold Yon War