update ripple for checkbox and title text size

This commit is contained in:
FunkyMuse 2023-07-10 15:06:28 +02:00
parent f9f8b53eb5
commit 97ceaf21d2
3 changed files with 39 additions and 10 deletions

View file

@ -0,0 +1,19 @@
package com.simplemobiletools.calculator.compose.extensions
import androidx.compose.material.ripple.RippleAlpha
import androidx.compose.material.ripple.RippleTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
object NoRippleTheme : RippleTheme {
@Composable
override fun defaultColor(): Color = Color.Unspecified
@Composable
override fun rippleAlpha(): RippleAlpha = RippleAlpha(
draggedAlpha = 0f,
focusedAlpha = 0f,
hoveredAlpha = 0f,
pressedAlpha = 0f,
)
}

View file

@ -1,18 +1,24 @@
package com.simplemobiletools.calculator.compose.settings
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
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.material.ripple.LocalRippleTheme
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
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.unit.dp
import com.simplemobiletools.calculator.compose.extensions.MyDevices
import com.simplemobiletools.calculator.compose.extensions.NoRippleTheme
import com.simplemobiletools.calculator.compose.theme.AppThemeSurface
import com.simplemobiletools.calculator.compose.theme.preferenceSummaryColor
import com.simplemobiletools.calculator.compose.theme.preferenceTitleColor
@ -25,13 +31,16 @@ fun SettingsCheckBoxComponent(
initialValue: Boolean = false,
isPreferenceEnabled: Boolean = true,
onChange: ((Boolean) -> Unit)? = null,
checkboxColor : Color = MaterialTheme.colorScheme.primary
checkboxColor: Color = MaterialTheme.colorScheme.primary
) {
val interactionSource = remember { MutableInteractionSource() }
val indication = LocalIndication.current
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = modifier
.fillMaxWidth()
.clickable(onClick = { onChange?.invoke(!initialValue) })
.clickable(onClick = { onChange?.invoke(!initialValue) }, interactionSource = interactionSource, indication = indication)
.padding(16.dp),
) {
Column(
@ -54,12 +63,15 @@ fun SettingsCheckBoxComponent(
)
}
}
Checkbox(
checked = initialValue,
onCheckedChange = { onChange?.invoke(it) },
enabled = isPreferenceEnabled,
colors = CheckboxDefaults.colors(checkedColor = checkboxColor, checkmarkColor = MaterialTheme.colorScheme.surface)
)
CompositionLocalProvider(LocalRippleTheme provides NoRippleTheme) {
Checkbox(
checked = initialValue,
onCheckedChange = { onChange?.invoke(it) },
enabled = isPreferenceEnabled,
colors = CheckboxDefaults.colors(checkedColor = checkboxColor, checkmarkColor = MaterialTheme.colorScheme.surface),
interactionSource = interactionSource
)
}
}
}

View file

@ -8,7 +8,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.simplemobiletools.calculator.compose.extensions.MyDevices
import com.simplemobiletools.calculator.compose.theme.AppThemeSurface
@ -22,7 +21,6 @@ fun SettingsTitleTextComponent(
Text(
text = text.uppercase(),
modifier = modifier,
fontWeight = FontWeight(300),
color = MaterialTheme.colorScheme.primary,
fontSize = with(LocalDensity.current) {
dimensionResource(id = com.simplemobiletools.commons.R.dimen.normal_text_size).toSp()