mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-09 16:17:44 +00:00
move some icons and iconButtons to separate file
This commit is contained in:
parent
875a98d3f4
commit
a8bd9058e7
12 changed files with 122 additions and 183 deletions
59
app/src/main/java/helium314/keyboard/settings/Icons.kt
Normal file
59
app/src/main/java/helium314/keyboard/settings/Icons.kt
Normal file
|
@ -0,0 +1,59 @@
|
|||
package helium314.keyboard.settings
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import helium314.keyboard.latin.R
|
||||
|
||||
@Composable
|
||||
fun NextScreenIcon() {
|
||||
Icon(painterResource(R.drawable.ic_arrow_left), null, Modifier.scale(-1f, 1f))
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun EditButton(enabled: Boolean = true, onClick: () -> Unit) {
|
||||
IconButton(onClick, enabled = enabled) { Icon(painterResource(R.drawable.ic_edit), "edit") }
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun DeleteButton(onClick: () -> Unit) {
|
||||
IconButton(onClick) { Icon(painterResource(R.drawable.ic_bin), stringResource(R.string.delete)) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SearchIcon() {
|
||||
Icon(painterResource(R.drawable.sym_keyboard_search_lxx), stringResource(R.string.label_search_key))
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun CloseIcon(@StringRes resId: Int) {
|
||||
Icon(painterResource(R.drawable.ic_close), stringResource(resId))
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun DefaultButton(isDefault: Boolean, onClick: () -> Unit) {
|
||||
IconButton(onClick = onClick, enabled = !isDefault) {
|
||||
Icon(painterResource(R.drawable.ic_settings_default), "default")
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
NextScreenIcon()
|
||||
SearchIcon()
|
||||
CloseIcon(R.string.dialog_close)
|
||||
EditButton { }
|
||||
DeleteButton { }
|
||||
DefaultButton(false) { }
|
||||
}
|
||||
}
|
|
@ -144,13 +144,13 @@ fun <T: Any?> SearchScreen(
|
|||
},
|
||||
actions = {
|
||||
IconButton(onClick = { setShowSearch(!showSearch) })
|
||||
{ Icon(painterResource(R.drawable.sym_keyboard_search_lxx), stringResource(R.string.label_search_key)) }
|
||||
{ SearchIcon() }
|
||||
if (menu != null)
|
||||
Box {
|
||||
var showMenu by remember { mutableStateOf(false) }
|
||||
IconButton(
|
||||
onClick = { showMenu = true }
|
||||
) { Icon(painterResource(R.drawable.ic_arrow_left,), "menu", Modifier.rotate(-90f)) }
|
||||
) { Icon(painterResource(R.drawable.ic_arrow_left), "menu", Modifier.rotate(-90f)) }
|
||||
DropdownMenu(
|
||||
expanded = showMenu,
|
||||
onDismissRequest = { showMenu = false }
|
||||
|
@ -224,11 +224,11 @@ fun ExpandableSearchField(
|
|||
value = search,
|
||||
onValueChange = onSearchChange,
|
||||
modifier = modifier.focusRequester(focusRequester),
|
||||
leadingIcon = { Icon(painterResource(R.drawable.sym_keyboard_search_lxx), stringResource(R.string.label_search_key)) },
|
||||
leadingIcon = { SearchIcon() },
|
||||
trailingIcon = { IconButton(onClick = {
|
||||
if (search.text.isBlank()) onDismiss()
|
||||
else onSearchChange(TextFieldValue())
|
||||
}) { Icon(painterResource(R.drawable.ic_close), stringResource(android.R.string.cancel)) } },
|
||||
}) { CloseIcon(android.R.string.cancel) } },
|
||||
singleLine = true,
|
||||
colors = colors
|
||||
)
|
||||
|
|
|
@ -14,7 +14,6 @@ import androidx.compose.foundation.lazy.LazyColumn
|
|||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.RadioButton
|
||||
|
@ -46,6 +45,8 @@ import helium314.keyboard.latin.utils.Log
|
|||
import helium314.keyboard.latin.utils.getActivity
|
||||
import helium314.keyboard.latin.utils.getStringResourceOrName
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.DeleteButton
|
||||
import helium314.keyboard.settings.EditButton
|
||||
import helium314.keyboard.settings.Setting
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.SettingsDestination
|
||||
|
@ -164,15 +165,12 @@ private fun AddColorRow(onDismissRequest: () -> Unit, userColors: Collection<Str
|
|||
modifier = Modifier.weight(1f),
|
||||
singleLine = true
|
||||
)
|
||||
IconButton(
|
||||
enabled = textValue.text.isNotEmpty() && textValue.text !in userColors,
|
||||
onClick = {
|
||||
onDismissRequest()
|
||||
prefs.edit().putString(prefKey, textValue.text).apply()
|
||||
SettingsDestination.navigateTo(targetScreen)
|
||||
keyboardNeedsReload = true
|
||||
}
|
||||
) { Icon(painterResource(R.drawable.ic_edit), "edit") }
|
||||
EditButton(textValue.text.isNotEmpty() && textValue.text !in userColors) {
|
||||
onDismissRequest()
|
||||
prefs.edit().putString(prefKey, textValue.text).apply()
|
||||
SettingsDestination.navigateTo(targetScreen)
|
||||
keyboardNeedsReload = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,15 +205,11 @@ private fun ColorItemRow(onDismissRequest: () -> Unit, item: String, isSelected:
|
|||
)
|
||||
if (isUser) {
|
||||
var showDialog by remember { mutableStateOf(false) }
|
||||
IconButton(
|
||||
onClick = { showDialog = true }
|
||||
) { Icon(painterResource(R.drawable.ic_bin), stringResource(R.string.delete)) }
|
||||
IconButton(
|
||||
onClick = {
|
||||
onDismissRequest()
|
||||
SettingsDestination.navigateTo(targetScreen + item)
|
||||
}
|
||||
) { Icon(painterResource(R.drawable.ic_edit), "edit") }
|
||||
DeleteButton { showDialog = true }
|
||||
EditButton {
|
||||
onDismissRequest()
|
||||
SettingsDestination.navigateTo(targetScreen + item)
|
||||
}
|
||||
if (showDialog)
|
||||
ConfirmationDialog(
|
||||
onDismissRequest = { showDialog = false },
|
||||
|
|
|
@ -9,8 +9,6 @@ import androidx.compose.foundation.layout.padding
|
|||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
|
@ -22,7 +20,6 @@ import androidx.compose.runtime.setValue
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.em
|
||||
|
@ -32,6 +29,7 @@ import helium314.keyboard.latin.R
|
|||
import helium314.keyboard.latin.common.LocaleUtils.localizedDisplayName
|
||||
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
||||
import helium314.keyboard.latin.utils.createDictionaryTextAnnotated
|
||||
import helium314.keyboard.settings.DeleteButton
|
||||
import helium314.keyboard.settings.dictionaryFilePicker
|
||||
import helium314.keyboard.settings.screens.getUserAndInternalDictionaries
|
||||
import java.util.Locale
|
||||
|
@ -72,9 +70,7 @@ fun DictionaryDialog(
|
|||
Column {
|
||||
Text(header.info(LocalContext.current.resources.configuration.locale()), style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
IconButton(
|
||||
onClick = { showDeleteDialog = true }
|
||||
) { Icon(painterResource(R.drawable.ic_bin), stringResource(R.string.delete)) }
|
||||
DeleteButton { showDeleteDialog = true }
|
||||
}
|
||||
}
|
||||
if (showDeleteDialog)
|
||||
|
|
|
@ -3,7 +3,6 @@ package helium314.keyboard.settings.dialogs
|
|||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -16,7 +15,6 @@ import androidx.compose.runtime.setValue
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import helium314.keyboard.latin.R
|
||||
|
@ -26,6 +24,7 @@ import helium314.keyboard.latin.utils.Log
|
|||
import helium314.keyboard.latin.utils.SubtypeSettings
|
||||
import helium314.keyboard.latin.utils.getActivity
|
||||
import helium314.keyboard.latin.utils.getStringResourceOrName
|
||||
import helium314.keyboard.settings.CloseIcon
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
import kotlinx.coroutines.Job
|
||||
|
@ -88,7 +87,7 @@ fun LayoutEditDialog(
|
|||
onValueChange = { displayNameValue = it },
|
||||
isError = !nameValid,
|
||||
supportingText = { if (!nameValid) Text(stringResource(R.string.name_invalid)) },
|
||||
trailingIcon = { if (!nameValid) Icon(painterResource(R.drawable.ic_close), stringResource(R.string.name_invalid)) },
|
||||
trailingIcon = { if (!nameValid) CloseIcon(R.string.name_invalid) },
|
||||
)
|
||||
},
|
||||
checkTextValid = { text ->
|
||||
|
|
|
@ -10,7 +10,6 @@ import androidx.compose.foundation.lazy.LazyColumn
|
|||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.RadioButton
|
||||
|
@ -45,6 +44,8 @@ import helium314.keyboard.latin.utils.SubtypeSettings
|
|||
import helium314.keyboard.latin.utils.getActivity
|
||||
import helium314.keyboard.latin.utils.getStringResourceOrName
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.DeleteButton
|
||||
import helium314.keyboard.settings.EditButton
|
||||
import helium314.keyboard.settings.Setting
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
|
@ -139,10 +140,9 @@ private fun AddLayoutRow(onNewLayout: (String) -> Unit, layoutType: LayoutType,
|
|||
modifier = Modifier.weight(1f),
|
||||
singleLine = true
|
||||
)
|
||||
IconButton(
|
||||
enabled = textValue.text.isNotEmpty() && LayoutUtilsCustom.getLayoutName(textValue.text, layoutType) !in userLayouts,
|
||||
onClick = { onNewLayout(textValue.text) }
|
||||
) { Icon(painterResource(R.drawable.ic_edit), "edit") }
|
||||
EditButton(textValue.text.isNotEmpty() && LayoutUtilsCustom.getLayoutName(textValue.text, layoutType) !in userLayouts) {
|
||||
onNewLayout(textValue.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,9 +186,7 @@ private fun LayoutItemRow(
|
|||
)
|
||||
if (isCustom) {
|
||||
var showDeleteDialog by remember { mutableStateOf(false) }
|
||||
IconButton(
|
||||
onClick = { showDeleteDialog = true }
|
||||
) { Icon(painterResource(R.drawable.ic_bin), stringResource(R.string.delete)) }
|
||||
DeleteButton { showDeleteDialog = true }
|
||||
if (showDeleteDialog) {
|
||||
val inUse = SubtypeSettings.getAdditionalSubtypes().any { st ->
|
||||
val map = LayoutType.getLayoutMap(st.getExtraValueOf(ExtraValue.KEYBOARD_LAYOUT_SET))
|
||||
|
@ -206,9 +204,7 @@ private fun LayoutItemRow(
|
|||
)
|
||||
}
|
||||
}
|
||||
IconButton(
|
||||
onClick = { onClickEdit(layoutName to (if (isCustom) null else LayoutUtils.getContent(layoutType, layoutName, ctx))) }
|
||||
) { Icon(painterResource(R.drawable.ic_edit), "edit") }
|
||||
EditButton { onClickEdit(layoutName to (if (isCustom) null else LayoutUtils.getContent(layoutType, layoutName, ctx))) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ import helium314.keyboard.latin.utils.getSecondaryLocales
|
|||
import helium314.keyboard.latin.utils.getStringResourceOrName
|
||||
import helium314.keyboard.latin.utils.mainLayoutName
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.DefaultButton
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.layoutFilePicker
|
||||
import helium314.keyboard.settings.layoutIntent
|
||||
|
@ -125,18 +126,16 @@ fun SubtypeDialog(
|
|||
Row {
|
||||
TextButton(onClick = { showKeyOrderDialog = true }, Modifier.weight(1f))
|
||||
{ Text(stringResource(R.string.popup_order), style = MaterialTheme.typography.bodyLarge) }
|
||||
DefaultButton(
|
||||
{ currentSubtype = currentSubtype.without(ExtraValue.POPUP_ORDER) },
|
||||
currentSubtype.getExtraValueOf(ExtraValue.POPUP_ORDER) == null
|
||||
)
|
||||
DefaultButton(currentSubtype.getExtraValueOf(ExtraValue.POPUP_ORDER) == null) {
|
||||
currentSubtype = currentSubtype.without(ExtraValue.POPUP_ORDER)
|
||||
}
|
||||
}
|
||||
Row {
|
||||
TextButton(onClick = { showHintOrderDialog = true }, Modifier.weight(1f))
|
||||
{ Text(stringResource(R.string.hint_source), style = MaterialTheme.typography.bodyLarge) }
|
||||
DefaultButton(
|
||||
{ currentSubtype = currentSubtype.without(ExtraValue.HINT_ORDER) },
|
||||
currentSubtype.getExtraValueOf(ExtraValue.HINT_ORDER) == null
|
||||
)
|
||||
DefaultButton(currentSubtype.getExtraValueOf(ExtraValue.HINT_ORDER) == null) {
|
||||
currentSubtype = currentSubtype.without(ExtraValue.HINT_ORDER)
|
||||
}
|
||||
}
|
||||
if (currentSubtype.locale.script() == SCRIPT_LATIN) {
|
||||
WithSmallTitle(stringResource(R.string.show_popup_keys_title)) {
|
||||
|
@ -145,10 +144,9 @@ fun SubtypeDialog(
|
|||
Row {
|
||||
TextButton(onClick = { showMorePopupsDialog = true }, Modifier.weight(1f))
|
||||
{ Text(stringResource(morePopupKeysResId(value))) }
|
||||
DefaultButton(
|
||||
{ currentSubtype = currentSubtype.without(ExtraValue.MORE_POPUPS) },
|
||||
explicitValue == null
|
||||
)
|
||||
DefaultButton(explicitValue == null) {
|
||||
currentSubtype = currentSubtype.without(ExtraValue.MORE_POPUPS)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,10 +160,9 @@ fun SubtypeDialog(
|
|||
currentSubtype = currentSubtype.with(ExtraValue.LOCALIZED_NUMBER_ROW, it.toString())
|
||||
}
|
||||
)
|
||||
DefaultButton(
|
||||
{ currentSubtype = currentSubtype.without(ExtraValue.LOCALIZED_NUMBER_ROW) },
|
||||
checked == null
|
||||
)
|
||||
DefaultButton(checked == null) {
|
||||
currentSubtype = currentSubtype.without(ExtraValue.LOCALIZED_NUMBER_ROW)
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalDivider()
|
||||
|
@ -183,10 +180,9 @@ fun SubtypeDialog(
|
|||
onSelected = {
|
||||
currentSubtype = currentSubtype.withLayout(type, it)
|
||||
},
|
||||
extraButton = { DefaultButton(
|
||||
onDefault = { currentSubtype = currentSubtype.withoutLayout(type) },
|
||||
isDefault = explicitLayout == null
|
||||
) },
|
||||
extraButton = { DefaultButton(explicitLayout == null) {
|
||||
currentSubtype = currentSubtype.withoutLayout(type)
|
||||
} },
|
||||
) {
|
||||
val displayName = if (LayoutUtilsCustom.isCustomLayout(it)) LayoutUtilsCustom.getDisplayName(it)
|
||||
else it.getStringResourceOrName("layout_", ctx)
|
||||
|
@ -462,19 +458,6 @@ fun <T>DropDownField(
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun DefaultButton(
|
||||
onDefault: () -> Unit,
|
||||
isDefault: Boolean
|
||||
) {
|
||||
IconButton(
|
||||
onClick = onDefault,
|
||||
enabled = !isDefault
|
||||
) {
|
||||
Icon(painterResource(R.drawable.ic_settings_default), "default")
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAvailableSecondaryLocales(context: Context, mainLocale: Locale): List<Locale> =
|
||||
getDictionaryLocales(context).filter { it != mainLocale && it.script() == mainLocale.script() }
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ package helium314.keyboard.settings.screens
|
|||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -12,10 +11,7 @@ import androidx.compose.runtime.getValue
|
|||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import helium314.keyboard.keyboard.KeyboardActionListener
|
||||
|
@ -33,6 +29,7 @@ import helium314.keyboard.latin.settings.DebugSettings
|
|||
import helium314.keyboard.latin.settings.Defaults
|
||||
import helium314.keyboard.latin.settings.Settings
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.NextScreenIcon
|
||||
import helium314.keyboard.settings.SettingsContainer
|
||||
import helium314.keyboard.settings.preferences.ListPreference
|
||||
import helium314.keyboard.settings.SettingsWithoutKey
|
||||
|
@ -195,13 +192,7 @@ fun createAdvancedSettings(context: Context) = listOf(
|
|||
Preference(
|
||||
name = it.title,
|
||||
onClick = { SettingsDestination.navigateTo(SettingsDestination.Debug) }
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
) { NextScreenIcon() }
|
||||
},
|
||||
Setting(context, Settings.PREF_EMOJI_MAX_SDK, R.string.prefs_key_emoji_max_sdk) { setting ->
|
||||
SliderPreference(
|
||||
|
|
|
@ -17,7 +17,6 @@ import androidx.compose.foundation.layout.Spacer
|
|||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
|
@ -39,7 +38,6 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
@ -57,9 +55,9 @@ import helium314.keyboard.latin.settings.Settings
|
|||
import helium314.keyboard.latin.settings.colorPrefsAndResIds
|
||||
import helium314.keyboard.latin.settings.getColorPrefsToHideInitially
|
||||
import helium314.keyboard.latin.utils.Log
|
||||
import helium314.keyboard.latin.utils.ResourceUtils
|
||||
import helium314.keyboard.latin.utils.getActivity
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.CloseIcon
|
||||
import helium314.keyboard.settings.SearchScreen
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.Theme
|
||||
|
@ -138,7 +136,7 @@ fun ColorsScreen(
|
|||
},
|
||||
isError = !nameValid,
|
||||
// supportingText = { if (!nameValid) Text(stringResource(R.string.name_invalid)) } // todo: this is cutting off bottom half of the actual text...
|
||||
trailingIcon = { if (!nameValid) Icon(painterResource(R.drawable.ic_close), null) },
|
||||
trailingIcon = { if (!nameValid) CloseIcon(R.string.name_invalid) },
|
||||
singleLine = true,
|
||||
)
|
||||
},
|
||||
|
|
|
@ -4,13 +4,10 @@ package helium314.keyboard.settings.screens
|
|||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import helium314.keyboard.latin.R
|
||||
|
@ -28,6 +25,7 @@ import helium314.keyboard.latin.utils.displayName
|
|||
import helium314.keyboard.latin.utils.getActivity
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.latin.utils.switchTo
|
||||
import helium314.keyboard.settings.NextScreenIcon
|
||||
import helium314.keyboard.settings.preferences.Preference
|
||||
import helium314.keyboard.settings.preferences.PreferenceCategory
|
||||
import helium314.keyboard.settings.SearchSettingsScreen
|
||||
|
@ -60,113 +58,53 @@ fun MainSettingsScreen(
|
|||
description = enabledSubtypes.joinToString(", ") { it.displayName(ctx) },
|
||||
onClick = onClickLanguage,
|
||||
icon = R.drawable.ic_settings_languages_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
) { NextScreenIcon() }
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_preferences),
|
||||
onClick = onClickPreferences,
|
||||
icon = R.drawable.ic_settings_preferences_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
) { NextScreenIcon() }
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_appearance),
|
||||
onClick = onClickAppearance,
|
||||
icon = R.drawable.ic_settings_appearance_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
) { NextScreenIcon() }
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_toolbar),
|
||||
onClick = onClickToolbar,
|
||||
icon = R.drawable.ic_settings_toolbar_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
) { NextScreenIcon() }
|
||||
if (JniUtils.sHaveGestureLib)
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_gesture),
|
||||
onClick = onClickGestureTyping,
|
||||
icon = R.drawable.ic_settings_gesture_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
) { NextScreenIcon() }
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_correction),
|
||||
onClick = onClickTextCorrection,
|
||||
icon = R.drawable.ic_settings_correction_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
) { NextScreenIcon() }
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_secondary_layouts),
|
||||
onClick = onClickLayouts,
|
||||
icon = R.drawable.ic_ime_switcher
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
) { NextScreenIcon() }
|
||||
Preference(
|
||||
name = stringResource(R.string.dictionary_settings_category),
|
||||
onClick = onClickDictionaries,
|
||||
icon = R.drawable.ic_dictionary
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
) { NextScreenIcon() }
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_advanced),
|
||||
onClick = onClickAdvanced,
|
||||
icon = R.drawable.ic_settings_advanced_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
) { NextScreenIcon() }
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_about),
|
||||
onClick = onClickAbout,
|
||||
icon = R.drawable.ic_settings_about_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
) { NextScreenIcon() }
|
||||
PreferenceCategory(title = "old screens")
|
||||
Preference(
|
||||
name = stringResource(R.string.language_and_layouts_title),
|
||||
|
|
|
@ -7,15 +7,12 @@ import androidx.compose.foundation.layout.Row
|
|||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import helium314.keyboard.latin.R
|
||||
|
@ -28,6 +25,7 @@ import helium314.keyboard.latin.utils.SubtypeSettings.getSystemLocales
|
|||
import helium314.keyboard.latin.utils.getSecondaryLocales
|
||||
import helium314.keyboard.latin.utils.locale
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.NextScreenIcon
|
||||
import helium314.keyboard.settings.SearchScreen
|
||||
import helium314.keyboard.settings.SettingsDestination
|
||||
import java.util.Locale
|
||||
|
@ -63,11 +61,7 @@ fun PersonalDictionariesScreen(
|
|||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(it.getLocaleDisplayNameForUserDictSettings(ctx), style = MaterialTheme.typography.bodyLarge)
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
NextScreenIcon()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.Manifest
|
|||
import android.content.Context
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -15,10 +14,7 @@ import androidx.compose.runtime.mutableStateOf
|
|||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import helium314.keyboard.latin.R
|
||||
|
@ -28,6 +24,7 @@ import helium314.keyboard.latin.settings.Settings
|
|||
import helium314.keyboard.latin.utils.Log
|
||||
import helium314.keyboard.latin.utils.getActivity
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.NextScreenIcon
|
||||
import helium314.keyboard.settings.SettingsContainer
|
||||
import helium314.keyboard.settings.preferences.ListPreference
|
||||
import helium314.keyboard.settings.SettingsWithoutKey
|
||||
|
@ -85,13 +82,7 @@ fun createCorrectionSettings(context: Context) = listOf(
|
|||
Preference(
|
||||
name = stringResource(R.string.edit_personal_dictionary),
|
||||
onClick = { SettingsDestination.navigateTo(SettingsDestination.PersonalDictionaries) },
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
) { NextScreenIcon() }
|
||||
},
|
||||
Setting(context, Settings.PREF_BLOCK_POTENTIALLY_OFFENSIVE,
|
||||
R.string.prefs_block_potentially_offensive_title, R.string.prefs_block_potentially_offensive_summary
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue