diff --git a/myExpenses/src/main/java/org/totschnig/myexpenses/activity/ManageCategories.kt b/myExpenses/src/main/java/org/totschnig/myexpenses/activity/ManageCategories.kt index 7c2f050e57..27994627c1 100644 --- a/myExpenses/src/main/java/org/totschnig/myexpenses/activity/ManageCategories.kt +++ b/myExpenses/src/main/java/org/totschnig/myexpenses/activity/ManageCategories.kt @@ -8,7 +8,6 @@ import android.view.MenuItem import androidx.activity.viewModels import androidx.annotation.PluralsRes import androidx.appcompat.view.ActionMode -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -34,7 +33,6 @@ import androidx.compose.ui.Alignment.Companion.CenterHorizontally import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.rememberNestedScrollInteropConnection -import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.core.view.isVisible @@ -50,9 +48,9 @@ import org.totschnig.myexpenses.compose.MenuEntry.Companion.delete import org.totschnig.myexpenses.compose.MenuEntry.Companion.edit import org.totschnig.myexpenses.compose.MenuEntry.Companion.select import org.totschnig.myexpenses.databinding.ActivityComposeBinding -import org.totschnig.myexpenses.dialog.SetupCategoriesConfirmDialogFragment import org.totschnig.myexpenses.dialog.MessageDialogFragment import org.totschnig.myexpenses.dialog.SelectCategoryMoveTargetDialogFragment +import org.totschnig.myexpenses.dialog.SetupCategoriesConfirmDialogFragment import org.totschnig.myexpenses.injector import org.totschnig.myexpenses.model.ContribFeature import org.totschnig.myexpenses.model.Sort @@ -252,9 +250,7 @@ class ManageCategories : ProtectedFragmentActivity(), Column(modifier = Modifier.fillMaxSize()) { if (typeFlags != null) { TypeConfiguration( - modifier = Modifier - .fillMaxWidth() - .background(color = colorResource(id = R.color.cardBackground)), + modifier = Modifier.align(CenterHorizontally), typeFlags = typeFlags, onCheckedChange = { viewModel.typeFilter = it } ) diff --git a/myExpenses/src/main/java/org/totschnig/myexpenses/compose/tidBits.kt b/myExpenses/src/main/java/org/totschnig/myexpenses/compose/tidBits.kt index bbb6481085..787b308ff7 100644 --- a/myExpenses/src/main/java/org/totschnig/myexpenses/compose/tidBits.kt +++ b/myExpenses/src/main/java/org/totschnig/myexpenses/compose/tidBits.kt @@ -2,20 +2,18 @@ package org.totschnig.myexpenses.compose import androidx.compose.animation.core.animateFloatAsState import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxScope -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ExpandLess -import androidx.compose.material3.Checkbox import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MultiChoiceSegmentedButtonRow +import androidx.compose.material3.SegmentedButton +import androidx.compose.material3.SegmentedButtonDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -27,10 +25,8 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.TextUnit -import androidx.compose.ui.unit.dp import app.futured.donut.compose.DonutProgress import app.futured.donut.compose.data.DonutModel import app.futured.donut.compose.data.DonutSection @@ -38,7 +34,8 @@ import org.totschnig.myexpenses.R import org.totschnig.myexpenses.db2.FLAG_EXPENSE import org.totschnig.myexpenses.db2.FLAG_INCOME import kotlin.experimental.and -import kotlin.experimental.xor +import kotlin.experimental.inv +import kotlin.experimental.or @Composable fun ExpansionHandle( @@ -108,8 +105,6 @@ fun DonutInABox( } } -// Swap this in when upgrading to 1.6 -/*@OptIn(ExperimentalMaterial3Api::class) @Composable fun TypeConfiguration( modifier: Modifier, @@ -132,30 +127,6 @@ fun TypeConfiguration( } } } -}*/ - -@Composable -fun TypeConfiguration( - modifier: Modifier, - typeFlags: Byte, - onCheckedChange: (Byte) -> Unit -) { - Row( - modifier = modifier, - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically - ) { - val options = listOf(R.string.expense to FLAG_EXPENSE, R.string.income to FLAG_INCOME) - options.forEach { type -> - Checkbox( - onCheckedChange = { - onCheckedChange(typeFlags xor type.second) - }, - checked = (typeFlags and type.second) != 0.toByte() - ) - Text(stringResource(id = type.first)) - } - } } @Composable