Slightly adjust the dictionary dialog (#1656)

This commit is contained in:
BlackyHawky 2025-06-03 19:27:01 +02:00 committed by GitHub
parent 97aec851e4
commit 0787a79de4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 6 deletions

View file

@ -86,7 +86,6 @@ fun MissingDictionaryDialog(onDismissRequest: () -> Unit, locale: Locale) {
fun createDictionaryTextAnnotated(locale: Locale): AnnotatedString { fun createDictionaryTextAnnotated(locale: Locale): AnnotatedString {
val knownDicts = mutableListOf<Pair<String, String>>() val knownDicts = mutableListOf<Pair<String, String>>()
val builder = AnnotatedString.Builder() val builder = AnnotatedString.Builder()
builder.appendLine(stringResource(R.string.dictionary_available))
val context = LocalContext.current val context = LocalContext.current
context.assets.open("dictionaries_in_dict_repo.csv").reader().forEachLine { context.assets.open("dictionaries_in_dict_repo.csv").reader().forEachLine {
if (it.isBlank()) return@forEachLine if (it.isBlank()) return@forEachLine

View file

@ -38,7 +38,6 @@ import helium314.keyboard.settings.DeleteButton
import helium314.keyboard.settings.ExpandButton import helium314.keyboard.settings.ExpandButton
import helium314.keyboard.settings.Theme import helium314.keyboard.settings.Theme
import helium314.keyboard.settings.dictionaryFilePicker import helium314.keyboard.settings.dictionaryFilePicker
import helium314.keyboard.settings.preferences.PreferenceCategory
import helium314.keyboard.settings.previewDark import helium314.keyboard.settings.previewDark
import helium314.keyboard.settings.screens.getUserAndInternalDictionaries import helium314.keyboard.settings.screens.getUserAndInternalDictionaries
import java.io.File import java.io.File
@ -65,19 +64,34 @@ fun DictionaryDialog(
val state = rememberScrollState() val state = rememberScrollState()
Column(Modifier.verticalScroll(state)) { Column(Modifier.verticalScroll(state)) {
if (hasInternal) { if (hasInternal) {
val color = if (mainDict == null) MaterialTheme.colorScheme.onSurface val color = if (mainDict == null) MaterialTheme.typography.titleSmall.color
else MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f) // for disabled look else MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f) // for disabled look
Text(stringResource(R.string.internal_dictionary_summary), color = color, modifier = Modifier.fillMaxWidth()) val bottomPadding = if (mainDict == null) 12.dp else 0.dp
Text(stringResource(R.string.internal_dictionary_summary),
modifier = Modifier
.fillMaxWidth()
.padding(bottom = bottomPadding),
color = color,
style = MaterialTheme.typography.titleSmall
)
} }
if (mainDict != null) if (mainDict != null)
DictionaryDetails(mainDict) DictionaryDetails(mainDict)
if (addonDicts.isNotEmpty()) { if (addonDicts.isNotEmpty()) {
PreferenceCategory(stringResource(R.string.dictionary_category_title)) HorizontalDivider()
Text(stringResource(R.string.dictionary_category_title),
modifier = Modifier.padding(vertical = 12.dp),
style = MaterialTheme.typography.titleSmall
)
addonDicts.forEach { DictionaryDetails(it) } addonDicts.forEach { DictionaryDetails(it) }
} }
val dictString = createDictionaryTextAnnotated(locale) val dictString = createDictionaryTextAnnotated(locale)
if (dictString.isNotEmpty()) { if (dictString.isNotEmpty()) {
HorizontalDivider() HorizontalDivider()
Text(stringResource(R.string.dictionary_available),
modifier = Modifier.padding(top = 12.dp, bottom = 4.dp),
style = MaterialTheme.typography.titleSmall
)
Text(dictString, style = LocalTextStyle.current.merge(lineHeight = 1.8.em)) Text(dictString, style = LocalTextStyle.current.merge(lineHeight = 1.8.em))
} }
} }
@ -114,7 +128,7 @@ private fun DictionaryDetails(dict: File) {
Text( Text(
header.info(LocalConfiguration.current.locale()), header.info(LocalConfiguration.current.locale()),
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.padding(horizontal = 10.dp) modifier = Modifier.padding(start = 10.dp, top = 0.dp, end = 10.dp, bottom = 12.dp)
) )
} }
if (showDeleteDialog) if (showDeleteDialog)