Skip to content

Commit

Permalink
Merge pull request #202 from tarkalabs/mohan/enhancement/TUIMediaThum…
Browse files Browse the repository at this point in the history
…bnail_update

fix : Placeholder handled for Image and Video in MediaThumNailComponent
  • Loading branch information
rajajawahar authored Feb 23, 2024
2 parents 40845fb + ef3205a commit f047df6
Show file tree
Hide file tree
Showing 51 changed files with 75 additions and 27 deletions.
2 changes: 1 addition & 1 deletion tarka-ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ publishing {
run {
groupId = "com.tarkalabs"
artifactId = getLibraryArtifactId()
version = "1.1.2"
version = "1.1.3"
artifact("$buildDir/outputs/aar/tarka-ui-release.aar")
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,24 @@ class TUIMediaThumbnailScreenShotTest(
)
}
}

@Test fun test_thumbnails_case_no_image() {
compareScreenshotFor(darkTheme = darkTheme, imageName = "TUIThumbnail_Type_No_Image_$testName") {
TUIMediaThumbnail(
type = Image(),
showTrailingIcon = showTrailingIcon,
size = thumbnailSize,
)
}
}

@Test fun test_thumbnails_case_no_video() {
compareScreenshotFor(darkTheme = darkTheme, imageName = "TUIThumbnail_Type_No_Video_$testName") {
TUIMediaThumbnail(
type = Video(),
showTrailingIcon = showTrailingIcon,
size = thumbnailSize,
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tarkalabs.tarkaui.components

import android.content.res.Configuration
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import androidx.compose.foundation.Image
Expand Down Expand Up @@ -35,10 +36,6 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.tarkalabs.tarkaui.icons.DeviceEq24
import com.tarkalabs.tarkaui.icons.Document24
import com.tarkalabs.tarkaui.icons.Eye12
import com.tarkalabs.tarkaui.icons.TarkaIcons
import com.tarkalabs.tarkaui.R
import com.tarkalabs.tarkaui.components.PlayPauseButtonSize.M
import com.tarkalabs.tarkaui.components.TUIMediaThumbnailSize.Large
Expand All @@ -47,13 +44,19 @@ import com.tarkalabs.tarkaui.components.TUIMediaThumbnailType.Audio
import com.tarkalabs.tarkaui.components.TUIMediaThumbnailType.Document
import com.tarkalabs.tarkaui.components.TUIMediaThumbnailType.Image
import com.tarkalabs.tarkaui.components.TUIMediaThumbnailType.Video
import com.tarkalabs.tarkaui.icons.DeviceEq24
import com.tarkalabs.tarkaui.icons.Document24
import com.tarkalabs.tarkaui.icons.Eye12
import com.tarkalabs.tarkaui.icons.Image24
import com.tarkalabs.tarkaui.icons.TarkaIcons.Regular
import com.tarkalabs.tarkaui.icons.Video24
import com.tarkalabs.tarkaui.theme.TUITheme

sealed class TUIMediaThumbnailType {
object Document : TUIMediaThumbnailType()
object Audio : TUIMediaThumbnailType()
data class Video(val image: ImageBitmap) : TUIMediaThumbnailType()
data class Image(val image: ImageBitmap) : TUIMediaThumbnailType()
data class Video(val image: ImageBitmap? = null) : TUIMediaThumbnailType()
data class Image(val image: ImageBitmap? = null) : TUIMediaThumbnailType()
}

enum class TUIMediaThumbnailSize {
Expand All @@ -64,7 +67,7 @@ enum class TUIMediaThumbnailSize {
@Composable fun TUIMediaThumbnail(
modifier: Modifier = Modifier,
size: TUIMediaThumbnailSize = Large,
type: TUIMediaThumbnailType,
type: TUIMediaThumbnailType?,
showTrailingIcon: Boolean,
onThumbnailClick: (() -> Unit)? = null,
onTrailingIconClick: (() -> Unit)? = null,
Expand Down Expand Up @@ -93,34 +96,44 @@ enum class TUIMediaThumbnailSize {
when (type) {
Audio -> {
Icon(
painter = painterResource(id = TarkaIcons.Regular.DeviceEq24.iconRes),
contentDescription = TarkaIcons.Regular.DeviceEq24.contentDescription,
painter = painterResource(id = Regular.DeviceEq24.iconRes),
contentDescription = Regular.DeviceEq24.contentDescription,
modifier = iconModifier,
tint = TUITheme.colors.onSurface
)
}

Document -> {
Icon(
painter = painterResource(id = TarkaIcons.Regular.Document24.iconRes),
contentDescription = TarkaIcons.Regular.Document24.contentDescription,
painter = painterResource(id = Regular.Document24.iconRes),
contentDescription = Regular.Document24.contentDescription,
modifier = iconModifier,
tint = TUITheme.colors.onSurface
)
}

is Image -> {
Image(bitmap = type.image,
contentDescription = stringResource(id = R.string.image_thumbnail),
modifier = Modifier
.then(if (onThumbnailClick != null) Modifier.clickable { onThumbnailClick.invoke() } else Modifier)
.fillMaxSize()
.clip(RoundedCornerShape(8.dp)),
contentScale = ContentScale.Crop)
if (type.image != null) {
Image(bitmap = type.image,
contentDescription = stringResource(id = R.string.image_thumbnail),
modifier = Modifier
.then(
if (onThumbnailClick != null) Modifier.clickable { onThumbnailClick.invoke() } else Modifier)
.fillMaxSize()
.clip(RoundedCornerShape(8.dp)),
contentScale = ContentScale.Crop)
} else {
Icon(
painter = painterResource(id = Regular.Image24.iconRes),
contentDescription = Regular.Image24.contentDescription,
modifier = iconModifier,
tint = TUITheme.colors.onSurface
)
}
}

is Video -> {
Box(contentAlignment = Alignment.Center) {
if (type.image != null) {
Image(
bitmap = type.image,
contentDescription = stringResource(id = R.string.video_thumbnail),
Expand All @@ -130,16 +143,23 @@ enum class TUIMediaThumbnailSize {
.clip(RoundedCornerShape(8.dp)),
contentScale = ContentScale.Crop
)
TUIPlayPauseButton(buttonSize = M, onClick = {onThumbnailClick?.invoke()})
TUIPlayPauseButton(buttonSize = M, onClick = { onThumbnailClick?.invoke() })
} else {
Icon(
painter = painterResource(id = Regular.Video24.iconRes),
contentDescription = Regular.Video24.contentDescription,
modifier = iconModifier,
tint = TUITheme.colors.onSurface
)
}
}
else -> {}
}


if (showTrailingIcon) {
Icon(
painter = painterResource(id = TarkaIcons.Regular.Eye12.iconRes),
contentDescription = TarkaIcons.Regular.Eye12.contentDescription,
painter = painterResource(id = Regular.Eye12.iconRes),
contentDescription = Regular.Eye12.contentDescription,
tint = Color.White,
modifier = Modifier
.align(Alignment.TopEnd)
Expand All @@ -162,7 +182,9 @@ data class TUIMediaThumbnailTags(
val thumbImageTag: String = "TUIMediaThumbnail_ThumbImage"
)

@Preview @Composable fun PreviewTUIThumbnail() {
@Preview
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable fun PreviewTUIThumbnail() {
TUITheme {
val option = BitmapFactory.Options()
option.inPreferredConfig = Bitmap.Config.ARGB_8888
Expand Down Expand Up @@ -191,6 +213,8 @@ data class TUIMediaThumbnailTags(
TUIMediaThumbnail(type = Audio, showTrailingIcon = false)
VerticalSpacer(space = 5)
TUIMediaThumbnail(type = Document, showTrailingIcon = false)
VerticalSpacer(space = 5)
TUIMediaThumbnail(type = Image(), showTrailingIcon = false)
VerticalSpacer(space = 50)
TUIMediaThumbnail(type = Image(image = bitmap), showTrailingIcon = false, size = Medium)
VerticalSpacer(space = 5)
Expand All @@ -199,6 +223,8 @@ data class TUIMediaThumbnailTags(
TUIMediaThumbnail(type = Audio, showTrailingIcon = false, size = Medium)
VerticalSpacer(space = 5)
TUIMediaThumbnail(type = Document, showTrailingIcon = false, size = Medium)
VerticalSpacer(space = 5)
TUIMediaThumbnail(type = Image(), showTrailingIcon = false, size = Medium)
}

HorizontalSpacer(space = 100)
Expand All @@ -215,6 +241,8 @@ data class TUIMediaThumbnailTags(
TUIMediaThumbnail(type = Audio, showTrailingIcon = true)
VerticalSpacer(space = 5)
TUIMediaThumbnail(type = Document, showTrailingIcon = true)
VerticalSpacer(space = 5)
TUIMediaThumbnail(type = Video(), showTrailingIcon = false)
VerticalSpacer(space = 50)
TUIMediaThumbnail(type = Image(image = bitmap), showTrailingIcon = true, size = Medium)
VerticalSpacer(space = 5)
Expand All @@ -223,9 +251,9 @@ data class TUIMediaThumbnailTags(
TUIMediaThumbnail(type = Audio, showTrailingIcon = true, size = Medium)
VerticalSpacer(space = 5)
TUIMediaThumbnail(type = Document, showTrailingIcon = true, size = Medium)

VerticalSpacer(space = 5)
TUIMediaThumbnail(type = Video(), showTrailingIcon = false, size = Medium)
}

}
}
}

0 comments on commit f047df6

Please sign in to comment.