mirror of https://github.com/tasks/tasks
Update list settings
* Remove unused resources * Fix check for icon changes * Break out composablespull/3193/head
parent
dc031da1b9
commit
e17a6762d9
@ -1,374 +0,0 @@
|
||||
package org.tasks.compose
|
||||
|
||||
/**
|
||||
* Composables for BaseListSettingActivity
|
||||
*/
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.requiredHeight
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.BasicTextField
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ProvideTextStyle
|
||||
import androidx.compose.material3.Snackbar
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.focus.onFocusChanged
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.SolidColor
|
||||
import androidx.compose.ui.graphics.drawscope.Stroke
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.res.colorResource
|
||||
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.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import kotlinx.coroutines.delay
|
||||
import org.tasks.R
|
||||
import org.tasks.compose.components.TasksIcon
|
||||
import org.tasks.themes.TasksIcons
|
||||
import org.tasks.themes.TasksTheme
|
||||
|
||||
@Composable
|
||||
@Preview (showBackground = true)
|
||||
private fun TitleBarPreview() {
|
||||
TasksTheme {
|
||||
ListSettings.Toolbar(
|
||||
title = "Tollbar title",
|
||||
save = { /*TODO*/ }, optionButton = { DeleteButton {} }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Preview(showBackground = true)
|
||||
private fun PromptActionPreview() {
|
||||
TasksTheme {
|
||||
ListSettings.PromptAction(
|
||||
showDialog = remember { mutableStateOf(true) },
|
||||
title = "Delete list?",
|
||||
onAction = { /*TODO*/ })
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Preview (showBackground = true)
|
||||
private fun IconSelectPreview () {
|
||||
TasksTheme {
|
||||
ListSettings.SelectIconRow(
|
||||
icon = TasksIcons.FILTER_LIST,
|
||||
selectIcon = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Preview (showBackground = true)
|
||||
private fun ColorSelectPreview () {
|
||||
TasksTheme {
|
||||
ListSettings.SelectColorRow(
|
||||
color = remember { mutableStateOf(Color.Red) },
|
||||
selectColor = {},
|
||||
clearColor = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object ListSettings {
|
||||
|
||||
@Composable
|
||||
fun Toolbar(
|
||||
title: String,
|
||||
save: () -> Unit,
|
||||
optionButton: @Composable () -> Unit,
|
||||
) {
|
||||
|
||||
/* Hady: reminder for the future
|
||||
val activity = LocalView.current.context as Activity
|
||||
activity.window.statusBarColor = colorResource(id = R.color.drawer_color_selected).toArgb()
|
||||
*/
|
||||
|
||||
Surface(
|
||||
shadowElevation = 4.dp,
|
||||
color = colorResource(id = R.color.content_background),
|
||||
contentColor = colorResource(id = R.color.text_primary),
|
||||
modifier = Modifier.requiredHeight(56.dp)
|
||||
)
|
||||
{
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
IconButton(onClick = save, modifier = Modifier.size(56.dp)) {
|
||||
Icon(
|
||||
imageVector = ImageVector.vectorResource(R.drawable.ic_outline_save_24px),
|
||||
contentDescription = stringResource(id = R.string.save),
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = title,
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 20.sp,
|
||||
modifier = Modifier
|
||||
.weight(0.9f)
|
||||
.padding(start = Constants.KEYLINE_FIRST)
|
||||
)
|
||||
optionButton()
|
||||
}
|
||||
}
|
||||
} /* ToolBar */
|
||||
|
||||
@Composable
|
||||
fun ProgressBar(showProgress: State<Boolean>) {
|
||||
Box(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.requiredHeight(3.dp))
|
||||
{
|
||||
if (showProgress.value) {
|
||||
LinearProgressIndicator(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
trackColor = LocalContentColor.current.copy(alpha = 0.3f), //Color.LightGray,
|
||||
color = colorResource(org.tasks.kmp.R.color.red_a400)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun TitleInput(
|
||||
text: MutableState<String>,
|
||||
error: MutableState<String>,
|
||||
requestKeyboard: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
label: String = stringResource(R.string.display_name),
|
||||
errorState: Color = MaterialTheme.colorScheme.secondary,
|
||||
activeState: Color = LocalContentColor.current.copy(alpha = 0.75f),
|
||||
inactiveState: Color = LocalContentColor.current.copy(alpha = 0.3f),
|
||||
) {
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
val requester = remember { FocusRequester() }
|
||||
val focused = remember { mutableStateOf(false) }
|
||||
val labelColor = when {
|
||||
(error.value != "") -> errorState
|
||||
(focused.value) -> activeState
|
||||
else -> inactiveState
|
||||
}
|
||||
val dividerColor = if (focused.value) errorState else labelColor
|
||||
val labelText = if (error.value != "") error.value else label
|
||||
|
||||
Row (modifier = modifier)
|
||||
{
|
||||
Column {
|
||||
Text(
|
||||
modifier = Modifier.padding(top = 18.dp, bottom = 4.dp),
|
||||
text = labelText,
|
||||
fontSize = 12.sp,
|
||||
letterSpacing = 0.sp,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = labelColor
|
||||
)
|
||||
|
||||
BasicTextField(
|
||||
value = text.value,
|
||||
textStyle = TextStyle(
|
||||
fontSize = LocalTextStyle.current.fontSize,
|
||||
color = LocalContentColor.current
|
||||
),
|
||||
onValueChange = {
|
||||
text.value = it
|
||||
if (error.value != "") error.value = ""
|
||||
},
|
||||
cursorBrush = SolidColor(errorState), // SolidColor(LocalContentColor.current),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 3.dp)
|
||||
.focusRequester(requester)
|
||||
.onFocusChanged { focused.value = (it.isFocused) }
|
||||
)
|
||||
HorizontalDivider(
|
||||
color = dividerColor,
|
||||
modifier = Modifier.padding(bottom = 8.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (requestKeyboard) {
|
||||
LaunchedEffect(null) {
|
||||
requester.requestFocus()
|
||||
delay(30) // Workaround. Otherwise keyboard don't show in 4/5 tries
|
||||
keyboardController?.show()
|
||||
}
|
||||
}
|
||||
} /* TextInput */
|
||||
|
||||
@Composable
|
||||
fun SelectColorRow(color: State<Color>, selectColor: () -> Unit, clearColor: () -> Unit) =
|
||||
SettingRow(
|
||||
modifier = Modifier.clickable(onClick = selectColor),
|
||||
left = {
|
||||
IconButton(onClick = { selectColor() }) {
|
||||
if (color.value == Color.Unspecified) {
|
||||
Icon(
|
||||
imageVector = ImageVector.vectorResource(R.drawable.ic_outline_not_interested_24px),
|
||||
tint = colorResource(R.color.icon_tint_with_alpha),
|
||||
contentDescription = null
|
||||
)
|
||||
} else {
|
||||
val borderColor = colorResource(R.color.icon_tint_with_alpha) // colorResource(R.color.text_tertiary)
|
||||
Box(
|
||||
modifier = Modifier.size(56.dp),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Canvas(modifier = Modifier.size(24.dp)) {
|
||||
drawCircle(color = color.value)
|
||||
drawCircle(color = borderColor, style = Stroke(width = 4.0f)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
center = {
|
||||
Text(
|
||||
text = LocalContext.current.getString(R.string.color),
|
||||
modifier = Modifier.padding(start = Constants.KEYLINE_FIRST)
|
||||
)
|
||||
},
|
||||
right = {
|
||||
if (color.value != Color.Unspecified) {
|
||||
IconButton(onClick = clearColor) {
|
||||
Icon(
|
||||
imageVector = ImageVector.vectorResource(id = R.drawable.ic_outline_clear_24px),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun SelectIconRow(icon: String, selectIcon: () -> Unit) =
|
||||
SettingRow(
|
||||
modifier = Modifier.clickable(onClick = selectIcon),
|
||||
left = {
|
||||
IconButton(onClick = selectIcon) {
|
||||
TasksIcon(
|
||||
label = icon,
|
||||
tint = colorResource(R.color.icon_tint_with_alpha)
|
||||
)
|
||||
}
|
||||
},
|
||||
center = {
|
||||
Text(
|
||||
text = LocalContext.current.getString(R.string.icon),
|
||||
modifier = Modifier.padding(start = Constants.KEYLINE_FIRST)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@Composable
|
||||
fun SettingRow(
|
||||
left: @Composable () -> Unit,
|
||||
center: @Composable () -> Unit,
|
||||
right: @Composable (() -> Unit)? = null,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = modifier) {
|
||||
Box (modifier = Modifier.size(56.dp), contentAlignment = Alignment.Center) {
|
||||
left()
|
||||
}
|
||||
Box (
|
||||
modifier = Modifier
|
||||
.height(56.dp)
|
||||
.weight(1f), contentAlignment = Alignment.CenterStart
|
||||
) {
|
||||
center()
|
||||
}
|
||||
right?.let {
|
||||
Box (modifier = Modifier.size(56.dp), contentAlignment = Alignment.Center) {
|
||||
it.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SettingsSurface(content: @Composable ColumnScope.() -> Unit) {
|
||||
ProvideTextStyle(LocalTextStyle.current.copy(fontSize = 18.sp)) {
|
||||
Surface(
|
||||
color = colorResource(id = R.color.window_background),
|
||||
contentColor = colorResource(id = R.color.text_primary)
|
||||
) {
|
||||
Column(modifier = Modifier.fillMaxSize()) { content() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Toaster(state: SnackbarHostState) {
|
||||
SnackbarHost(state) { data ->
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Snackbar(
|
||||
modifier = Modifier.padding(horizontal = 24.dp),
|
||||
shape = RoundedCornerShape(10.dp),
|
||||
containerColor = colorResource(id = R.color.snackbar_background),
|
||||
contentColor = colorResource(id = R.color.snackbar_text_color),
|
||||
) {
|
||||
Text(text = data.visuals.message, fontSize = 18.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun PromptAction(
|
||||
showDialog: MutableState<Boolean>,
|
||||
title: String,
|
||||
onAction: () -> Unit,
|
||||
onCancel: () -> Unit = { showDialog.value = false }
|
||||
) {
|
||||
if (showDialog.value) {
|
||||
AlertDialog(
|
||||
onDismissRequest = onCancel,
|
||||
title = { Text(title, style = MaterialTheme.typography.headlineSmall) },
|
||||
confirmButton = { Constants.TextButton(text = R.string.ok, onClick = onAction) },
|
||||
dismissButton = { Constants.TextButton(text = R.string.cancel, onClick = onCancel) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package org.tasks.compose.settings
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.requiredHeight
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun ProgressBar(showProgress: State<Boolean>) {
|
||||
Box(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.requiredHeight(3.dp))
|
||||
{
|
||||
if (showProgress.value) {
|
||||
LinearProgressIndicator(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
trackColor = LocalContentColor.current.copy(alpha = 0.3f), //Color.LightGray,
|
||||
color = colorResource(org.tasks.kmp.R.color.red_a400)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package org.tasks.compose.settings
|
||||
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import org.tasks.R
|
||||
import org.tasks.compose.Constants
|
||||
import org.tasks.themes.TasksTheme
|
||||
|
||||
@Composable
|
||||
fun PromptAction(
|
||||
showDialog: MutableState<Boolean>,
|
||||
title: String,
|
||||
onAction: () -> Unit,
|
||||
onCancel: () -> Unit = { showDialog.value = false }
|
||||
) {
|
||||
if (showDialog.value) {
|
||||
AlertDialog(
|
||||
onDismissRequest = onCancel,
|
||||
title = { Text(title, style = MaterialTheme.typography.headlineSmall) },
|
||||
confirmButton = { Constants.TextButton(text = R.string.ok, onClick = onAction) },
|
||||
dismissButton = { Constants.TextButton(text = R.string.cancel, onClick = onCancel) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Preview(showBackground = true)
|
||||
private fun PromptActionPreview() {
|
||||
TasksTheme {
|
||||
PromptAction(
|
||||
showDialog = remember { mutableStateOf(true) },
|
||||
title = "Delete list?",
|
||||
onAction = { /*TODO*/ })
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package org.tasks.compose.settings
|
||||
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Clear
|
||||
import androidx.compose.material.icons.outlined.NotInterested
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.drawscope.Stroke
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.tasks.R
|
||||
import org.tasks.compose.Constants
|
||||
import org.tasks.kmp.org.tasks.compose.settings.SettingRow
|
||||
import org.tasks.themes.TasksTheme
|
||||
|
||||
@Composable
|
||||
fun SelectColorRow(color: State<Color>, selectColor: () -> Unit, clearColor: () -> Unit) =
|
||||
SettingRow(
|
||||
modifier = Modifier.clickable(onClick = selectColor),
|
||||
left = {
|
||||
IconButton(onClick = { selectColor() }) {
|
||||
if (color.value == Color.Unspecified) {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.NotInterested,
|
||||
tint = colorResource(R.color.icon_tint_with_alpha),
|
||||
contentDescription = null
|
||||
)
|
||||
} else {
|
||||
val borderColor = colorResource(R.color.icon_tint_with_alpha) // colorResource(R.color.text_tertiary)
|
||||
Box(
|
||||
modifier = Modifier.size(56.dp),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Canvas(modifier = Modifier.size(24.dp)) {
|
||||
drawCircle(color = color.value)
|
||||
drawCircle(color = borderColor, style = Stroke(width = 4.0f)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
center = {
|
||||
Text(
|
||||
text = LocalContext.current.getString(R.string.color),
|
||||
modifier = Modifier.padding(start = Constants.KEYLINE_FIRST)
|
||||
)
|
||||
},
|
||||
right = {
|
||||
if (color.value != Color.Unspecified) {
|
||||
IconButton(onClick = clearColor) {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.Clear,
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@Composable
|
||||
@Preview(showBackground = true)
|
||||
private fun ColorSelectPreview () {
|
||||
TasksTheme {
|
||||
SelectColorRow(
|
||||
color = remember { mutableStateOf(Color.Red) },
|
||||
selectColor = {},
|
||||
clearColor = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package org.tasks.compose.settings
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import org.tasks.R
|
||||
import org.tasks.compose.Constants
|
||||
import org.tasks.compose.components.TasksIcon
|
||||
import org.tasks.kmp.org.tasks.compose.settings.SettingRow
|
||||
import org.tasks.themes.TasksIcons
|
||||
import org.tasks.themes.TasksTheme
|
||||
|
||||
@Composable
|
||||
fun SelectIconRow(icon: String, selectIcon: () -> Unit) =
|
||||
SettingRow(
|
||||
modifier = Modifier.clickable(onClick = selectIcon),
|
||||
left = {
|
||||
IconButton(onClick = selectIcon) {
|
||||
TasksIcon(
|
||||
label = icon,
|
||||
tint = colorResource(R.color.icon_tint_with_alpha)
|
||||
)
|
||||
}
|
||||
},
|
||||
center = {
|
||||
Text(
|
||||
text = LocalContext.current.getString(R.string.icon),
|
||||
modifier = Modifier.padding(start = Constants.KEYLINE_FIRST)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@Composable
|
||||
@Preview(showBackground = true)
|
||||
private fun IconSelectPreview () {
|
||||
TasksTheme {
|
||||
SelectIconRow(
|
||||
icon = TasksIcons.FILTER_LIST,
|
||||
selectIcon = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package org.tasks.compose.settings
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.ProvideTextStyle
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.unit.sp
|
||||
import org.tasks.R
|
||||
|
||||
@Composable
|
||||
fun SettingsSurface(content: @Composable ColumnScope.() -> Unit) {
|
||||
ProvideTextStyle(LocalTextStyle.current.copy(fontSize = 18.sp)) {
|
||||
Surface(
|
||||
color = colorResource(id = R.color.window_background),
|
||||
contentColor = colorResource(id = R.color.text_primary)
|
||||
) {
|
||||
Column(modifier = Modifier.fillMaxSize()) { content() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
package org.tasks.compose.settings
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.text.BasicTextField
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.focus.onFocusChanged
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.SolidColor
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import kotlinx.coroutines.delay
|
||||
import org.tasks.R
|
||||
|
||||
@Composable
|
||||
fun TitleInput(
|
||||
text: MutableState<String>,
|
||||
error: MutableState<String>,
|
||||
requestKeyboard: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
label: String = stringResource(R.string.display_name),
|
||||
errorState: Color = MaterialTheme.colorScheme.secondary,
|
||||
activeState: Color = LocalContentColor.current.copy(alpha = 0.75f),
|
||||
inactiveState: Color = LocalContentColor.current.copy(alpha = 0.3f),
|
||||
) {
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
val requester = remember { FocusRequester() }
|
||||
val focused = remember { mutableStateOf(false) }
|
||||
val labelColor = when {
|
||||
(error.value != "") -> errorState
|
||||
(focused.value) -> activeState
|
||||
else -> inactiveState
|
||||
}
|
||||
val dividerColor = if (focused.value) errorState else labelColor
|
||||
val labelText = if (error.value != "") error.value else label
|
||||
|
||||
Row (modifier = modifier)
|
||||
{
|
||||
Column {
|
||||
Text(
|
||||
modifier = Modifier.padding(top = 18.dp, bottom = 4.dp),
|
||||
text = labelText,
|
||||
fontSize = 12.sp,
|
||||
letterSpacing = 0.sp,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = labelColor
|
||||
)
|
||||
|
||||
BasicTextField(
|
||||
value = text.value,
|
||||
textStyle = TextStyle(
|
||||
fontSize = LocalTextStyle.current.fontSize,
|
||||
color = LocalContentColor.current
|
||||
),
|
||||
onValueChange = {
|
||||
text.value = it
|
||||
if (error.value != "") error.value = ""
|
||||
},
|
||||
cursorBrush = SolidColor(errorState), // SolidColor(LocalContentColor.current),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 3.dp)
|
||||
.focusRequester(requester)
|
||||
.onFocusChanged { focused.value = (it.isFocused) }
|
||||
)
|
||||
HorizontalDivider(
|
||||
color = dividerColor,
|
||||
modifier = Modifier.padding(bottom = 8.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (requestKeyboard) {
|
||||
LaunchedEffect(null) {
|
||||
requester.requestFocus()
|
||||
delay(30) // Workaround. Otherwise keyboard don't show in 4/5 tries
|
||||
keyboardController?.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package org.tasks.compose.settings
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Snackbar
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import org.tasks.R
|
||||
|
||||
@Composable
|
||||
fun Toaster(state: SnackbarHostState) {
|
||||
SnackbarHost(state) { data ->
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Snackbar(
|
||||
modifier = Modifier.padding(horizontal = 24.dp),
|
||||
shape = RoundedCornerShape(10.dp),
|
||||
containerColor = colorResource(id = R.color.snackbar_background),
|
||||
contentColor = colorResource(id = R.color.snackbar_text_color),
|
||||
) {
|
||||
Text(text = data.visuals.message, fontSize = 18.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package org.tasks.compose.settings
|
||||
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.requiredHeight
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import org.tasks.R
|
||||
import org.tasks.compose.Constants
|
||||
import org.tasks.compose.DeleteButton
|
||||
import org.tasks.themes.TasksTheme
|
||||
|
||||
@Composable
|
||||
fun Toolbar(
|
||||
title: String,
|
||||
save: () -> Unit,
|
||||
optionButton: @Composable () -> Unit,
|
||||
) {
|
||||
|
||||
/* Hady: reminder for the future
|
||||
val activity = LocalView.current.context as Activity
|
||||
activity.window.statusBarColor = colorResource(id = R.color.drawer_color_selected).toArgb()
|
||||
*/
|
||||
|
||||
Surface(
|
||||
shadowElevation = 4.dp,
|
||||
color = colorResource(id = R.color.content_background),
|
||||
contentColor = colorResource(id = R.color.text_primary),
|
||||
modifier = Modifier.requiredHeight(56.dp)
|
||||
)
|
||||
{
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
IconButton(onClick = save, modifier = Modifier.size(56.dp)) {
|
||||
Icon(
|
||||
imageVector = ImageVector.vectorResource(R.drawable.ic_outline_save_24px),
|
||||
contentDescription = stringResource(id = R.string.save),
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = title,
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 20.sp,
|
||||
modifier = Modifier
|
||||
.weight(0.9f)
|
||||
.padding(start = Constants.KEYLINE_FIRST),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
optionButton()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Preview(showBackground = true)
|
||||
private fun TitleBarPreview() {
|
||||
TasksTheme {
|
||||
Toolbar(
|
||||
title = "Toolbar title",
|
||||
save = { /*TODO*/ },
|
||||
optionButton = { DeleteButton {} }
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:alpha="0.08" android:color="?attr/colorAccent" android:state_checked="true"/>
|
||||
<item android:color="@android:color/transparent" android:state_checked="false"/>
|
||||
</selector>
|
||||
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:alpha="0.16" android:color="?attr/colorAccent" android:state_pressed="true"/>
|
||||
<item android:alpha="0.12" android:color="?attr/colorAccent" android:state_focused="true" android:state_hovered="true"/>
|
||||
<item android:alpha="0.12" android:color="?attr/colorAccent" android:state_focused="true"/>
|
||||
<item android:alpha="0.04" android:color="?attr/colorAccent" android:state_hovered="true"/>
|
||||
<item android:alpha="0.00" android:color="?attr/colorAccent"/>
|
||||
</selector>
|
||||
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?attr/colorAccent" android:state_checked="true"/>
|
||||
<item android:alpha="0.12" android:color="?attr/colorOnSurface" android:state_checked="false"/>
|
||||
</selector>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.3 KiB |
@ -1,10 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M15,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM15,6c1.1,0 2,0.9 2,2s-0.9,2 -2,2 -2,-0.9 -2,-2 0.9,-2 2,-2zM15,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4zM9,18c0.22,-0.72 3.31,-2 6,-2 2.7,0 5.8,1.29 6,2L9,18zM6,15v-3h3v-2L6,10L6,7L4,7v3L1,10v2h3v3z"/>
|
||||
</vector>
|
||||
@ -1,64 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/root_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:descendantFocusability="beforeDescendants"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/toolbar"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/progress_bar"
|
||||
layout="@layout/progress_view" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/name_layout"
|
||||
style="@style/TagSettingsRow"
|
||||
android:hint="@string/display_name">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/name"
|
||||
style="@style/TagSettingsEditText"
|
||||
android:inputType="textCapSentences|textAutoCorrect" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<include layout="@layout/list_settings_color"/>
|
||||
|
||||
<include layout="@layout/list_settings_icon"/>
|
||||
|
||||
<androidx.compose.ui.platform.ComposeView
|
||||
android:id="@+id/people"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<androidx.compose.ui.platform.ComposeView
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/keyline_first"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:padding="0dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/toolbar"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/progress_bar"
|
||||
layout="@layout/progress_view"/>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:descendantFocusability="beforeDescendants"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/TagSettingsRow"
|
||||
android:hint="@string/display_name">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/name"
|
||||
style="@style/TagSettingsEditText"
|
||||
android:inputType="textCapSentences|textFilter"
|
||||
android:maxLines="1" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<include layout="@layout/list_settings_color"/>
|
||||
|
||||
<include layout="@layout/list_settings_icon"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/root_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:descendantFocusability="beforeDescendants"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/toolbar"/>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/name_layout"
|
||||
style="@style/TagSettingsRow"
|
||||
android:hint="@string/display_name">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/name"
|
||||
style="@style/TagSettingsEditText"
|
||||
android:inputType="textCapSentences|textAutoCorrect" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<include layout="@layout/list_settings_color"/>
|
||||
|
||||
<include layout="@layout/list_settings_icon"/>
|
||||
|
||||
<TextView
|
||||
style="@style/TagSettingsRow"
|
||||
android:text="@string/geofence_radius"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/keyline_first"
|
||||
android:paddingEnd="@dimen/keyline_first" />
|
||||
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/slider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/keyline_first"
|
||||
android:paddingEnd="@dimen/keyline_first"
|
||||
app:trackColorActive="?attr/colorSecondary"
|
||||
app:thumbColor="?attr/colorSecondary"
|
||||
app:tickColorActive="?attr/colorOnSecondary"
|
||||
app:tickColorInactive="?attr/colorSecondary"
|
||||
app:tickColor="@android:color/transparent"
|
||||
app:trackColorInactive="@color/text_tertiary"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/map"
|
||||
android:padding="@dimen/keyline_first"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
@ -1,41 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/toolbar"/>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:descendantFocusability="beforeDescendants"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/name_layout"
|
||||
style="@style/TagSettingsRow"
|
||||
android:hint="@string/display_name">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/name"
|
||||
style="@style/TagSettingsEditText"
|
||||
android:inputType="textCapSentences|textFilter"
|
||||
android:maxLines="1" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<include layout="@layout/list_settings_color"/>
|
||||
|
||||
<include layout="@layout/list_settings_icon"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
@ -1,41 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.button.MaterialButtonToggleGroup
|
||||
android:id="@+id/button_toggle"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/keyline_first"
|
||||
android:orientation="horizontal"
|
||||
app:selectionRequired="true"
|
||||
app:singleSelection="true">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_and"
|
||||
style="@style/OutlineButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/custom_filter_and" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_or"
|
||||
style="@style/OutlineButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/custom_filter_or" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_not"
|
||||
style="@style/OutlineButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/custom_filter_not" />
|
||||
|
||||
</com.google.android.material.button.MaterialButtonToggleGroup>
|
||||
|
||||
</LinearLayout>
|
||||
@ -1,80 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<include layout="@layout/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"/>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/toolbar"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:descendantFocusability="beforeDescendants"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/name_layout"
|
||||
style="@style/TagSettingsRow"
|
||||
android:hint="@string/display_name">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:imeOptions="flagNoExtractUi"
|
||||
android:inputType="textCapSentences|textFilter"
|
||||
android:maxLines="1" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<include layout="@layout/list_settings_color"/>
|
||||
|
||||
<include layout="@layout/list_settings_icon"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/colorSecondary"
|
||||
android:text="@string/custom_filter_criteria"
|
||||
android:padding="@dimen/keyline_first"
|
||||
style="@style/TextAppearance.AppCompat.Body2" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/task_list_footer_height"
|
||||
android:clipToPadding="false"
|
||||
android:nestedScrollingEnabled="false"/>
|
||||
|
||||
<androidx.compose.ui.platform.ComposeView
|
||||
android:id="@+id/filter_criteria_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/keyline_first"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:text="@string/CFA_button_add"
|
||||
app:icon="@drawable/ic_outline_add_24px"
|
||||
app:borderWidth="0dp"/>
|
||||
|
||||
</RelativeLayout>
|
||||
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/icon_row"
|
||||
style="@style/TagSettingsRow"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<androidx.compose.ui.platform.ComposeView
|
||||
android:id="@+id/icon"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</RelativeLayout>
|
||||
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/delete"
|
||||
android:icon="@drawable/ic_outline_delete_24px"
|
||||
android:title="@string/delete"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
</menu>
|
||||
@ -0,0 +1,36 @@
|
||||
package org.tasks.kmp.org.tasks.compose.settings
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun SettingRow(
|
||||
left: @Composable () -> Unit,
|
||||
center: @Composable () -> Unit,
|
||||
right: @Composable (() -> Unit)? = null,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = modifier) {
|
||||
Box (modifier = Modifier.size(56.dp), contentAlignment = Alignment.Center) {
|
||||
left()
|
||||
}
|
||||
Box (
|
||||
modifier = Modifier
|
||||
.height(56.dp)
|
||||
.weight(1f), contentAlignment = Alignment.CenterStart
|
||||
) {
|
||||
center()
|
||||
}
|
||||
right?.let {
|
||||
Box (modifier = Modifier.size(56.dp), contentAlignment = Alignment.Center) {
|
||||
it.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue