@@ -17,6 +17,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
1717import androidx.compose.material3.CardDefaults
1818import androidx.compose.material3.ElevatedCard
1919import androidx.compose.material3.ExperimentalMaterial3Api
20+ import androidx.compose.material3.MaterialTheme
2021import androidx.compose.material3.MaterialTheme.colorScheme
2122import androidx.compose.material3.MaterialTheme.typography
2223import androidx.compose.material3.Text
@@ -28,6 +29,7 @@ import androidx.compose.runtime.mutableStateOf
2829import androidx.compose.runtime.remember
2930import androidx.compose.runtime.setValue
3031import androidx.compose.ui.Modifier
32+ import androidx.compose.ui.draw.clip
3133import androidx.compose.ui.draw.scale
3234import androidx.compose.ui.focus.FocusRequester
3335import androidx.compose.ui.focus.focusRequester
@@ -68,39 +70,61 @@ fun MobileAppCard(
6870 onClick : () -> Unit = {},
6971 onLongClick : () -> Unit = {}
7072) {
73+ val shape = MaterialTheme .shapes.medium
74+
7175 ElevatedCard (
76+ shape = shape,
7277 colors = CardDefaults .elevatedCardColors(
7378 containerColor = colorScheme.surface,
7479 contentColor = colorScheme.onSurface
7580 ),
76- modifier = Modifier
77- .fillMaxWidth()
78- .combinedClickable(onClick = onClick, onLongClick = onLongClick) // instead of onClick param
81+ modifier = Modifier .fillMaxWidth()
7982 ) {
80- Column (Modifier .padding(12 .dp)) {
81- val settings by AppGraph .settings.settingsFlow.collectAsState(initial = AppSettings ())
82- if (settings.showAppIcons) {
83- AsyncImage (
84- model = ImageRequest .Builder (LocalContext .current)
85- .data(app.iconUrl)
86- .crossfade(true )
87- .build(),
88- contentDescription = app.name,
89- placeholder = painterResource(R .drawable.ic_app_placeholder),
90- error = painterResource(R .drawable.ic_app_placeholder),
91- modifier = Modifier .fillMaxWidth().height(140 .dp)
83+ Box (
84+ Modifier
85+ .fillMaxWidth()
86+ .clip(shape)
87+ .combinedClickable(onClick = onClick, onLongClick = onLongClick)
88+ ) {
89+ Column (Modifier .padding(12 .dp)) {
90+ val settings by AppGraph .settings.settingsFlow.collectAsState(initial = AppSettings ())
91+ if (settings.showAppIcons) {
92+ AsyncImage (
93+ model = ImageRequest .Builder (LocalContext .current)
94+ .data(app.iconUrl)
95+ .crossfade(true )
96+ .build(),
97+ contentDescription = app.name,
98+ placeholder = painterResource(R .drawable.ic_app_placeholder),
99+ error = painterResource(R .drawable.ic_app_placeholder),
100+ modifier = Modifier .fillMaxWidth().height(140 .dp)
101+ )
102+ } else {
103+ Box (Modifier .fillMaxWidth().height(140 .dp))
104+ }
105+ Spacer (Modifier .height(8 .dp))
106+ Text (
107+ app.name,
108+ style = typography.titleSmall,
109+ maxLines = 1 ,
110+ overflow = TextOverflow .Ellipsis
92111 )
93- } else {
94- Box (Modifier .fillMaxWidth().height(140 .dp))
95- }
96- Spacer (Modifier .height(8 .dp))
97- Text (app.name, style = typography.titleSmall, maxLines = 1 , overflow = TextOverflow .Ellipsis )
98- Text (app.summary, style = typography.bodySmall, maxLines = 2 , overflow = TextOverflow .Ellipsis )
99- Spacer (Modifier .height(4 .dp))
100- Row {
101- Text (text = app.category, style = typography.labelSmall, color = colorScheme.primary)
102- Spacer (Modifier .weight(1f ))
103- Text (text = " v${app.version} " , style = typography.labelSmall)
112+ Text (
113+ app.summary,
114+ style = typography.bodySmall,
115+ maxLines = 2 ,
116+ overflow = TextOverflow .Ellipsis
117+ )
118+ Spacer (Modifier .height(4 .dp))
119+ Row {
120+ Text (
121+ text = app.category,
122+ style = typography.labelSmall,
123+ color = colorScheme.primary
124+ )
125+ Spacer (Modifier .weight(1f ))
126+ Text (text = " v${app.version} " , style = typography.labelSmall)
127+ }
104128 }
105129 }
106130 }
@@ -114,47 +138,59 @@ fun TVAppCard(
114138 onClick : () -> Unit = {},
115139 onLongClick : () -> Unit = {}
116140) {
141+ val shape = RoundedCornerShape (16 .dp)
117142 val (focused, setFocused) = rememberDebouncedFocusState()
118- val scale by animateFloatAsState(
119- targetValue = if (focused) 1.05f else 1f ,
120- animationSpec = TvFocusConfig .tvFocusAnimationSpec,
121- label = " tv_card_scale"
122- )
143+
123144 val colors = colorScheme
124- val focusRequester = remember { FocusRequester () }
125- LaunchedEffect (autofocus) { if (autofocus) focusRequester.requestFocus() }
126145
127146 ElevatedCard (
128- shape = RoundedCornerShape ( 16 .dp) ,
147+ shape = shape ,
129148 modifier = Modifier
130- .scale(scale )
131- .focusRequester(focusRequester )
149+ .scale(if (focused) 1.05f else 1f )
150+ .focusRequester(remember { FocusRequester () } )
132151 .onFocusChanged { setFocused(it.isFocused) }
133- .combinedClickable(onClick = onClick, onLongClick = onLongClick ),
152+ .fillMaxWidth( ),
134153 colors = CardDefaults .elevatedCardColors(
135- containerColor = if (focused) colors .primaryContainer else colors .surface,
136- contentColor = if (focused) colors .onPrimaryContainer else colors .onSurface
154+ containerColor = if (focused) colorScheme .primaryContainer else colorScheme .surface,
155+ contentColor = if (focused) colorScheme .onPrimaryContainer else colorScheme .onSurface
137156 )
138157 ) {
139- Column (Modifier .padding(16 .dp)) {
140- val settings by AppGraph .settings.settingsFlow.collectAsState(initial = AppSettings ())
141- if (settings.showAppIcons) {
142- AsyncImage (
143- model = ImageRequest .Builder (LocalContext .current)
144- .data(app.iconUrl)
145- .crossfade(true )
146- .build(),
147- contentDescription = app.name,
148- placeholder = painterResource(R .drawable.ic_app_placeholder),
149- error = painterResource(R .drawable.ic_app_placeholder),
150- modifier = Modifier .fillMaxWidth().height(140 .dp)
158+ Box (
159+ Modifier
160+ .fillMaxWidth()
161+ .clip(shape)
162+ .combinedClickable(onClick = onClick, onLongClick = onLongClick)
163+ ) {
164+ Column (Modifier .padding(16 .dp)) {
165+ val settings by AppGraph .settings.settingsFlow.collectAsState(initial = AppSettings ())
166+ if (settings.showAppIcons) {
167+ AsyncImage (
168+ model = ImageRequest .Builder (LocalContext .current)
169+ .data(app.iconUrl)
170+ .crossfade(true )
171+ .build(),
172+ contentDescription = app.name,
173+ placeholder = painterResource(R .drawable.ic_app_placeholder),
174+ error = painterResource(R .drawable.ic_app_placeholder),
175+ modifier = Modifier .fillMaxWidth().height(140 .dp)
176+ )
177+ } else {
178+ Box (Modifier .fillMaxWidth().height(140 .dp))
179+ }
180+ Spacer (Modifier .height(8 .dp))
181+ Text (
182+ app.name,
183+ style = typography.titleSmall,
184+ maxLines = 1 ,
185+ color = if (focused) colors.onPrimaryContainer else colors.onSurface
186+ )
187+ Text (
188+ app.summary,
189+ style = typography.bodySmall,
190+ maxLines = 2 ,
191+ color = if (focused) colors.onPrimaryContainer.copy(alpha = 0.8f ) else colors.onSurfaceVariant
151192 )
152- } else {
153- Box (Modifier .fillMaxWidth().height(140 .dp))
154193 }
155- Spacer (Modifier .height(8 .dp))
156- Text (app.name, style = typography.titleSmall, maxLines = 1 , color = if (focused) colors.onPrimaryContainer else colors.onSurface)
157- Text (app.summary, style = typography.bodySmall, maxLines = 2 , color = if (focused) colors.onPrimaryContainer.copy(alpha = 0.8f ) else colors.onSurfaceVariant)
158194 }
159195 }
160196}
0 commit comments