From 8fee9dbc450baa56dbb361f24295d6bea583e23d Mon Sep 17 00:00:00 2001 From: Joshua Soberg Date: Sat, 22 Feb 2025 13:57:30 -0500 Subject: [PATCH] fix: Accommodate large font for node filter (#1602) Fixes #1561 * Add large font preview * Adjust default min size such that the filter input will accomodate larger fonts. Also, align the dropdown icon and use body1 typography for input text * Add license and newline to fix detekt issues --- .../mesh/ui/components/NodeFilterTextField.kt | 10 +++++--- .../ui/compose/preview/LargeFontPreview.kt | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/com/geeksville/mesh/ui/compose/preview/LargeFontPreview.kt diff --git a/app/src/main/java/com/geeksville/mesh/ui/components/NodeFilterTextField.kt b/app/src/main/java/com/geeksville/mesh/ui/components/NodeFilterTextField.kt index d31ef804..b39e055b 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/components/NodeFilterTextField.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/components/NodeFilterTextField.kt @@ -22,6 +22,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.text.KeyboardActions @@ -43,19 +44,20 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.focus.onFocusEvent import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource -import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import com.geeksville.mesh.R import com.geeksville.mesh.model.NodeSortOption +import com.geeksville.mesh.ui.compose.preview.LargeFontPreview import com.geeksville.mesh.ui.theme.AppTheme @Composable @@ -80,6 +82,7 @@ fun NodeFilterTextField( ) NodeSortButton( + modifier = Modifier.align(Alignment.CenterVertically), currentSortOption = currentSortOption, onSortSelect = onSortSelect, includeUnknown = includeUnknown, @@ -101,7 +104,7 @@ private fun NodeFilterTextField( OutlinedTextField( modifier = modifier - .heightIn(max = 48.dp) + .defaultMinSize(minHeight = 48.dp) .onFocusEvent { isFocused = it.isFocused }, value = filterText, placeholder = { @@ -130,7 +133,7 @@ private fun NodeFilterTextField( ) } }, - textStyle = TextStyle( + textStyle = MaterialTheme.typography.body1.copy( color = MaterialTheme.colors.onBackground ), maxLines = 1, @@ -223,6 +226,7 @@ private fun NodeSortButton( } @PreviewLightDark +@LargeFontPreview @Composable private fun NodeFilterTextFieldPreview() { AppTheme { diff --git a/app/src/main/java/com/geeksville/mesh/ui/compose/preview/LargeFontPreview.kt b/app/src/main/java/com/geeksville/mesh/ui/compose/preview/LargeFontPreview.kt new file mode 100644 index 00000000..92041ad4 --- /dev/null +++ b/app/src/main/java/com/geeksville/mesh/ui/compose/preview/LargeFontPreview.kt @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Meshtastic LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.geeksville.mesh.ui.compose.preview + +import androidx.compose.ui.tooling.preview.Preview + +@Preview(name = "Large Font", fontScale = 2f) +annotation class LargeFontPreview