@@ -32,12 +32,12 @@ import androidx.compose.ui.text.style.TextOverflow
32
32
import androidx.compose.ui.text.withStyle
33
33
import androidx.compose.ui.unit.DpSize
34
34
import androidx.compose.ui.unit.dp
35
- import androidx.core.text.trimmedLength
36
35
import coil.compose.AsyncImage
37
36
import coil.request.ImageRequest
38
37
import dev.marlonlom.apps.cappajv.core.database.entities.CatalogItemTuple
39
38
import dev.marlonlom.apps.cappajv.ui.layout.DevicePosture
40
39
import dev.marlonlom.apps.cappajv.ui.main.CappajvAppState
40
+ import dev.marlonlom.apps.cappajv.ui.navigation.NavigationType
41
41
42
42
/* *
43
43
* Catalog tuple row composable ui.
@@ -65,9 +65,13 @@ internal fun CatalogTupleRow(
65
65
onCatalogItemTupleClicked(tuple.id)
66
66
},
67
67
) {
68
+ val verticalAlignment = when {
69
+ appState.navigationType == NavigationType .EXPANDED_NAV -> Alignment .Bottom
70
+ else -> Alignment .CenterVertically
71
+ }
68
72
Row (
69
73
modifier = modifier.padding(vertical = 10 .dp),
70
- verticalAlignment = Alignment . CenterVertically ,
74
+ verticalAlignment = verticalAlignment ,
71
75
horizontalArrangement = Arrangement .spacedBy(16 .dp)
72
76
) {
73
77
CatalogTuplePosterImage (tuple, appState)
@@ -77,7 +81,7 @@ internal fun CatalogTupleRow(
77
81
.padding(end = 10 .dp)
78
82
) {
79
83
CatalogTupleTitle (tuple, appState)
80
- CatalogTupleSamplePunctuationText (tuple)
84
+ CatalogTupleSamplePunctuationText (tuple, appState )
81
85
}
82
86
}
83
87
}
@@ -88,11 +92,13 @@ internal fun CatalogTupleRow(
88
92
*
89
93
* @author marlonlom
90
94
*
91
- * @param tuple Catalog item.
95
+ * @param tuple Catalog item tuple data.
96
+ * @param appState Application ui state.
92
97
*/
93
98
@Composable
94
99
private fun CatalogTupleSamplePunctuationText (
95
- tuple : CatalogItemTuple
100
+ tuple : CatalogItemTuple ,
101
+ appState : CappajvAppState ,
96
102
) {
97
103
val samplePunctuationTxt = buildAnnotatedString {
98
104
val textParts = tuple.samplePunctuation.split(" :" )
@@ -102,11 +108,7 @@ private fun CatalogTupleSamplePunctuationText(
102
108
color = MaterialTheme .colorScheme.secondary,
103
109
)
104
110
) {
105
- val punctuationTitle = when {
106
- textParts[0 ].trimmedLength() > 10 -> textParts[0 ].split(" " )[0 ].plus(" ..." )
107
- else -> textParts[0 ]
108
- }
109
- append(punctuationTitle)
111
+ append(textParts[0 ])
110
112
}
111
113
append(" : " )
112
114
append(textParts[1 ].trim())
@@ -122,9 +124,21 @@ private fun CatalogTupleSamplePunctuationText(
122
124
}
123
125
}
124
126
}
127
+
128
+ val textStyle = when {
129
+ appState.navigationType == NavigationType .EXPANDED_NAV -> MaterialTheme .typography.bodyLarge
130
+ else -> MaterialTheme .typography.labelMedium
131
+ }
132
+
133
+ val bottomPadding = when {
134
+ appState.navigationType == NavigationType .EXPANDED_NAV -> 10 .dp
135
+ else -> 0 .dp
136
+ }
137
+
125
138
Text (
139
+ modifier = Modifier .padding(bottom = bottomPadding),
126
140
text = samplePunctuationTxt,
127
- style = MaterialTheme .typography.labelMedium ,
141
+ style = textStyle ,
128
142
)
129
143
}
130
144
@@ -138,7 +152,8 @@ private fun CatalogTupleSamplePunctuationText(
138
152
*/
139
153
@Composable
140
154
private fun CatalogTupleTitle (
141
- tuple : CatalogItemTuple , appState : CappajvAppState
155
+ tuple : CatalogItemTuple ,
156
+ appState : CappajvAppState ,
142
157
) {
143
158
Text (
144
159
text = tuple.title,
@@ -160,7 +175,8 @@ private fun CatalogTupleTitle(
160
175
*/
161
176
@Composable
162
177
private fun CatalogTuplePosterImage (
163
- tuple : CatalogItemTuple , appState : CappajvAppState
178
+ tuple : CatalogItemTuple ,
179
+ appState : CappajvAppState ,
164
180
) {
165
181
val imageRequest = ImageRequest .Builder (LocalContext .current).data(tuple.picture).crossfade(true ).build()
166
182
@@ -180,17 +196,31 @@ private fun CatalogTuplePosterImage(
180
196
)
181
197
}
182
198
199
+ /* *
200
+ * returns catalog tuple card image size.
201
+ *
202
+ * @param appState Application ui state.
203
+ */
183
204
@Composable
184
205
private fun getCatalogTupleImageSizeDp (appState : CappajvAppState ): DpSize = when {
206
+ appState.navigationType == NavigationType .EXPANDED_NAV -> DpSize (88 .dp, 104 .dp)
207
+
185
208
appState.isCompactWidth.and (appState.isLandscape.not ())
186
209
.and (appState.devicePosture is DevicePosture .Separating .TableTop ) -> DpSize (48 .dp, 56 .dp)
187
210
188
211
else -> DpSize (56 .dp, 64 .dp)
189
212
}
190
213
191
214
215
+ /* *
216
+ * returns catalog tuple card title text style.
217
+ *
218
+ * @param appState Application ui state.
219
+ */
192
220
@Composable
193
221
private fun getCatalogTupleTitleStyle (appState : CappajvAppState ) = when {
222
+ appState.navigationType == NavigationType .EXPANDED_NAV -> MaterialTheme .typography.titleLarge
223
+
194
224
appState.isCompactWidth.and (appState.isLandscape.not ())
195
225
.and (appState.devicePosture is DevicePosture .Separating .TableTop ) -> MaterialTheme .typography.bodyMedium
196
226
0 commit comments