kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
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 issuespull/1606/head
rodzic
84d916f410
commit
8fee9dbc45
|
@ -22,6 +22,7 @@ import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.defaultMinSize
|
||||||
import androidx.compose.foundation.layout.heightIn
|
import androidx.compose.foundation.layout.heightIn
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.text.KeyboardActions
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
|
@ -43,19 +44,20 @@ import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.focus.onFocusEvent
|
import androidx.compose.ui.focus.onFocusEvent
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.platform.LocalFocusManager
|
import androidx.compose.ui.platform.LocalFocusManager
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.res.vectorResource
|
import androidx.compose.ui.res.vectorResource
|
||||||
import androidx.compose.ui.text.TextStyle
|
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import androidx.compose.ui.tooling.preview.PreviewLightDark
|
import androidx.compose.ui.tooling.preview.PreviewLightDark
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.geeksville.mesh.R
|
import com.geeksville.mesh.R
|
||||||
import com.geeksville.mesh.model.NodeSortOption
|
import com.geeksville.mesh.model.NodeSortOption
|
||||||
|
import com.geeksville.mesh.ui.compose.preview.LargeFontPreview
|
||||||
import com.geeksville.mesh.ui.theme.AppTheme
|
import com.geeksville.mesh.ui.theme.AppTheme
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -80,6 +82,7 @@ fun NodeFilterTextField(
|
||||||
)
|
)
|
||||||
|
|
||||||
NodeSortButton(
|
NodeSortButton(
|
||||||
|
modifier = Modifier.align(Alignment.CenterVertically),
|
||||||
currentSortOption = currentSortOption,
|
currentSortOption = currentSortOption,
|
||||||
onSortSelect = onSortSelect,
|
onSortSelect = onSortSelect,
|
||||||
includeUnknown = includeUnknown,
|
includeUnknown = includeUnknown,
|
||||||
|
@ -101,7 +104,7 @@ private fun NodeFilterTextField(
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.heightIn(max = 48.dp)
|
.defaultMinSize(minHeight = 48.dp)
|
||||||
.onFocusEvent { isFocused = it.isFocused },
|
.onFocusEvent { isFocused = it.isFocused },
|
||||||
value = filterText,
|
value = filterText,
|
||||||
placeholder = {
|
placeholder = {
|
||||||
|
@ -130,7 +133,7 @@ private fun NodeFilterTextField(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
textStyle = TextStyle(
|
textStyle = MaterialTheme.typography.body1.copy(
|
||||||
color = MaterialTheme.colors.onBackground
|
color = MaterialTheme.colors.onBackground
|
||||||
),
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
|
@ -223,6 +226,7 @@ private fun NodeSortButton(
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreviewLightDark
|
@PreviewLightDark
|
||||||
|
@LargeFontPreview
|
||||||
@Composable
|
@Composable
|
||||||
private fun NodeFilterTextFieldPreview() {
|
private fun NodeFilterTextFieldPreview() {
|
||||||
AppTheme {
|
AppTheme {
|
||||||
|
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.geeksville.mesh.ui.compose.preview
|
||||||
|
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
|
||||||
|
@Preview(name = "Large Font", fontScale = 2f)
|
||||||
|
annotation class LargeFontPreview
|
Ładowanie…
Reference in New Issue