Added fade transition between states

This commit is contained in:
imkunet 2024-02-19 15:22:29 -05:00 committed by imkunet
parent e861b97bac
commit 5a42eb0d5f
No known key found for this signature in database
GPG Key ID: 32E0ECFB90A68C42

View File

@ -68,7 +68,7 @@ fun MangaNotesScreen(
text = { text = {
Text( Text(
text = stringResource( text = stringResource(
if (state.editing) MR.strings.action_apply else MR.strings.action_edit if (state.editing) MR.strings.action_apply else MR.strings.action_edit,
), ),
) )
}, },
@ -85,7 +85,11 @@ fun MangaNotesScreen(
}, },
modifier = modifier, modifier = modifier,
) { paddingValues -> ) { paddingValues ->
if (state.editing) { AnimatedVisibility(
state.editing,
enter = fadeIn(),
exit = fadeOut(),
) {
MangaNotesTextArea( MangaNotesTextArea(
state = state, state = state,
onSave = onSave, onSave = onSave,
@ -100,35 +104,40 @@ fun MangaNotesScreen(
.only(WindowInsetsSides.Bottom), .only(WindowInsetsSides.Bottom),
), ),
) )
return@Scaffold
} }
if (state.notes.isNullOrBlank()) { AnimatedVisibility(
!state.editing && state.notes.isNullOrBlank(),
enter = fadeIn(),
exit = fadeOut(),
) {
EmptyScreen( EmptyScreen(
stringRes = MR.strings.information_no_notes, stringRes = MR.strings.information_no_notes,
modifier = Modifier.padding(paddingValues), modifier = Modifier.padding(paddingValues),
) )
return@Scaffold
} }
RichText( AnimatedVisibility(
modifier = Modifier !state.editing && !state.notes.isNullOrBlank(),
.verticalScroll(rememberScrollState()) enter = fadeIn(),
.fillMaxWidth() exit = fadeOut(),
.padding(
horizontal = MaterialTheme.padding.medium,
vertical = paddingValues.calculateTopPadding() + MaterialTheme.padding.medium,
),
style = RichTextStyle(
stringStyle = RichTextStringStyle(
linkStyle = SpanStyle(color = MaterialTheme.colorScheme.primary),
),
),
) { ) {
Markdown(content = state.notes) RichText(
modifier = Modifier
.verticalScroll(rememberScrollState())
.fillMaxWidth()
.padding(
horizontal = MaterialTheme.padding.medium,
vertical = paddingValues.calculateTopPadding() + MaterialTheme.padding.medium,
),
style = RichTextStyle(
stringStyle = RichTextStringStyle(
linkStyle = SpanStyle(color = MaterialTheme.colorScheme.primary),
),
),
) {
Markdown(content = state.notes.orEmpty())
}
} }
return@Scaffold
} }
} }