From 774acc402dd6e9869807f50b8caa6dc617b0688b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 18:29:24 +0000 Subject: [PATCH 1/4] chore(deps): bump com.pinterest.ktlint:ktlint-bom from 1.2.1 to 1.3.1 Bumps [com.pinterest.ktlint:ktlint-bom](https://github.com/pinterest/ktlint) from 1.2.1 to 1.3.1. - [Release notes](https://github.com/pinterest/ktlint/releases) - [Changelog](https://github.com/pinterest/ktlint/blob/master/CHANGELOG.md) - [Commits](https://github.com/pinterest/ktlint/compare/1.2.1...1.3.1) --- updated-dependencies: - dependency-name: com.pinterest.ktlint:ktlint-bom dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ca74ad568..628e1edd2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,7 +20,7 @@ kotlinx-coroutines = "1.9.0" kotlinx-collections-immutable = "0.3.8" kotlinx-serialization-json = "1.7.3" ksp = "2.0.20-1.0.25" -ktlint = "1.2.1" +ktlint = "1.3.1" lint = "31.6.1" minCompileSdk = "24" paparazzi = "1.3.4" From 285ed5d57ba3ec783e73d13d6cbc2f94d970e855 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Tue, 1 Oct 2024 18:45:23 +0000 Subject: [PATCH 2/4] spotlessApply --- .../spark/catalog/icons/IconsScreen.kt | 5 +- .../spark/catalog/themes/SegmentedButton.kt | 9 +-- .../kleinanzeigen/KleinanzeigenTheme.kt | 12 +-- .../themeprovider/leboncoin/LeboncoinTheme.kt | 14 ++-- .../milanuncios/MilanunciosTheme.kt | 12 +-- .../themeprovider/subito/SubitoTheme.kt | 12 +-- .../com/adevinta/spark/catalog/ui/Backdrop.kt | 34 ++++---- .../adevinta/spark/PreviewScreenshotTests.kt | 10 +-- .../spark/placeholder/PlaceholderTest.kt | 4 +- .../spark/components/appbar/TopAppBar.kt | 24 +++--- .../bottomsheet/layout/Swipeable.kt | 78 ++++++++----------- .../bottomsheet/layout/SwipeableV2.kt | 42 +++++----- .../spark/components/card/CardColors.kt | 12 +-- .../spark/components/divider/Divider.kt | 20 ++--- .../drawer/DismissibleNavigationDrawer.kt | 10 +-- .../iconbuttons/IconButtonDefaults.kt | 12 +-- .../toggle/IconToggleButtonIcons.kt | 5 +- .../adevinta/spark/components/image/Image.kt | 12 ++- .../spark/components/menu/DropdownMenu.kt | 6 +- .../placeholder/PlaceholderFoundation.kt | 4 +- .../placeholder/PlaceholderHighlight.kt | 6 +- .../progress/tracker/ProgressStep.kt | 5 +- .../rating/FractionalRectangleShape.kt | 18 ++--- .../spark/components/slider/Slider.kt | 8 +- .../snackbars/SnackbarHostAnimationUtils.kt | 5 +- .../components/surface/ElevationOverlay.kt | 15 ++-- .../spark/components/surface/Surface.kt | 4 +- .../adevinta/spark/components/tab/TabGroup.kt | 9 +-- .../com/adevinta/spark/components/tags/Tag.kt | 5 +- .../textfields/DefaultSparkTextFieldColors.kt | 26 +++---- .../components/textfields/SparkTextField.kt | 5 +- .../textfields/SparkTextFieldMeasurePolicy.kt | 24 ++---- .../spark/components/toggles/Switch.kt | 5 +- .../spark/res/AnnotatedStringResource.kt | 6 +- .../kotlin/com/adevinta/spark/tokens/Color.kt | 21 ++--- .../com/adevinta/spark/tokens/Elevation.kt | 28 +++---- .../kotlin/com/adevinta/spark/tokens/Font.kt | 5 +- .../com/adevinta/spark/tokens/Ripple.kt | 8 +- .../adevinta/spark/tools/modifiers/Layout.kt | 10 +-- .../spark/tools/modifiers/TouchTarget.kt | 4 +- .../spark/tools/modifiers/UsageOverlay.kt | 5 +- 41 files changed, 230 insertions(+), 329 deletions(-) diff --git a/catalog/src/main/kotlin/com/adevinta/spark/catalog/icons/IconsScreen.kt b/catalog/src/main/kotlin/com/adevinta/spark/catalog/icons/IconsScreen.kt index d4cb92233..30fdacdd5 100644 --- a/catalog/src/main/kotlin/com/adevinta/spark/catalog/icons/IconsScreen.kt +++ b/catalog/src/main/kotlin/com/adevinta/spark/catalog/icons/IconsScreen.kt @@ -167,10 +167,7 @@ public fun IconsScreen( } } -private data class NamedIcon( - @DrawableRes val drawableRes: Int, - val name: String, -) +private data class NamedIcon(@DrawableRes val drawableRes: Int, val name: String) private suspend fun getAllIconsRes(context: Context) = withContext(Default) { IconR.drawable::class.java.declaredFields.mapNotNull { field -> diff --git a/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/SegmentedButton.kt b/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/SegmentedButton.kt index 3a39dcd5e..b867d4f10 100644 --- a/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/SegmentedButton.kt +++ b/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/SegmentedButton.kt @@ -185,10 +185,7 @@ internal interface MultiSelectorState { } @Stable -internal class MultiSelectorStateImpl( - options: List, - selectedOption: String, -) : MultiSelectorState { +internal class MultiSelectorStateImpl(options: List, selectedOption: String) : MultiSelectorState { override val selectedIndex: Int get() = _selectedIndex @@ -208,9 +205,7 @@ internal class MultiSelectorStateImpl( return _selectedIndex == other._selectedIndex } - override fun hashCode(): Int { - return _selectedIndex.hashCode() - } + override fun hashCode(): Int = _selectedIndex.hashCode() } @Composable diff --git a/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/kleinanzeigen/KleinanzeigenTheme.kt b/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/kleinanzeigen/KleinanzeigenTheme.kt index d5a6386d3..f1dc44801 100644 --- a/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/kleinanzeigen/KleinanzeigenTheme.kt +++ b/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/kleinanzeigen/KleinanzeigenTheme.kt @@ -30,18 +30,14 @@ import com.adevinta.spark.tokens.SparkTypography public object KleinanzeigenTheme : ThemeProvider { @Composable - override fun colors(useDarkColors: Boolean, isPro: Boolean): SparkColors { - return when { - useDarkColors || isSystemInDarkTheme() -> KleinanzeigenDark - else -> KleinanzeigenLight - } + override fun colors(useDarkColors: Boolean, isPro: Boolean): SparkColors = when { + useDarkColors || isSystemInDarkTheme() -> KleinanzeigenDark + else -> KleinanzeigenLight } @Composable override fun shapes(): SparkShapes = KleinanzeigenShapes @Composable - override fun typography(): SparkTypography { - return KleinanzeigenTypo - } + override fun typography(): SparkTypography = KleinanzeigenTypo } diff --git a/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/leboncoin/LeboncoinTheme.kt b/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/leboncoin/LeboncoinTheme.kt index bbd1b64b8..1b51b15a0 100644 --- a/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/leboncoin/LeboncoinTheme.kt +++ b/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/leboncoin/LeboncoinTheme.kt @@ -31,19 +31,15 @@ import com.adevinta.spark.tokens.lightSparkColors public object LeboncoinTheme : ThemeProvider { @Composable - override fun colors(useDarkColors: Boolean, isPro: Boolean): SparkColors { - return if (useDarkColors) { - if (isPro) LeboncoinColorProDark else darkSparkColors() - } else { - if (isPro) LeboncoinColorProLight else lightSparkColors() - } + override fun colors(useDarkColors: Boolean, isPro: Boolean): SparkColors = if (useDarkColors) { + if (isPro) LeboncoinColorProDark else darkSparkColors() + } else { + if (isPro) LeboncoinColorProLight else lightSparkColors() } @Composable override fun shapes(): SparkShapes = LeboncoinShapes @Composable - override fun typography(): SparkTypography { - return LeboncoinTypo - } + override fun typography(): SparkTypography = LeboncoinTypo } diff --git a/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/milanuncios/MilanunciosTheme.kt b/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/milanuncios/MilanunciosTheme.kt index e2c5bbb43..c53d58bbd 100644 --- a/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/milanuncios/MilanunciosTheme.kt +++ b/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/milanuncios/MilanunciosTheme.kt @@ -31,18 +31,14 @@ import com.adevinta.spark.tokens.sparkTypography public object MilanunciosTheme : ThemeProvider { @Composable - override fun colors(useDarkColors: Boolean, isPro: Boolean): SparkColors { - return when { - useDarkColors || isSystemInDarkTheme() -> MilanunciosDark - else -> MilanunciosLight - } + override fun colors(useDarkColors: Boolean, isPro: Boolean): SparkColors = when { + useDarkColors || isSystemInDarkTheme() -> MilanunciosDark + else -> MilanunciosLight } @Composable override fun shapes(): SparkShapes = MilanunciosShapes @Composable - override fun typography(): SparkTypography { - return sparkTypography() - } + override fun typography(): SparkTypography = sparkTypography() } diff --git a/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/subito/SubitoTheme.kt b/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/subito/SubitoTheme.kt index 6e294f166..5ad67f8d6 100644 --- a/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/subito/SubitoTheme.kt +++ b/catalog/src/main/kotlin/com/adevinta/spark/catalog/themes/themeprovider/subito/SubitoTheme.kt @@ -31,18 +31,14 @@ import com.adevinta.spark.tokens.sparkTypography public object SubitoTheme : ThemeProvider { @Composable - override fun colors(useDarkColors: Boolean, isPro: Boolean): SparkColors { - return when { - useDarkColors || isSystemInDarkTheme() -> SubitoDark - else -> SubitoLight - } + override fun colors(useDarkColors: Boolean, isPro: Boolean): SparkColors = when { + useDarkColors || isSystemInDarkTheme() -> SubitoDark + else -> SubitoLight } @Composable override fun shapes(): SparkShapes = SubitoShapes @Composable - override fun typography(): SparkTypography { - return sparkTypography() - } + override fun typography(): SparkTypography = sparkTypography() } diff --git a/catalog/src/main/kotlin/com/adevinta/spark/catalog/ui/Backdrop.kt b/catalog/src/main/kotlin/com/adevinta/spark/catalog/ui/Backdrop.kt index 6d0f50a3b..969d63e2b 100644 --- a/catalog/src/main/kotlin/com/adevinta/spark/catalog/ui/Backdrop.kt +++ b/catalog/src/main/kotlin/com/adevinta/spark/catalog/ui/Backdrop.kt @@ -185,24 +185,22 @@ public fun rememberBackdropScaffoldState( animationSpec: AnimationSpec = SwipeableDefaults.AnimationSpec, confirmStateChange: (BackdropValue) -> Boolean = { true }, snackbarHostState: SnackbarHostState = remember { SnackbarHostState() }, -): BackdropScaffoldState { - return rememberSaveable( - animationSpec, - confirmStateChange, - snackbarHostState, - saver = BackdropScaffoldState.Saver( - animationSpec = animationSpec, - confirmStateChange = confirmStateChange, - snackbarHostState = snackbarHostState, - ), - ) { - BackdropScaffoldState( - initialValue = initialValue, - animationSpec = animationSpec, - confirmStateChange = confirmStateChange, - snackbarHostState = snackbarHostState, - ) - } +): BackdropScaffoldState = rememberSaveable( + animationSpec, + confirmStateChange, + snackbarHostState, + saver = BackdropScaffoldState.Saver( + animationSpec = animationSpec, + confirmStateChange = confirmStateChange, + snackbarHostState = snackbarHostState, + ), +) { + BackdropScaffoldState( + initialValue = initialValue, + animationSpec = animationSpec, + confirmStateChange = confirmStateChange, + snackbarHostState = snackbarHostState, + ) } /** diff --git a/spark-screenshot-testing/src/test/kotlin/com/adevinta/spark/PreviewScreenshotTests.kt b/spark-screenshot-testing/src/test/kotlin/com/adevinta/spark/PreviewScreenshotTests.kt index 4dc4c2de6..d12e10f89 100644 --- a/spark-screenshot-testing/src/test/kotlin/com/adevinta/spark/PreviewScreenshotTests.kt +++ b/spark-screenshot-testing/src/test/kotlin/com/adevinta/spark/PreviewScreenshotTests.kt @@ -29,9 +29,7 @@ import org.junit.Test internal class PreviewScreenshotTests { - enum class BaseDeviceConfig( - val deviceConfig: DeviceConfig, - ) { + enum class BaseDeviceConfig(val deviceConfig: DeviceConfig) { PIXEL_5( DeviceConfig.PIXEL_5.copy( softButtons = false, @@ -74,6 +72,6 @@ internal class PreviewScreenshotTests { private val partPro = listOf("_part_light", "_pro_light", "_part_dark", "_pro_dark") private val lightDark = listOf("_light", "_dark") -private fun previewFullName(preview: ShowkaseBrowserComponent): String { - return (preview.group + "_" + preview.componentName).replace(" ", "") -} +private fun previewFullName( + preview: ShowkaseBrowserComponent, +): String = (preview.group + "_" + preview.componentName).replace(" ", "") diff --git a/spark/src/androidTest/kotlin/com/adevinta/spark/placeholder/PlaceholderTest.kt b/spark/src/androidTest/kotlin/com/adevinta/spark/placeholder/PlaceholderTest.kt index afac1eb39..a9f731af7 100644 --- a/spark/src/androidTest/kotlin/com/adevinta/spark/placeholder/PlaceholderTest.kt +++ b/spark/src/androidTest/kotlin/com/adevinta/spark/placeholder/PlaceholderTest.kt @@ -321,7 +321,5 @@ internal class Solid( ) : PlaceholderHighlight { override fun alpha(progress: Float): Float = 1f - override fun brush(progress: Float, size: Size): Brush { - return SolidColor(color) - } + override fun brush(progress: Float, size: Size): Brush = SolidColor(color) } diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/appbar/TopAppBar.kt b/spark/src/main/kotlin/com/adevinta/spark/components/appbar/TopAppBar.kt index d58e8d6b0..1a84824bc 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/appbar/TopAppBar.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/appbar/TopAppBar.kt @@ -322,13 +322,11 @@ public class TopAppBarColors internal constructor( * percentage */ @Composable - internal fun containerColor(colorTransitionFraction: Float): Color { - return lerp( - containerColor, - scrolledContainerColor, - FastOutLinearInEasing.transform(colorTransitionFraction), - ) - } + internal fun containerColor(colorTransitionFraction: Float): Color = lerp( + containerColor, + scrolledContainerColor, + FastOutLinearInEasing.transform(colorTransitionFraction), + ) override fun equals(other: Any?): Boolean { if (this === other) return true @@ -950,13 +948,11 @@ private fun TopAppBarLayout( * @param elevationTransitionFraction a `0.0` to `1.0` value that represents a color transition percentage */ @Composable -private fun containerElevation(elevationTransitionFraction: Float): Dp { - return lerp( - ElevationTokens.Level0, - ElevationTokens.Level2, - FastOutLinearInEasing.transform(elevationTransitionFraction), - ) -} +private fun containerElevation(elevationTransitionFraction: Float): Dp = lerp( + ElevationTokens.Level0, + ElevationTokens.Level2, + FastOutLinearInEasing.transform(elevationTransitionFraction), +) // An easing function used to compute the alpha value that is applied to the top title part of a // Medium or Large app bar. diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/Swipeable.kt b/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/Swipeable.kt index 0fface738..2ba004dcc 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/Swipeable.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/Swipeable.kt @@ -483,9 +483,7 @@ public class SwipeProgress( return result } - override fun toString(): String { - return "SwipeProgress(from=$from, to=$to, fraction=$fraction)" - } + override fun toString(): String = "SwipeProgress(from=$from, to=$to, fraction=$fraction)" } /** @@ -504,19 +502,17 @@ public fun rememberSwipeableState( initialValue: T, animationSpec: AnimationSpec = AnimationSpec, confirmStateChange: (newValue: T) -> Boolean = { true }, -): SwipeableState { - return rememberSaveable( - saver = SwipeableState.Saver( - animationSpec = animationSpec, - confirmStateChange = confirmStateChange, - ), - ) { - SwipeableState( - initialValue = initialValue, - animationSpec = animationSpec, - confirmStateChange = confirmStateChange, - ) - } +): SwipeableState = rememberSaveable( + saver = SwipeableState.Saver( + animationSpec = animationSpec, + confirmStateChange = confirmStateChange, + ), +) { + SwipeableState( + initialValue = initialValue, + animationSpec = animationSpec, + confirmStateChange = confirmStateChange, + ) } /** @@ -683,10 +679,13 @@ public interface ThresholdConfig { @InternalSparkApi // This is a copy from Material 3 Swipeable until b/163132293 is closed // Until this is fixed use it when you really cannot use a BottomSheetDialogFragment -public data class FixedThreshold(private val offset: Dp) : ThresholdConfig { - override fun Density.computeThreshold(fromValue: Float, toValue: Float): Float { - return fromValue + offset.toPx() * sign(toValue - fromValue) - } +public data class FixedThreshold( + private val offset: Dp, +) : ThresholdConfig { + override fun Density.computeThreshold( + fromValue: Float, + toValue: Float, + ): Float = fromValue + offset.toPx() * sign(toValue - fromValue) } /** @@ -697,12 +696,9 @@ public data class FixedThreshold(private val offset: Dp) : ThresholdConfig { @Immutable @ExperimentalMaterial3Api internal data class FractionalThreshold( - /*@FloatRange(from = 0.0, to = 1.0)*/ - private val fraction: Float, -) : ThresholdConfig { - override fun Density.computeThreshold(fromValue: Float, toValue: Float): Float { - return lerp(fromValue, toValue, fraction) - } + /*@FloatRange(from = 0.0, to = 1.0)*/private val fraction: Float,) : + ThresholdConfig { + override fun Density.computeThreshold(fromValue: Float, toValue: Float): Float = lerp(fromValue, toValue, fraction) } /** @@ -762,9 +758,7 @@ public class ResistanceConfig( return result } - override fun toString(): String { - return "ResistanceConfig(basis=$basis, factorAtMin=$factorAtMin, factorAtMax=$factorAtMax)" - } + override fun toString() = "ResistanceConfig(basis=$basis, factorAtMin=$factorAtMin, factorAtMax=$factorAtMax)" } /** @@ -841,9 +835,7 @@ private fun computeTarget( } } -private fun Map.getOffset(state: T): Float? { - return entries.firstOrNull { it.value == state }?.key -} +private fun Map.getOffset(state: T): Float? = entries.firstOrNull { it.value == state }?.key /** * Contains useful defaults for [swipeable] and [SwipeableState]. @@ -882,13 +874,11 @@ public object SwipeableDefaults { anchors: Set, factorAtMin: Float = StandardResistanceFactor, factorAtMax: Float = StandardResistanceFactor, - ): ResistanceConfig? { - return if (anchors.size <= 1) { - null - } else { - val basis = anchors.maxOrNull()!! - anchors.minOrNull()!! - ResistanceConfig(basis, factorAtMin, factorAtMax) - } + ): ResistanceConfig? = if (anchors.size <= 1) { + null + } else { + val basis = anchors.maxOrNull()!! - anchors.minOrNull()!! + ResistanceConfig(basis, factorAtMin, factorAtMax) } } @@ -910,12 +900,10 @@ public val SwipeableState.PreUpPostDownNestedScrollConnection: NestedScro consumed: Offset, available: Offset, source: NestedScrollSource, - ): Offset { - return if (source == NestedScrollSource.UserInput) { - performDrag(available.toFloat()).toOffset() - } else { - Offset.Zero - } + ): Offset = if (source == NestedScrollSource.UserInput) { + performDrag(available.toFloat()).toOffset() + } else { + Offset.Zero } override suspend fun onPreFling(available: Velocity): Velocity { diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/SwipeableV2.kt b/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/SwipeableV2.kt index ab208470b..237b3faf3 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/SwipeableV2.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/SwipeableV2.kt @@ -539,26 +539,24 @@ internal fun rememberSwipeableV2State( initialValue: T, animationSpec: AnimationSpec = SwipeableV2Defaults.AnimationSpec, confirmValueChange: (newValue: T) -> Boolean = { true }, -): SwipeableV2State { - return rememberSaveable( - initialValue, - animationSpec, - confirmValueChange, - saver = SwipeableV2State.Saver( - animationSpec = animationSpec, - confirmValueChange = confirmValueChange, - positionalThreshold = SwipeableV2Defaults.PositionalThreshold, - velocityThreshold = SwipeableV2Defaults.VelocityThreshold, - ), - ) { - SwipeableV2State( - initialValue = initialValue, - animationSpec = animationSpec, - confirmValueChange = confirmValueChange, - positionalThreshold = SwipeableV2Defaults.PositionalThreshold, - velocityThreshold = SwipeableV2Defaults.VelocityThreshold, - ) - } +): SwipeableV2State = rememberSaveable( + initialValue, + animationSpec, + confirmValueChange, + saver = SwipeableV2State.Saver( + animationSpec = animationSpec, + confirmValueChange = confirmValueChange, + positionalThreshold = SwipeableV2Defaults.PositionalThreshold, + velocityThreshold = SwipeableV2Defaults.VelocityThreshold, + ), +) { + SwipeableV2State( + initialValue = initialValue, + animationSpec = animationSpec, + confirmValueChange = confirmValueChange, + positionalThreshold = SwipeableV2Defaults.PositionalThreshold, + velocityThreshold = SwipeableV2Defaults.VelocityThreshold, + ) } /** @@ -673,7 +671,9 @@ private class SwipeAnchorsModifier( private val onDensityChanged: (density: Density) -> Unit, private val onSizeChanged: (layoutSize: IntSize) -> Unit, inspectorInfo: InspectorInfo.() -> Unit, -) : LayoutModifier, OnRemeasuredModifier, InspectorValueInfo(inspectorInfo) { +) : InspectorValueInfo(inspectorInfo), + LayoutModifier, + OnRemeasuredModifier { private var lastDensity: Float = -1f private var lastFontScale: Float = -1f diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/card/CardColors.kt b/spark/src/main/kotlin/com/adevinta/spark/components/card/CardColors.kt index ee941a1b5..ae5768253 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/card/CardColors.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/card/CardColors.kt @@ -47,9 +47,9 @@ public class CardColors internal constructor( * @param enabled whether the card is enabled */ @Composable - internal fun containerColor(enabled: Boolean): State { - return rememberUpdatedState(if (enabled) containerColor else disabledContainerColor) - } + internal fun containerColor( + enabled: Boolean, + ): State = rememberUpdatedState(if (enabled) containerColor else disabledContainerColor) /** * Represents the content color for this card, depending on [enabled]. @@ -57,9 +57,9 @@ public class CardColors internal constructor( * @param enabled whether the card is enabled */ @Composable - internal fun contentColor(enabled: Boolean): State { - return rememberUpdatedState(if (enabled) contentColor else disabledContentColor) - } + internal fun contentColor( + enabled: Boolean, + ): State = rememberUpdatedState(if (enabled) contentColor else disabledContentColor) override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/divider/Divider.kt b/spark/src/main/kotlin/com/adevinta/spark/components/divider/Divider.kt index 4180d61f7..f21b627dc 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/divider/Divider.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/divider/Divider.kt @@ -196,23 +196,19 @@ public fun VerticalDivider( private fun calculateLineHeight( dividerPosition: LabelVerticalAlignment, labelVerticalAlignment: LabelVerticalAlignment, -): Dimension { - return if (dividerPosition == labelVerticalAlignment) { - Dimension.value(40.dp) - } else { - Dimension.fillToConstraints.atLeast(40.dp) - } +): Dimension = if (dividerPosition == labelVerticalAlignment) { + Dimension.value(40.dp) +} else { + Dimension.fillToConstraints.atLeast(40.dp) } private fun calculateLineWidth( dividerPosition: LabelHorizontalAlignment, labelVerticalAlignment: LabelHorizontalAlignment, -): Dimension { - return if (dividerPosition == labelVerticalAlignment) { - Dimension.value(40.dp) - } else { - Dimension.fillToConstraints.atLeast(40.dp) - } +): Dimension = if (dividerPosition == labelVerticalAlignment) { + Dimension.value(40.dp) +} else { + Dimension.fillToConstraints.atLeast(40.dp) } @Preview( diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/drawer/DismissibleNavigationDrawer.kt b/spark/src/main/kotlin/com/adevinta/spark/components/drawer/DismissibleNavigationDrawer.kt index f297507ad..870149642 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/drawer/DismissibleNavigationDrawer.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/drawer/DismissibleNavigationDrawer.kt @@ -107,12 +107,10 @@ public fun DismissibleNavigationDrawer( public fun rememberDrawerState( initialValue: DrawerValue, confirmStateChange: (DrawerValue) -> Boolean = { true }, -): DrawerState { - return rememberMaterialDrawerState( - initialValue = initialValue, - confirmStateChange = confirmStateChange, - ) -} +): DrawerState = rememberMaterialDrawerState( + initialValue = initialValue, + confirmStateChange = confirmStateChange, +) @OptIn(ExperimentalMaterial3Api::class) @Preview( diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/iconbuttons/IconButtonDefaults.kt b/spark/src/main/kotlin/com/adevinta/spark/components/iconbuttons/IconButtonDefaults.kt index 55b2e9e9d..3b4d3c415 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/iconbuttons/IconButtonDefaults.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/iconbuttons/IconButtonDefaults.kt @@ -187,9 +187,9 @@ internal class IconButtonColors( * @param enabled whether the icon button is enabled */ @Composable - internal fun containerColor(enabled: Boolean): State { - return rememberUpdatedState(if (enabled) containerColor else disabledContainerColor) - } + internal fun containerColor( + enabled: Boolean, + ): State = rememberUpdatedState(if (enabled) containerColor else disabledContainerColor) /** * Represents the content color for this icon button, depending on [enabled]. @@ -197,9 +197,9 @@ internal class IconButtonColors( * @param enabled whether the icon button is enabled */ @Composable - internal fun contentColor(enabled: Boolean): State { - return rememberUpdatedState(if (enabled) contentColor else disabledContentColor) - } + internal fun contentColor( + enabled: Boolean, + ): State = rememberUpdatedState(if (enabled) contentColor else disabledContentColor) override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/iconbuttons/toggle/IconToggleButtonIcons.kt b/spark/src/main/kotlin/com/adevinta/spark/components/iconbuttons/toggle/IconToggleButtonIcons.kt index c1924a9cc..8fcce6f31 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/iconbuttons/toggle/IconToggleButtonIcons.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/iconbuttons/toggle/IconToggleButtonIcons.kt @@ -27,7 +27,4 @@ import com.adevinta.spark.icons.SparkIcon * @property checked [SparkIcon] to be used for the checked state * @property unchecked [SparkIcon] to be used for the unchecked state */ -public data class IconToggleButtonIcons( - val checked: SparkIcon, - val unchecked: SparkIcon, -) +public data class IconToggleButtonIcons(val checked: SparkIcon, val unchecked: SparkIcon) diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/image/Image.kt b/spark/src/main/kotlin/com/adevinta/spark/components/image/Image.kt index 7fc5ecd43..af51d58d8 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/image/Image.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/image/Image.kt @@ -230,13 +230,11 @@ public sealed class State { public data class Error(override val painter: Painter?) : State() } -private fun AsyncImagePainter.State.asImageState(): State { - return when (this) { - AsyncImagePainter.State.Empty -> State.Empty - is AsyncImagePainter.State.Error -> State.Error(painter) - is AsyncImagePainter.State.Loading -> State.Loading(painter) - is AsyncImagePainter.State.Success -> State.Success(painter) - } +private fun AsyncImagePainter.State.asImageState(): State = when (this) { + AsyncImagePainter.State.Empty -> State.Empty + is AsyncImagePainter.State.Error -> State.Error(painter) + is AsyncImagePainter.State.Loading -> State.Loading(painter) + is AsyncImagePainter.State.Success -> State.Success(painter) } @Preview( diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/menu/DropdownMenu.kt b/spark/src/main/kotlin/com/adevinta/spark/components/menu/DropdownMenu.kt index f2b0e9994..0a7dd9f75 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/menu/DropdownMenu.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/menu/DropdownMenu.kt @@ -228,9 +228,9 @@ public fun DropdownMenuItem( * @param enabled whether the menu item is enabled */ @Composable -private fun MenuItemColors.textColor(enabled: Boolean): State { - return rememberUpdatedState(if (enabled) textColor else disabledTextColor) -} +private fun MenuItemColors.textColor( + enabled: Boolean, +): State = rememberUpdatedState(if (enabled) textColor else disabledTextColor) /** * Represents the leading icon color for a menu item, depending on its [enabled] state. diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/placeholder/PlaceholderFoundation.kt b/spark/src/main/kotlin/com/adevinta/spark/components/placeholder/PlaceholderFoundation.kt index 88d73e6d7..b9091f9d3 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/placeholder/PlaceholderFoundation.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/placeholder/PlaceholderFoundation.kt @@ -337,6 +337,4 @@ public fun PlaceholderDefaults.fadeHighlightColor( public fun PlaceholderDefaults.shimmerHighlightColor( backgroundColor: Color = SparkTheme.colors.surface, alpha: Float = 0.3f, -): Color { - return backgroundColor.copy(alpha = alpha) -} +): Color = backgroundColor.copy(alpha = alpha) diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/placeholder/PlaceholderHighlight.kt b/spark/src/main/kotlin/com/adevinta/spark/components/placeholder/PlaceholderHighlight.kt index 48d870c18..2aef09258 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/placeholder/PlaceholderHighlight.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/placeholder/PlaceholderHighlight.kt @@ -103,10 +103,8 @@ public fun PlaceholderHighlight.Companion.shimmer( progressForMaxAlpha = progressForMaxAlpha, ) -private data class Fade( - private val highlightColor: Color, - override val animationSpec: InfiniteRepeatableSpec, -) : PlaceholderHighlight { +private data class Fade(private val highlightColor: Color, override val animationSpec: InfiniteRepeatableSpec) : + PlaceholderHighlight { private val brush = SolidColor(highlightColor) override fun brush(progress: Float, size: Size): Brush = brush diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/progress/tracker/ProgressStep.kt b/spark/src/main/kotlin/com/adevinta/spark/components/progress/tracker/ProgressStep.kt index b6feed0c7..37010c05c 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/progress/tracker/ProgressStep.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/progress/tracker/ProgressStep.kt @@ -31,7 +31,4 @@ import androidx.compose.ui.text.AnnotatedString * other class inheriting from [CharSequence] will be displayed as plain text. * @property enabled Indicate whether the step is enabled or disabled. Disabled steps won't be interactive. */ -public data class ProgressStep( - public val label: CharSequence, - public val enabled: Boolean, -) +public data class ProgressStep(public val label: CharSequence, public val enabled: Boolean) diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/rating/FractionalRectangleShape.kt b/spark/src/main/kotlin/com/adevinta/spark/components/rating/FractionalRectangleShape.kt index ddc728cf3..472b7839e 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/rating/FractionalRectangleShape.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/rating/FractionalRectangleShape.kt @@ -39,14 +39,12 @@ internal class FractionalRectangleShape( size: Size, layoutDirection: LayoutDirection, density: Density, - ): Outline { - return Outline.Rectangle( - Rect( - left = (startFraction * size.width).coerceAtMost(size.width - 1f), - top = 0f, - right = (endFraction * size.width).coerceAtLeast(1f), - bottom = size.height, - ), - ) - } + ): Outline = Outline.Rectangle( + Rect( + left = (startFraction * size.width).coerceAtMost(size.width - 1f), + top = 0f, + right = (endFraction * size.width).coerceAtLeast(1f), + bottom = size.height, + ), + ) } diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/slider/Slider.kt b/spark/src/main/kotlin/com/adevinta/spark/components/slider/Slider.kt index aa12bca3a..80c7bbdf4 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/slider/Slider.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/slider/Slider.kt @@ -201,8 +201,12 @@ internal fun Handle( } } -private fun stepsToTickFractions(steps: Int): FloatArray { - return if (steps == 0) floatArrayOf() else FloatArray(steps + 2) { it.toFloat() / (steps + 1) } +private fun stepsToTickFractions(steps: Int): FloatArray = if (steps == 0) { + floatArrayOf() +} else { + FloatArray(steps + 2) { + it.toFloat() / (steps + 1) + } } internal val TrackHeight = 4.dp diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/snackbars/SnackbarHostAnimationUtils.kt b/spark/src/main/kotlin/com/adevinta/spark/components/snackbars/SnackbarHostAnimationUtils.kt index 5acda0984..c055299de 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/snackbars/SnackbarHostAnimationUtils.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/snackbars/SnackbarHostAnimationUtils.kt @@ -80,10 +80,7 @@ internal fun SnackbarDuration.toMillis( /** * Represents an animation item with a key and a transition. */ -internal data class FadeInFadeOutAnimationItem( - val key: T, - val transition: FadeInFadeOutTransition, -) +internal data class FadeInFadeOutAnimationItem(val key: T, val transition: FadeInFadeOutTransition) /** * Represents a transition for the FadeInFadeOut animation. diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/surface/ElevationOverlay.kt b/spark/src/main/kotlin/com/adevinta/spark/components/surface/ElevationOverlay.kt index 481dd892e..63a5de398 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/surface/ElevationOverlay.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/surface/ElevationOverlay.kt @@ -74,13 +74,14 @@ public fun interface ElevationOverlay { private object DefaultElevationOverlay : ElevationOverlay { @ReadOnlyComposable @Composable - override fun apply(color: Color, elevation: Dp): Color { - return if (elevation > 0.dp && SparkTheme.colors.surface.luminance() <= 0.5) { - val foregroundColor = calculateForegroundColor(elevation) - foregroundColor.compositeOver(color) - } else { - color - } + override fun apply( + color: Color, + elevation: Dp, + ): Color = if (elevation > 0.dp && SparkTheme.colors.surface.luminance() <= 0.5) { + val foregroundColor = calculateForegroundColor(elevation) + foregroundColor.compositeOver(color) + } else { + color } } diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/surface/Surface.kt b/spark/src/main/kotlin/com/adevinta/spark/components/surface/Surface.kt index 45268bcbc..a54d0fa16 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/surface/Surface.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/surface/Surface.kt @@ -486,6 +486,4 @@ private fun surfaceColorAtElevation( color: Color, elevationOverlay: ElevationOverlay?, absoluteElevation: Dp, -): Color { - return elevationOverlay?.apply(color, absoluteElevation) ?: color -} +): Color = elevationOverlay?.apply(color, absoluteElevation) ?: color diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/tab/TabGroup.kt b/spark/src/main/kotlin/com/adevinta/spark/components/tab/TabGroup.kt index b321e928d..37b129ca4 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/tab/TabGroup.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/tab/TabGroup.kt @@ -208,10 +208,7 @@ private enum class TabSlots { /** * Class holding onto state needed for [ScrollableTabRow] */ -private class ScrollableTabData( - private val scrollState: ScrollState, - private val coroutineScope: CoroutineScope, -) { +private class ScrollableTabData(private val scrollState: ScrollState, private val coroutineScope: CoroutineScope) { private var selectedTab: Int? = null fun onLaidOut( @@ -291,9 +288,7 @@ internal class TabPosition internal constructor(val left: Dp, val width: Dp) { return result } - override fun toString(): String { - return "TabPosition(left=$left, right=$right, width=$width)" - } + override fun toString(): String = "TabPosition(left=$left, right=$right, width=$width)" } /** diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/tags/Tag.kt b/spark/src/main/kotlin/com/adevinta/spark/components/tags/Tag.kt index 4932e8155..732c98b76 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/tags/Tag.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/tags/Tag.kt @@ -186,10 +186,7 @@ internal fun SparkTag( } @Immutable -public data class TagColors( - val backgroundColor: Color, - val contentColor: Color, -) +public data class TagColors(val backgroundColor: Color, val contentColor: Color) public object TagDefaults { internal val MinHeight = 20.dp diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/textfields/DefaultSparkTextFieldColors.kt b/spark/src/main/kotlin/com/adevinta/spark/components/textfields/DefaultSparkTextFieldColors.kt index fbd8d57f8..ec2c0e573 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/textfields/DefaultSparkTextFieldColors.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/textfields/DefaultSparkTextFieldColors.kt @@ -207,12 +207,10 @@ internal data class DefaultSparkTextFieldColors( * Represents the container color for this text field. */ @Composable - internal fun containerColor(enabled: Boolean): State { - return if (enabled) { - animateColorAsState(containerColor, tween(durationMillis = 150), label = "Container Color") - } else { - rememberUpdatedState(disabledContainerColor) - } + internal fun containerColor(enabled: Boolean): State = if (enabled) { + animateColorAsState(containerColor, tween(durationMillis = 150), label = "Container Color") + } else { + rememberUpdatedState(disabledContainerColor) } /** @@ -221,9 +219,9 @@ internal data class DefaultSparkTextFieldColors( * @param enabled whether the text field is enabled */ @Composable - internal fun placeholderColor(enabled: Boolean): State { - return rememberUpdatedState(if (enabled) placeholderColor else disabledPlaceholderColor) - } + internal fun placeholderColor( + enabled: Boolean, + ): State = rememberUpdatedState(if (enabled) placeholderColor else disabledPlaceholderColor) /** * Represents the color used for the label of this text field. @@ -248,9 +246,9 @@ internal data class DefaultSparkTextFieldColors( } @Composable - internal fun textColor(enabled: Boolean): State { - return rememberUpdatedState(if (enabled) textColor else disabledTextColor) - } + internal fun textColor( + enabled: Boolean, + ): State = rememberUpdatedState(if (enabled) textColor else disabledTextColor) @Composable internal fun supportingTextColor( @@ -276,9 +274,7 @@ internal data class DefaultSparkTextFieldColors( * @param state whether the text field's current value is in error, success or alert */ @Composable - internal fun cursorColor(state: TextFieldState?): State { - return rememberUpdatedState(state?.color() ?: cursorColor) - } + internal fun cursorColor(state: TextFieldState?): State = rememberUpdatedState(state?.color() ?: cursorColor) /** * Represents the colors used for text selection in this text field. diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/textfields/SparkTextField.kt b/spark/src/main/kotlin/com/adevinta/spark/components/textfields/SparkTextField.kt index b89613185..8af79f0d6 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/textfields/SparkTextField.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/textfields/SparkTextField.kt @@ -369,10 +369,7 @@ private fun animateBorderStrokeAsState( } @Stable -public data class TextFieldCharacterCounter( - val count: Int, - val maxCharacter: Int, -) +public data class TextFieldCharacterCounter(val count: Int, val maxCharacter: Int) @Composable private fun Label(text: String?, required: Boolean) { diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/textfields/SparkTextFieldMeasurePolicy.kt b/spark/src/main/kotlin/com/adevinta/spark/components/textfields/SparkTextFieldMeasurePolicy.kt index 50bc78783..99fd3579d 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/textfields/SparkTextFieldMeasurePolicy.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/textfields/SparkTextFieldMeasurePolicy.kt @@ -205,37 +205,29 @@ internal class SparkTextFieldMeasurePolicy( override fun IntrinsicMeasureScope.maxIntrinsicHeight( measurables: List, width: Int, - ): Int { - return intrinsicHeight(measurables, width) { intrinsicMeasurable, w -> - intrinsicMeasurable.maxIntrinsicHeight(w) - } + ): Int = intrinsicHeight(measurables, width) { intrinsicMeasurable, w -> + intrinsicMeasurable.maxIntrinsicHeight(w) } override fun IntrinsicMeasureScope.minIntrinsicHeight( measurables: List, width: Int, - ): Int { - return intrinsicHeight(measurables, width) { intrinsicMeasurable, w -> - intrinsicMeasurable.minIntrinsicHeight(w) - } + ): Int = intrinsicHeight(measurables, width) { intrinsicMeasurable, w -> + intrinsicMeasurable.minIntrinsicHeight(w) } override fun IntrinsicMeasureScope.maxIntrinsicWidth( measurables: List, height: Int, - ): Int { - return intrinsicWidth(measurables, height) { intrinsicMeasurable, h -> - intrinsicMeasurable.maxIntrinsicWidth(h) - } + ): Int = intrinsicWidth(measurables, height) { intrinsicMeasurable, h -> + intrinsicMeasurable.maxIntrinsicWidth(h) } override fun IntrinsicMeasureScope.minIntrinsicWidth( measurables: List, height: Int, - ): Int { - return intrinsicWidth(measurables, height) { intrinsicMeasurable, h -> - intrinsicMeasurable.minIntrinsicWidth(h) - } + ): Int = intrinsicWidth(measurables, height) { intrinsicMeasurable, h -> + intrinsicMeasurable.minIntrinsicWidth(h) } private fun IntrinsicMeasureScope.intrinsicWidth( diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/toggles/Switch.kt b/spark/src/main/kotlin/com/adevinta/spark/components/toggles/Switch.kt index de4bdda11..112938aa4 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/toggles/Switch.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/toggles/Switch.kt @@ -187,10 +187,7 @@ public fun SwitchLabelled( * @property checked icon to be used for the thumb in checked state * @property unchecked icon to be used for the thumb in unchecked state */ -public data class SwitchIcons( - val checked: SparkIcon = SparkIcons.Check, - val unchecked: SparkIcon = SparkIcons.Close, -) +public data class SwitchIcons(val checked: SparkIcon = SparkIcons.Check, val unchecked: SparkIcon = SparkIcons.Close) @Preview( group = "Toggles", diff --git a/spark/src/main/kotlin/com/adevinta/spark/res/AnnotatedStringResource.kt b/spark/src/main/kotlin/com/adevinta/spark/res/AnnotatedStringResource.kt index 6c3b65b90..97caed81e 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/res/AnnotatedStringResource.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/res/AnnotatedStringResource.kt @@ -227,9 +227,9 @@ internal fun Resources.getQuantityText(@PluralsRes id: Int, quantity: Int, varar * Convert a [Spanned] to a [String] without the `

` and `

` tags that are added by `toHtml()` which * added a padding at the end of the text. */ -private fun Spanned.toHtmlWithoutParagraphs(): String { - return toHtml().substringAfter("

").substringBeforeLast("

") -} +private fun Spanned.toHtmlWithoutParagraphs(): String = toHtml() + .substringAfter("

") + .substringBeforeLast("

") private fun CharSequence.asAnnotatedString( density: Density, diff --git a/spark/src/main/kotlin/com/adevinta/spark/tokens/Color.kt b/spark/src/main/kotlin/com/adevinta/spark/tokens/Color.kt index 0b3aa1e68..f03052a14 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/tokens/Color.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/tokens/Color.kt @@ -926,10 +926,10 @@ public fun SparkColors.contentColorFor(backgroundColor: Color): Color = when (ba */ @Composable @ReadOnlyComposable -public fun contentColorFor(backgroundColor: Color): Color { - return SparkTheme.colors.contentColorFor(backgroundColor).takeOrElse { - LocalContentColor.current - } +public fun contentColorFor( + backgroundColor: Color, +): Color = SparkTheme.colors.contentColorFor(backgroundColor).takeOrElse { + LocalContentColor.current } /** @@ -1065,12 +1065,13 @@ internal fun SparkColors.updateColorsFrom(other: SparkColors) { * [ColorScheme.surface]. */ @InternalSparkApi -public fun SparkColors.applyTonalElevation(backgroundColor: Color, elevation: Dp): Color { - return if (backgroundColor == surface) { - surfaceColorAtElevation(elevation) - } else { - backgroundColor - } +public fun SparkColors.applyTonalElevation( + backgroundColor: Color, + elevation: Dp, +): Color = if (backgroundColor == surface) { + surfaceColorAtElevation(elevation) +} else { + backgroundColor } /** diff --git a/spark/src/main/kotlin/com/adevinta/spark/tokens/Elevation.kt b/spark/src/main/kotlin/com/adevinta/spark/tokens/Elevation.kt index 82b908713..21f87e1db 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/tokens/Elevation.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/tokens/Elevation.kt @@ -94,14 +94,12 @@ private object ElevationDefaults { * * @param interaction the [Interaction] that is being animated to */ - fun incomingAnimationSpecForInteraction(interaction: Interaction): AnimationSpec? { - return when (interaction) { - is PressInteraction.Press -> DefaultIncomingSpec - is DragInteraction.Start -> DefaultIncomingSpec - is HoverInteraction.Enter -> DefaultIncomingSpec - is FocusInteraction.Focus -> DefaultIncomingSpec - else -> null - } + fun incomingAnimationSpecForInteraction(interaction: Interaction): AnimationSpec? = when (interaction) { + is PressInteraction.Press -> DefaultIncomingSpec + is DragInteraction.Start -> DefaultIncomingSpec + is HoverInteraction.Enter -> DefaultIncomingSpec + is FocusInteraction.Focus -> DefaultIncomingSpec + else -> null } /** @@ -110,14 +108,12 @@ private object ElevationDefaults { * * @param interaction the [Interaction] that is being animated away from */ - fun outgoingAnimationSpecForInteraction(interaction: Interaction): AnimationSpec? { - return when (interaction) { - is PressInteraction.Press -> DefaultOutgoingSpec - is DragInteraction.Start -> DefaultOutgoingSpec - is HoverInteraction.Enter -> HoveredOutgoingSpec - is FocusInteraction.Focus -> DefaultOutgoingSpec - else -> null - } + fun outgoingAnimationSpecForInteraction(interaction: Interaction): AnimationSpec? = when (interaction) { + is PressInteraction.Press -> DefaultOutgoingSpec + is DragInteraction.Start -> DefaultOutgoingSpec + is HoverInteraction.Enter -> HoveredOutgoingSpec + is FocusInteraction.Focus -> DefaultOutgoingSpec + else -> null } } diff --git a/spark/src/main/kotlin/com/adevinta/spark/tokens/Font.kt b/spark/src/main/kotlin/com/adevinta/spark/tokens/Font.kt index 87d5e127d..e43ffcf60 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/tokens/Font.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/tokens/Font.kt @@ -49,10 +49,7 @@ public fun sparkFontFamily( * Utility class to handle the change of font family for the SparkTheme. */ @Immutable -public class SparkFontFamily( - private val useSparkTokensHighlighter: Boolean, - private val fontFamily: FontFamily, -) { +public class SparkFontFamily(private val useSparkTokensHighlighter: Boolean, private val fontFamily: FontFamily) { /** * The [FontFamily] used globally inside the app. */ diff --git a/spark/src/main/kotlin/com/adevinta/spark/tokens/Ripple.kt b/spark/src/main/kotlin/com/adevinta/spark/tokens/Ripple.kt index 94e171fda..e32ee5fdc 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/tokens/Ripple.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/tokens/Ripple.kt @@ -130,9 +130,7 @@ public fun ripple( color: ColorProducer, bounded: Boolean = true, radius: Dp = Dp.Unspecified, -): IndicationNodeFactory { - return RippleNodeFactory(bounded, radius, color) -} +): IndicationNodeFactory = RippleNodeFactory(bounded, radius, color) @Stable private class RippleNodeFactory private constructor( @@ -183,7 +181,9 @@ private class DelegatingThemeAwareRippleNode( private val bounded: Boolean, private val radius: Dp, private val color: ColorProducer, -) : DelegatingNode(), CompositionLocalConsumerModifierNode, ObserverModifierNode { +) : DelegatingNode(), + CompositionLocalConsumerModifierNode, + ObserverModifierNode { private var rippleNode: DelegatableNode? = null override fun onAttach() { diff --git a/spark/src/main/kotlin/com/adevinta/spark/tools/modifiers/Layout.kt b/spark/src/main/kotlin/com/adevinta/spark/tools/modifiers/Layout.kt index d0664fdfc..1abe30873 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/tools/modifiers/Layout.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/tools/modifiers/Layout.kt @@ -49,9 +49,8 @@ import kotlinx.collections.immutable.ImmutableList public fun Modifier.ignoreParentHorizontalPadding(horizontalPadding: Dp): Modifier = this then IgnoreParentHorizontalPaddingModifier(horizontalPadding) -private data class IgnoreParentHorizontalPaddingModifier( - private val horizontalPadding: Dp, -) : ModifierNodeElement() { +private data class IgnoreParentHorizontalPaddingModifier(private val horizontalPadding: Dp) : + ModifierNodeElement() { override fun create() = IgnoreParentHorizontalPaddingModifierNode(horizontalPadding) @@ -65,9 +64,8 @@ private data class IgnoreParentHorizontalPaddingModifier( } } -private class IgnoreParentHorizontalPaddingModifierNode( - var horizontalPadding: Dp, -) : Modifier.Node(), +private class IgnoreParentHorizontalPaddingModifierNode(var horizontalPadding: Dp) : + Modifier.Node(), LayoutModifierNode { override fun MeasureScope.measure( measurable: Measurable, diff --git a/spark/src/main/kotlin/com/adevinta/spark/tools/modifiers/TouchTarget.kt b/spark/src/main/kotlin/com/adevinta/spark/tools/modifiers/TouchTarget.kt index 8cb6cbab2..015f785a7 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/tools/modifiers/TouchTarget.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/tools/modifiers/TouchTarget.kt @@ -64,7 +64,9 @@ private class MinimumTouchTargetModifier : ModifierNodeElement Date: Tue, 1 Oct 2024 19:05:47 +0000 Subject: [PATCH 3/4] fix ktlint formatter > Format was not able to resolve all violations which (theoretically) can be autocorrected in file Swipeable.kt in 3 consecutive runs of format --- .../adevinta/spark/components/bottomsheet/layout/Swipeable.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/Swipeable.kt b/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/Swipeable.kt index 2ba004dcc..f5c57299e 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/Swipeable.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/Swipeable.kt @@ -695,8 +695,7 @@ public data class FixedThreshold( */ @Immutable @ExperimentalMaterial3Api -internal data class FractionalThreshold( - /*@FloatRange(from = 0.0, to = 1.0)*/private val fraction: Float,) : +internal data class FractionalThreshold(/*@FloatRange(from = 0.0, to = 1.0)*/private val fraction: Float) : ThresholdConfig { override fun Density.computeThreshold(fromValue: Float, toValue: Float): Float = lerp(fromValue, toValue, fraction) } From 0ab57f101c948443fa0f392334101174172e1d67 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Tue, 1 Oct 2024 19:10:01 +0000 Subject: [PATCH 4/4] Fixup --- .../adevinta/spark/components/bottomsheet/layout/Swipeable.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/Swipeable.kt b/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/Swipeable.kt index f5c57299e..970ac76b0 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/Swipeable.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/components/bottomsheet/layout/Swipeable.kt @@ -757,7 +757,8 @@ public class ResistanceConfig( return result } - override fun toString() = "ResistanceConfig(basis=$basis, factorAtMin=$factorAtMin, factorAtMax=$factorAtMax)" + override fun toString(): String = + "ResistanceConfig(basis=$basis, factorAtMin=$factorAtMin, factorAtMax=$factorAtMax)" } /**