Skip to content

Commit

Permalink
chore: apply 4.0.0-beta25 source code
Browse files Browse the repository at this point in the history
  • Loading branch information
bnaing committed Oct 25, 2024
1 parent 0d15e9b commit 5b9d8aa
Show file tree
Hide file tree
Showing 21 changed files with 580 additions and 397 deletions.
2 changes: 1 addition & 1 deletion buildsystem/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
amityKotlinVersion = "1.6.20"
amityLifecycleExtensionVersion = "2.0.0"
amityMockkVersion = "1.10.0"
amityMessagingSdkVersion = '6.44.0'
amityMessagingSdkVersion = '6.45.0'
amityRxLifeCycleVersion = '1.1.2-beta01'
amityJacocoVersion = '0.8.5'
amityExoplayerVersion = '2.18.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import androidx.compose.ui.text.TextLayoutResult
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.rememberTextMeasurer
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Constraints
Expand Down Expand Up @@ -191,12 +190,19 @@ private fun getTrimmedText(
val startIndex = textLayoutResult.getLineStart(visiblePreviewLines - 1)
val endIndex = textLayoutResult.getLineEnd(visiblePreviewLines - 1)
val lastLine = text.substring(startIndex, endIndex)
if (lastLine.length > 25) {

val newText = if (lastLine.length > 25) {
val lengthToReduce = readMore.length * 3 / 2
text.substring(0, endIndex - lengthToReduce)
} else {
text.substring(0, endIndex)
}

if (newText.endsWith("\n")) {
newText.replaceRange(endIndex - 1, endIndex, "")
} else {
newText
}
} else {
text
}
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/assets/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"preferred_theme": "default",
"preferred_theme": "light",
"theme": {
"light": {
"primary_color": "#1054DE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fun AmityEditCommentContainer(
Text(
text = getElementScope().getConfig().getValue("save_button_text"),
style = AmityTheme.typography.caption.copy(
color = AmityTheme.colors.baseInverse,
color = Color.White,
),
modifier = modifier.testTag(getAccessibilityId())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fun AmityPendingPostsPage(
postId = post.getPostId(),
onApproved = {
getPageScope().showSnackbar(
message = "Post accepted",
message = "Post accepted.",
drawableRes = R.drawable.amity_ic_snack_bar_success,
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.paging.compose.collectAsLazyPagingItems
import com.amity.socialcloud.sdk.model.social.post.AmityPost
import com.amity.socialcloud.uikit.common.ad.AmityListItem
import com.amity.socialcloud.uikit.common.ui.base.AmityBaseElement
import com.amity.socialcloud.uikit.common.ui.base.AmityBasePage
import com.amity.socialcloud.uikit.common.ui.elements.AmityNewsFeedDivider
import com.amity.socialcloud.uikit.common.ui.theme.AmityTheme
import com.amity.socialcloud.uikit.common.utils.getIcon
import com.amity.socialcloud.uikit.community.compose.AmitySocialBehaviorHelper
Expand All @@ -54,9 +51,6 @@ import com.amity.socialcloud.uikit.community.compose.paging.feed.community.amity
import com.amity.socialcloud.uikit.community.compose.paging.feed.community.amityCommunityPinnedFeedLLS
import com.amity.socialcloud.uikit.community.compose.paging.feed.community.amityCommunityVideoFeedLLS
import com.amity.socialcloud.uikit.community.compose.post.detail.AmityPostCategory
import com.amity.socialcloud.uikit.community.compose.post.detail.components.AmityPostContentComponent
import com.amity.socialcloud.uikit.community.compose.post.detail.components.AmityPostContentComponentStyle
import com.amity.socialcloud.uikit.community.compose.socialhome.components.AmityPostAdView

@OptIn(ExperimentalMaterialApi::class, ExperimentalFoundationApi::class)
@SuppressLint("UnrememberedMutableState")
Expand Down Expand Up @@ -294,5 +288,4 @@ fun AmityCommunityProfilePage(
}
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.amity.socialcloud.uikit.community.compose.community.profile

import androidx.lifecycle.viewModelScope
import androidx.paging.PagingData
import com.amity.socialcloud.sdk.api.core.AmityCoreClient
import com.amity.socialcloud.sdk.api.social.AmitySocialClient
Expand All @@ -16,17 +17,19 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.schedulers.Schedulers
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.launch
import java.util.concurrent.TimeUnit

class AmityCommunityProfileViewModel(private val communityId: String) :
AmityBaseViewModel() {
val disposable = CompositeDisposable()

private val _communityProfileState by lazy {
MutableStateFlow(CommunityProfileState.Initial(communityId))
MutableStateFlow(CommunityProfileState(communityId))
}

val communityProfileState get() = _communityProfileState
Expand All @@ -37,21 +40,29 @@ class AmityCommunityProfileViewModel(private val communityId: String) :

fun refresh() {
disposable.clear()
_communityProfileState.value = CommunityProfileState.Initial(communityId)
viewModelScope.launch {
_communityProfileState.value = _communityProfileState.value.copy(
isRefreshing = true
)
}

Flowable.combineLatest(
AmitySocialClient.newCommunityRepository().getCommunity(communityId).doOnError { },
AmityCoreClient.hasPermission(AmityPermission.EDIT_COMMUNITY).atCommunity(communityId)
.check().onErrorReturn { communityProfileState.value.isModerator }
) { community, hasPermission -> Pair(community, hasPermission) }
.doOnNext { (community, isModerator) ->
val isMember = community.isJoined()
_communityProfileState.value = CommunityProfileState(
communityId,
community,
isRefreshing = false,
isMember = isMember,
isModerator = isModerator
)
viewModelScope.launch {
delay(100)
_communityProfileState.value = _communityProfileState.value.copy(
communityId = communityId,
community = community,
isRefreshing = false,
isMember = isMember,
isModerator = isModerator
)
}
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
Expand Down Expand Up @@ -133,18 +144,7 @@ class AmityCommunityProfileViewModel(private val communityId: String) :
data class CommunityProfileState(
val communityId: String,
val community: AmityCommunity? = null,
val isRefreshing: Boolean,
val isMember: Boolean,
val isModerator: Boolean,
) {

companion object {
fun Initial(communityId: String) = CommunityProfileState(
communityId = communityId,
community = null,
isRefreshing = true,
isMember = false,
isModerator = false,
)
}
}
val isRefreshing: Boolean = true,
val isMember: Boolean = false,
val isModerator: Boolean = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.amity.socialcloud.sdk.model.social.community.AmityCommunity
import com.amity.socialcloud.uikit.common.common.isNotEmptyOrBlank
import com.amity.socialcloud.uikit.common.ui.base.AmityBaseComponent
import com.amity.socialcloud.uikit.common.ui.elements.AmityExpandableText
import com.amity.socialcloud.uikit.common.ui.scope.AmityComposePageScope
import com.amity.socialcloud.uikit.common.ui.theme.AmityTheme
import com.amity.socialcloud.uikit.community.compose.community.profile.element.AmityCommunityCategoryListElement
Expand Down Expand Up @@ -58,19 +56,17 @@ fun AmityCommunityHeaderComponent(
if (categories.isNotEmpty()) {
AmityCommunityCategoryListElement(categories = categories)
}
if (community.getDescription().isNotBlank()) {

if (community.getDescription().isNotEmptyOrBlank()) {
Row(modifier = Modifier.padding(vertical = 8.dp, horizontal = 16.dp)) {
Text(
AmityExpandableText(
text = community.getDescription(),
style = TextStyle(
fontSize = 15.sp,
lineHeight = 20.sp,
fontWeight = FontWeight(400),
color = AmityTheme.colors.base,
)
previewLines = 4,
modifier = modifier.padding(vertical = 8.dp)
)
}
}
}

AmityCommunityInfoView(
pageScope = pageScope,
componentScope = getComponentScope(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fun AmityCommunityInfoView(
Row(
modifier = Modifier
.padding(top = 8.dp, bottom = 16.dp, start = 16.dp, end = 16.dp),
verticalAlignment = Alignment.Bottom,
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = getNumberAbbreveation(community?.getPostCount() ?: 0),
Expand Down
Loading

0 comments on commit 5b9d8aa

Please sign in to comment.