Skip to content

Commit

Permalink
Merge pull request #34 from ryanmoelter/renovate/kotlinter
Browse files Browse the repository at this point in the history
Update dependency org.jmailen.kotlinter to v3.16.0
  • Loading branch information
ryanmoelter authored Aug 23, 2023
2 parents 2dc238f + de23833 commit d50010e
Show file tree
Hide file tree
Showing 23 changed files with 85 additions and 85 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ testCore = "1.5.0"
lint = "31.1.1"

detekt = "1.18.0"
kotlinter = "3.12.0"
kotlinter = "3.16.0"

[plugins]
kotest = { id = "io.kotest.multiplatform", version.ref = "kotest" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private var adapterMap = emptyMap<Navigable<@Composable () -> Unit>, AdapterLife

public class ActivityLifecycleComposeAdapter(
private val navigable: Navigable<@Composable () -> Unit>,
private val context: Activity
private val context: Activity,
) : DefaultLifecycleObserver {

override fun onStart(owner: ActivityLifecycleOwner) {
Expand Down Expand Up @@ -59,7 +59,7 @@ public fun ComponentActivity.setContentNavigable(navigable: Navigable<@Composabl

private fun Navigable<@Composable () -> Unit>.attachAndAddToStaticMap(
lifecycleAdapter: ActivityLifecycleComposeAdapter,
lifecycle: ActivityLifecycle
lifecycle: ActivityLifecycle,
) {
lifecycle.addObserver(lifecycleAdapter)
adapterMap = adapterMap + (this to (lifecycleAdapter to lifecycle))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public fun Displayable<@Composable () -> Unit>.Content(modifier: Modifier = Modi
@Composable
public fun Displayable(
displayable: Displayable<@Composable () -> Unit>,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
): Unit = displayable.Content(modifier)

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.ryanmoelter.magellanx.compose
import androidx.compose.runtime.Composable

public open class SimpleComposeStep(
private val SimpleContent: @Composable SimpleComposeStep.() -> Unit
private val SimpleContent: @Composable SimpleComposeStep.() -> Unit,
) : ComposeStep() {

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public open class ComposeNavigator :

AnimatedContent(
targetState = currentNavigable,
transitionSpec = currentTransitionSpec.getTransitionForDirection(currentDirection)
transitionSpec = currentTransitionSpec.getTransitionForDirection(currentDirection),
) { navigable ->
DisposableEffect(
key1 = navigable,
Expand All @@ -87,7 +87,7 @@ public open class ComposeNavigator :
} else {
onDispose { }
}
}
},
)
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
navigable?.Content()
Expand All @@ -104,24 +104,24 @@ public open class ComposeNavigator :

public open fun goTo(
navigable: Navigable<@Composable () -> Unit>,
overrideTransitionSpec: MagellanComposeTransition? = null
overrideTransitionSpec: MagellanComposeTransition? = null,
) {
navigate(FORWARD) { backStack ->
backStack + ComposeNavigationEvent(
navigable = navigable,
transitionSpec = overrideTransitionSpec ?: defaultTransition
transitionSpec = overrideTransitionSpec ?: defaultTransition,
)
}
}

public open fun replace(
navigable: Navigable<@Composable () -> Unit>,
overrideTransitionSpec: MagellanComposeTransition? = null
overrideTransitionSpec: MagellanComposeTransition? = null,
) {
navigate(FORWARD) { backStack ->
backStack - backStack.last() + ComposeNavigationEvent(
navigable = navigable,
transitionSpec = overrideTransitionSpec ?: defaultTransition
transitionSpec = overrideTransitionSpec ?: defaultTransition,
)
}
}
Expand Down Expand Up @@ -155,7 +155,7 @@ public open class ComposeNavigator :

public open fun navigate(
direction: Direction,
backStackOperation: (backStack: List<ComposeNavigationEvent>) -> List<ComposeNavigationEvent>
backStackOperation: (backStack: List<ComposeNavigationEvent>) -> List<ComposeNavigationEvent>,
) {
// TODO: Intercept touch events, if necessary
NavigationPropagator._beforeNavigation.tryEmit(Unit)
Expand All @@ -171,7 +171,7 @@ public open class ComposeNavigator :
findBackstackChangesAndUpdateStates(
oldBackStack = oldBackStack.map { it.navigable },
newBackStack = newBackStack.map { it.navigable },
from = fromNavigable
from = fromNavigable,
)
/* Optimistically update toNavigable's limit to smooth out transitions. This will also get set
* by the DisposedEffect in #Content(), but redundancy is fine. fromNavigable's limit will be
Expand All @@ -186,7 +186,7 @@ public open class ComposeNavigator :
private fun findBackstackChangesAndUpdateStates(
oldBackStack: List<Navigable<*>>,
newBackStack: List<Navigable<*>>,
from: Navigable<*>?
from: Navigable<*>?,
) {
val oldNavigables = oldBackStack.toSet()
// Don't remove the last Navigable (from) until it's removed from composition in DisposedEffect
Expand All @@ -208,5 +208,5 @@ public open class ComposeNavigator :

public data class ComposeNavigationEvent(
val navigable: Navigable<@Composable () -> Unit>,
val transitionSpec: MagellanComposeTransition
val transitionSpec: MagellanComposeTransition,
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ package com.ryanmoelter.magellanx.compose.navigation
* Represent the direction in which we are navigating, either forward or backward.
*/
public enum class Direction {
FORWARD, BACKWARD;
FORWARD, BACKWARD
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@ import kotlin.math.roundToInt
public interface MagellanComposeTransition {

@Composable

public fun getTransitionForDirection(
direction: Direction
direction: Direction,
): AnimatedContentTransitionScope<Navigable<@Composable () -> Unit>?>.() -> ContentTransform
}

public class SimpleComposeTransition(
public val transitionSpec: AnimatedContentTransitionScope<Navigable<@Composable () -> Unit>?>.(
Direction
) -> ContentTransform
Direction,
) -> ContentTransform,
) : MagellanComposeTransition {

@Composable
public override fun getTransitionForDirection(
direction: Direction
direction: Direction,
): AnimatedContentTransitionScope<Navigable<@Composable () -> Unit>?>.() -> ContentTransform {
return { transitionSpec(direction) }
}
Expand Down Expand Up @@ -63,15 +62,15 @@ public val showTransition: MagellanComposeTransition = SimpleComposeTransition {
Direction.FORWARD -> {
fadeIn() +
slideInVertically(
initialOffsetY = { fullHeight -> (fullHeight * HEIGHT_OFFSET_FACTOR).roundToInt() }
initialOffsetY = { fullHeight -> (fullHeight * HEIGHT_OFFSET_FACTOR).roundToInt() },
) togetherWith
fadeOut() + scaleOut(targetScale = SCALE_UP_FACTOR)
}

Direction.BACKWARD -> {
fadeIn() + scaleIn(initialScale = SCALE_UP_FACTOR) togetherWith
fadeOut() + slideOutVertically(
targetOffsetY = { fullHeight -> (fullHeight * HEIGHT_OFFSET_FACTOR).roundToInt() }
targetOffsetY = { fullHeight -> (fullHeight * HEIGHT_OFFSET_FACTOR).roundToInt() },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public fun LifecycleOwner.getLifecycleStateSnapshot(): String {
lifecycleAware.getLifecycleStateSnapshotRecursive(
"",
index == children.lastIndex,
currentState
currentState,
)
}
.forEach { stringBuilder.append(it) }
Expand All @@ -28,7 +28,7 @@ public fun LifecycleOwner.getLifecycleStateSnapshot(): String {
private fun LifecycleAware.getLifecycleStateSnapshotRecursive(
indent: String,
isLastChild: Boolean,
parentLifecycleState: LifecycleState
parentLifecycleState: LifecycleState,
): String {
val stringBuilder = StringBuilder()
val lineChar = if (isLastChild) CONNECTOR_L else VERTICAL_T
Expand All @@ -44,7 +44,7 @@ private fun LifecycleAware.getLifecycleStateSnapshotRecursive(
lifecycleAware.getLifecycleStateSnapshotRecursive(
childIndent,
index == children.lastIndex,
currentState
currentState,
)
}
.forEach { stringBuilder.append(it) }
Expand All @@ -60,6 +60,6 @@ private fun LifecycleOwner.describeSelf(indent: String): String =

private fun LifecycleAware.describeSelf(
indent: String,
parentLifecycleState: LifecycleState
parentLifecycleState: LifecycleState,
): String =
"$indent${this::class.java.simpleName} (${parentLifecycleState.name}?)\n"
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public object Magellan {
@JvmOverloads
public fun init(
disableAnimations: Boolean = false,
logDebugInfo: Boolean = false
logDebugInfo: Boolean = false,
) {
this.logDebugInfo = logDebugInfo
this.disableAnimations = disableAnimations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ryanmoelter.magellanx.core.lifecycle

public class CreateAndAttachFieldToLifecycleWhenShownDelegate<Field>(
public val fieldSupplier: () -> Field
public val fieldSupplier: () -> Field,
) : LifecycleAware {

public var field: Field? = null
Expand All @@ -17,9 +17,9 @@ public class CreateAndAttachFieldToLifecycleWhenShownDelegate<Field>(
}

public fun <Field> LifecycleOwner.createAndAttachFieldToLifecycleWhenShown(
fieldSupplier: () -> Field
fieldSupplier: () -> Field,
): AttachFieldToLifecycleDelegate<CreateAndAttachFieldToLifecycleWhenShownDelegate<Field>, Field?> =
attachFieldToLifecycle(
CreateAndAttachFieldToLifecycleWhenShownDelegate(fieldSupplier),
{ it.field }
{ it.field },
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public abstract class LifecycleAwareComponent : LifecycleAware, LifecycleOwner {
if (currentState != LifecycleState.Destroyed) {
throw IllegalStateException(
"Cannot create() from a state that is not Destroyed: " +
"${this::class.java.simpleName} is ${currentState::class.java.simpleName}"
"${this::class.java.simpleName} is ${currentState::class.java.simpleName}",
)
}
lifecycleRegistry.create()
Expand All @@ -27,7 +27,7 @@ public abstract class LifecycleAwareComponent : LifecycleAware, LifecycleOwner {
if (currentState != LifecycleState.Created) {
throw IllegalStateException(
"Cannot show() from a state that is not Created: " +
"${this::class.java.simpleName} is ${currentState::class.java.simpleName}"
"${this::class.java.simpleName} is ${currentState::class.java.simpleName}",
)
}
lifecycleRegistry.show()
Expand All @@ -38,7 +38,7 @@ public abstract class LifecycleAwareComponent : LifecycleAware, LifecycleOwner {
if (currentState != LifecycleState.Shown) {
throw IllegalStateException(
"Cannot resume() from a state that is not Shown: " +
"${this::class.java.simpleName} is ${currentState::class.java.simpleName}"
"${this::class.java.simpleName} is ${currentState::class.java.simpleName}",
)
}
lifecycleRegistry.resume()
Expand All @@ -49,7 +49,7 @@ public abstract class LifecycleAwareComponent : LifecycleAware, LifecycleOwner {
if (currentState != LifecycleState.Resumed) {
throw IllegalStateException(
"Cannot pause() from a state that is not Resumed: " +
"${this::class.java.simpleName} is ${currentState::class.java.simpleName}"
"${this::class.java.simpleName} is ${currentState::class.java.simpleName}",
)
}
onPause()
Expand All @@ -60,7 +60,7 @@ public abstract class LifecycleAwareComponent : LifecycleAware, LifecycleOwner {
if (currentState != LifecycleState.Shown) {
throw IllegalStateException(
"Cannot hide() from a state that is not Shown: " +
"${this::class.java.simpleName} is ${currentState::class.java.simpleName}"
"${this::class.java.simpleName} is ${currentState::class.java.simpleName}",
)
}
onHide()
Expand All @@ -71,7 +71,7 @@ public abstract class LifecycleAwareComponent : LifecycleAware, LifecycleOwner {
if (currentState != LifecycleState.Created) {
throw IllegalStateException(
"Cannot destroy() from a state that is not Created: " +
"${this::class.java.simpleName} is ${currentState::class.java.simpleName}"
"${this::class.java.simpleName} is ${currentState::class.java.simpleName}",
)
}
onDestroy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ import kotlin.reflect.KProperty

public fun <ChildType : LifecycleAware, PropertyType> LifecycleOwner.attachFieldToLifecycle(
lifecycleAware: ChildType,
getPropertyType: (ChildType) -> PropertyType
getPropertyType: (ChildType) -> PropertyType,
): AttachFieldToLifecycleDelegate<ChildType, PropertyType> {
return AttachFieldToLifecycleDelegate(
parent = this,
lifecycleAware = lifecycleAware,
getPropertyType = getPropertyType
getPropertyType = getPropertyType,
)
}

public fun <ChildType : LifecycleAware> LifecycleOwner.attachFieldToLifecycle(
lifecycleAware: ChildType
lifecycleAware: ChildType,
): AttachFieldToLifecycleDelegate<ChildType, ChildType> {
return AttachFieldToLifecycleDelegate(
parent = this,
lifecycleAware = lifecycleAware,
getPropertyType = { lifecycleAware }
getPropertyType = { lifecycleAware },
)
}

public class AttachFieldToLifecycleDelegate<ChildType : LifecycleAware, PropertyType>(
private val parent: LifecycleOwner,
private val lifecycleAware: ChildType,
private val getPropertyType: (ChildType) -> PropertyType
private val getPropertyType: (ChildType) -> PropertyType,
) {

private var hasOverrideValue = false
Expand Down Expand Up @@ -68,14 +68,14 @@ public fun <ChildType : LifecycleAware> LifecycleOwner.attachLateinitFieldToLife
}

public class AttachLateinitFieldToLifecycleDelegate<ChildType : LifecycleAware>(
private val parent: LifecycleOwner
private val parent: LifecycleOwner,
) {

private var lifecycleAware: ChildType? = null

public operator fun getValue(thisRef: Any?, property: KProperty<*>): ChildType {
return lifecycleAware ?: error(
"This lateinit LifecycleAware has not been set yet. (Has your dependency injection run yet?)"
"This lateinit LifecycleAware has not been set yet. (Has your dependency injection run yet?)",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public interface LifecycleOwner {

public fun attachToLifecycle(
lifecycleAware: LifecycleAware,
detachedState: LifecycleState = LifecycleState.Destroyed
detachedState: LifecycleState = LifecycleState.Destroyed,
)

public fun removeFromLifecycle(
lifecycleAware: LifecycleAware,
detachedState: LifecycleState = LifecycleState.Destroyed
detachedState: LifecycleState = LifecycleState.Destroyed,
)
}
Loading

0 comments on commit d50010e

Please sign in to comment.