new attachment: gift
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
package dev.meloda.fast.model.api.data
|
package dev.meloda.fast.model.api.data
|
||||||
|
|
||||||
import dev.meloda.fast.model.api.domain.VkGiftDomain
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
|
import dev.meloda.fast.model.api.domain.VkGiftDomain
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class VkGiftData(
|
data class VkGiftData(
|
||||||
@Json(name = "id") val id: Long,
|
@Json(name = "id") val id: Long,
|
||||||
|
@Json(name = "thumb_512") val thumb512: String?,
|
||||||
@Json(name = "thumb_256") val thumb256: String?,
|
@Json(name = "thumb_256") val thumb256: String?,
|
||||||
@Json(name = "thumb_96") val thumb96: String?,
|
@Json(name = "thumb_96") val thumb96: String?,
|
||||||
@Json(name = "thumb_48") val thumb48: String
|
@Json(name = "thumb_48") val thumb48: String
|
||||||
@@ -14,6 +15,7 @@ data class VkGiftData(
|
|||||||
|
|
||||||
fun toDomain() = VkGiftDomain(
|
fun toDomain() = VkGiftDomain(
|
||||||
id = id,
|
id = id,
|
||||||
|
thumb512 = thumb512,
|
||||||
thumb256 = thumb256,
|
thumb256 = thumb256,
|
||||||
thumb96 = thumb96,
|
thumb96 = thumb96,
|
||||||
thumb48 = thumb48
|
thumb48 = thumb48
|
||||||
|
|||||||
@@ -4,10 +4,14 @@ import dev.meloda.fast.model.api.data.AttachmentType
|
|||||||
|
|
||||||
data class VkGiftDomain(
|
data class VkGiftDomain(
|
||||||
val id: Long,
|
val id: Long,
|
||||||
|
val thumb512: String?,
|
||||||
val thumb256: String?,
|
val thumb256: String?,
|
||||||
val thumb96: String?,
|
val thumb96: String?,
|
||||||
val thumb48: String
|
val thumb48: String
|
||||||
) : VkAttachment {
|
) : VkAttachment {
|
||||||
|
|
||||||
override val type: AttachmentType = AttachmentType.GIFT
|
override val type: AttachmentType = AttachmentType.GIFT
|
||||||
|
|
||||||
|
fun getMaxSizeThumb(): String = thumb512 ?: thumb256 ?: thumb96 ?: thumb48
|
||||||
|
fun getDefaultThumbSizeOrLess(): String = thumb256 ?: thumb96 ?: thumb48
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -37,6 +37,7 @@ import dev.meloda.fast.model.api.domain.VkAttachment
|
|||||||
import dev.meloda.fast.model.api.domain.VkAudioDomain
|
import dev.meloda.fast.model.api.domain.VkAudioDomain
|
||||||
import dev.meloda.fast.model.api.domain.VkAudioMessageDomain
|
import dev.meloda.fast.model.api.domain.VkAudioMessageDomain
|
||||||
import dev.meloda.fast.model.api.domain.VkFileDomain
|
import dev.meloda.fast.model.api.domain.VkFileDomain
|
||||||
|
import dev.meloda.fast.model.api.domain.VkGiftDomain
|
||||||
import dev.meloda.fast.model.api.domain.VkLinkDomain
|
import dev.meloda.fast.model.api.domain.VkLinkDomain
|
||||||
import dev.meloda.fast.model.api.domain.VkPhotoDomain
|
import dev.meloda.fast.model.api.domain.VkPhotoDomain
|
||||||
import dev.meloda.fast.model.api.domain.VkStickerDomain
|
import dev.meloda.fast.model.api.domain.VkStickerDomain
|
||||||
@@ -124,6 +125,10 @@ fun Attachments(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AttachmentType.GIFT -> {
|
||||||
|
Gift(item = attachment as VkGiftDomain)
|
||||||
|
}
|
||||||
|
|
||||||
AttachmentType.VIDEO_MESSAGE -> {
|
AttachmentType.VIDEO_MESSAGE -> {
|
||||||
var isPlaying by remember {
|
var isPlaying by remember {
|
||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
|
|||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
package dev.meloda.fast.messageshistory.presentation.attachments
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
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.layout.width
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
import androidx.compose.ui.layout.ContentScale
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.res.vectorResource
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import coil.compose.AsyncImage
|
||||||
|
import dev.meloda.fast.model.api.domain.VkGiftDomain
|
||||||
|
import dev.meloda.fast.ui.R
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun Gift(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
item: VkGiftDomain
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = modifier.width(192.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||||
|
) {
|
||||||
|
AsyncImage(
|
||||||
|
model = item.getDefaultThumbSizeOrLess(),
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(8.dp)
|
||||||
|
.fillMaxWidth()
|
||||||
|
)
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = ImageVector.vectorResource(R.drawable.ic_attachment_gift),
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(16.dp)
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.width(6.dp))
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.message_attachments_gift),
|
||||||
|
style = MaterialTheme.typography.labelMedium,
|
||||||
|
lineHeight = 18.sp
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(6.dp))
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user