Add Compose lint checks

Still need to address most of them though.
This commit is contained in:
arkon
2023-11-11 18:13:44 -05:00
parent 402e2c47fb
commit cb67f1de52
22 changed files with 57 additions and 26 deletions

View File

@ -14,10 +14,10 @@ import androidx.compose.ui.unit.dp
@Composable
fun ActionButton(
modifier: Modifier = Modifier,
title: String,
icon: ImageVector,
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
TextButton(
modifier = modifier,

View File

@ -56,11 +56,11 @@ private val sheetAnimationSpec = tween<Float>(durationMillis = 350)
@Composable
fun AdaptiveSheet(
modifier: Modifier = Modifier,
isTabletUi: Boolean,
tonalElevation: Dp,
enableSwipeDismiss: Boolean,
onDismissRequest: () -> Unit,
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
) {
val density = LocalDensity.current

View File

@ -23,7 +23,10 @@ import androidx.compose.ui.unit.dp
import tachiyomi.presentation.core.theme.header
@Composable
fun CollapsibleBox(heading: String, content: @Composable () -> Unit) {
fun CollapsibleBox(
heading: String,
content: @Composable () -> Unit,
) {
var expanded by remember { mutableStateOf(false) }
Column {

View File

@ -17,10 +17,10 @@ import androidx.compose.ui.unit.dp
@Composable
fun LabeledCheckbox(
modifier: Modifier = Modifier,
label: String,
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
) {
Row(

View File

@ -11,7 +11,12 @@ import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.unit.dp
@Composable
fun LinkIcon(modifier: Modifier = Modifier, label: String, icon: ImageVector, url: String) {
fun LinkIcon(
label: String,
icon: ImageVector,
url: String,
modifier: Modifier = Modifier,
) {
val uriHandler = LocalUriHandler.current
IconButton(
modifier = modifier.padding(4.dp),

View File

@ -9,7 +9,10 @@ import androidx.compose.ui.text.font.FontWeight
import tachiyomi.presentation.core.components.material.padding
@Composable
fun ListGroupHeader(modifier: Modifier = Modifier, text: String) {
fun ListGroupHeader(
text: String,
modifier: Modifier = Modifier,
) {
Text(
text = text,
modifier = modifier

View File

@ -156,11 +156,11 @@ fun RadioItem(label: String, selected: Boolean, onClick: () -> Unit) {
@Composable
fun SliderItem(
label: String,
min: Int = 0,
max: Int,
value: Int,
valueText: String,
onChange: (Int) -> Unit,
max: Int,
min: Int = 0,
) {
val haptic = LocalHapticFeedback.current

View File

@ -17,10 +17,10 @@ import androidx.compose.ui.unit.dp
@Composable
fun TwoPanelBox(
modifier: Modifier = Modifier,
contentWindowInsets: WindowInsets = WindowInsets(0),
startContent: @Composable BoxScope.() -> Unit,
endContent: @Composable BoxScope.() -> Unit,
modifier: Modifier = Modifier,
contentWindowInsets: WindowInsets = WindowInsets(0),
) {
val direction = LocalLayoutDirection.current
val padding = contentWindowInsets.asPaddingValues()

View File

@ -54,9 +54,9 @@ import kotlin.math.absoluteValue
@Composable
fun WheelNumberPicker(
items: List<Number>,
modifier: Modifier = Modifier,
startIndex: Int = 0,
items: List<Number>,
size: DpSize = DpSize(128.dp, 128.dp),
onSelectionChanged: (index: Int) -> Unit = {},
backgroundContent: (@Composable (size: DpSize) -> Unit)? = {
@ -78,9 +78,9 @@ fun WheelNumberPicker(
@Composable
fun WheelTextPicker(
items: List<String>,
modifier: Modifier = Modifier,
startIndex: Int = 0,
items: List<String>,
size: DpSize = DpSize(128.dp, 128.dp),
onSelectionChanged: (index: Int) -> Unit = {},
backgroundContent: (@Composable (size: DpSize) -> Unit)? = {
@ -101,9 +101,9 @@ fun WheelTextPicker(
@Composable
private fun <T> WheelPicker(
items: List<T>,
modifier: Modifier = Modifier,
startIndex: Int = 0,
items: List<T>,
size: DpSize = DpSize(128.dp, 128.dp),
onSelectionChanged: (index: Int) -> Unit = {},
manualInputType: KeyboardType? = null,

View File

@ -46,7 +46,10 @@ fun ExtendedFloatingActionButton(
contentColor: Color = contentColorFor(containerColor),
elevation: FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation(),
) {
val minWidth by animateDpAsState(if (expanded) ExtendedFabMinimumWidth else FabContainerWidth)
val minWidth by animateDpAsState(
targetValue = if (expanded) ExtendedFabMinimumWidth else FabContainerWidth,
label = "minWidth",
)
FloatingActionButton(
modifier = modifier.sizeIn(minWidth = minWidth),
onClick = onClick,
@ -56,8 +59,14 @@ fun ExtendedFloatingActionButton(
contentColor = contentColor,
elevation = elevation,
) {
val startPadding by animateDpAsState(if (expanded) ExtendedFabIconSize / 2 else 0.dp)
val endPadding by animateDpAsState(if (expanded) ExtendedFabTextPadding else 0.dp)
val startPadding by animateDpAsState(
targetValue = if (expanded) ExtendedFabIconSize / 2 else 0.dp,
label = "startPadding",
)
val endPadding by animateDpAsState(
targetValue = if (expanded) ExtendedFabTextPadding else 0.dp,
label = "endPadding",
)
Row(
modifier = Modifier.padding(start = startPadding, end = endPadding),

View File

@ -20,9 +20,9 @@ import androidx.compose.ui.unit.dp
fun IconToggleButton(
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
modifier: Modifier = Modifier,
imageVector: ImageVector,
title: String,
modifier: Modifier = Modifier,
) {
FilledIconToggleButton(
checked = checked,

View File

@ -36,10 +36,12 @@ private fun Modifier.tabIndicatorOffset(
val currentTabWidth by animateDpAsState(
targetValue = currentTabPosition.width,
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
label = "currentTabWidth",
)
val offset by animateDpAsState(
targetValue = currentTabPosition.left + (currentTabWidth * currentPageOffsetFraction),
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
label = "offset",
)
Modifier
.offset { IntOffset(x = offset.roundToPx(), y = 0) }