Skip to content

Commit

Permalink
chore(deps): update plugin org.jmailen.kotlinter to v4 (#90)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
renovate[bot] authored Dec 4, 2023
1 parent f0a82be commit 265d92b
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 26 deletions.
10 changes: 8 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ ij_kotlin_imports_layout=*,^
ij_kotlin_allow_trailing_comma=true
ij_kotlin_allow_trailing_comma_on_call_site=true
ktlint_experimental = enabled
ktlint_standard_filename = disabled
ktlint_standard_function-naming = disabled
ktlint_standard_function-signature = disabled
ktlint_standard_multiline-expression-wrapping = disabled
ktlint_standard_chain-method-continuation = disabled # weird rule
ktlint_standard_discouraged-comment-location = disabled # it disallows comments to multi-line fun args
ktlint_standard_property-naming = disabled
ktlint_standard_function-naming = disabled
ktlint_standard_string-template-indent = disabled # due to multiline-expression-wrapping dependency
ktlint_standard_class-signature = disabled # due to discouraged-comment-location
ktlint_standard_if-else-wrapping = disabled # due to discouraged-comment-location
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
id("org.jetbrains.kotlin.android") version "1.9.20" apply false
id("org.jetbrains.kotlin.plugin.serialization") version "1.9.20" apply false
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2" apply false
id("org.jmailen.kotlinter") version "3.16.0" apply false
id("org.jmailen.kotlinter") version "4.1.0" apply false
id("com.android.application") version "8.2.0" apply false
id("com.vanniktech.maven.publish.base") version "0.25.3" apply false
}
Expand Down
30 changes: 18 additions & 12 deletions core/src/main/kotlin/com/kiwi/navigationcompose/typed/NavBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.serializer

private typealias EnterTransitionFactory =
(@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)

private typealias ExitTransitionFactory =
(@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)

