-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
453 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,13 @@ | ||
package ksm | ||
|
||
import ksm.annotation.LibraryConstructor | ||
import ksm.builder.StateControllerBuilder | ||
import ksm.annotation.LibraryApi | ||
import ksm.context.StateContext | ||
import ksm.configuration.plugin.ConfigurationPlugin | ||
import ksm.context.finish | ||
import ksm.finish.once.plugin.FinishOncePlugin | ||
import ksm.lifecycle.plugin.LifecyclePlugin | ||
|
||
@LibraryConstructor | ||
public inline fun pluginStateController( | ||
context: StateContext = StateContext.Empty, | ||
enableConfiguration: Boolean = true, | ||
enableLifecycle: Boolean = true, | ||
enableFinishOnce: Boolean = true, | ||
builder: StateControllerBuilder.() -> Unit = {} | ||
): StateController { | ||
return StateControllerBuilder(context).apply { | ||
if (enableConfiguration) install(ConfigurationPlugin) | ||
if (enableLifecycle) install(LifecyclePlugin) | ||
if (enableFinishOnce) install(FinishOncePlugin) | ||
|
||
builder() | ||
}.context.asStateController() | ||
} | ||
|
||
public interface StateController { | ||
public val context: StateContext | ||
} | ||
|
||
public fun StateController.finish() { | ||
context.finish() | ||
} | ||
|
||
public fun StateContext.asStateController(): StateController { | ||
return object : StateController { | ||
override val context = this@asStateController | ||
public interface Builder { | ||
@LibraryApi | ||
public var context: StateContext | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package ksm.annotation | ||
|
||
@RequiresOptIn( | ||
message = "This api is intended to be used by library developers only, consider not to use it", | ||
level = RequiresOptIn.Level.ERROR | ||
) | ||
public annotation class LibraryApi |
7 changes: 0 additions & 7 deletions
7
core/src/commonMain/kotlin/ksm/annotation/LibraryConstructor.kt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
core/src/commonMain/kotlin/ksm/builder/StateControllerBuilder.kt
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
core/src/commonMain/kotlin/ksm/context/FinishStateContext.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
kotlinx-coroutines/src/commonMain/kotlin/ksm/coroutines/StateController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package ksm.coroutines | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import ksm.StateController | ||
import ksm.plugin.PluginController | ||
|
||
public val StateController.scope: CoroutineScope | ||
public val PluginController.scope: CoroutineScope | ||
get() = context.scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 3 additions & 35 deletions
38
navigation/src/commonMain/kotlin/ksm/navigation/NavigationController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,7 @@ | ||
package ksm.navigation | ||
|
||
import ksm.StateController | ||
import ksm.pluginStateController | ||
import ksm.annotation.LibraryConstructor | ||
import ksm.builder.StateControllerBuilder | ||
import ksm.context.StateContext | ||
import ksm.navigation.state.name.plugin.StateNamePlugin | ||
import ksm.navigation.state.parameters.plugin.StateParametersPlugin | ||
import ksm.navigation.stack.installStackPlugin | ||
import ksm.navigation.state.route.plugin.StateRoutePlugin | ||
import ksm.plugin.PluginController | ||
|
||
@LibraryConstructor | ||
public inline fun navigationStateController( | ||
context: StateContext = StateContext.Empty, | ||
enableConfiguration: Boolean = true, | ||
enableLifecycle: Boolean = true, | ||
enableStateName: Boolean = true, | ||
enableStateParameters: Boolean = true, | ||
enableStack: Boolean = true, | ||
enableFinishOnce: Boolean = true, | ||
enableStateRoutePlugin: Boolean = true, | ||
block: StateControllerBuilder.() -> Unit = {} | ||
): StateController { | ||
return pluginStateController( | ||
context = context, | ||
enableConfiguration = enableConfiguration, | ||
enableLifecycle = enableLifecycle, | ||
enableFinishOnce = enableFinishOnce | ||
) { | ||
// Installing built-in features | ||
installStackPlugin(enableStack) { | ||
if (enableStateName) install(StateNamePlugin) | ||
if (enableStateParameters) install(StateParametersPlugin) | ||
if (enableStateRoutePlugin) install(StateRoutePlugin) | ||
block() | ||
} | ||
} | ||
public interface NavigationController : PluginController { | ||
public interface Builder : PluginController.Builder | ||
} |
Oops, something went wrong.