mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-09 16:17:44 +00:00
reduce padding for LayoutEditDialog
This commit is contained in:
parent
42f4561422
commit
d8e9a004e5
3 changed files with 14 additions and 11 deletions
|
@ -28,9 +28,6 @@ import kotlinx.coroutines.Job
|
|||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
// todo: make it wider!
|
||||
// maybe make it a completely separate dialog, not even using the 3-button thing?
|
||||
// though we could provide with parameter, and maybe some sort of reduce-padding option
|
||||
@Composable
|
||||
fun LayoutEditDialog(
|
||||
onDismissRequest: () -> Unit,
|
||||
|
@ -78,7 +75,6 @@ fun LayoutEditDialog(
|
|||
isError = !nameValid,
|
||||
supportingText = { if (!nameValid) Text(stringResource(R.string.name_invalid)) },
|
||||
trailingIcon = { if (!nameValid) Icon(painterResource(R.drawable.ic_close), null) },
|
||||
// textStyle = MaterialTheme.typography.titleMedium, // todo: only makes it a tiny bit smaller, find a better way
|
||||
)
|
||||
},
|
||||
checkTextValid = {
|
||||
|
@ -99,6 +95,7 @@ fun LayoutEditDialog(
|
|||
// decorFitsSystemWindows = false is necessary so the dialog is not covered by keyboard
|
||||
// but this also stops the background from being darkened... great idea to combine both
|
||||
// todo: also it results in an ugly effect when adding a new layout... need to find something else
|
||||
properties = DialogProperties(decorFitsSystemWindows = false)
|
||||
properties = DialogProperties(decorFitsSystemWindows = false),
|
||||
reducePadding = true,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ fun TextInputDialog(
|
|||
singleLine: Boolean = true,
|
||||
keyboardType: KeyboardType = KeyboardType.Unspecified,
|
||||
properties: DialogProperties = DialogProperties(),
|
||||
reducePadding: Boolean = false,
|
||||
checkTextValid: (text: String) -> Boolean = { it.isNotBlank() }
|
||||
) {
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
|
@ -77,7 +78,8 @@ fun TextInputDialog(
|
|||
singleLine = singleLine
|
||||
)
|
||||
},
|
||||
properties = properties
|
||||
properties = properties,
|
||||
reducePadding = reducePadding,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.PaddingValues
|
|||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.sizeIn
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
|
@ -29,7 +28,6 @@ import androidx.compose.ui.window.Dialog
|
|||
import androidx.compose.ui.window.DialogProperties
|
||||
import helium314.keyboard.settings.Theme
|
||||
|
||||
// text should be smaller, and background should be darkened
|
||||
@Composable
|
||||
fun ThreeButtonAlertDialog(
|
||||
onDismissRequest: () -> Unit,
|
||||
|
@ -42,6 +40,7 @@ fun ThreeButtonAlertDialog(
|
|||
confirmButtonText: String? = stringResource(android.R.string.ok),
|
||||
cancelButtonText: String = stringResource(android.R.string.cancel),
|
||||
neutralButtonText: String? = null,
|
||||
reducePadding: Boolean = false,
|
||||
properties: DialogProperties = DialogProperties()
|
||||
) {
|
||||
Dialog(
|
||||
|
@ -57,17 +56,22 @@ fun ThreeButtonAlertDialog(
|
|||
color = MaterialTheme.colorScheme.surface,
|
||||
contentColor = contentColorFor(MaterialTheme.colorScheme.surface),
|
||||
) {
|
||||
Column(modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 6.dp)) {
|
||||
Column(modifier = Modifier.padding(
|
||||
start = if (reducePadding) 8.dp else 16.dp,
|
||||
end = if (reducePadding) 8.dp else 16.dp,
|
||||
top = if (reducePadding) 8.dp else 16.dp,
|
||||
bottom = if (reducePadding) 2.dp else 6.dp
|
||||
)) {
|
||||
title?.let {
|
||||
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.titleLarge) {
|
||||
Box(Modifier.padding(PaddingValues(bottom = 16.dp))) {
|
||||
Box(Modifier.padding(PaddingValues(bottom = if (reducePadding) 4.dp else 16.dp))) {
|
||||
title()
|
||||
}
|
||||
}
|
||||
}
|
||||
text?.let {
|
||||
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.bodyMedium) {
|
||||
Box(Modifier.weight(weight = 1f, fill = false).padding(bottom = 8.dp)) {
|
||||
Box(Modifier.weight(weight = 1f, fill = false).padding(bottom = if (reducePadding) 2.dp else 8.dp)) {
|
||||
text()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue