enhancement: improve instance info (#123)

* enhancement: improve community list loading

* enhancement: show subscribers in community list in instance detail

* enhancement: improve some spacings
This commit is contained in:
Diego Beraldin 2023-11-10 21:26:45 +01:00 committed by GitHub
parent 0ba6643de4
commit ef42875a9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 78 additions and 33 deletions

View File

@ -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,
)

View File

@ -118,7 +118,7 @@ fun CommunityHeader(
Text(
modifier = Modifier.padding(
horizontal = Spacing.m,
vertical = Spacing.xs,
vertical = Spacing.s,
).onClick(
rememberCallback {
optionsExpanded = false

View File

@ -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,
)
}
}
}
}
}

View File

@ -236,7 +236,7 @@ fun PostCardFooter(
Text(
modifier = Modifier.padding(
horizontal = Spacing.m,
vertical = Spacing.xs,
vertical = Spacing.s,
).onClick(
rememberCallback {
optionsExpanded = false

View File

@ -121,7 +121,7 @@ fun UserHeader(
Text(
modifier = Modifier.padding(
horizontal = Spacing.m,
vertical = Spacing.xs,
vertical = Spacing.s,
).onClick(
rememberCallback {
optionsExpanded = false

View File

@ -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 {

View File

@ -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<CommunityModel>()
if (!itemList.isNullOrEmpty()) {

View File

@ -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()