Skip to content

Commit

Permalink
Remove visible furigana during reading letter practice
Browse files Browse the repository at this point in the history
  • Loading branch information
syt0r committed Aug 30, 2024
1 parent e3eb00b commit a76488a
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ua.syt0r.kanji.presentation.screen.main.screen.practice_letter.use_case
import ua.syt0r.kanji.core.app_data.AppDataRepository
import ua.syt0r.kanji.core.app_data.data.JapaneseWord
import ua.syt0r.kanji.core.app_data.data.ReadingType
import ua.syt0r.kanji.core.app_data.data.withEmptyFurigana
import ua.syt0r.kanji.core.app_data.data.withEncodedText
import ua.syt0r.kanji.core.japanese.RomajiConverter
import ua.syt0r.kanji.core.japanese.getKanaInfo
Expand Down Expand Up @@ -50,8 +51,11 @@ class DefaultGetLetterPracticeQueueItemDataUseCase(
)
}

val encodedWords = encodeWords(descriptor.character, words)

val encodedWords = encodeWords(
character = descriptor.character,
words = words,
isReadingPractice = descriptor is LetterPracticeQueueItemDescriptor.Reading
)

return when (descriptor) {
is LetterPracticeQueueItemDescriptor.Writing -> {
Expand Down Expand Up @@ -158,9 +162,18 @@ class DefaultGetLetterPracticeQueueItemDataUseCase(
}
}

private fun encodeWords(character: String, words: List<JapaneseWord>): List<JapaneseWord> {
private fun encodeWords(
character: String,
words: List<JapaneseWord>,
isReadingPractice: Boolean
): List<JapaneseWord> {
return words.map { word ->
word.copy(readings = word.readings.map { it.withEncodedText(character) })
word.copy(
readings = word.readings.map {
it.withEncodedText(character)
.let { if (isReadingPractice) it.withEmptyFurigana() else it }
}
)
}
}

Expand Down

0 comments on commit a76488a

Please sign in to comment.