diff --git a/core-commonui/components/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/FloatingActionButtonMenu.kt b/core-commonui/components/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/FloatingActionButtonMenu.kt index e6148a368..48f0c90b4 100644 --- a/core-commonui/components/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/FloatingActionButtonMenu.kt +++ b/core-commonui/components/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/FloatingActionButtonMenu.kt @@ -106,10 +106,14 @@ fun FloatingActionButtonMenu( horizontalArrangement = Arrangement.spacedBy(Spacing.xxs) ) { Text( - modifier = Modifier.background( - color = MaterialTheme.colorScheme.background, - shape = RoundedCornerShape(CornerSize.s), - ).padding(vertical = Spacing.xs, horizontal = Spacing.s), + modifier = Modifier + .background( + color = MaterialTheme.colorScheme.background, + shape = RoundedCornerShape(CornerSize.s), + ).padding( + vertical = Spacing.s, + horizontal = Spacing.s + ), text = item.text, style = MaterialTheme.typography.bodyMedium, ) diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommunityHeader.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommunityHeader.kt index c8b85c417..34dd7c513 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommunityHeader.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommunityHeader.kt @@ -118,7 +118,7 @@ fun CommunityHeader( Text( modifier = Modifier.padding( horizontal = Spacing.m, - vertical = Spacing.xs, + vertical = Spacing.s, ).onClick( rememberCallback { optionsExpanded = false diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommunityItem.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommunityItem.kt index c2ad5f5a4..0ba534b9f 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommunityItem.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommunityItem.kt @@ -6,6 +6,9 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Group +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -13,6 +16,7 @@ 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.text.style.TextOverflow import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.IconSize import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.CommunityModel @@ -23,6 +27,7 @@ fun CommunityItem( modifier: Modifier = Modifier, small: Boolean = false, autoLoadImages: Boolean = true, + showSubscribers: Boolean = false, ) { val title = community.title.replace("&", "&") val communityName = community.name @@ -54,27 +59,51 @@ fun CommunityItem( ) } ScaledContent { - Column( - modifier = Modifier.padding(start = Spacing.xs), + Row( + modifier = Modifier.padding(horizontal = Spacing.xs) ) { - Text( - text = buildString { - append(title) - }, - style = MaterialTheme.typography.bodyLarge, - color = MaterialTheme.colorScheme.onBackground, - ) - Text( - text = buildString { - append("!") - append(communityName) - if (communityHost.isNotEmpty()) { - append("@$communityHost") - } - }, - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onBackground, - ) + Column( + modifier = Modifier.weight(1f) + ) { + Text( + text = buildString { + append(title) + }, + style = MaterialTheme.typography.bodyLarge, + color = MaterialTheme.colorScheme.onBackground, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + Text( + text = buildString { + append("!") + append(communityName) + if (communityHost.isNotEmpty()) { + append("@$communityHost") + } + }, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onBackground, + ) + } + if (showSubscribers) { + Row( + modifier = Modifier.padding(start = Spacing.xxs), + horizontalArrangement = Arrangement.spacedBy(Spacing.xs), + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + text = community.subscribers.toString(), + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.onBackground, + ) + Icon( + imageVector = Icons.Default.Group, + contentDescription = "", + tint = MaterialTheme.colorScheme.onBackground, + ) + } + } } } } diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardFooter.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardFooter.kt index 696ff6772..c07475f76 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardFooter.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardFooter.kt @@ -236,7 +236,7 @@ fun PostCardFooter( Text( modifier = Modifier.padding( horizontal = Spacing.m, - vertical = Spacing.xs, + vertical = Spacing.s, ).onClick( rememberCallback { optionsExpanded = false diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/UserHeader.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/UserHeader.kt index 517516c4e..9ce7c6f9b 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/UserHeader.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/UserHeader.kt @@ -121,7 +121,7 @@ fun UserHeader( Text( modifier = Modifier.padding( horizontal = Spacing.m, - vertical = Spacing.xs, + vertical = Spacing.s, ).onClick( rememberCallback { optionsExpanded = false diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/instanceinfo/InstanceInfoScreen.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/instanceinfo/InstanceInfoScreen.kt index 0cbfb4dda..2bedbe5c4 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/instanceinfo/InstanceInfoScreen.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/instanceinfo/InstanceInfoScreen.kt @@ -43,6 +43,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.Communi import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.ScaledContent import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getInstanceInfoViewModel import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getNavigationCoordinator +import com.github.diegoberaldin.raccoonforlemmy.core.commonui.selectcommunity.CommunityItemPlaceholder import com.github.diegoberaldin.raccoonforlemmy.core.persistence.di.getSettingsRepository import com.github.diegoberaldin.raccoonforlemmy.core.utils.onClick import com.github.diegoberaldin.raccoonforlemmy.core.utils.rememberCallback @@ -148,6 +149,11 @@ class InstanceInfoScreen( } } } + if (uiState.loading && uiState.communities.isEmpty()) { + items(5) { + CommunityItemPlaceholder() + } + } items(uiState.communities) { CommunityItem( modifier = Modifier.onClick( @@ -162,6 +168,7 @@ class InstanceInfoScreen( ), community = it, autoLoadImages = uiState.autoLoadImages, + showSubscribers = true, ) } item { diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/instanceinfo/InstanceInfoViewModel.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/instanceinfo/InstanceInfoViewModel.kt index 213df2df8..f3046769b 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/instanceinfo/InstanceInfoViewModel.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/instanceinfo/InstanceInfoViewModel.kt @@ -5,6 +5,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.architecture.MviModel import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.SettingsRepository import com.github.diegoberaldin.raccoonforlemmy.domain.identity.repository.IdentityRepository import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.CommunityModel +import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.ListingType import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.SearchResultType import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository.CommunityRepository import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository.SiteRepository @@ -80,6 +81,7 @@ class InstanceInfoViewModel( instance = instance, page = currentPage, limit = 50, + listingType = ListingType.Local, resultType = SearchResultType.Communities, )?.filterIsInstance() if (!itemList.isNullOrEmpty()) { diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/selectcommunity/CommunityItemPlaceholder.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/selectcommunity/CommunityItemPlaceholder.kt index 0d39541c7..971c78590 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/selectcommunity/CommunityItemPlaceholder.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/selectcommunity/CommunityItemPlaceholder.kt @@ -7,6 +7,8 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -30,24 +32,25 @@ fun CommunityItemPlaceholder() { ) { Box( modifier = Modifier - .height(IconSize.m) - .fillMaxWidth() - .clip(RoundedCornerShape(CornerSize.s)) - .shimmerEffect() + .padding(Spacing.xxxs) + .size(IconSize.l) + .clip(CircleShape) + .shimmerEffect(), ) Column( modifier = Modifier.padding(start = Spacing.xs), + verticalArrangement = Arrangement.spacedBy(Spacing.xxs), ) { Box( modifier = Modifier - .height(50.dp) + .height(40.dp) .fillMaxWidth() .clip(RoundedCornerShape(CornerSize.s)) .shimmerEffect() ) Box( modifier = Modifier - .height(30.dp) + .height(20.dp) .fillMaxWidth() .clip(RoundedCornerShape(CornerSize.s)) .shimmerEffect()