mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-14 20:39:59 -05:00
Add Compose lint checks
Still need to address most of them though.
This commit is contained in:
parent
402e2c47fb
commit
cb67f1de52
22 changed files with 57 additions and 26 deletions
|
@ -167,6 +167,7 @@ dependencies {
|
||||||
implementation(compose.accompanist.permissions)
|
implementation(compose.accompanist.permissions)
|
||||||
implementation(compose.accompanist.themeadapter)
|
implementation(compose.accompanist.themeadapter)
|
||||||
implementation(compose.accompanist.systemuicontroller)
|
implementation(compose.accompanist.systemuicontroller)
|
||||||
|
lintChecks(compose.lintchecks)
|
||||||
|
|
||||||
implementation(androidx.paging.runtime)
|
implementation(androidx.paging.runtime)
|
||||||
implementation(androidx.paging.compose)
|
implementation(androidx.paging.compose)
|
||||||
|
|
|
@ -75,8 +75,8 @@ fun SetIntervalDialog(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WheelTextPicker(
|
WheelTextPicker(
|
||||||
size = size,
|
|
||||||
items = items,
|
items = items,
|
||||||
|
size = size,
|
||||||
startIndex = selectedInterval,
|
startIndex = selectedInterval,
|
||||||
onSelectionChanged = { selectedInterval = it },
|
onSelectionChanged = { selectedInterval = it },
|
||||||
)
|
)
|
||||||
|
|
|
@ -102,9 +102,9 @@ fun TrackChapterSelector(
|
||||||
title = stringResource(R.string.chapters),
|
title = stringResource(R.string.chapters),
|
||||||
content = {
|
content = {
|
||||||
WheelNumberPicker(
|
WheelNumberPicker(
|
||||||
|
items = range.toList(),
|
||||||
modifier = Modifier.align(Alignment.Center),
|
modifier = Modifier.align(Alignment.Center),
|
||||||
startIndex = selection,
|
startIndex = selection,
|
||||||
items = range.toList(),
|
|
||||||
onSelectionChanged = { onSelectionChange(it) },
|
onSelectionChanged = { onSelectionChange(it) },
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -125,9 +125,9 @@ fun TrackScoreSelector(
|
||||||
title = stringResource(R.string.score),
|
title = stringResource(R.string.score),
|
||||||
content = {
|
content = {
|
||||||
WheelTextPicker(
|
WheelTextPicker(
|
||||||
|
items = selections,
|
||||||
modifier = Modifier.align(Alignment.Center),
|
modifier = Modifier.align(Alignment.Center),
|
||||||
startIndex = selections.indexOf(selection).takeIf { it > 0 } ?: (selections.size / 2),
|
startIndex = selections.indexOf(selection).takeIf { it > 0 } ?: (selections.size / 2),
|
||||||
items = selections,
|
|
||||||
onSelectionChanged = { onSelectionChange(selections[it]) },
|
onSelectionChanged = { onSelectionChange(selections[it]) },
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,6 @@ corektx = "androidx.core:core-ktx:1.12.0"
|
||||||
splashscreen = "androidx.core:core-splashscreen:1.0.1"
|
splashscreen = "androidx.core:core-splashscreen:1.0.1"
|
||||||
recyclerview = "androidx.recyclerview:recyclerview:1.3.2"
|
recyclerview = "androidx.recyclerview:recyclerview:1.3.2"
|
||||||
viewpager = "androidx.viewpager:viewpager:1.1.0-alpha01"
|
viewpager = "androidx.viewpager:viewpager:1.1.0-alpha01"
|
||||||
glance = "androidx.glance:glance-appwidget:1.0.0"
|
|
||||||
profileinstaller = "androidx.profileinstaller:profileinstaller:1.3.1"
|
profileinstaller = "androidx.profileinstaller:profileinstaller:1.3.1"
|
||||||
|
|
||||||
lifecycle-common = { module = "androidx.lifecycle:lifecycle-common", version.ref = "lifecycle_version" }
|
lifecycle-common = { module = "androidx.lifecycle:lifecycle-common", version.ref = "lifecycle_version" }
|
||||||
|
|
|
@ -19,7 +19,11 @@ material-icons = { module = "androidx.compose.material:material-icons-extended"
|
||||||
# Some components aren't available in Material3
|
# Some components aren't available in Material3
|
||||||
material-core = { module = "androidx.compose.material:material" }
|
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-webview = { module = "com.google.accompanist:accompanist-webview", version.ref = "accompanist" }
|
||||||
accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", 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-themeadapter = { module = "com.google.accompanist:accompanist-themeadapter-material3", version.ref = "accompanist" }
|
||||||
accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", 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" }
|
|
@ -35,6 +35,7 @@ dependencies {
|
||||||
debugImplementation(compose.ui.tooling)
|
debugImplementation(compose.ui.tooling)
|
||||||
implementation(compose.ui.tooling.preview)
|
implementation(compose.ui.tooling.preview)
|
||||||
implementation(compose.ui.util)
|
implementation(compose.ui.util)
|
||||||
|
lintChecks(compose.lintchecks)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|
|
@ -14,10 +14,10 @@ import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ActionButton(
|
fun ActionButton(
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
title: String,
|
title: String,
|
||||||
icon: ImageVector,
|
icon: ImageVector,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
TextButton(
|
TextButton(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
|
|
|
@ -56,11 +56,11 @@ private val sheetAnimationSpec = tween<Float>(durationMillis = 350)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AdaptiveSheet(
|
fun AdaptiveSheet(
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
isTabletUi: Boolean,
|
isTabletUi: Boolean,
|
||||||
tonalElevation: Dp,
|
tonalElevation: Dp,
|
||||||
enableSwipeDismiss: Boolean,
|
enableSwipeDismiss: Boolean,
|
||||||
onDismissRequest: () -> Unit,
|
onDismissRequest: () -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
content: @Composable () -> Unit,
|
content: @Composable () -> Unit,
|
||||||
) {
|
) {
|
||||||
val density = LocalDensity.current
|
val density = LocalDensity.current
|
||||||
|
|
|
@ -23,7 +23,10 @@ import androidx.compose.ui.unit.dp
|
||||||
import tachiyomi.presentation.core.theme.header
|
import tachiyomi.presentation.core.theme.header
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CollapsibleBox(heading: String, content: @Composable () -> Unit) {
|
fun CollapsibleBox(
|
||||||
|
heading: String,
|
||||||
|
content: @Composable () -> Unit,
|
||||||
|
) {
|
||||||
var expanded by remember { mutableStateOf(false) }
|
var expanded by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
|
|
@ -17,10 +17,10 @@ import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LabeledCheckbox(
|
fun LabeledCheckbox(
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
label: String,
|
label: String,
|
||||||
checked: Boolean,
|
checked: Boolean,
|
||||||
onCheckedChange: (Boolean) -> Unit,
|
onCheckedChange: (Boolean) -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
|
|
|
@ -11,7 +11,12 @@ import androidx.compose.ui.platform.LocalUriHandler
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
@Composable
|
@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
|
val uriHandler = LocalUriHandler.current
|
||||||
IconButton(
|
IconButton(
|
||||||
modifier = modifier.padding(4.dp),
|
modifier = modifier.padding(4.dp),
|
||||||
|
|
|
@ -9,7 +9,10 @@ import androidx.compose.ui.text.font.FontWeight
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
import tachiyomi.presentation.core.components.material.padding
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ListGroupHeader(modifier: Modifier = Modifier, text: String) {
|
fun ListGroupHeader(
|
||||||
|
text: String,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = text,
|
text = text,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
|
|
|
@ -156,11 +156,11 @@ fun RadioItem(label: String, selected: Boolean, onClick: () -> Unit) {
|
||||||
@Composable
|
@Composable
|
||||||
fun SliderItem(
|
fun SliderItem(
|
||||||
label: String,
|
label: String,
|
||||||
min: Int = 0,
|
|
||||||
max: Int,
|
|
||||||
value: Int,
|
value: Int,
|
||||||
valueText: String,
|
valueText: String,
|
||||||
onChange: (Int) -> Unit,
|
onChange: (Int) -> Unit,
|
||||||
|
max: Int,
|
||||||
|
min: Int = 0,
|
||||||
) {
|
) {
|
||||||
val haptic = LocalHapticFeedback.current
|
val haptic = LocalHapticFeedback.current
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,10 @@ import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun TwoPanelBox(
|
fun TwoPanelBox(
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
contentWindowInsets: WindowInsets = WindowInsets(0),
|
|
||||||
startContent: @Composable BoxScope.() -> Unit,
|
startContent: @Composable BoxScope.() -> Unit,
|
||||||
endContent: @Composable BoxScope.() -> Unit,
|
endContent: @Composable BoxScope.() -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
contentWindowInsets: WindowInsets = WindowInsets(0),
|
||||||
) {
|
) {
|
||||||
val direction = LocalLayoutDirection.current
|
val direction = LocalLayoutDirection.current
|
||||||
val padding = contentWindowInsets.asPaddingValues()
|
val padding = contentWindowInsets.asPaddingValues()
|
||||||
|
|
|
@ -54,9 +54,9 @@ import kotlin.math.absoluteValue
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun WheelNumberPicker(
|
fun WheelNumberPicker(
|
||||||
|
items: List<Number>,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
startIndex: Int = 0,
|
startIndex: Int = 0,
|
||||||
items: List<Number>,
|
|
||||||
size: DpSize = DpSize(128.dp, 128.dp),
|
size: DpSize = DpSize(128.dp, 128.dp),
|
||||||
onSelectionChanged: (index: Int) -> Unit = {},
|
onSelectionChanged: (index: Int) -> Unit = {},
|
||||||
backgroundContent: (@Composable (size: DpSize) -> Unit)? = {
|
backgroundContent: (@Composable (size: DpSize) -> Unit)? = {
|
||||||
|
@ -78,9 +78,9 @@ fun WheelNumberPicker(
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun WheelTextPicker(
|
fun WheelTextPicker(
|
||||||
|
items: List<String>,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
startIndex: Int = 0,
|
startIndex: Int = 0,
|
||||||
items: List<String>,
|
|
||||||
size: DpSize = DpSize(128.dp, 128.dp),
|
size: DpSize = DpSize(128.dp, 128.dp),
|
||||||
onSelectionChanged: (index: Int) -> Unit = {},
|
onSelectionChanged: (index: Int) -> Unit = {},
|
||||||
backgroundContent: (@Composable (size: DpSize) -> Unit)? = {
|
backgroundContent: (@Composable (size: DpSize) -> Unit)? = {
|
||||||
|
@ -101,9 +101,9 @@ fun WheelTextPicker(
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun <T> WheelPicker(
|
private fun <T> WheelPicker(
|
||||||
|
items: List<T>,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
startIndex: Int = 0,
|
startIndex: Int = 0,
|
||||||
items: List<T>,
|
|
||||||
size: DpSize = DpSize(128.dp, 128.dp),
|
size: DpSize = DpSize(128.dp, 128.dp),
|
||||||
onSelectionChanged: (index: Int) -> Unit = {},
|
onSelectionChanged: (index: Int) -> Unit = {},
|
||||||
manualInputType: KeyboardType? = null,
|
manualInputType: KeyboardType? = null,
|
||||||
|
|
|
@ -46,7 +46,10 @@ fun ExtendedFloatingActionButton(
|
||||||
contentColor: Color = contentColorFor(containerColor),
|
contentColor: Color = contentColorFor(containerColor),
|
||||||
elevation: FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation(),
|
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(
|
FloatingActionButton(
|
||||||
modifier = modifier.sizeIn(minWidth = minWidth),
|
modifier = modifier.sizeIn(minWidth = minWidth),
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
|
@ -56,8 +59,14 @@ fun ExtendedFloatingActionButton(
|
||||||
contentColor = contentColor,
|
contentColor = contentColor,
|
||||||
elevation = elevation,
|
elevation = elevation,
|
||||||
) {
|
) {
|
||||||
val startPadding by animateDpAsState(if (expanded) ExtendedFabIconSize / 2 else 0.dp)
|
val startPadding by animateDpAsState(
|
||||||
val endPadding by animateDpAsState(if (expanded) ExtendedFabTextPadding else 0.dp)
|
targetValue = if (expanded) ExtendedFabIconSize / 2 else 0.dp,
|
||||||
|
label = "startPadding",
|
||||||
|
)
|
||||||
|
val endPadding by animateDpAsState(
|
||||||
|
targetValue = if (expanded) ExtendedFabTextPadding else 0.dp,
|
||||||
|
label = "endPadding",
|
||||||
|
)
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.padding(start = startPadding, end = endPadding),
|
modifier = Modifier.padding(start = startPadding, end = endPadding),
|
||||||
|
|
|
@ -20,9 +20,9 @@ import androidx.compose.ui.unit.dp
|
||||||
fun IconToggleButton(
|
fun IconToggleButton(
|
||||||
checked: Boolean,
|
checked: Boolean,
|
||||||
onCheckedChange: (Boolean) -> Unit,
|
onCheckedChange: (Boolean) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
imageVector: ImageVector,
|
imageVector: ImageVector,
|
||||||
title: String,
|
title: String,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
FilledIconToggleButton(
|
FilledIconToggleButton(
|
||||||
checked = checked,
|
checked = checked,
|
||||||
|
|
|
@ -36,10 +36,12 @@ private fun Modifier.tabIndicatorOffset(
|
||||||
val currentTabWidth by animateDpAsState(
|
val currentTabWidth by animateDpAsState(
|
||||||
targetValue = currentTabPosition.width,
|
targetValue = currentTabPosition.width,
|
||||||
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
|
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
|
||||||
|
label = "currentTabWidth",
|
||||||
)
|
)
|
||||||
val offset by animateDpAsState(
|
val offset by animateDpAsState(
|
||||||
targetValue = currentTabPosition.left + (currentTabWidth * currentPageOffsetFraction),
|
targetValue = currentTabPosition.left + (currentTabWidth * currentPageOffsetFraction),
|
||||||
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
|
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
|
||||||
|
label = "offset",
|
||||||
)
|
)
|
||||||
Modifier
|
Modifier
|
||||||
.offset { IntOffset(x = offset.roundToPx(), y = 0) }
|
.offset { IntOffset(x = offset.roundToPx(), y = 0) }
|
||||||
|
|
|
@ -25,7 +25,8 @@ dependencies {
|
||||||
implementation(project(":domain"))
|
implementation(project(":domain"))
|
||||||
implementation(project(":presentation-core"))
|
implementation(project(":presentation-core"))
|
||||||
|
|
||||||
implementation(androidx.glance)
|
implementation(compose.glance)
|
||||||
|
lintChecks(compose.lintchecks)
|
||||||
|
|
||||||
implementation(platform(libs.coil.bom))
|
implementation(platform(libs.coil.bom))
|
||||||
implementation(libs.coil.core)
|
implementation(libs.coil.core)
|
||||||
|
|
|
@ -95,10 +95,10 @@ abstract class BaseUpdatesGridGlanceWidget(
|
||||||
val data by flow.collectAsState(initial = null)
|
val data by flow.collectAsState(initial = null)
|
||||||
UpdatesWidget(
|
UpdatesWidget(
|
||||||
data = data,
|
data = data,
|
||||||
modifier = containerModifier,
|
|
||||||
contentColor = foreground,
|
contentColor = foreground,
|
||||||
topPadding = topPadding,
|
topPadding = topPadding,
|
||||||
bottomPadding = bottomPadding,
|
bottomPadding = bottomPadding,
|
||||||
|
modifier = containerModifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,10 @@ val CoverWidth = 58.dp
|
||||||
val CoverHeight = 87.dp
|
val CoverHeight = 87.dp
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun UpdatesMangaCover(modifier: GlanceModifier = GlanceModifier, cover: Bitmap?) {
|
fun UpdatesMangaCover(
|
||||||
|
cover: Bitmap?,
|
||||||
|
modifier: GlanceModifier = GlanceModifier,
|
||||||
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.size(width = CoverWidth, height = CoverHeight)
|
.size(width = CoverWidth, height = CoverHeight)
|
||||||
|
|
|
@ -29,10 +29,10 @@ import tachiyomi.presentation.widget.util.stringResource
|
||||||
@Composable
|
@Composable
|
||||||
fun UpdatesWidget(
|
fun UpdatesWidget(
|
||||||
data: List<Pair<Long, Bitmap?>>?,
|
data: List<Pair<Long, Bitmap?>>?,
|
||||||
modifier: GlanceModifier = GlanceModifier,
|
|
||||||
contentColor: ColorProvider,
|
contentColor: ColorProvider,
|
||||||
topPadding: Dp,
|
topPadding: Dp,
|
||||||
bottomPadding: Dp,
|
bottomPadding: Dp,
|
||||||
|
modifier: GlanceModifier = GlanceModifier,
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
contentAlignment = Alignment.Center,
|
contentAlignment = Alignment.Center,
|
||||||
|
@ -83,8 +83,8 @@ fun UpdatesWidget(
|
||||||
addCategory(mangaId.toString())
|
addCategory(mangaId.toString())
|
||||||
}
|
}
|
||||||
UpdatesMangaCover(
|
UpdatesMangaCover(
|
||||||
modifier = GlanceModifier.clickable(actionStartActivity(intent)),
|
|
||||||
cover = cover,
|
cover = cover,
|
||||||
|
modifier = GlanceModifier.clickable(actionStartActivity(intent)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue