Remove MainListHostFragment and rescope list vms to the activity.

This commit is contained in:
Alex Hart
2025-05-05 11:54:19 -03:00
committed by Michelle Tang
parent bc94a92f68
commit 6d04c8ba42
20 changed files with 293 additions and 423 deletions

View File

@@ -9,13 +9,18 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.viewinterop.AndroidView
import androidx.lifecycle.map
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.rx3.asFlow
import org.thoughtcrime.securesms.components.AvatarImageView
import org.thoughtcrime.securesms.database.model.ProfileAvatarFileDetails
import org.thoughtcrime.securesms.profiles.AvatarHelper
@@ -36,11 +41,21 @@ fun AvatarImage(
)
} else {
val context = LocalContext.current
val state = recipient.live().liveData.map { AvatarImageState(NameUtil.getAbbreviation(it.getDisplayName(context)), it, AvatarHelper.getAvatarFileDetails(context, it.id)) }.observeAsState().value ?: return
var state: AvatarImageState by remember {
mutableStateOf(AvatarImageState(null, recipient, ProfileAvatarFileDetails.NO_DETAILS))
}
LaunchedEffect(recipient.id) {
Recipient.observable(recipient.id).asFlow()
.collectLatest {
state = AvatarImageState(NameUtil.getAbbreviation(it.getDisplayName(context)), it, AvatarHelper.getAvatarFileDetails(context, it.id))
}
}
AndroidView(
factory = {
AvatarImageView(context).apply {
initialize(context, null)
this.contentDescription = contentDescription
}
},