diff --git a/app/src/main/kotlin/com/aliucord/manager/ui/screens/about/components/LeadContributor.kt b/app/src/main/kotlin/com/aliucord/manager/ui/screens/about/components/LeadContributor.kt index 4bc7ce9..3ffd0e6 100644 --- a/app/src/main/kotlin/com/aliucord/manager/ui/screens/about/components/LeadContributor.kt +++ b/app/src/main/kotlin/com/aliucord/manager/ui/screens/about/components/LeadContributor.kt @@ -1,94 +1,96 @@ package com.aliucord.manager.ui.screens.about.components import androidx.compose.foundation.clickable -import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.* import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalUriHandler +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import coil3.compose.SubcomposeAsyncImage +import com.aliucord.manager.network.models.Developer import com.valentinilk.shimmer.shimmer @Composable -fun LeadContributor( - name: String, - roles: String, - username: String = name, - modifier: Modifier = Modifier, +fun ContributorListItem( + contributor: Developer, + isLast: Boolean = false, + modifier: Modifier = Modifier ) { val uriHandler = LocalUriHandler.current - Column( - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.spacedBy(16.dp), - modifier = - modifier.clickable( - onClick = { - uriHandler.openUri("https://github.com/$username") - }, - indication = ripple(bounded = false, radius = 90.dp), - interactionSource = remember(::MutableInteractionSource) - ) - .widthIn(min = 100.dp) - ) { - SubcomposeAsyncImage( - model = "https://github.com/$username.png", - contentDescription = username, + Column(modifier = modifier.fillMaxWidth()) { + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .fillMaxWidth() + .clickable( + onClick = { uriHandler.openUri("https://github.com/${contributor.username}") } + ) + .padding(horizontal = 24.dp, vertical = 16.dp) + ) { + SubcomposeAsyncImage( + model = contributor.avatarUrl, + contentDescription = contributor.username, + contentScale = ContentScale.Crop, + loading = { + Surface( + color = MaterialTheme.colorScheme.surfaceVariant, + modifier = Modifier + .size(56.dp) + .clip(CircleShape) + .shimmer() + ) {} + }, error = { Surface( - content = {}, - tonalElevation = 2.dp, - modifier = Modifier.fillMaxSize().shimmer(), - ) + color = MaterialTheme.colorScheme.surfaceVariant, + modifier = Modifier + .size(56.dp) + .clip(CircleShape) + ) {} }, - modifier = Modifier.size(80.dp).clip(CircleShape), - ) + modifier = Modifier + .size(56.dp) + .clip(CircleShape) + ) - Column(horizontalAlignment = Alignment.CenterHorizontally) { - Text(text = name, style = MaterialTheme.typography.titleMedium.copy(fontSize = 18.sp)) + Spacer(modifier = Modifier.width(20.dp)) - val roleParts = roles.split(Regex("\\s*-\\s*"), limit = 2) - if (roleParts.size == 2) { - // Render left and right parts on two separate lines, removing the dash + Column( + modifier = Modifier.weight(1f) + ) { Text( - text = roleParts[0], - style = - MaterialTheme.typography.titleSmall.copy( - color = - MaterialTheme.colorScheme.onSurface.copy( - alpha = 0.6f - ) - ) - ) - Text( - text = roleParts[1], - style = - MaterialTheme.typography.bodySmall.copy( - color = - MaterialTheme.colorScheme.onSurface.copy( - alpha = 0.6f - ) - ) - ) - } else { - Text( - text = roles, - style = - MaterialTheme.typography.titleSmall.copy( - color = - MaterialTheme.colorScheme.onSurface.copy( - alpha = 0.6f - ) - ) + text = contributor.username, + style = MaterialTheme.typography.titleMedium, + color = MaterialTheme.colorScheme.onSurface, + maxLines = 1, + overflow = TextOverflow.Ellipsis ) + + Spacer(modifier = Modifier.height(4.dp)) + + contributor.role?.let { role -> + Text( + text = role, + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.onSurfaceVariant + ) + } } } + + if (!isLast) { + Divider( + color = MaterialTheme.colorScheme.outline.copy(alpha = 0.1f), + thickness = 1.dp, + modifier = Modifier.padding(start = 100.dp, end = 24.dp) + ) + } } }