fix(community): improvements to community list and detail

This commit is contained in:
Diego Beraldin 2023-08-15 18:03:50 +02:00
parent 9787bc533f
commit 2b9dfa799b
2 changed files with 38 additions and 32 deletions

View File

@ -299,38 +299,40 @@ class CommunityDetailScreen(
}, },
style = MaterialTheme.typography.headlineSmall, style = MaterialTheme.typography.headlineSmall,
) )
Button( if (!isOnOtherInstance) {
modifier = Modifier Button(
.align(Alignment.CenterHorizontally) modifier = Modifier
.padding(top = Spacing.m), .align(Alignment.CenterHorizontally)
onClick = { .padding(top = Spacing.m),
when (community.subscribed) { onClick = {
true -> model.reduce(CommunityDetailMviModel.Intent.Unsubscribe) when (community.subscribed) {
false -> model.reduce(CommunityDetailMviModel.Intent.Subscribe) true -> model.reduce(CommunityDetailMviModel.Intent.Unsubscribe)
else -> Unit false -> model.reduce(CommunityDetailMviModel.Intent.Subscribe)
} else -> Unit
}, }
) { },
Row(
horizontalArrangement = Arrangement.spacedBy(Spacing.s),
verticalAlignment = Alignment.CenterVertically,
) { ) {
Image( Row(
imageVector = when (community.subscribed) { horizontalArrangement = Arrangement.spacedBy(Spacing.s),
true -> Icons.Default.Check verticalAlignment = Alignment.CenterVertically,
false -> Icons.Default.AddCircle ) {
else -> Icons.Default.MoreHoriz Image(
}, imageVector = when (community.subscribed) {
contentDescription = null, true -> Icons.Default.Check
colorFilter = ColorFilter.tint(color = MaterialTheme.colorScheme.onPrimary), false -> Icons.Default.AddCircle
) else -> Icons.Default.MoreHoriz
Text( },
text = when (community.subscribed) { contentDescription = null,
true -> stringResource(MR.strings.community_button_subscribed) colorFilter = ColorFilter.tint(color = MaterialTheme.colorScheme.onPrimary),
false -> stringResource(MR.strings.community_button_subscribe) )
else -> stringResource(MR.strings.community_button_pending) Text(
}, text = when (community.subscribed) {
) true -> stringResource(MR.strings.community_button_subscribed)
false -> stringResource(MR.strings.community_button_subscribe)
else -> stringResource(MR.strings.community_button_pending)
},
)
}
} }
} }
} }

View File

@ -85,7 +85,11 @@ class CommunityListViewModel(
val items = communityRepository.getSubscribed( val items = communityRepository.getSubscribed(
auth = auth, auth = auth,
).filter { ).filter {
it.name.contains(searchText) if (searchText.isNotBlank()) {
it.name.contains(searchText)
} else {
true
}
} }
currentPage++ currentPage++
mvi.updateState { mvi.updateState {