1818package org.quantumbadger.redreader.compose.ui
1919
2020import android.util.Log
21+ import androidx.compose.animation.AnimatedVisibility
22+ import androidx.compose.animation.animateContentSize
23+ import androidx.compose.animation.fadeIn
24+ import androidx.compose.animation.fadeOut
25+ import androidx.compose.animation.slideInVertically
26+ import androidx.compose.animation.slideOutVertically
2127import androidx.compose.foundation.ExperimentalFoundationApi
2228import androidx.compose.foundation.background
2329import androidx.compose.foundation.combinedClickable
@@ -37,7 +43,6 @@ import androidx.compose.foundation.layout.height
3743import androidx.compose.foundation.layout.padding
3844import androidx.compose.foundation.layout.systemBars
3945import androidx.compose.foundation.layout.systemBarsPadding
40- import androidx.compose.foundation.layout.width
4146import androidx.compose.foundation.lazy.LazyColumn
4247import androidx.compose.foundation.lazy.grid.GridCells
4348import androidx.compose.foundation.lazy.grid.GridItemSpan
@@ -218,44 +223,52 @@ fun AlbumScreen(
218223 Modifier
219224 .padding(horizontal = 16 .dp)
220225 .fillMaxWidth()
226+ .animateContentSize()
221227 ) {
222228
223229 // Space for the top bar
224230 Spacer (Modifier .height(topBarHeight))
225231
226- if (! prefs.albumCompactTitle.value) {
227-
228- Spacer (Modifier .height(10 .dp))
229-
230- Text (
231- modifier = Modifier
232- .fillMaxWidth()
233- .focusRequester(accessibilityFocusRequester)
234- .focusable(true )
235- .semantics {
236- heading()
237- },
238- text = album.title ? : stringResource(R .string.image_gallery),
239- style = theme.album.title,
240- overflow = TextOverflow .Ellipsis ,
241- maxLines = 2
242- )
243-
244- Spacer (Modifier .height(6 .dp))
232+ AnimatedVisibility (
233+ modifier = Modifier .fillMaxWidth(),
234+ visible = ! prefs.albumCompactTitle.value,
235+ enter = fadeIn() + slideInVertically { - it },
236+ exit = fadeOut() + slideOutVertically { - it }
237+ ) {
238+
239+ Column {
240+ Spacer (Modifier .height(10 .dp))
241+
242+ Text (
243+ modifier = Modifier
244+ .fillMaxWidth()
245+ .focusRequester(accessibilityFocusRequester)
246+ .focusable(true )
247+ .semantics {
248+ heading()
249+ },
250+ text = album.title ? : stringResource(R .string.image_gallery),
251+ style = theme.album.title,
252+ overflow = TextOverflow .Ellipsis ,
253+ maxLines = 2
254+ )
245255
246- Text (
247- modifier = Modifier .fillMaxWidth(),
248- text = album.description ? : pluralStringResource(
249- R .plurals.album_image_count,
250- album.images.size,
251- album.images.size
252- ),
253- style = theme.album.subtitle,
254- overflow = TextOverflow .Ellipsis ,
255- maxLines = 3
256- )
256+ Spacer (Modifier .height(6 .dp))
257+
258+ Text (
259+ modifier = Modifier .fillMaxWidth(),
260+ text = album.description ? : pluralStringResource(
261+ R .plurals.album_image_count,
262+ album.images.size,
263+ album.images.size
264+ ),
265+ style = theme.album.subtitle,
266+ overflow = TextOverflow .Ellipsis ,
267+ maxLines = 3
268+ )
257269
258- Spacer (Modifier .height(16 .dp))
270+ Spacer (Modifier .height(16 .dp))
271+ }
259272 }
260273 }
261274 }
@@ -419,26 +432,30 @@ fun AlbumScreen(
419432 tint = theme.album.toolbarIconColor
420433 )
421434
422- if (prefs.albumCompactTitle.value) {
423-
424- Spacer (Modifier .width(6 .dp))
425-
426- Text (
427- modifier = Modifier
428- .weight(1f )
429- .focusRequester(accessibilityFocusRequester)
430- .focusable(true )
431- .semantics {
432- heading()
433- },
434- text = album.title ? : stringResource(R .string.image_gallery),
435- style = theme.album.titleCompact,
436- overflow = TextOverflow .Ellipsis ,
437- maxLines = 1
438- )
439-
440- } else {
441- Spacer (Modifier .weight(1f ))
435+ Box (
436+ modifier = Modifier
437+ .weight(1f )
438+ .padding(start = 6 .dp),
439+ ) {
440+ androidx.compose.animation.AnimatedVisibility (
441+ modifier = Modifier .fillMaxWidth(),
442+ visible = prefs.albumCompactTitle.value,
443+ enter = fadeIn() + slideInVertically { - it },
444+ exit = fadeOut() + slideOutVertically { - it }
445+ ) {
446+ Text (
447+ modifier = Modifier
448+ .focusRequester(accessibilityFocusRequester)
449+ .focusable(true )
450+ .semantics {
451+ heading()
452+ },
453+ text = album.title ? : stringResource(R .string.image_gallery),
454+ style = theme.album.titleCompact,
455+ overflow = TextOverflow .Ellipsis ,
456+ maxLines = 1
457+ )
458+ }
442459 }
443460
444461 AlbumSettingsButton ()
0 commit comments