Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step 1: AniList Markdown -> ASTNode #113

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/anilist/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ dependencies {
implementation(libs.hilt.android)
implementation(libs.hilt.navigationCompose)
ksp(libs.hilt.android.compiler)

implementation(libs.intellij.markdown)
}

apollo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import android.graphics.Color
import com.imashnake.animite.api.anilist.MediaListQuery
import com.imashnake.animite.api.anilist.MediaQuery
import com.imashnake.animite.api.anilist.type.MediaRankType
import org.intellij.markdown.ast.ASTNode
import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor
import org.intellij.markdown.parser.MarkdownParser

data class Media(
/** @see MediaQuery.Media.bannerImage */
Expand All @@ -14,9 +17,8 @@ data class Media(
val color: Int,
/** @see MediaQuery.Media.title */
val title: String?,
/** TODO: https://github.com/imashnake0/Animite/issues/58.
* @see MediaQuery.Media.description */
val description: String,
/** The [ASTNode] is the parsed [MediaQuery.Media.description]. */
val description: Pair<ASTNode, String>?,
/** @see MediaQuery.Media.rankings */
val rankings: List<Ranking>,
/** @see MediaQuery.Media.genres */
Expand Down Expand Up @@ -69,7 +71,10 @@ data class Media(
coverImage = query.coverImage?.extraLarge ?: query.coverImage?.large ?: query.coverImage?.medium,
color = query.coverImage?.color?.let { Color.parseColor(it) } ?: Color.TRANSPARENT,
title = query.title?.romaji ?: query.title?.english ?: query.title?.native,
description = query.description.orEmpty(),
description = query.description?.let {
// TODO: Replace with `AFMFlavourDescriptor`.
MarkdownParser(CommonMarkFlavourDescriptor()).buildMarkdownTreeFromString(it) to it
},
rankings = if (query.rankings == null) { emptyList() } else {
// TODO: Is this filter valid?
query.rankings.filter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.imashnake.animite.features.media
import android.content.Intent
import android.content.res.Configuration
import android.net.Uri
import android.text.Html
import android.util.Log
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
Expand Down Expand Up @@ -113,9 +112,7 @@ fun MediaPage(
) {
MediaDetails(
title = media.title.orEmpty(),
description = Html
.fromHtml(media.description.orEmpty(), Html.FROM_HTML_MODE_COMPACT)
.toString(),
description = media.description.orEmpty(),
// TODO Can we do something about this Modifier chain?
modifier = Modifier
.padding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MediaPageViewModel @Inject constructor(
coverImage = media?.coverImage,
color = media?.color,
title = media?.title,
description = media?.description,
description = media?.description?.second,
ranks = media?.rankings,
genres = media?.genres,
characters = media?.characters,
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/com/imashnake/animite/features/theme/Type.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package com.imashnake.animite.features.theme

import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.googlefonts.Font
import androidx.compose.ui.text.googlefonts.GoogleFont
Expand All @@ -28,7 +30,14 @@ val manropeFontFamily = FontFamily(
Font(manropeFont, fontProvider, FontWeight.Medium),
Font(manropeFont, fontProvider, FontWeight.Normal),
Font(manropeFont, fontProvider, FontWeight.Light),
Font(manropeFont, fontProvider, FontWeight.ExtraLight)
Font(manropeFont, fontProvider, FontWeight.ExtraLight),
Font(R.font.manrope_italic, FontWeight.Normal, FontStyle.Italic),
Font(R.font.manrope_bold_italic, FontWeight.Bold, FontStyle.Italic),
Font(R.font.manrope_extra_bold_italic, FontWeight.ExtraBold, FontStyle.Italic),
Font(R.font.manrope_light_italic, FontWeight.Light, FontStyle.Italic),
Font(R.font.manrope_medium_italic, FontWeight.Medium, FontStyle.Italic),
Font(R.font.manrope_extra_light_italic, FontWeight.ExtraLight, FontStyle.Italic),
Font(R.font.manrope_semi_bold_italic, FontWeight.SemiBold, FontStyle.Italic),
)

const val baselineShift = 0.2f
Expand Down
Binary file added app/src/main/res/font/manrope_bold_italic.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added app/src/main/res/font/manrope_italic.ttf
Binary file not shown.
Binary file added app/src/main/res/font/manrope_light_italic.ttf
Binary file not shown.
Binary file added app/src/main/res/font/manrope_medium_italic.ttf
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ dagger = "2.50"
# https://developer.android.com/jetpack/androidx/releases/hilt.
hilt = "1.1.0"

intellijMarkdown = "0.6.1"

# Kotlin
# https://kotlinlang.org/docs/releases.html#release-details.
kotlin = "1.9.21"
Expand Down Expand Up @@ -105,6 +107,7 @@ kotlin-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coro
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "dagger" }
hilt-android-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "dagger" }
hilt-navigationCompose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "hilt" }
intellij-markdown = { group = "org.jetbrains", name = "markdown", version.ref = "intellijMarkdown" }
test-junit = { group = "junit", name = "junit", version.ref = "junit" }

[bundles]
Expand Down