/**
* Add the Composable to the NavGraphBuilder with type-safe arguments and route.
*
Expand All @@ -50,10 +56,10 @@ import kotlinx.serialization.serializer
@MainThread
public inline fun <reified T : Destination> NavGraphBuilder.composable(
deepLinks: List<NavDeepLink> = emptyList(),
noinline enterTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
noinline exitTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
noinline popEnterTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
noinline popExitTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
noinline enterTransition: EnterTransitionFactory? = null,
noinline exitTransition: ExitTransitionFactory? = null,
noinline popEnterTransition: EnterTransitionFactory? = enterTransition,
noinline popExitTransition: ExitTransitionFactory? = exitTransition,
noinline content: @Composable T.(NavBackStackEntry) -> Unit,
) {
composable(
Expand Down Expand Up @@ -185,10 +191,10 @@ public fun <T : Destination> NavGraphBuilder.dialog(
public inline fun <reified T : Destination> NavGraphBuilder.navigation(
startDestination: String,
deepLinks: List<NavDeepLink> = emptyList(),
noinline enterTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
noinline exitTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
noinline popEnterTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
noinline popExitTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
noinline enterTransition: EnterTransitionFactory? = null,
noinline exitTransition: ExitTransitionFactory? = null,
noinline popEnterTransition: EnterTransitionFactory? = enterTransition,
noinline popExitTransition: ExitTransitionFactory? = exitTransition,
noinline builder: NavGraphBuilder.() -> Unit,
) {
navigation(
Expand Down Expand Up @@ -219,10 +225,10 @@ public fun <T : Destination> NavGraphBuilder.navigation(
serializer: KSerializer<T>,
startDestination: String,
deepLinks: List<NavDeepLink> = emptyList(),
enterTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
exitTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
popEnterTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
popExitTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
enterTransition: EnterTransitionFactory? = null,
exitTransition: ExitTransitionFactory? = null,
popEnterTransition: EnterTransitionFactory? = enterTransition,
popExitTransition: ExitTransitionFactory? = exitTransition,
builder: NavGraphBuilder.() -> Unit,
) {
registerDestinationType(kClass, serializer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public fun NavController.navigate(
public inline fun <reified T : Destination> NavOptions.Builder.setPopUpTo(
inclusive: Boolean,
saveState: Boolean = false,
): NavOptions.Builder {
return setPopUpTo(createRoutePattern<T>(), inclusive, saveState)
}
): NavOptions.Builder = setPopUpTo(createRoutePattern<T>(), inclusive, saveState)

/**
* Navigates to the specified [Destination].
Expand All @@ -54,10 +52,8 @@ public inline fun <reified T : Destination> NavOptionsBuilder.popUpTo(
public inline fun <reified T : Destination> NavController.popBackStack(
inclusive: Boolean,
saveState: Boolean = false,
): Boolean {
return popBackStack(
route = createRoutePattern<T>(),
inclusive = inclusive,
saveState = saveState,
)
}
): Boolean = popBackStack(
route = createRoutePattern<T>(),
inclusive = inclusive,
saveState = saveState,
)
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,23 @@ internal class UriDataDecoder(
// natively supported

override fun decodeInt(): Int = data.get(elementName)!!.toInt()

override fun decodeLong(): Long = data.get(elementName)!!.toLong()

override fun decodeFloat(): Float = data.get(elementName)!!.toFloat()

override fun decodeBoolean(): Boolean = data.get(elementName)!!.toBooleanStrict()

override fun decodeString(): String = data.get(elementName)!!

// delegated to other primitives

override fun decodeDouble(): Double = data.get(elementName)!!.toDouble()

override fun decodeByte(): Byte = data.get(elementName)!!.toByte()

override fun decodeShort(): Short = data.get(elementName)!!.toShort()

override fun decodeChar(): Char = data.get(elementName)!![0]

override fun decodeEnum(enumDescriptor: SerialDescriptor): Int = decodeInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ import androidx.lifecycle.SavedStateHandle

internal interface UriDataMap {
fun contains(key: String): Boolean

fun get(key: String): String?
}

internal class BundleDataMap(
private val bundle: Bundle,
) : UriDataMap {
override fun contains(key: String): Boolean = bundle.containsKey(key)

override fun get(key: String): String? = bundle.getString(key)
}

internal class SavedStateDataMap(
private val savedStateHandle: SavedStateHandle,
) : UriDataMap {
override fun contains(key: String): Boolean = savedStateHandle.contains(key)

override fun get(key: String): String? = savedStateHandle[key]
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,25 @@ internal class UrlEncoder(
}

override fun encodeNull() {}

override fun encodeNotNullMark() {}

override fun encodeInt(value: Int) = appendValue(value.toString())

override fun encodeLong(value: Long) = appendValue(value.toString())

override fun encodeFloat(value: Float) = appendValue(value.toString())

override fun encodeBoolean(value: Boolean) = appendValue(if (value) "true" else "false")

override fun encodeString(value: String) = appendValue(value)

override fun encodeDouble(value: Double) = appendValue(value.toString())

override fun encodeByte(value: Byte) = appendValue(value.toString())

override fun encodeShort(value: Short) = appendValue(value.toString())

override fun encodeChar(value: Char) = appendValue(value.toString())

override fun encodeEnum(enumDescriptor: SerialDescriptor, index: Int) = encodeInt(index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ internal class RoutePatternTest {
) : Destination

Assert.assertEquals(
"com.kiwi.navigationcompose.typed.internal.RoutePatternTest.test.TestData/{a}/{c}/{g}/{i}/{k}/{m}/{o}?b={b}&d={d}&e={e}&f={f}&h={h}&j={j}&l={l}&n={n}",
"com.kiwi.navigationcompose.typed.internal.RoutePatternTest.test.TestData/" +
"{a}/{c}/{g}/{i}/{k}/{m}/{o}?b={b}&d={d}&e={e}&f={f}&h={h}&j={j}&l={l}&n={n}",
createRoutePattern<TestData>(),
)
}
Expand Down

0 comments on commit 265d92b

Please sign in to comment.