diff --git a/anilist/src/commonMain/graphql/ViewerMutation.graphql b/anilist/src/commonMain/graphql/ViewerMutation.graphql index 73d53f9..ae09baf 100644 --- a/anilist/src/commonMain/graphql/ViewerMutation.graphql +++ b/anilist/src/commonMain/graphql/ViewerMutation.graphql @@ -1,7 +1,8 @@ -mutation ViewerMutation($adult: Boolean, $color: String) { +mutation ViewerMutation($adult: Boolean, $color: String, $html: Boolean) { UpdateUser(displayAdultContent: $adult, profileColor: $color) { id, name, + about(asHtml: $html), avatar { medium, large diff --git a/anilist/src/commonMain/graphql/ViewerQuery.graphql b/anilist/src/commonMain/graphql/ViewerQuery.graphql index f0b2067..a027579 100644 --- a/anilist/src/commonMain/graphql/ViewerQuery.graphql +++ b/anilist/src/commonMain/graphql/ViewerQuery.graphql @@ -1,7 +1,8 @@ -query ViewerQuery { +query ViewerQuery($html: Boolean) { Viewer { id, name, + about(asHtml: $html), avatar { medium, large diff --git a/anilist/src/commonMain/kotlin/dev/datlag/aniflow/anilist/model/User.kt b/anilist/src/commonMain/kotlin/dev/datlag/aniflow/anilist/model/User.kt index 02c70ba..337f59d 100644 --- a/anilist/src/commonMain/kotlin/dev/datlag/aniflow/anilist/model/User.kt +++ b/anilist/src/commonMain/kotlin/dev/datlag/aniflow/anilist/model/User.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.Serializable data class User( val id: Int, val name: String, + val description: String? = null, val avatar: Avatar = Avatar(), val banner: String? = null, val displayAdultContent: Boolean = false, @@ -16,6 +17,7 @@ data class User( constructor(query: ViewerQuery.Viewer) : this( id = query.id, name = query.name, + description = query.about?.ifBlank { null }, avatar = query.avatar.let(::Avatar), banner = query.bannerImage?.ifBlank { null }, displayAdultContent = query.options?.displayAdultContent ?: false, @@ -25,6 +27,7 @@ data class User( constructor(mutation: ViewerMutation.UpdateUser) : this( id = mutation.id, name = mutation.name, + description = mutation.about?.ifBlank { null }, avatar = mutation.avatar.let(::Avatar), banner = mutation.bannerImage?.ifBlank { null }, displayAdultContent = mutation.options?.displayAdultContent ?: false, diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/other/UserHelper.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/other/UserHelper.kt index 289d9b8..d560ca7 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/other/UserHelper.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/other/UserHelper.kt @@ -27,7 +27,11 @@ class UserHelper( val isLoggedIn: Flow = userSettings.isAniListLoggedIn.distinctUntilChanged() private val changedUser: MutableStateFlow = MutableStateFlow(null) - private val userQuery = client.query(ViewerQuery()).toFlow() + private val userQuery = client.query( + ViewerQuery( + html = Optional.present(true) + ) + ).toFlow() private val defaultUser = isLoggedIn.transform { loggedIn -> if (loggedIn) { emitAll( @@ -83,7 +87,8 @@ class UserHelper( changedUser.emit( client.mutation( ViewerMutation( - adult = Optional.present(value) + adult = Optional.present(value), + html = Optional.present(true) ) ).execute().data?.UpdateUser?.let(::User) ) @@ -96,7 +101,8 @@ class UserHelper( changedUser.emit( client.mutation( ViewerMutation( - color = Optional.present(value.label) + color = Optional.present(value.label), + html = Optional.present(true) ) ).execute().data?.UpdateUser?.let(::User) ) diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/initial/settings/SettingsScreen.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/initial/settings/SettingsScreen.kt index 0106554..7ef33bc 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/initial/settings/SettingsScreen.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/initial/settings/SettingsScreen.kt @@ -15,6 +15,7 @@ import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -36,6 +37,7 @@ import dev.chrisbanes.haze.haze import dev.datlag.aniflow.LocalHaze import dev.datlag.aniflow.LocalPaddingValues import dev.datlag.aniflow.SharedRes +import dev.datlag.aniflow.common.htmlToAnnotatedString import dev.datlag.aniflow.common.plus import dev.datlag.aniflow.common.toComposeColor import dev.datlag.aniflow.common.toComposeString @@ -85,6 +87,12 @@ fun SettingsScreen(component: SettingsComponent) { style = MaterialTheme.typography.headlineMedium, fontWeight = FontWeight.Bold ) + u.description?.let { + Text( + modifier = Modifier.padding(bottom = 8.dp), + text = it.htmlToAnnotatedString() + ) + } } } ?: Text( modifier = Modifier.padding(bottom = 8.dp), @@ -127,7 +135,7 @@ fun SettingsScreen(component: SettingsComponent) { item { val selectedColor by component.selectedColor.collectAsStateWithLifecycle(null) val useCase = rememberUseCaseState() - val colors = AppSettings.Color.all.toList() + val colors = remember { AppSettings.Color.all.toList() } OptionDialog( state = useCase, @@ -138,6 +146,7 @@ fun SettingsScreen(component: SettingsComponent) { imageVector = Icons.Filled.Circle, tint = it.toComposeColor() ), + selected = it == selectedColor, titleText = stringResource(it.toComposeString()) ) },