11package com.techlads.composetv.features.details
22
33import androidx.activity.compose.BackHandler
4+ import androidx.compose.animation.core.animateDpAsState
45import androidx.compose.foundation.Image
56import androidx.compose.foundation.background
67import androidx.compose.foundation.layout.*
78import androidx.compose.runtime.Composable
9+ import androidx.compose.runtime.LaunchedEffect
10+ import androidx.compose.runtime.mutableStateOf
11+ import androidx.compose.runtime.remember
812import androidx.compose.ui.Alignment
913import androidx.compose.ui.Modifier
1014import androidx.compose.ui.layout.ContentScale
@@ -21,8 +25,11 @@ import androidx.tv.material3.Text
2125import com.techlads.composetv.R
2226import com.techlads.composetv.theme.AppTheme
2327import com.techlads.composetv.theme.Material3Theme
24- import com.techlads.composetv.widgets.BorderedFocusableItem
2528import com.techlads.composetv.widgets.Button
29+ import com.techlads.composetv.widgets.ThumbnailImageCard
30+ import kotlinx.coroutines.delay
31+
32+ const val ANIMATION_DELAY = 600L
2633
2734@Composable
2835fun ProductDetailsScreen (onBackPressed : () -> Unit ) {
@@ -34,6 +41,17 @@ private fun ProductDetailsContent(onBackPressed: () -> Unit) {
3441
3542 BackHandler (onBack = onBackPressed)
3643
44+ val isLoaded = remember {
45+ mutableStateOf(false )
46+ }
47+
48+ val animatedPortraitSize = animateDpAsState(targetValue = if (isLoaded.value) 150 .dp else 1 .dp)
49+
50+ LaunchedEffect (key1 = Unit ) {
51+ delay(ANIMATION_DELAY )
52+ isLoaded.value = true
53+ }
54+
3755 Box {
3856 SearchIcon (
3957 modifier = Modifier
@@ -60,11 +78,13 @@ private fun ProductDetailsContent(onBackPressed: () -> Unit) {
6078 }
6179
6280 ThumbnailImageCard (
63- modifier = Modifier
81+ Modifier
6482 .align(Alignment .CenterStart )
65- .padding(start = 30 .dp),
66- parent = 1 , child = 1
67- )
83+ .padding(start = 30 .dp)
84+ .width(animatedPortraitSize.value)
85+ ) {
86+ Text (text = " 1x1" )
87+ }
6888 }
6989}
7090
@@ -207,20 +227,6 @@ fun Rating(rating: String) {
207227 }
208228}
209229
210- @Composable
211- fun ThumbnailImageCard (modifier : Modifier , parent : Int , child : Int ) {
212- BorderedFocusableItem (
213- onClick = { },
214- modifier = modifier
215- .padding(8 .dp)
216- .size(width = 150 .dp, height = 200 .dp)
217- ) {
218- Box (contentAlignment = Alignment .Center , modifier = Modifier .fillMaxSize()) {
219- Text (text = " Item $parent x $child " , textAlign = TextAlign .Center )
220- }
221- }
222- }
223-
224230@Preview(device = Devices .TV_1080p )
225231@Composable
226232fun DetailsScreenPrev () {
0 commit comments