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

@ -167,6 +167,7 @@ dependencies {
implementation(compose.accompanist.permissions)
implementation(compose.accompanist.themeadapter)
implementation(compose.accompanist.systemuicontroller)
lintChecks(compose.lintchecks)
implementation(androidx.paging.runtime)
implementation(androidx.paging.compose)

View File

@ -75,8 +75,8 @@ fun SetIntervalDialog(
}
}
WheelTextPicker(
size = size,
items = items,
size = size,
startIndex = selectedInterval,
onSelectionChanged = { selectedInterval = it },
)

View File

@ -102,9 +102,9 @@ fun TrackChapterSelector(
title = stringResource(R.string.chapters),
content = {
WheelNumberPicker(
items = range.toList(),
modifier = Modifier.align(Alignment.Center),
startIndex = selection,
items = range.toList(),
onSelectionChanged = { onSelectionChange(it) },
)
},
@ -125,9 +125,9 @@ fun TrackScoreSelector(
title = stringResource(R.string.score),
content = {
WheelTextPicker(
items = selections,
modifier = Modifier.align(Alignment.Center),
startIndex = selections.indexOf(selection).takeIf { it > 0 } ?: (selections.size / 2),
items = selections,
onSelectionChanged = { onSelectionChange(selections[it]) },
)
},

View File

@ -14,7 +14,6 @@ corektx = "androidx.core:core-ktx:1.12.0"
splashscreen = "androidx.core:core-splashscreen:1.0.1"
recyclerview = "androidx.recyclerview:recyclerview:1.3.2"
viewpager = "androidx.viewpager:viewpager:1.1.0-alpha01"
glance = "androidx.glance:glance-appwidget:1.0.0"
profileinstaller = "androidx.profileinstaller:profileinstaller:1.3.1"
lifecycle-common = { module = "androidx.lifecycle:lifecycle-common", version.ref = "lifecycle_version" }

View File

@ -19,7 +19,11 @@ material-icons = { module = "androidx.compose.material:material-icons-extended"
# Some components aren't available in Material3
material-core = { module = "androidx.compose.material:material" }
glance = "androidx.glance:glance-appwidget:1.0.0"
accompanist-webview = { module = "com.google.accompanist:accompanist-webview", version.ref = "accompanist" }
accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist" }
accompanist-themeadapter = { module = "com.google.accompanist:accompanist-themeadapter-material3", version.ref = "accompanist" }
accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" }
lintchecks = { module = "com.slack.lint.compose:compose-lint-checks", version = "1.2.0" }

View File

@ -35,6 +35,7 @@ dependencies {
debugImplementation(compose.ui.tooling)
implementation(compose.ui.tooling.preview)
implementation(compose.ui.util)
lintChecks(compose.lintchecks)
}
tasks {

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) }

View File

@ -25,7 +25,8 @@ dependencies {
implementation(project(":domain"))
implementation(project(":presentation-core"))
implementation(androidx.glance)
implementation(compose.glance)
lintChecks(compose.lintchecks)
implementation(platform(libs.coil.bom))
implementation(libs.coil.core)

View File

@ -95,10 +95,10 @@ abstract class BaseUpdatesGridGlanceWidget(
val data by flow.collectAsState(initial = null)
UpdatesWidget(
data = data,
modifier = containerModifier,
contentColor = foreground,
topPadding = topPadding,
bottomPadding = bottomPadding,
modifier = containerModifier,
)
}
}

View File

@ -17,7 +17,10 @@ val CoverWidth = 58.dp
val CoverHeight = 87.dp
@Composable
fun UpdatesMangaCover(modifier: GlanceModifier = GlanceModifier, cover: Bitmap?) {
fun UpdatesMangaCover(
cover: Bitmap?,
modifier: GlanceModifier = GlanceModifier,
) {
Box(
modifier = modifier
.size(width = CoverWidth, height = CoverHeight)

View File

@ -29,10 +29,10 @@ import tachiyomi.presentation.widget.util.stringResource
@Composable
fun UpdatesWidget(
data: List<Pair<Long, Bitmap?>>?,
modifier: GlanceModifier = GlanceModifier,
contentColor: ColorProvider,
topPadding: Dp,
bottomPadding: Dp,
modifier: GlanceModifier = GlanceModifier,
) {
Box(
contentAlignment = Alignment.Center,
@ -83,8 +83,8 @@ fun UpdatesWidget(
addCategory(mangaId.toString())
}
UpdatesMangaCover(
modifier = GlanceModifier.clickable(actionStartActivity(intent)),
cover = cover,
modifier = GlanceModifier.clickable(actionStartActivity(intent)),
)
}
}