some coil & compose improvements
This commit is contained in:
+1
-6
@@ -37,7 +37,6 @@ 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.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.res.painterResource
|
||||
@@ -47,7 +46,6 @@ import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import coil.compose.AsyncImage
|
||||
import coil.request.ImageRequest
|
||||
import com.meloda.app.fast.auth.captcha.CaptchaViewModel
|
||||
import com.meloda.app.fast.auth.captcha.CaptchaViewModelImpl
|
||||
import com.meloda.app.fast.auth.captcha.model.CaptchaScreenState
|
||||
@@ -188,10 +186,7 @@ fun CaptchaScreen(
|
||||
)
|
||||
} else {
|
||||
AsyncImage(
|
||||
model = ImageRequest.Builder(LocalContext.current)
|
||||
.data(screenState.captchaImageUrl)
|
||||
.crossfade(true)
|
||||
.build(),
|
||||
model = screenState.captchaImageUrl,
|
||||
contentDescription = "Captcha image",
|
||||
contentScale = ContentScale.FillBounds,
|
||||
modifier = imageModifier
|
||||
|
||||
+3
@@ -1,5 +1,8 @@
|
||||
package com.meloda.app.fast.chatmaterials.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
@Immutable
|
||||
data class ChatMaterialsScreenState(
|
||||
val isLoading: Boolean,
|
||||
val materials: List<UiChatMaterial>,
|
||||
|
||||
+1
-7
@@ -10,21 +10,16 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import coil.ImageLoader
|
||||
import coil.compose.AsyncImage
|
||||
import com.meloda.app.fast.chatmaterials.model.UiChatMaterial
|
||||
|
||||
@Composable
|
||||
fun ChatMaterialItem(
|
||||
item: UiChatMaterial,
|
||||
imageLoader: ImageLoader
|
||||
) {
|
||||
fun ChatMaterialItem(item: UiChatMaterial) {
|
||||
when (item) {
|
||||
is UiChatMaterial.Photo -> {
|
||||
AsyncImage(
|
||||
model = item.previewUrl,
|
||||
contentDescription = null,
|
||||
imageLoader = imageLoader,
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
@@ -36,7 +31,6 @@ fun ChatMaterialItem(
|
||||
AsyncImage(
|
||||
model = item.previewUrl,
|
||||
contentDescription = null,
|
||||
imageLoader = imageLoader,
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
||||
+2
-12
@@ -57,13 +57,11 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.DpOffset
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import coil.imageLoader
|
||||
import com.meloda.app.fast.chatmaterials.ChatMaterialsViewModel
|
||||
import com.meloda.app.fast.chatmaterials.ChatMaterialsViewModelImpl
|
||||
import com.meloda.app.fast.chatmaterials.model.ChatMaterialsScreenState
|
||||
@@ -109,8 +107,6 @@ fun ChatMaterialsScreen(
|
||||
|
||||
val attachments = screenState.materials
|
||||
|
||||
val imageLoader = LocalContext.current.imageLoader
|
||||
|
||||
var moreClearBlur by rememberSaveable {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
@@ -317,10 +313,7 @@ fun ChatMaterialsScreen(
|
||||
}
|
||||
}
|
||||
items(attachments) { item ->
|
||||
ChatMaterialItem(
|
||||
item = item,
|
||||
imageLoader = imageLoader
|
||||
)
|
||||
ChatMaterialItem(item = item)
|
||||
}
|
||||
repeat(3) {
|
||||
item {
|
||||
@@ -349,10 +342,7 @@ fun ChatMaterialsScreen(
|
||||
Spacer(modifier = Modifier.height(padding.calculateTopPadding()))
|
||||
}
|
||||
items(attachments) { item ->
|
||||
ChatMaterialItem(
|
||||
item = item,
|
||||
imageLoader = imageLoader
|
||||
)
|
||||
ChatMaterialItem(item = item)
|
||||
}
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(padding.calculateBottomPadding()))
|
||||
|
||||
+1
-3
@@ -52,7 +52,6 @@ import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import coil.compose.AsyncImage
|
||||
import coil.request.ImageRequest
|
||||
import com.meloda.app.fast.common.UiImage
|
||||
import com.meloda.app.fast.conversations.DotsFlashing
|
||||
import com.meloda.app.fast.conversations.model.ConversationOption
|
||||
@@ -171,8 +170,7 @@ fun ConversationItem(
|
||||
)
|
||||
} else {
|
||||
AsyncImage(
|
||||
model = ImageRequest.Builder(context).data(avatarImage)
|
||||
.crossfade(true).build(),
|
||||
model = avatarImage,
|
||||
contentDescription = "Avatar",
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
|
||||
+1
-5
@@ -23,7 +23,6 @@ import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import coil.compose.AsyncImage
|
||||
import coil.request.ImageRequest
|
||||
import com.meloda.app.fast.designsystem.R
|
||||
import com.meloda.app.fast.friends.model.UiFriend
|
||||
|
||||
@@ -55,10 +54,7 @@ fun FriendItem(
|
||||
)
|
||||
} else {
|
||||
AsyncImage(
|
||||
model = ImageRequest.Builder(context)
|
||||
.data(friendAvatar)
|
||||
.crossfade(true)
|
||||
.build(),
|
||||
model = friendAvatar,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
|
||||
Reference in New Issue
Block a user