diff --git a/AGENTS.md b/AGENTS.md index a028d172..a324c657 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -34,7 +34,7 @@ Important top-level areas: Core framework module families: - `scope`, `di-common` -- `presenter`, `presenter-molecule` +- `presenter`, `presenter-compose` - `renderer`, `renderer-android-view`, `renderer-compose-multiplatform` - `robot`, `robot-compose-multiplatform`, `robot-internal` - `kotlin-inject`, `kotlin-inject-extensions` @@ -60,7 +60,7 @@ Do not introduce a dependency on an `:impl` module outside these application ass The framework’s architectural flow is: 1. `Scope` and DI assemble objects for a lifecycle boundary. -2. `MoleculePresenter` implementations produce models. +2. `ComposePresenter` implementations produce models. 3. App-specific `Template` presenters wrap the root model tree. 4. `RendererFactory` resolves platform renderers for those models. 5. Thin platform entrypoints bootstrap the root scope and start rendering. diff --git a/CHANGELOG.md b/CHANGELOG.md index d288116a..a4216970 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Changed +- **Breaking change:** Rename the Molecule-specific presenter API to Compose-focused names, including `MoleculePresenter` to `ComposePresenter`, its scope APIs, Gradle DSL options, and `:presenter-molecule:*` artifacts to `:presenter-compose:*`. + ### Deprecated ### Removed diff --git a/buildSrc/src/main/kotlin/software/ralf/app/platform/gradle/buildsrc/BasePlugin.kt b/buildSrc/src/main/kotlin/software/ralf/app/platform/gradle/buildsrc/BasePlugin.kt index c7761c84..d350897e 100644 --- a/buildSrc/src/main/kotlin/software/ralf/app/platform/gradle/buildsrc/BasePlugin.kt +++ b/buildSrc/src/main/kotlin/software/ralf/app/platform/gradle/buildsrc/BasePlugin.kt @@ -75,9 +75,9 @@ public open class BasePlugin : Plugin { "${APP_PLATFORM_GROUP}:presenter-backstack-nav3-testing" to ":presenter-backstack-nav3:testing", "${APP_PLATFORM_GROUP}:presenter-public" to ":presenter:public", - "${APP_PLATFORM_GROUP}:presenter-molecule-public" to ":presenter-molecule:public", - "${APP_PLATFORM_GROUP}:presenter-molecule-impl" to ":presenter-molecule:impl", - "${APP_PLATFORM_GROUP}:presenter-molecule-testing" to ":presenter-molecule:testing", + "${APP_PLATFORM_GROUP}:presenter-compose-public" to ":presenter-compose:public", + "${APP_PLATFORM_GROUP}:presenter-compose-impl" to ":presenter-compose:impl", + "${APP_PLATFORM_GROUP}:presenter-compose-testing" to ":presenter-compose:testing", "${APP_PLATFORM_GROUP}:renderer-public" to ":renderer:public", "${APP_PLATFORM_GROUP}:renderer-android-view-public" to ":renderer-android-view:public", "${APP_PLATFORM_GROUP}:renderer-compose-multiplatform-public" to diff --git a/docs/presenter.md b/docs/presenter.md index cb2db152..a54ce7b1 100644 --- a/docs/presenter.md +++ b/docs/presenter.md @@ -3,12 +3,12 @@ !!! note While App Platform has a generic `Presenter` interface to remove coupling, we strongly recommend using - `MoleculePresenter` for implementations. `MoleculePresenters` are an opt-in feature through the Gradle DSL. + `ComposePresenter` for implementations. `ComposePresenters` are an opt-in feature through the Gradle DSL. The default value is `false`. ```groovy appPlatform { - enableMoleculePresenters true + enableComposePresenters true } ``` @@ -18,7 +18,7 @@ App Platform implements the unidirectional dataflow pattern to decouple business does this allow for better testing of business logic and provides clear boundaries, but individual apps can also share more code and change the look and feel when needed. -## `MoleculePresenter` +## `ComposePresenter` In the unidirectional dataflow pattern events and state only travel into one direction through a single stream. State is produced by `Presenters` and can be observed through a reactive stream: @@ -37,11 +37,11 @@ use case of Compose is handling, creating and modifying tree-like data structure UI frameworks. Molecule reuses Compose to handle state management and state transitions to implement business logic in the form of `@Composable` functions with all the benefits that Compose provides. -The [MoleculePresenter](https://github.com/vRallev/app-platform/blob/main/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/MoleculePresenter.kt) +The [ComposePresenter](https://github.com/vRallev/app-platform/blob/main/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenter.kt) interface looks like this: ```kotlin -fun interface MoleculePresenter { +fun interface ComposePresenter { @Composable fun present(input: InputT): ModelT } @@ -52,7 +52,7 @@ represent the state of a `Presenter`. Usually, they’re implemented as immutabl Using sealed hierarchies is a good practice to allow to differentiate between different states: ```kotlin -interface LoginPresenter : MoleculePresenter { +interface LoginPresenter : ComposePresenter { sealed interface Model : BaseModel { data object LoggedOut : Model @@ -78,7 +78,7 @@ Observers of the state of a `Presenter`, such as the UI layer, communicate back Events are sent through a lambda in the `Model`, which the `Presenter` must provide: ```kotlin hl_lines="16" -interface LoginPresenter : MoleculePresenter { +interface LoginPresenter : ComposePresenter { sealed interface Event { data object Logout : Event @@ -123,10 +123,10 @@ class LoginPresenterImpl : LoginPresenter { !!! note - `MoleculePresenters` are never singletons. They are automatically bound to an API using + `ComposePresenters` are never singletons. They are automatically bound to an API using `@ContributesBinding`, but they don't use the `@SingleIn` annotation. Metro can instantiate a contributed presenter with a single constructor without `@Inject`; `kotlin-inject-anvil` users - should still use `@Inject` for constructor injection. `MoleculePresenters` manage their state in + should still use `@Inject` for constructor injection. `ComposePresenters` manage their state in the `@Composable` function with the Compose runtime. Therefore, it's strongly discouraged to have any class properties. @@ -204,7 +204,7 @@ While the pattern isn’t used frequently, parent presenters can provide input t returned model from the child presenter can be used further to change the control flow. ```kotlin -interface ChildPresenter : MoleculePresenter { +interface ChildPresenter : ComposePresenter { data class Input( val argument: String, ) @@ -272,7 +272,7 @@ on presenter inputs. ## Launching -`MoleculePresenters` can inject other presenters and call their `present()` function inline. If you are already in a +`ComposePresenters` can inject other presenters and call their `present()` function inline. If you are already in a composable UI context, then you can simply call the presenter to compute the model: ```kotlin @@ -288,12 +288,12 @@ In this example the `LoginPresenter` model is computed from an iOS Compose Multi In other scenarios a composable context may not be available and it's necessary to turn the `@Composable` functions into a `StateFlow` for consumption. -[`MoleculeScope`](https://github.com/vRallev/app-platform/blob/main/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/MoleculeScope.kt) -helps to turn a `MoleculePresenter` into a `Presenter`, which then exposes a `StateFlow`: +[`ComposePresenterScope`](https://github.com/vRallev/app-platform/blob/main/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenterScope.kt) +helps to turn a `ComposePresenter` into a `Presenter`, which then exposes a `StateFlow`: ```kotlin -val stateFlow = moleculeScope - .launchMoleculePresenter( +val stateFlow = composePresenterScope + .launchComposePresenter( presenter = myPresenter, input = Unit, ) @@ -302,52 +302,52 @@ val stateFlow = moleculeScope !!! warning - `MoleculeScope` wraps a `CoroutineScope`. The presenter keeps running, recomposing and producing new models - until the `MoleculeScope` is canceled. If the `MoleculeScope` is never canceled, then presenters leak and will + `ComposePresenterScope` wraps a `CoroutineScope`. The presenter keeps running, recomposing and producing new models + until the `ComposePresenterScope` is canceled. If the `ComposePresenterScope` is never canceled, then presenters leak and will cause issues later. - Use [`MoleculeScopeFactory`](https://github.com/vRallev/app-platform/blob/main/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/MoleculeScopeFactory.kt) - to create a new `MoleculeScope` instance and call `cancel()` when you don't need it anymore. + Use [`ComposePresenterScopeFactory`](https://github.com/vRallev/app-platform/blob/main/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory.kt) + to create a new `ComposePresenterScope` instance and call `cancel()` when you don't need it anymore. On Android an implementation using `ViewModels` may look like this: ```kotlin class MainActivityViewModel( - moleculeScopeFactory: MoleculeScopeFactory, + composePresenterScopeFactory: ComposePresenterScopeFactory, myPresenter: MyPresenter, ) : ViewModel() { - private val moleculeScope = moleculeScopeFactory.createMoleculeScope() + private val composePresenterScope = composePresenterScopeFactory.createComposePresenterScope() // Expose the models for consumption. - val models = moleculeScope - .launchMoleculePresenter( + val models = composePresenterScope + .launchComposePresenter( presenter = myPresenter, input = Unit ) .models override fun onCleared() { - moleculeScope.cancel() + composePresenterScope.cancel() } } ``` !!! info - By default `MoleculeScope` uses the main thread for running presenters and + By default `ComposePresenterScope` uses the main thread for running presenters and [`RecompositionMode.ContextClock`](https://github.com/cashapp/molecule/blob/trunk/molecule-runtime/src/commonMain/kotlin/app/cash/molecule/RecompositionMode.kt), meaning a new model is produced only once per UI frame and further changes are conflated. - This behavior can be changed by creating a custom `MoleculeScope`, e.g. tests make use of this: + This behavior can be changed by creating a custom `ComposePresenterScope`, e.g. tests make use of this: ```kotlin - fun TestScope.moleculeScope( + fun TestScope.composePresenterScope( coroutineContext: CoroutineContext = EmptyCoroutineContext - ): MoleculeScope { - val scope = backgroundScope + CoroutineName("TestMoleculeScope") + coroutineContext + ): ComposePresenterScope { + val scope = backgroundScope + CoroutineName("TestComposePresenterScope") + coroutineContext - return MoleculeScope(scope, RecompositionMode.Immediate) + return ComposePresenterScope(scope, RecompositionMode.Immediate) } ``` @@ -365,7 +365,7 @@ Use `presentDetached()` when a child presenter should run in its own Molecule hi class ParentPresenter( private val busyPresenter: BusyPresenter, private val expensivePresenter: ExpensivePresenter, -) : MoleculePresenter { +) : ComposePresenter { @Composable override fun present(input: Unit): Model { @@ -398,8 +398,8 @@ in that case, child presenter updates are driven by the detached hierarchy's own ## Testing -A [`test()`](https://github.com/vRallev/app-platform/blob/main/presenter-molecule/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/TestPresenter.kt) -utility function is provided to make testing `MoleculePresenters` easy using the [Turbine](https://github.com/cashapp/turbine/) +A [`test()`](https://github.com/vRallev/app-platform/blob/main/presenter-compose/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/TestPresenter.kt) +utility function is provided to make testing `ComposePresenters` easy using the [Turbine](https://github.com/cashapp/turbine/) library: ```kotlin @@ -466,7 +466,7 @@ Platform in the application scope and can be injected: @Inject class RootPresenter( private val backGestureDispatcherPresenter: BackGestureDispatcherPresenter, -) : MoleculePresenter { +) : ComposePresenter { @Composable override fun present(input: Unit): Model { return withCompositionLocal( @@ -732,8 +732,8 @@ is called with their initial state. These presenters only remember their state, The Compose runtime provides `rememberSaveable { }` and `SaveableStateHolder` as a solution to save and restore small pieces of UI state. App Platform provides the experimental -[`ReturningSaveableStateHolder`](https://github.com/vRallev/app-platform/blob/main/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/saveable/ReturningSaveableStateHolder.kt) -API for `@Composable` functions that return a value. This matters for `MoleculePresenter` functions, because a presenter +[`ReturningSaveableStateHolder`](https://github.com/vRallev/app-platform/blob/main/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/saveable/ReturningSaveableStateHolder.kt) +API for `@Composable` functions that return a value. This matters for `ComposePresenter` functions, because a presenter doesn't render UI directly; it returns a model. `Presenters` wrapped with `ReturningSaveableStateHolder` can use `rememberSaveable { }` to restore state even after they @@ -741,7 +741,7 @@ weren't part of the hierarchy anymore: ```kotlin import software.ralf.app.platform.ExperimentalAppPlatform -import software.ralf.app.platform.presenter.molecule.saveable.rememberReturningSaveableStateHolder +import software.ralf.app.platform.presenter.compose.saveable.rememberReturningSaveableStateHolder @OptIn(ExperimentalAppPlatform::class) @Composable @@ -797,13 +797,13 @@ This pattern can be generalized: ```kotlin interface NavigationManager { - val currentPresenter: StateFlow> + val currentPresenter: StateFlow> - fun navigateTo(presenter: MoleculePresenter) + fun navigateTo(presenter: ComposePresenter) } @Inject -class NavigationPresenter(val navigationManager: NavigationManager) : MoleculePresenter { +class NavigationPresenter(val navigationManager: NavigationManager) : ComposePresenter { @Compose fun present(input: Unit): BaseModel { @@ -822,11 +822,11 @@ The easiest way to import it is the Gradle plugin option: ```groovy appPlatform { - enableMoleculePresenterBackstack true + enableComposePresenterBackstack true } ``` -This option adds the presenter backstack module and also enables Molecule presenters and Compose UI. The API keeps the +This option adds the presenter backstack module and also enables Compose presenters and Compose UI. The API keeps the backstack in presenter code, while the renderer integration delegates rendering, back gestures, retained entries, and transitions to Navigation 3. @@ -834,8 +834,8 @@ The Recipes app wraps the shared API in a small app-specific presenter: ```kotlin class CrossSlideBackstackPresenter( - private val initialPresenter: MoleculePresenter -) : MoleculePresenter { + private val initialPresenter: ComposePresenter +) : ComposePresenter { @Composable override fun present(input: Unit): Model { return presenterBackstack(initialPresenter) { backstack -> @@ -977,7 +977,7 @@ class YourType public val LocalYourType: ProvidableCompositionLocal = compositionLocalOf { null } -class ParentPresenter : MoleculePresenter { +class ParentPresenter : ComposePresenter { @Composable override fun present(input: Unit): Model { val yourType = remember { YourType() } @@ -990,7 +990,7 @@ class ParentPresenter : MoleculePresenter { } } -class ChildPresenter : MoleculePresenter { +class ChildPresenter : ComposePresenter { @Composable override fun present(input: Unit): Model { val yourType = checkNotNull(LocalYourType.current) @@ -1010,7 +1010,7 @@ layer without depending on Compose Foundation's `TextFieldState`. ```kotlin @OptIn(ExperimentalAppPlatform::class) -class SearchPresenter : MoleculePresenter { +class SearchPresenter : ComposePresenter { @Composable override fun present(input: Unit): Model { val query = remember { PresenterTextFieldState() } @@ -1070,8 +1070,8 @@ sealed interface SampleAppTemplate : Template { class SampleAppTemplatePresenter( private val appBarPresenter: AppBarPresenter, - private val rootPresenter: MoleculePresenter, -) : MoleculePresenter { + private val rootPresenter: ComposePresenter, +) : ComposePresenter { @Composable fun present(input: Unit): SampleAppTemplate { val contentModel = rootPresenter.present(Unit) @@ -1092,7 +1092,7 @@ specific [`AppBarConfigModel`](https://github.com/vRallev/app-platform/blob/main interface, which provides the configuration for the app bar. Implementing this interface is optional: ```kotlin -class MenuPresenter : MoleculePresenter { +class MenuPresenter : ComposePresenter { @Composable override fun present(input: Unit): Model { ... @@ -1354,7 +1354,7 @@ The root `Presenter` responsible for the `Presenter` backstack computes the `Mod @Composable override fun present(input: Unit): Model { val backstack = remember { - mutableStateListOf>().apply { + mutableStateListOf>().apply { // There must be always one element. add(SwiftUiChildPresenter(index = 0, backstack = this)) } diff --git a/docs/setup.md b/docs/setup.md index e92b5daa..41b643de 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -25,11 +25,11 @@ are explained in more detail in many of the following sections. // false by default. Alternative DI option. Configures KSP and adds the kotlin-inject-anvil library as dependency. enableKotlinInject true - // false by default. Configures Molecule and provides access to the MoleculePresenter API. - enableMoleculePresenters true + // false by default. Configures Molecule and provides access to the ComposePresenter API. + enableComposePresenters true - // false by default. Adds the Navigation 3 presenter backstack module and enables Molecule presenters and Compose UI. - enableMoleculePresenterBackstack true + // false by default. Adds the Navigation 3 presenter backstack module and enables Compose presenters and Compose UI. + enableComposePresenterBackstack true // false by default. Adds the necessary dependencies to use Compose Multiplatform with Renderers. enableComposeUi true @@ -60,11 +60,11 @@ are explained in more detail in many of the following sections. // false by default. Alternative DI option. Configures KSP and adds the kotlin-inject-anvil library as dependency. enableKotlinInject(true) - // false by default. Configures Molecule and provides access to the MoleculePresenter API. - enableMoleculePresenters(true) + // false by default. Configures Molecule and provides access to the ComposePresenter API. + enableComposePresenters(true) - // false by default. Adds the Navigation 3 presenter backstack module and enables Molecule presenters and Compose UI. - enableMoleculePresenterBackstack(true) + // false by default. Adds the Navigation 3 presenter backstack module and enables Compose presenters and Compose UI. + enableComposePresenterBackstack(true) // false by default. Adds the necessary dependencies to use Compose Multiplatform with Renderers. enableComposeUi(true) @@ -77,7 +77,7 @@ are explained in more detail in many of the following sections. !!! note - All settings of App Platform are optional and opt-in, e.g. you can use Molecule Presenters without enabling + All settings of App Platform are optional and opt-in, e.g. you can use Compose Presenters without enabling the opinionated module structure. Compose UI can be enabled without using `Metro` or `kotlin-inject-anvil`. When you do want DI, Metro is the recommended default. @@ -89,7 +89,7 @@ This repository includes project-neutral skills for coding agents working on app | --- | --- | | [Module structure](https://github.com/vRallev/app-platform/blob/main/skills/app-platform-module-structure/SKILL.md) | Public, implementation, testing, and robot module boundaries; app assembly; and Gradle checks | | [Scopes](https://github.com/vRallev/app-platform/blob/main/skills/app-platform-scope/SKILL.md) | App Platform lifetimes, coroutine scopes, and Metro graph integration | -| [Presenters](https://github.com/vRallev/app-platform/blob/main/skills/app-platform-presenters/SKILL.md) | `MoleculePresenter` models, state, composition, hosting, and template selection | +| [Presenters](https://github.com/vRallev/app-platform/blob/main/skills/app-platform-presenters/SKILL.md) | `ComposePresenter` models, state, composition, hosting, and template selection | | [Renderers](https://github.com/vRallev/app-platform/blob/main/skills/app-platform-renderers/SKILL.md) | Compose and Android View renderers, factories, child rendering, and template layouts | | [Testing](https://github.com/vRallev/app-platform/blob/main/skills/app-platform-testing/SKILL.md) | Fakes, shared unit tests, optional Desktop renderer tests, and robot integration tests | diff --git a/docs/template.md b/docs/template.md index 324d9a5e..5ed86ebc 100644 --- a/docs/template.md +++ b/docs/template.md @@ -36,8 +36,8 @@ e.g. ```kotlin hl_lines="8" @Inject class SampleAppTemplatePresenter( - @Assisted private val rootPresenter: MoleculePresenter, -) : MoleculePresenter { + @Assisted private val rootPresenter: ComposePresenter, +) : ComposePresenter { @Composable override fun present(input: Unit): SampleAppTemplate { return withCompositionLocals { diff --git a/gradle-plugin/api/gradle-plugin.api b/gradle-plugin/api/gradle-plugin.api index 79c074c3..ed14f75b 100644 --- a/gradle-plugin/api/gradle-plugin.api +++ b/gradle-plugin/api/gradle-plugin.api @@ -2,13 +2,13 @@ public class software/ralf/app/platform/gradle/AppPlatformExtension { public fun (Lorg/gradle/api/model/ObjectFactory;Lorg/gradle/api/Project;)V public final fun addImplModuleDependencies (Z)V public final fun addPublicModuleDependencies (Z)V + public final fun enableComposePresenterBackstack (Z)V + public final fun enableComposePresenters (Z)V public final fun enableComposeUi (Z)V public final fun enableKotlinInject (Z)V public final fun enableMetro (Z)V public final fun enableModuleStructure (Lorg/gradle/api/Action;)V public final fun enableModuleStructure (Z)V - public final fun enableMoleculePresenterBackstack (Z)V - public final fun enableMoleculePresenters (Z)V } public class software/ralf/app/platform/gradle/AppPlatformPlugin : org/gradle/api/Plugin { diff --git a/gradle-plugin/src/main/kotlin/software/ralf/app/platform/gradle/AppPlatformExtension.kt b/gradle-plugin/src/main/kotlin/software/ralf/app/platform/gradle/AppPlatformExtension.kt index c7349c73..6cb0a4ad 100644 --- a/gradle-plugin/src/main/kotlin/software/ralf/app/platform/gradle/AppPlatformExtension.kt +++ b/gradle-plugin/src/main/kotlin/software/ralf/app/platform/gradle/AppPlatformExtension.kt @@ -27,8 +27,8 @@ import software.ralf.app.platform.gradle.ModuleStructurePlugin.Companion.testing * enableKotlinInject true // false is the default * enableMetro true // false is the default * - * enableMoleculePresenters true // false is the default - * enableMoleculePresenterBackstack true // false is the default + * enableComposePresenters true // false is the default + * enableComposePresenterBackstack true // false is the default * enableModuleStructure true // false is the default * enableModuleStructure { * enableDependencyCheck false // true is the default @@ -81,46 +81,45 @@ constructor(objects: ObjectFactory, private val project: Project) { internal fun isMetroEnabled(): Property = enableMetro - private val enableMoleculePresenters: Property = + private val enableComposePresenters: Property = objects.property(Boolean::class.java).convention(false) - /** Adds the Molecule Gradle plugin as dependency and gives access to `MoleculePresenter`. */ - public fun enableMoleculePresenters(enabled: Boolean) { - if (enabled == enableMoleculePresenters.get()) return + /** Adds Molecule and Compose compiler dependencies and gives access to `ComposePresenter`. */ + public fun enableComposePresenters(enabled: Boolean) { + if (enabled == enableComposePresenters.get()) return - enableMoleculePresenters.set(enabled) - enableMoleculePresenters.disallowChanges() + enableComposePresenters.set(enabled) + enableComposePresenters.disallowChanges() if (enabled) { addPublicModuleDependencies(true) - project.enableMoleculePresenters() + project.enableComposePresenters() } } - internal fun isMoleculeEnabled(): Property = enableMoleculePresenters + internal fun isComposePresentersEnabled(): Property = enableComposePresenters - private val enableMoleculePresenterBackstack: Property = + private val enableComposePresenterBackstack: Property = objects.property(Boolean::class.java).convention(false) /** - * Adds the Navigation 3 presenter backstack module and enables Molecule presenters and Compose - * UI. + * Adds the Navigation 3 presenter backstack module and enables Compose presenters and Compose UI. */ - public fun enableMoleculePresenterBackstack(enabled: Boolean) { - if (enabled == enableMoleculePresenterBackstack.get()) return + public fun enableComposePresenterBackstack(enabled: Boolean) { + if (enabled == enableComposePresenterBackstack.get()) return - enableMoleculePresenterBackstack.set(enabled) - enableMoleculePresenterBackstack.disallowChanges() + enableComposePresenterBackstack.set(enabled) + enableComposePresenterBackstack.disallowChanges() if (enabled) { - enableMoleculePresenters(true) + enableComposePresenters(true) enableComposeUi(true) - project.enableMoleculePresenterBackstack() + project.enableComposePresenterBackstack() } } - internal fun isMoleculePresenterBackstackEnabled(): Property = - enableMoleculePresenterBackstack + internal fun isComposePresenterBackstackEnabled(): Property = + enableComposePresenterBackstack private val enableComposeUi: Property = objects.property(Boolean::class.java).convention(false) @@ -365,7 +364,7 @@ private fun Project.enableMetroCompilerPlugin() { } } -private fun Project.enableMoleculePresenters() { +private fun Project.enableComposePresenters() { plugins.apply(PluginIds.COMPOSE_COMPILER) plugins.withId(PluginIds.KOTLIN_MULTIPLATFORM) { @@ -373,11 +372,11 @@ private fun Project.enableMoleculePresenters() { implementation("app.cash.molecule:molecule-runtime:$MOLECULE_VERSION") implementation("org.jetbrains.compose.runtime:runtime:$COMPOSE_MULTIPLATFORM_VERSION") implementation("androidx.compose.runtime:runtime-retain:$COMPOSE_MULTIPLATFORM_VERSION") - implementation("$APP_PLATFORM_GROUP:presenter-molecule-public:$APP_PLATFORM_VERSION") + implementation("$APP_PLATFORM_GROUP:presenter-compose-public:$APP_PLATFORM_VERSION") } testingSourceSets.forEach { sourceSetName -> kmpExtension.sourceSets.getByName(sourceSetName).dependencies { - implementation("$APP_PLATFORM_GROUP:presenter-molecule-testing:$APP_PLATFORM_VERSION") + implementation("$APP_PLATFORM_GROUP:presenter-compose-testing:$APP_PLATFORM_VERSION") } } } @@ -394,18 +393,18 @@ private fun Project.enableMoleculePresenters() { ) dependencies.add( "implementation", - "$APP_PLATFORM_GROUP:presenter-molecule-public:$APP_PLATFORM_VERSION", + "$APP_PLATFORM_GROUP:presenter-compose-public:$APP_PLATFORM_VERSION", ) testingSourceSets.forEach { sourceSetName -> dependencies.add( sourceSetName, - "$APP_PLATFORM_GROUP:presenter-molecule-testing:$APP_PLATFORM_VERSION", + "$APP_PLATFORM_GROUP:presenter-compose-testing:$APP_PLATFORM_VERSION", ) } } } -private fun Project.enableMoleculePresenterBackstack() { +private fun Project.enableComposePresenterBackstack() { plugins.withId(PluginIds.KOTLIN_MULTIPLATFORM) { kmpExtension.sourceSets.getByName("commonMain").dependencies { implementation("$APP_PLATFORM_GROUP:presenter-backstack-nav3-public:$APP_PLATFORM_VERSION") diff --git a/gradle-plugin/src/main/kotlin/software/ralf/app/platform/gradle/AppPlatformPlugin.kt b/gradle-plugin/src/main/kotlin/software/ralf/app/platform/gradle/AppPlatformPlugin.kt index 0a56e72a..143ef4ab 100644 --- a/gradle-plugin/src/main/kotlin/software/ralf/app/platform/gradle/AppPlatformPlugin.kt +++ b/gradle-plugin/src/main/kotlin/software/ralf/app/platform/gradle/AppPlatformPlugin.kt @@ -87,8 +87,8 @@ public open class AppPlatformPlugin : Plugin { } val implementationDependencies = buildSet { - if (appPlatform.isMoleculeEnabled().get()) { - add("$APP_PLATFORM_GROUP:presenter-molecule-impl:$APP_PLATFORM_VERSION") + if (appPlatform.isComposePresentersEnabled().get()) { + add("$APP_PLATFORM_GROUP:presenter-compose-impl:$APP_PLATFORM_VERSION") } if (appPlatform.isKotlinInjectEnabled().get()) { add("$APP_PLATFORM_GROUP:kotlin-inject-impl:$APP_PLATFORM_VERSION") @@ -125,8 +125,8 @@ public open class AppPlatformPlugin : Plugin { "metro-impl", "metro-public", "presenter-backstack-nav3-public", - "presenter-molecule-impl", - "presenter-molecule-public", + "presenter-compose-impl", + "presenter-compose-public", "presenter-public", "renderer-compose-multiplatform-public", "renderer-public", diff --git a/gradle-plugin/src/test/kotlin/software/ralf/app/platform/gradle/AppPlatformExtensionTest.kt b/gradle-plugin/src/test/kotlin/software/ralf/app/platform/gradle/AppPlatformExtensionTest.kt index 1593c367..71078454 100644 --- a/gradle-plugin/src/test/kotlin/software/ralf/app/platform/gradle/AppPlatformExtensionTest.kt +++ b/gradle-plugin/src/test/kotlin/software/ralf/app/platform/gradle/AppPlatformExtensionTest.kt @@ -77,9 +77,21 @@ class AppPlatformExtensionTest { .isTrue() } - private fun createExtension(): AppPlatformExtension { + @Test + fun `Compose presenter backstack enables Compose presenters and Compose UI`() { + val extension = createExtension(PluginIds.KOTLIN_JVM) + + extension.enableComposePresenterBackstack(true) + + assertThat(extension.isComposePresenterBackstackEnabled().get()).isTrue() + assertThat(extension.isComposePresentersEnabled().get()).isTrue() + assertThat(extension.isComposeUiEnabled().get()).isTrue() + } + + private fun createExtension(pluginId: String? = null): AppPlatformExtension { val rootProject = ProjectBuilder.builder().withName("root").build() val moduleProject = ProjectBuilder.builder().withName("impl").withParent(rootProject).build() + pluginId?.let { moduleProject.plugins.apply(it) } moduleProject.plugins.apply(AppPlatformPlugin::class.java) return moduleProject.extensions.getByType(AppPlatformExtension::class.java) } diff --git a/gradle-plugin/src/test/kotlin/software/ralf/app/platform/gradle/AppPlatformPluginDependencyTest.kt b/gradle-plugin/src/test/kotlin/software/ralf/app/platform/gradle/AppPlatformPluginDependencyTest.kt index f9f8bf10..93c2e485 100644 --- a/gradle-plugin/src/test/kotlin/software/ralf/app/platform/gradle/AppPlatformPluginDependencyTest.kt +++ b/gradle-plugin/src/test/kotlin/software/ralf/app/platform/gradle/AppPlatformPluginDependencyTest.kt @@ -134,6 +134,76 @@ class AppPlatformPluginDependencyTest { ) } + @Test + fun `KMP Compose presenter dependency wiring uses renamed artifacts`() { + val project = createProject(name = "impl") + project.plugins.apply(PluginIds.KOTLIN_MULTIPLATFORM) + project.plugins.apply(AppPlatformPlugin::class.java) + + project.appPlatform.enableComposePresenters(true) + project.appPlatform.addImplModuleDependencies(true) + + project.evaluate() + + project.assertHasDependency( + "commonMainImplementation", + appPlatformDependency("presenter-compose-public"), + ) + project.assertHasDependency( + "commonTestImplementation", + appPlatformDependency("presenter-compose-testing"), + ) + project.assertHasDependency( + "commonMainImplementation", + appPlatformDependency("presenter-compose-impl"), + ) + } + + @Test + fun `JVM Compose presenter backstack dependency wiring uses renamed artifacts`() { + val project = createProject(name = "impl") + project.plugins.apply(PluginIds.KOTLIN_JVM) + project.plugins.apply(AppPlatformPlugin::class.java) + + project.appPlatform.enableComposePresenterBackstack(true) + project.appPlatform.addImplModuleDependencies(true) + + project.evaluate() + + project.assertHasDependency( + "implementation", + appPlatformDependency("presenter-compose-public"), + ) + project.assertHasDependency( + "testImplementation", + appPlatformDependency("presenter-compose-testing"), + ) + project.assertHasDependency( + "implementation", + appPlatformDependency("presenter-compose-impl"), + ) + project.assertHasDependency( + "implementation", + appPlatformDependency("presenter-backstack-nav3-public"), + ) + project.assertHasDependency( + "testImplementation", + appPlatformDependency("presenter-backstack-nav3-testing"), + ) + } + + @Test + fun `native framework exports renamed Compose presenter artifacts`() { + val exportedDependencies = AppPlatformPlugin.exportedDependencies() + + assertThat(exportedDependencies).contains(appPlatformDependency("presenter-compose-public")) + assertThat(exportedDependencies).contains(appPlatformDependency("presenter-compose-impl")) + assertThat(exportedDependencies) + .doesNotContain(appPlatformDependency("presenter-molecule-public")) + assertThat(exportedDependencies) + .doesNotContain(appPlatformDependency("presenter-molecule-impl")) + } + private fun createProject(name: String): Project { val rootProject = ProjectBuilder.builder().withName("root").build() return ProjectBuilder.builder().withName(name).withParent(rootProject).build() diff --git a/gradle.properties b/gradle.properties index 40c72d97..a8875847 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=0.1.6-SNAPSHOT +VERSION_NAME=0.2.0-SNAPSHOT GROUP=software.ralf.app.platform org.gradle.jvmargs=-Xmx8g -Dfile.encoding=UTF-8 diff --git a/presenter-backstack-nav3/public/api/android/public.api b/presenter-backstack-nav3/public/api/android/public.api index 7ad7bf41..c18f3a52 100644 --- a/presenter-backstack-nav3/public/api/android/public.api +++ b/presenter-backstack-nav3/public/api/android/public.api @@ -15,8 +15,8 @@ public abstract class software/ralf/app/platform/presenter/backstack/nav3/Presen public abstract interface class software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope { public abstract fun getLastBackstackChange ()Landroidx/compose/runtime/State; public abstract fun pop ()V - public abstract fun push (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;)V - public abstract fun replaceTop (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;)V + public abstract fun push (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;)V + public abstract fun replaceTop (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;)V } public abstract interface class software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope$BackstackChange { @@ -36,7 +36,7 @@ public final class software/ralf/app/platform/presenter/backstack/nav3/Presenter public final class software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScopeKt { public static final fun getBackstack (Lsoftware/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope;)Ljava/util/List; public static final fun getLocalBackstackScope ()Landroidx/compose/runtime/ProvidableCompositionLocal; - public static final fun presenterBackstack (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/BaseModel; + public static final fun presenterBackstack (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/BaseModel; public static final fun requireNotNull (Landroidx/compose/runtime/CompositionLocal;Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope; } diff --git a/presenter-backstack-nav3/public/api/desktop/public.api b/presenter-backstack-nav3/public/api/desktop/public.api index 7ad7bf41..c18f3a52 100644 --- a/presenter-backstack-nav3/public/api/desktop/public.api +++ b/presenter-backstack-nav3/public/api/desktop/public.api @@ -15,8 +15,8 @@ public abstract class software/ralf/app/platform/presenter/backstack/nav3/Presen public abstract interface class software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope { public abstract fun getLastBackstackChange ()Landroidx/compose/runtime/State; public abstract fun pop ()V - public abstract fun push (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;)V - public abstract fun replaceTop (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;)V + public abstract fun push (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;)V + public abstract fun replaceTop (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;)V } public abstract interface class software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope$BackstackChange { @@ -36,7 +36,7 @@ public final class software/ralf/app/platform/presenter/backstack/nav3/Presenter public final class software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScopeKt { public static final fun getBackstack (Lsoftware/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope;)Ljava/util/List; public static final fun getLocalBackstackScope ()Landroidx/compose/runtime/ProvidableCompositionLocal; - public static final fun presenterBackstack (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/BaseModel; + public static final fun presenterBackstack (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/BaseModel; public static final fun requireNotNull (Landroidx/compose/runtime/CompositionLocal;Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope; } diff --git a/presenter-backstack-nav3/public/build.gradle b/presenter-backstack-nav3/public/build.gradle index 3ca87490..032a8992 100644 --- a/presenter-backstack-nav3/public/build.gradle +++ b/presenter-backstack-nav3/public/build.gradle @@ -10,11 +10,11 @@ appPlatformBuildSrc { dependencies { commonMainApi project(':di-common:public') - commonMainApi project(':presenter-molecule:public') + commonMainApi project(':presenter-compose:public') commonMainApi project(':renderer-compose-multiplatform:public') commonMainApi libs.navigation3.runtime commonMainApi libs.navigation3.ui - commonTestImplementation project(':presenter-molecule:testing') + commonTestImplementation project(':presenter-compose:testing') } diff --git a/presenter-backstack-nav3/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope.kt b/presenter-backstack-nav3/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope.kt index 1ca521d7..db24b9ff 100644 --- a/presenter-backstack-nav3/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope.kt +++ b/presenter-backstack-nav3/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope.kt @@ -12,9 +12,9 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.withCompositionLocal import software.ralf.app.platform.ExperimentalAppPlatform import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter -import software.ralf.app.platform.presenter.molecule.saveable.ReturningSaveableStateHolder -import software.ralf.app.platform.presenter.molecule.saveable.rememberReturningSaveableStateHolder +import software.ralf.app.platform.presenter.compose.ComposePresenter +import software.ralf.app.platform.presenter.compose.saveable.ReturningSaveableStateHolder +import software.ralf.app.platform.presenter.compose.saveable.rememberReturningSaveableStateHolder /** * Receiver scope for [presenterBackstack]. [lastBackstackChange] observes the current stack and @@ -27,7 +27,7 @@ public interface PresenterBackstackScope { public val lastBackstackChange: State /** Pushes a new presenter to the top of the backstack. */ - public fun push(presenter: MoleculePresenter) + public fun push(presenter: ComposePresenter) /** * Removes the top presenter from the backstack. @@ -38,13 +38,13 @@ public interface PresenterBackstackScope { public fun pop() /** Replaces the top presenter in the stack with [presenter]. */ - public fun replaceTop(presenter: MoleculePresenter) + public fun replaceTop(presenter: ComposePresenter) /** Describes the current state of the backstack and the last operation applied to it. */ public interface BackstackChange { /** The current presenter stack. This list always contains at least the initial presenter. */ - public val backstack: List> + public val backstack: List> /** The last action applied to the backstack. */ public val action: Action @@ -65,7 +65,7 @@ public interface PresenterBackstackScope { /** Convenience accessor for the current presenter stack. */ @ExperimentalAppPlatform -public val PresenterBackstackScope.backstack: List> +public val PresenterBackstackScope.backstack: List> get() = lastBackstackChange.value.backstack /** @@ -108,7 +108,7 @@ public fun CompositionLocal.requireNotNull(): Presente * * class WelcomePresenter( * private val tutorialPresenter: TutorialPresenter, - * ) : MoleculePresenter { + * ) : ComposePresenter { * @Composable * override fun present(input: Unit): Model { * return presenterBackstack(tutorialPresenter) { backstack -> @@ -146,7 +146,7 @@ public fun CompositionLocal.requireNotNull(): Presente * ```kotlin * class TutorialPresenter( * private val signInPresenter: SignInPresenter, - * ) : MoleculePresenter { + * ) : ComposePresenter { * @Composable * override fun present(input: Unit): TutorialModel { * val backstack = LocalBackstackScope.requireNotNull() @@ -168,7 +168,7 @@ public fun CompositionLocal.requireNotNull(): Presente @ExperimentalAppPlatform @Composable public fun presenterBackstack( - initialPresenter: MoleculePresenter, + initialPresenter: ComposePresenter, content: @Composable PresenterBackstackScope.(List) -> ModelT, ): ModelT { val scope = remember { PresenterBackstackScopeImpl(initialPresenter) } diff --git a/presenter-backstack-nav3/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScopeImpl.kt b/presenter-backstack-nav3/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScopeImpl.kt index 25e754ba..7a25d212 100644 --- a/presenter-backstack-nav3/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScopeImpl.kt +++ b/presenter-backstack-nav3/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScopeImpl.kt @@ -7,9 +7,9 @@ import androidx.compose.runtime.mutableStateOf import kotlin.collections.plus import software.ralf.app.platform.ExperimentalAppPlatform import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter -internal class PresenterBackstackScopeImpl(initial: MoleculePresenter) : +internal class PresenterBackstackScopeImpl(initial: ComposePresenter) : PresenterBackstackScope { private var nextKey = 0 private val initialEntry = newEntry(initial) @@ -27,7 +27,7 @@ internal class PresenterBackstackScopeImpl(initial: MoleculePresenter get() = _lastBackstackChange.value.entries - override fun push(presenter: MoleculePresenter) { + override fun push(presenter: ComposePresenter) { val oldEntries = _lastBackstackChange.value.entries _lastBackstackChange.value = BackstackChangeImpl( @@ -47,7 +47,7 @@ internal class PresenterBackstackScopeImpl(initial: MoleculePresenter) { + override fun replaceTop(presenter: ComposePresenter) { val oldEntries = _lastBackstackChange.value.entries _lastBackstackChange.value = BackstackChangeImpl( @@ -56,7 +56,7 @@ internal class PresenterBackstackScopeImpl(initial: MoleculePresenter): PresenterBackstackEntry { + private fun newEntry(presenter: ComposePresenter): PresenterBackstackEntry { return PresenterBackstackEntry(key = nextKey++, presenter = presenter) } @@ -64,7 +64,7 @@ internal class PresenterBackstackScopeImpl(initial: MoleculePresenter, override val action: PresenterBackstackScope.BackstackChange.Action, ) : PresenterBackstackScope.BackstackChange { - override val backstack: List> = entries.map { + override val backstack: List> = entries.map { it.presenter } } @@ -72,5 +72,5 @@ internal class PresenterBackstackScopeImpl(initial: MoleculePresenter, + val presenter: ComposePresenter, ) diff --git a/presenter-backstack-nav3/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScopeTest.kt b/presenter-backstack-nav3/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScopeTest.kt index bb4faee0..feb46fad 100644 --- a/presenter-backstack-nav3/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScopeTest.kt +++ b/presenter-backstack-nav3/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScopeTest.kt @@ -15,8 +15,8 @@ import kotlinx.coroutines.test.runTest import software.ralf.app.platform.ExperimentalAppPlatform import software.ralf.app.platform.presenter.BaseModel import software.ralf.app.platform.presenter.backstack.nav3.PresenterBackstackScope.BackstackChange.Action -import software.ralf.app.platform.presenter.molecule.MoleculePresenter -import software.ralf.app.platform.presenter.molecule.test +import software.ralf.app.platform.presenter.compose.ComposePresenter +import software.ralf.app.platform.presenter.compose.test class PresenterBackstackScopeTest { @Test @@ -130,9 +130,9 @@ class PresenterBackstackScopeTest { } private fun createScopeSnapshotPresenter( - initialPresenter: MoleculePresenter - ): MoleculePresenter { - return object : MoleculePresenter { + initialPresenter: ComposePresenter + ): ComposePresenter { + return object : ComposePresenter { @Composable override fun present(input: Unit): ScopeSnapshotModel { return presenterBackstack(initialPresenter) { modelBackstack -> @@ -149,9 +149,9 @@ class PresenterBackstackScopeTest { } private fun createPresenterBackstackModelPresenter( - initialPresenter: MoleculePresenter - ): MoleculePresenter { - return object : MoleculePresenter { + initialPresenter: ComposePresenter + ): ComposePresenter { + return object : ComposePresenter { @Composable override fun present(input: Unit): PresenterBackstackModel { return presenterBackstack(initialPresenter) { modelBackstack -> @@ -161,12 +161,12 @@ class PresenterBackstackScopeTest { } } - private class FixedPresenter(private val model: BaseModel) : MoleculePresenter { + private class FixedPresenter(private val model: BaseModel) : ComposePresenter { @Composable override fun present(input: Unit): BaseModel = model } - private class PushPresenter(private val childPresenter: MoleculePresenter) : - MoleculePresenter { + private class PushPresenter(private val childPresenter: ComposePresenter) : + ComposePresenter { @Composable override fun present(input: Unit): BaseModel { val backstackScope = LocalBackstackScope.requireNotNull() @@ -174,7 +174,7 @@ class PresenterBackstackScopeTest { } } - private class SaveableStatefulPresenter : MoleculePresenter { + private class SaveableStatefulPresenter : ComposePresenter { @Composable override fun present(input: Unit): BaseModel { var value by rememberSaveable { mutableStateOf("Initial") } @@ -185,7 +185,7 @@ class PresenterBackstackScopeTest { private data class ScopeSnapshotModel( val scope: PresenterBackstackScope, val localScope: PresenterBackstackScope, - val backstack: List>, + val backstack: List>, val modelBackstack: List, val action: Action, ) : BaseModel diff --git a/presenter-backstack-nav3/testing/api/android/testing.api b/presenter-backstack-nav3/testing/api/android/testing.api index 3095b84d..a5bef992 100644 --- a/presenter-backstack-nav3/testing/api/android/testing.api +++ b/presenter-backstack-nav3/testing/api/android/testing.api @@ -1,17 +1,17 @@ public final class software/ralf/app/platform/presenter/backstack/nav3/FakePresenterBackstackScope : software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope { public static final field $stable I public fun ()V - public fun (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;)V - public synthetic fun (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;)V + public synthetic fun (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun getLastBackstackChange ()Landroidx/compose/runtime/State; public final fun getRecordedBackstackChanges ()Lkotlinx/coroutines/flow/StateFlow; public fun pop ()V - public fun push (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;)V - public fun replaceTop (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;)V + public fun push (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;)V + public fun replaceTop (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;)V } public final class software/ralf/app/platform/presenter/backstack/nav3/TestPresenterBackstackScopePresenterKt { - public static final fun withPresenterBackstackScope (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lsoftware/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter; - public static synthetic fun withPresenterBackstackScope$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lsoftware/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter; + public static final fun withPresenterBackstackScope (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lsoftware/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter; + public static synthetic fun withPresenterBackstackScope$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lsoftware/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter; } diff --git a/presenter-backstack-nav3/testing/api/desktop/testing.api b/presenter-backstack-nav3/testing/api/desktop/testing.api index 3095b84d..a5bef992 100644 --- a/presenter-backstack-nav3/testing/api/desktop/testing.api +++ b/presenter-backstack-nav3/testing/api/desktop/testing.api @@ -1,17 +1,17 @@ public final class software/ralf/app/platform/presenter/backstack/nav3/FakePresenterBackstackScope : software/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope { public static final field $stable I public fun ()V - public fun (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;)V - public synthetic fun (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;)V + public synthetic fun (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun getLastBackstackChange ()Landroidx/compose/runtime/State; public final fun getRecordedBackstackChanges ()Lkotlinx/coroutines/flow/StateFlow; public fun pop ()V - public fun push (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;)V - public fun replaceTop (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;)V + public fun push (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;)V + public fun replaceTop (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;)V } public final class software/ralf/app/platform/presenter/backstack/nav3/TestPresenterBackstackScopePresenterKt { - public static final fun withPresenterBackstackScope (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lsoftware/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter; - public static synthetic fun withPresenterBackstackScope$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lsoftware/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter; + public static final fun withPresenterBackstackScope (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lsoftware/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter; + public static synthetic fun withPresenterBackstackScope$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lsoftware/ralf/app/platform/presenter/backstack/nav3/PresenterBackstackScope;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter; } diff --git a/presenter-backstack-nav3/testing/build.gradle b/presenter-backstack-nav3/testing/build.gradle index 04a1cf3b..a00c2792 100644 --- a/presenter-backstack-nav3/testing/build.gradle +++ b/presenter-backstack-nav3/testing/build.gradle @@ -9,7 +9,7 @@ appPlatformBuildSrc { } dependencies { - commonMainApi project(':presenter-molecule:public') + commonMainApi project(':presenter-compose:public') - commonTestImplementation project(':presenter-molecule:testing') + commonTestImplementation project(':presenter-compose:testing') } diff --git a/presenter-backstack-nav3/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/FakePresenterBackstackScope.kt b/presenter-backstack-nav3/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/FakePresenterBackstackScope.kt index 1be2f005..63ef0bdd 100644 --- a/presenter-backstack-nav3/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/FakePresenterBackstackScope.kt +++ b/presenter-backstack-nav3/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/FakePresenterBackstackScope.kt @@ -13,7 +13,7 @@ import software.ralf.app.platform.ExperimentalAppPlatform import software.ralf.app.platform.presenter.BaseModel import software.ralf.app.platform.presenter.backstack.nav3.PresenterBackstackScope.BackstackChange import software.ralf.app.platform.presenter.backstack.nav3.PresenterBackstackScope.BackstackChange.Action -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter /** * Test fake for [PresenterBackstackScope]. @@ -27,7 +27,7 @@ import software.ralf.app.platform.presenter.molecule.MoleculePresenter * test needs to call [pop]: create the fake with the default root, [push] the presenter under test, * then invoke the model callback. If the presenter under test is the root entry, [pop] is a no-op. * - * [lastBackstackChange] is backed by Compose snapshot state so Molecule presenters that read + * [lastBackstackChange] is backed by Compose snapshot state so Compose presenters that read * `lastBackstackChange.value` recompose when the fake changes. The state uses referential equality * because every recorded mutation represents a new backstack change, even when the resulting * presenter list and action match the previous change. @@ -66,8 +66,8 @@ import software.ralf.app.platform.presenter.molecule.MoleculePresenter */ @ExperimentalAppPlatform public class FakePresenterBackstackScope( - rootPresenter: MoleculePresenter = - object : MoleculePresenter { + rootPresenter: ComposePresenter = + object : ComposePresenter { @Composable override fun present(input: Unit): BaseModel { return object : BaseModel {} @@ -92,7 +92,7 @@ public class FakePresenterBackstackScope( */ public val recordedBackstackChanges: StateFlow> = _recordedBackstackChanges - override fun push(presenter: MoleculePresenter) { + override fun push(presenter: ComposePresenter) { updateBackstack(backstack = backstack + presenter, action = Action.PUSH) } @@ -102,12 +102,12 @@ public class FakePresenterBackstackScope( } } - override fun replaceTop(presenter: MoleculePresenter) { + override fun replaceTop(presenter: ComposePresenter) { updateBackstack(backstack = backstack.dropLast(1) + presenter, action = Action.REPLACE) } private fun updateBackstack( - backstack: List>, + backstack: List>, action: Action, ) { val backstackChange = BackstackChangeImpl(backstack = backstack.toList(), action = action) @@ -116,7 +116,7 @@ public class FakePresenterBackstackScope( } private class BackstackChangeImpl( - override val backstack: List>, + override val backstack: List>, override val action: Action, ) : BackstackChange } diff --git a/presenter-backstack-nav3/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/TestPresenterBackstackScopePresenter.kt b/presenter-backstack-nav3/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/TestPresenterBackstackScopePresenter.kt index beaae660..57d69dfa 100644 --- a/presenter-backstack-nav3/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/TestPresenterBackstackScopePresenter.kt +++ b/presenter-backstack-nav3/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/backstack/nav3/TestPresenterBackstackScopePresenter.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.withCompositionLocal import software.ralf.app.platform.ExperimentalAppPlatform import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter /** * Wraps the receiver presenter with another presenter to provide a [PresenterBackstackScope] as @@ -52,12 +52,12 @@ import software.ralf.app.platform.presenter.molecule.MoleculePresenter * ``` */ @ExperimentalAppPlatform -public fun MoleculePresenter +public fun ComposePresenter .withPresenterBackstackScope( scope: PresenterBackstackScope = FakePresenterBackstackScope() -): MoleculePresenter { +): ComposePresenter { val delegate = this - return object : MoleculePresenter { + return object : ComposePresenter { @Composable override fun present(input: InputT): ModelT { return withCompositionLocal(LocalBackstackScope provides scope) { diff --git a/presenter-backstack-nav3/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/backstack/nav3/FakePresenterBackstackScopeTest.kt b/presenter-backstack-nav3/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/backstack/nav3/FakePresenterBackstackScopeTest.kt index 8e44f5df..68f79c2a 100644 --- a/presenter-backstack-nav3/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/backstack/nav3/FakePresenterBackstackScopeTest.kt +++ b/presenter-backstack-nav3/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/backstack/nav3/FakePresenterBackstackScopeTest.kt @@ -10,7 +10,7 @@ import kotlin.test.Test import software.ralf.app.platform.ExperimentalAppPlatform import software.ralf.app.platform.presenter.BaseModel import software.ralf.app.platform.presenter.backstack.nav3.PresenterBackstackScope.BackstackChange.Action -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter class FakePresenterBackstackScopeTest { @Test @@ -89,7 +89,7 @@ class FakePresenterBackstackScopeTest { assertThat(scope.lastBackstackChange.value).isSameInstanceAs(changes.last()) } - private class TestPresenter(private val id: String) : MoleculePresenter { + private class TestPresenter(private val id: String) : ComposePresenter { @Composable override fun present(input: Unit): BaseModel { return TestModel(id) diff --git a/presenter-backstack-nav3/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/backstack/nav3/TestPresenterBackstackScopePresenterTest.kt b/presenter-backstack-nav3/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/backstack/nav3/TestPresenterBackstackScopePresenterTest.kt index a2daa592..60c0ddd9 100644 --- a/presenter-backstack-nav3/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/backstack/nav3/TestPresenterBackstackScopePresenterTest.kt +++ b/presenter-backstack-nav3/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/backstack/nav3/TestPresenterBackstackScopePresenterTest.kt @@ -15,14 +15,14 @@ import kotlinx.coroutines.test.runTest import software.ralf.app.platform.ExperimentalAppPlatform import software.ralf.app.platform.presenter.BaseModel import software.ralf.app.platform.presenter.backstack.nav3.PresenterBackstackScope.BackstackChange.Action -import software.ralf.app.platform.presenter.molecule.MoleculePresenter -import software.ralf.app.platform.presenter.molecule.test +import software.ralf.app.platform.presenter.compose.ComposePresenter +import software.ralf.app.platform.presenter.compose.test class TestPresenterBackstackScopePresenterTest { @Test fun `a presenter cannot be tested without the backstack scope wrapper`() = runTest { val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): BaseModel { LocalBackstackScope.requireNotNull() @@ -39,7 +39,7 @@ class TestPresenterBackstackScopePresenterTest { data class Model(val scope: PresenterBackstackScope) : BaseModel val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { return Model(LocalBackstackScope.requireNotNull()) @@ -54,10 +54,10 @@ class TestPresenterBackstackScopePresenterTest { @Test fun `the default fake does not add the receiver presenter to the backstack`() = runTest { - data class Model(val backstack: List>) : BaseModel + data class Model(val backstack: List>) : BaseModel val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { return Model(LocalBackstackScope.requireNotNull().backstack) @@ -79,7 +79,7 @@ class TestPresenterBackstackScopePresenterTest { val scope = FakePresenterBackstackScope() val rootPresenter = scope.backstack.single() val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { val backstackScope = LocalBackstackScope.requireNotNull() @@ -108,7 +108,7 @@ class TestPresenterBackstackScopePresenterTest { val childPresenter = TestPresenter("child") val scope = FakePresenterBackstackScope(rootPresenter) val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { val backstackScope = LocalBackstackScope.requireNotNull() @@ -140,7 +140,7 @@ class TestPresenterBackstackScopePresenterTest { val childPresenter = TestPresenter("child") val scope = FakePresenterBackstackScope(rootPresenter) val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { val backstackScope = LocalBackstackScope.requireNotNull() @@ -164,7 +164,7 @@ class TestPresenterBackstackScopePresenterTest { val rootPresenter = TestPresenter("root") val scope = FakePresenterBackstackScope(rootPresenter) val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { val backstackScope = LocalBackstackScope.requireNotNull() @@ -186,7 +186,7 @@ class TestPresenterBackstackScopePresenterTest { } } - private class TestPresenter(private val id: String) : MoleculePresenter { + private class TestPresenter(private val id: String) : ComposePresenter { @Composable override fun present(input: Unit): BaseModel { return TestModel(id) diff --git a/presenter-compose/impl/api/android/impl.api b/presenter-compose/impl/api/android/impl.api new file mode 100644 index 00000000..cf88740c --- /dev/null +++ b/presenter-compose/impl/api/android/impl.api @@ -0,0 +1,85 @@ +public final class software/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactory : software/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory { + public static final field $stable I + public fun (Lkotlin/jvm/functions/Function0;)V + public fun createComposePresenterScope ()Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; + public fun createComposePresenterScopeFromCoroutineScope (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryComponent { + public fun provideAndroidComposePresenterScopeFactory (Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; +} + +public final class software/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryComponent$DefaultImpls { + public static fun provideAndroidComposePresenterScopeFactory (Lsoftware/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryComponent;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph { + public fun provideAndroidComposePresenterScopeFactory (Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; +} + +public final class software/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph$DefaultImpls { + public static fun provideAndroidComposePresenterScopeFactory (Lsoftware/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph$MetroContributionToAppScope : software/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph { +} + +public final class software/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph$MetroContributionToAppScope$DefaultImpls { + public static fun provideAndroidComposePresenterScopeFactory (Lsoftware/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph$MetroContributionToAppScope;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; +} + +public final class software/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph$ProvideAndroidComposePresenterScopeFactoryMetroFactory : dev/zacsweers/metro/internal/Factory { + public static final field $stable I + public static final field Companion Lsoftware/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph$ProvideAndroidComposePresenterScopeFactoryMetroFactory$Companion; + public synthetic fun (Lsoftware/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph;Ldev/zacsweers/metro/Provider;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public static final fun create (Lsoftware/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph;Ldev/zacsweers/metro/Provider;)Lsoftware/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph$ProvideAndroidComposePresenterScopeFactoryMetroFactory; + public final fun declarationMirror (Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; + public synthetic fun invoke ()Ljava/lang/Object; + public final fun invoke ()Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; + public static final fun provideAndroidComposePresenterScopeFactory (Lsoftware/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; +} + +public final class software/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph$ProvideAndroidComposePresenterScopeFactoryMetroFactory$Companion { + public final fun create (Lsoftware/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph;Ldev/zacsweers/metro/Provider;)Lsoftware/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph$ProvideAndroidComposePresenterScopeFactoryMetroFactory; + public final fun provideAndroidComposePresenterScopeFactory (Lsoftware/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactoryGraph;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterComponent { + public fun provideDefaultBackGestureDispatcherPresenter ()Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterComponent$DefaultImpls { + public static fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterComponent;)Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph { + public fun provideDefaultBackGestureDispatcherPresenter ()Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$DefaultImpls { + public static fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$MetroContributionToAppScope : software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph { +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$MetroContributionToAppScope$DefaultImpls { + public static fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$MetroContributionToAppScope;)Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory : dev/zacsweers/metro/internal/Factory { + public static final field $stable I + public static final field Companion Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory$Companion; + public synthetic fun (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public static final fun create (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory; + public final fun declarationMirror ()Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; + public synthetic fun invoke ()Ljava/lang/Object; + public final fun invoke ()Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; + public static final fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory$Companion { + public final fun create (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory; + public final fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + diff --git a/presenter-compose/impl/api/desktop/impl.api b/presenter-compose/impl/api/desktop/impl.api new file mode 100644 index 00000000..b3be07a0 --- /dev/null +++ b/presenter-compose/impl/api/desktop/impl.api @@ -0,0 +1,73 @@ +public final class software/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactory : software/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory { + public static final field $stable I + public fun (Lkotlin/jvm/functions/Function0;)V + public fun createComposePresenterScope ()Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; + public fun createComposePresenterScopeFromCoroutineScope (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryComponent { + public fun provideDesktopComposePresenterScopeFactory (Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; +} + +public final class software/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryComponent$DefaultImpls { + public static fun provideDesktopComposePresenterScopeFactory (Lsoftware/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryComponent;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryGraph { + public fun provideDesktopComposePresenterScopeFactory (Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; +} + +public final class software/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryGraph$DefaultImpls { + public static fun provideDesktopComposePresenterScopeFactory (Lsoftware/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryGraph;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; +} + +public final class software/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryGraph$ProvideDesktopComposePresenterScopeFactoryMetroFactory : dev/zacsweers/metro/internal/Factory { + public static final field $stable I + public static final field Companion Lsoftware/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryGraph$ProvideDesktopComposePresenterScopeFactoryMetroFactory$Companion; + public synthetic fun (Lsoftware/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryGraph;Ldev/zacsweers/metro/Provider;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public static final fun create (Lsoftware/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryGraph;Ldev/zacsweers/metro/Provider;)Lsoftware/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryGraph$ProvideDesktopComposePresenterScopeFactoryMetroFactory; + public final fun declarationMirror (Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; + public synthetic fun invoke ()Ljava/lang/Object; + public final fun invoke ()Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; + public static final fun provideDesktopComposePresenterScopeFactory (Lsoftware/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryGraph;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; +} + +public final class software/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryGraph$ProvideDesktopComposePresenterScopeFactoryMetroFactory$Companion { + public fun ()V + public final fun create (Lsoftware/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryGraph;Ldev/zacsweers/metro/Provider;)Lsoftware/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryGraph$ProvideDesktopComposePresenterScopeFactoryMetroFactory; + public final fun provideDesktopComposePresenterScopeFactory (Lsoftware/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactoryGraph;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterComponent { + public fun provideDefaultBackGestureDispatcherPresenter ()Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterComponent$DefaultImpls { + public static fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterComponent;)Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph { + public fun provideDefaultBackGestureDispatcherPresenter ()Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$DefaultImpls { + public static fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory : dev/zacsweers/metro/internal/Factory { + public static final field $stable I + public static final field Companion Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory$Companion; + public synthetic fun (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public static final fun create (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory; + public final fun declarationMirror ()Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; + public synthetic fun invoke ()Ljava/lang/Object; + public final fun invoke ()Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; + public static final fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory$Companion { + public fun ()V + public final fun create (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory; + public final fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + diff --git a/presenter-molecule/impl/build.gradle b/presenter-compose/impl/build.gradle similarity index 100% rename from presenter-molecule/impl/build.gradle rename to presenter-compose/impl/build.gradle diff --git a/presenter-molecule/impl/src/androidMain/kotlin/software/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactory.kt b/presenter-compose/impl/src/androidMain/kotlin/software/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactory.kt similarity index 52% rename from presenter-molecule/impl/src/androidMain/kotlin/software/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactory.kt rename to presenter-compose/impl/src/androidMain/kotlin/software/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactory.kt index 408ee614..9f510e6b 100644 --- a/presenter-molecule/impl/src/androidMain/kotlin/software/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactory.kt +++ b/presenter-compose/impl/src/androidMain/kotlin/software/ralf/app/platform/presenter/compose/AndroidComposePresenterScopeFactory.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import app.cash.molecule.AndroidUiDispatcher import app.cash.molecule.RecompositionMode @@ -14,34 +14,36 @@ import software.amazon.lastmile.kotlin.inject.anvil.SingleIn as KiSingleIn import software.ralf.app.platform.presenter.PresenterCoroutineScope /** - * Runs `MoleculePresenters` on the main thread provided by [PresenterCoroutineScope] and recomposes + * Runs `ComposePresenters` on the main thread provided by [PresenterCoroutineScope] and recomposes * only once per screen refresh when needed. */ -public class AndroidMoleculeScopeFactory(coroutineScopeFactory: () -> CoroutineScope) : - MoleculeScopeFactory by DefaultMoleculeScopeFactory( +public class AndroidComposePresenterScopeFactory(coroutineScopeFactory: () -> CoroutineScope) : + ComposePresenterScopeFactory by DefaultComposePresenterScopeFactory( coroutineScopeFactory = coroutineScopeFactory, coroutineContext = AndroidUiDispatcher.Main, recompositionMode = RecompositionMode.ContextClock, ) -/** Provides the [AndroidMoleculeScopeFactory] in the kotlin-inject graph. */ +/** Provides the [AndroidComposePresenterScopeFactory] in the kotlin-inject graph. */ @KiContributesTo(KiAppScope::class) -public interface AndroidMoleculeScopeFactoryComponent { - /** Provides the [AndroidMoleculeScopeFactory] in the kotlin-inject graph as a singleton. */ +public interface AndroidComposePresenterScopeFactoryComponent { + /** + * Provides the [AndroidComposePresenterScopeFactory] in the kotlin-inject graph as a singleton. + */ @KiProvides @KiSingleIn(KiAppScope::class) - public fun provideAndroidMoleculeScopeFactory( + public fun provideAndroidComposePresenterScopeFactory( @PresenterCoroutineScope coroutineScopeFactory: () -> CoroutineScope - ): MoleculeScopeFactory = AndroidMoleculeScopeFactory(coroutineScopeFactory) + ): ComposePresenterScopeFactory = AndroidComposePresenterScopeFactory(coroutineScopeFactory) } -/** Provides the [AndroidMoleculeScopeFactory] in the Metro graph. */ +/** Provides the [AndroidComposePresenterScopeFactory] in the Metro graph. */ @MetroContributesTo(MetroAppScope::class) -public interface AndroidMoleculeScopeFactoryGraph { - /** Provides the [AndroidMoleculeScopeFactory] in the Metro graph as a singleton. */ +public interface AndroidComposePresenterScopeFactoryGraph { + /** Provides the [AndroidComposePresenterScopeFactory] in the Metro graph as a singleton. */ @MetroProvides @MetroSingleIn(MetroAppScope::class) - public fun provideAndroidMoleculeScopeFactory( + public fun provideAndroidComposePresenterScopeFactory( @PresenterCoroutineScope coroutineScopeFactory: () -> CoroutineScope - ): MoleculeScopeFactory = AndroidMoleculeScopeFactory { coroutineScopeFactory() } + ): ComposePresenterScopeFactory = AndroidComposePresenterScopeFactory { coroutineScopeFactory() } } diff --git a/presenter-compose/impl/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/DefaultComposePresenterScopeFactory.kt b/presenter-compose/impl/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/DefaultComposePresenterScopeFactory.kt new file mode 100644 index 00000000..3a724dea --- /dev/null +++ b/presenter-compose/impl/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/DefaultComposePresenterScopeFactory.kt @@ -0,0 +1,33 @@ +package software.ralf.app.platform.presenter.compose + +import app.cash.molecule.RecompositionMode +import kotlin.coroutines.CoroutineContext +import kotlin.coroutines.EmptyCoroutineContext +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.plus +import software.ralf.app.platform.presenter.PresenterCoroutineScope + +/** + * Creates new [ComposePresenterScope]s with the given defaults. When calling + * [createComposePresenterScope], then [coroutineScopeFactory] is used as default scope. + * [coroutineContext] allows you to add additional elements to created scopes. [recompositionMode] + * is used for launching [ComposePresenter]s. + */ +internal class DefaultComposePresenterScopeFactory( + @PresenterCoroutineScope private val coroutineScopeFactory: () -> CoroutineScope, + private val coroutineContext: CoroutineContext = EmptyCoroutineContext, + private val recompositionMode: RecompositionMode, +) : ComposePresenterScopeFactory { + + override fun createComposePresenterScope(): ComposePresenterScope = + createComposePresenterScopeFromCoroutineScope(coroutineScopeFactory()) + + override fun createComposePresenterScopeFromCoroutineScope( + coroutineScope: CoroutineScope, + coroutineContext: CoroutineContext, + ): ComposePresenterScope = + ComposePresenterScope( + coroutineScope = coroutineScope + this.coroutineContext + coroutineContext, + recompositionMode = recompositionMode, + ) +} diff --git a/presenter-molecule/impl/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenter.kt b/presenter-compose/impl/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenter.kt similarity index 96% rename from presenter-molecule/impl/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenter.kt rename to presenter-compose/impl/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenter.kt index 506f538a..04d60e3a 100644 --- a/presenter-molecule/impl/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenter.kt +++ b/presenter-compose/impl/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/DefaultBackGestureDispatcherPresenter.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.backgesture +package software.ralf.app.platform.presenter.compose.backgesture import dev.zacsweers.metro.AppScope as MetroAppScope import dev.zacsweers.metro.ContributesTo as MetroContributesTo diff --git a/presenter-molecule/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/DefaultMoleculeScopeFactoryTest.kt b/presenter-compose/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/DefaultComposePresenterScopeFactoryTest.kt similarity index 54% rename from presenter-molecule/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/DefaultMoleculeScopeFactoryTest.kt rename to presenter-compose/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/DefaultComposePresenterScopeFactoryTest.kt index 49880a84..d7fbbc73 100644 --- a/presenter-molecule/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/DefaultMoleculeScopeFactoryTest.kt +++ b/presenter-compose/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/DefaultComposePresenterScopeFactoryTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import app.cash.molecule.RecompositionMode import assertk.assertThat @@ -9,54 +9,54 @@ import kotlin.test.Test import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope -class DefaultMoleculeScopeFactoryTest { +class DefaultComposePresenterScopeFactoryTest { @Test - fun `the default provided coroutine scope is used when creating a new MoleculeScope`() { + fun `the default provided coroutine scope is used when creating a new ComposePresenterScope`() { val factory = factory(scope = CoroutineScope(CoroutineName("abc"))) - val moleculeScope = factory.createMoleculeScope() + val composePresenterScope = factory.createComposePresenterScope() - assertThat(moleculeScope.name).isEqualTo("abc") + assertThat(composePresenterScope.name).isEqualTo("abc") } @Test - fun `the given coroutine scope is used when creating a new MoleculeScope`() { + fun `the given coroutine scope is used when creating a new ComposePresenterScope`() { val factory = factory(scope = CoroutineScope(CoroutineName("abc"))) - val moleculeScope = - factory.createMoleculeScopeFromCoroutineScope(CoroutineScope(CoroutineName("def"))) + val composePresenterScope = + factory.createComposePresenterScopeFromCoroutineScope(CoroutineScope(CoroutineName("def"))) - assertThat(moleculeScope.name).isEqualTo("def") + assertThat(composePresenterScope.name).isEqualTo("def") } @Test - fun `default coroutine context elements are applied when creating a new MoleculeScope`() { + fun `default coroutine context elements are applied when creating a new ComposePresenterScope`() { val factory = factory(coroutineContext = CoroutineName("abc")) - val moleculeScope = factory.createMoleculeScope() + val composePresenterScope = factory.createComposePresenterScope() - assertThat(moleculeScope.name).isEqualTo("abc") + assertThat(composePresenterScope.name).isEqualTo("abc") } @Test - fun `the given coroutine context elements override default elements when creating a new MoleculeScope`() { + fun `given coroutine context elements override defaults when creating a ComposePresenterScope`() { val factory = factory(coroutineContext = CoroutineName("abc")) - val moleculeScope = - factory.createMoleculeScopeFromCoroutineScope( + val composePresenterScope = + factory.createComposePresenterScopeFromCoroutineScope( coroutineScope = CoroutineScope(EmptyCoroutineContext), coroutineContext = CoroutineName("def"), ) - assertThat(moleculeScope.name).isEqualTo("def") + assertThat(composePresenterScope.name).isEqualTo("def") } private fun factory( scope: CoroutineScope = CoroutineScope(EmptyCoroutineContext), coroutineContext: CoroutineContext = EmptyCoroutineContext, ) = - DefaultMoleculeScopeFactory( + DefaultComposePresenterScopeFactory( coroutineScopeFactory = { scope }, coroutineContext = coroutineContext, recompositionMode = RecompositionMode.Immediate, ) - private val MoleculeScope.name: String + private val ComposePresenterScope.name: String get() = requireNotNull(coroutineScope.coroutineContext[CoroutineName.Key]?.name) } diff --git a/presenter-molecule/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/KotlinInjectInjectionTest.kt b/presenter-compose/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/KotlinInjectInjectionTest.kt similarity index 77% rename from presenter-molecule/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/KotlinInjectInjectionTest.kt rename to presenter-compose/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/KotlinInjectInjectionTest.kt index 66218845..e23504c7 100644 --- a/presenter-molecule/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/KotlinInjectInjectionTest.kt +++ b/presenter-compose/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/KotlinInjectInjectionTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import app.cash.molecule.RecompositionMode import assertk.assertThat @@ -29,12 +29,12 @@ class KotlinInjectInjectionTest { val component = createTestComponent(testScope, testDispatcher) - val moleculeScope = component.moleculeScopeFactory.createMoleculeScope() + val composePresenterScope = component.composePresenterScopeFactory.createComposePresenterScope() - assertThat(moleculeScope.coroutineScope.coroutineContext[CoroutineName.Key]?.name) + assertThat(composePresenterScope.coroutineScope.coroutineContext[CoroutineName.Key]?.name) .isEqualTo("TestName") - moleculeScope.cancel() + composePresenterScope.cancel() } } @@ -44,7 +44,7 @@ abstract class KotlinInjectTestComponent( private val coroutineScope: CoroutineScope, private val coroutineDispatcher: CoroutineDispatcher, ) : PresenterCoroutineScopeComponent { - abstract val moleculeScopeFactory: MoleculeScopeFactory + abstract val composePresenterScopeFactory: ComposePresenterScopeFactory @Provides @ForScope(AppScope::class) @@ -55,17 +55,17 @@ abstract class KotlinInjectTestComponent( fun provideMainCoroutineDispatcher(): CoroutineDispatcher = coroutineDispatcher @Provides - fun provideMoleculeScopeFactory( - factory: KotlinInjectTestMoleculeScopeFactory - ): MoleculeScopeFactory = factory + fun provideComposePresenterScopeFactory( + factory: KotlinInjectTestComposePresenterScopeFactory + ): ComposePresenterScopeFactory = factory } @Inject @SingleIn(AppScope::class) -class KotlinInjectTestMoleculeScopeFactory( +class KotlinInjectTestComposePresenterScopeFactory( @PresenterCoroutineScope coroutineScopeFactory: () -> CoroutineScope ) : - MoleculeScopeFactory by DefaultMoleculeScopeFactory( + ComposePresenterScopeFactory by DefaultComposePresenterScopeFactory( coroutineScopeFactory = coroutineScopeFactory, coroutineContext = EmptyCoroutineContext, recompositionMode = RecompositionMode.Immediate, diff --git a/presenter-molecule/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/MetroInjectionTest.kt b/presenter-compose/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/MetroInjectionTest.kt similarity index 72% rename from presenter-molecule/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/MetroInjectionTest.kt rename to presenter-compose/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/MetroInjectionTest.kt index a77e0f44..bbcd8c0b 100644 --- a/presenter-molecule/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/MetroInjectionTest.kt +++ b/presenter-compose/impl/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/MetroInjectionTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import app.cash.molecule.RecompositionMode import assertk.assertThat @@ -24,12 +24,12 @@ class MetroInjectionTest { val component = createGraphFactory().create(testScope) - val moleculeScope = component.moleculeScopeFactory.createMoleculeScope() + val composePresenterScope = component.composePresenterScopeFactory.createComposePresenterScope() - assertThat(moleculeScope.coroutineScope.coroutineContext[CoroutineName.Key]?.name) + assertThat(composePresenterScope.coroutineScope.coroutineContext[CoroutineName.Key]?.name) .isEqualTo("TestName") - moleculeScope.cancel() + composePresenterScope.cancel() } } @@ -45,17 +45,17 @@ interface MetroTestComponent { ): MetroTestComponent } - val moleculeScopeFactory: MoleculeScopeFactory + val composePresenterScopeFactory: ComposePresenterScopeFactory - @Binds val MetroTestMoleculeScopeFactory.bind: MoleculeScopeFactory + @Binds val MetroTestComposePresenterScopeFactory.bind: ComposePresenterScopeFactory } @Inject @SingleIn(AppScope::class) -class MetroTestMoleculeScopeFactory( +class MetroTestComposePresenterScopeFactory( @PresenterCoroutineScope coroutineScopeFactory: () -> CoroutineScope ) : - MoleculeScopeFactory by DefaultMoleculeScopeFactory( + ComposePresenterScopeFactory by DefaultComposePresenterScopeFactory( coroutineScopeFactory = { coroutineScopeFactory() }, coroutineContext = EmptyCoroutineContext, recompositionMode = RecompositionMode.Immediate, diff --git a/presenter-molecule/impl/src/wasmJsMain/kotlin/software/ralf/app/platform/presenter/molecule/WasmJsMoleculeScopeFactory.kt b/presenter-compose/impl/src/desktopMain/kotlin/software/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactory.kt similarity index 50% rename from presenter-molecule/impl/src/wasmJsMain/kotlin/software/ralf/app/platform/presenter/molecule/WasmJsMoleculeScopeFactory.kt rename to presenter-compose/impl/src/desktopMain/kotlin/software/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactory.kt index bb81dc5b..970b7893 100644 --- a/presenter-molecule/impl/src/wasmJsMain/kotlin/software/ralf/app/platform/presenter/molecule/WasmJsMoleculeScopeFactory.kt +++ b/presenter-compose/impl/src/desktopMain/kotlin/software/ralf/app/platform/presenter/compose/DesktopComposePresenterScopeFactory.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import app.cash.molecule.RecompositionMode import dev.zacsweers.metro.AppScope as MetroAppScope @@ -13,33 +13,35 @@ import software.amazon.lastmile.kotlin.inject.anvil.SingleIn as KiSingleIn import software.ralf.app.platform.presenter.PresenterCoroutineScope /** - * Runs `MoleculePresenters` on the main thread provided by [PresenterCoroutineScope] and recomposes + * Runs `ComposePresenters` on the main thread provided by [PresenterCoroutineScope] and recomposes * as fast as possible. */ -public class WasmJsMoleculeScopeFactory(coroutineScopeFactory: () -> CoroutineScope) : - MoleculeScopeFactory by DefaultMoleculeScopeFactory( +public class DesktopComposePresenterScopeFactory(coroutineScopeFactory: () -> CoroutineScope) : + ComposePresenterScopeFactory by DefaultComposePresenterScopeFactory( coroutineScopeFactory = coroutineScopeFactory, recompositionMode = RecompositionMode.Immediate, ) -/** Provides the [WasmJsMoleculeScopeFactory] in the kotlin-inject graph. */ +/** Provides the [DesktopComposePresenterScopeFactory] in the kotlin-inject graph. */ @KiContributesTo(KiAppScope::class) -public interface WasmJsMoleculeScopeFactoryComponent { - /** Provides the [WasmJsMoleculeScopeFactory] in the kotlin-inject graph as a singleton. */ +public interface DesktopComposePresenterScopeFactoryComponent { + /** + * Provides the [DesktopComposePresenterScopeFactory] in the kotlin-inject graph as a singleton. + */ @KiProvides @KiSingleIn(KiAppScope::class) - public fun provideWasmJsMoleculeScopeFactory( + public fun provideDesktopComposePresenterScopeFactory( @PresenterCoroutineScope coroutineScopeFactory: () -> CoroutineScope - ): MoleculeScopeFactory = WasmJsMoleculeScopeFactory(coroutineScopeFactory) + ): ComposePresenterScopeFactory = DesktopComposePresenterScopeFactory(coroutineScopeFactory) } -/** Provides the [WasmJsMoleculeScopeFactory] in the Metro graph. */ +/** Provides the [DesktopComposePresenterScopeFactory] in the Metro graph. */ @MetroContributesTo(MetroAppScope::class) -public interface WasmJsMoleculeScopeFactoryGraph { - /** Provides the [WasmJsMoleculeScopeFactory] in the Metro graph as a singleton. */ +public interface DesktopComposePresenterScopeFactoryGraph { + /** Provides the [DesktopComposePresenterScopeFactory] in the Metro graph as a singleton. */ @MetroProvides @MetroSingleIn(MetroAppScope::class) - public fun provideWasmJsMoleculeScopeFactory( + public fun provideDesktopComposePresenterScopeFactory( @PresenterCoroutineScope coroutineScopeFactory: () -> CoroutineScope - ): MoleculeScopeFactory = WasmJsMoleculeScopeFactory { coroutineScopeFactory() } + ): ComposePresenterScopeFactory = DesktopComposePresenterScopeFactory { coroutineScopeFactory() } } diff --git a/presenter-molecule/impl/src/iosMain/kotlin/software/ralf/app/platform/presenter/molecule/IosMoleculeScopeFactory.kt b/presenter-compose/impl/src/iosMain/kotlin/software/ralf/app/platform/presenter/compose/IosComposePresenterScopeFactory.kt similarity index 54% rename from presenter-molecule/impl/src/iosMain/kotlin/software/ralf/app/platform/presenter/molecule/IosMoleculeScopeFactory.kt rename to presenter-compose/impl/src/iosMain/kotlin/software/ralf/app/platform/presenter/compose/IosComposePresenterScopeFactory.kt index 01b4dde8..06f91b83 100644 --- a/presenter-molecule/impl/src/iosMain/kotlin/software/ralf/app/platform/presenter/molecule/IosMoleculeScopeFactory.kt +++ b/presenter-compose/impl/src/iosMain/kotlin/software/ralf/app/platform/presenter/compose/IosComposePresenterScopeFactory.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import app.cash.molecule.DisplayLinkClock import app.cash.molecule.RecompositionMode @@ -14,34 +14,34 @@ import software.amazon.lastmile.kotlin.inject.anvil.SingleIn as KiSingleIn import software.ralf.app.platform.presenter.PresenterCoroutineScope /** - * Runs `MoleculePresenters` on the main thread provided by [PresenterCoroutineScope] and recomposes + * Runs `ComposePresenters` on the main thread provided by [PresenterCoroutineScope] and recomposes * only once per screen refresh when needed. */ -public class IosMoleculeScopeFactory(coroutineScopeFactory: () -> CoroutineScope) : - MoleculeScopeFactory by DefaultMoleculeScopeFactory( +public class IosComposePresenterScopeFactory(coroutineScopeFactory: () -> CoroutineScope) : + ComposePresenterScopeFactory by DefaultComposePresenterScopeFactory( coroutineScopeFactory = coroutineScopeFactory, coroutineContext = DisplayLinkClock, recompositionMode = RecompositionMode.ContextClock, ) -/** Provides the [IosMoleculeScopeFactory] in the kotlin-inject graph. */ +/** Provides the [IosComposePresenterScopeFactory] in the kotlin-inject graph. */ @KiContributesTo(KiAppScope::class) -public interface IosMoleculeScopeFactoryComponent { - /** Provides the [IosMoleculeScopeFactory] in the kotlin-inject graph as a singleton. */ +public interface IosComposePresenterScopeFactoryComponent { + /** Provides the [IosComposePresenterScopeFactory] in the kotlin-inject graph as a singleton. */ @KiProvides @KiSingleIn(KiAppScope::class) - public fun provideIosMoleculeScopeFactory( + public fun provideIosComposePresenterScopeFactory( @PresenterCoroutineScope coroutineScopeFactory: () -> CoroutineScope - ): MoleculeScopeFactory = IosMoleculeScopeFactory(coroutineScopeFactory) + ): ComposePresenterScopeFactory = IosComposePresenterScopeFactory(coroutineScopeFactory) } -/** Provides the [IosMoleculeScopeFactory] in the Metro graph. */ +/** Provides the [IosComposePresenterScopeFactory] in the Metro graph. */ @MetroContributesTo(MetroAppScope::class) -public interface IosMoleculeScopeFactoryGraph { - /** Provides the [IosMoleculeScopeFactory] in the Metro graph as a singleton. */ +public interface IosComposePresenterScopeFactoryGraph { + /** Provides the [IosComposePresenterScopeFactory] in the Metro graph as a singleton. */ @MetroProvides @MetroSingleIn(MetroAppScope::class) - public fun provideIosMoleculeScopeFactory( + public fun provideIosComposePresenterScopeFactory( @PresenterCoroutineScope coroutineScopeFactory: () -> CoroutineScope - ): MoleculeScopeFactory = IosMoleculeScopeFactory { coroutineScopeFactory() } + ): ComposePresenterScopeFactory = IosComposePresenterScopeFactory { coroutineScopeFactory() } } diff --git a/presenter-molecule/impl/src/desktopMain/kotlin/software/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactory.kt b/presenter-compose/impl/src/linuxMain/kotlin/software/ralf/app/platform/presenter/compose/LinuxComposePresenterScopeFactory.kt similarity index 51% rename from presenter-molecule/impl/src/desktopMain/kotlin/software/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactory.kt rename to presenter-compose/impl/src/linuxMain/kotlin/software/ralf/app/platform/presenter/compose/LinuxComposePresenterScopeFactory.kt index e1d423e1..dc4b3cad 100644 --- a/presenter-molecule/impl/src/desktopMain/kotlin/software/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactory.kt +++ b/presenter-compose/impl/src/linuxMain/kotlin/software/ralf/app/platform/presenter/compose/LinuxComposePresenterScopeFactory.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import app.cash.molecule.RecompositionMode import dev.zacsweers.metro.AppScope as MetroAppScope @@ -13,33 +13,33 @@ import software.amazon.lastmile.kotlin.inject.anvil.SingleIn as KiSingleIn import software.ralf.app.platform.presenter.PresenterCoroutineScope /** - * Runs `MoleculePresenters` on the main thread provided by [PresenterCoroutineScope] and recomposes + * Runs `ComposePresenters` on the main thread provided by [PresenterCoroutineScope] and recomposes * as fast as possible. */ -public class DesktopMoleculeScopeFactory(coroutineScopeFactory: () -> CoroutineScope) : - MoleculeScopeFactory by DefaultMoleculeScopeFactory( +public class LinuxComposePresenterScopeFactory(coroutineScopeFactory: () -> CoroutineScope) : + ComposePresenterScopeFactory by DefaultComposePresenterScopeFactory( coroutineScopeFactory = coroutineScopeFactory, recompositionMode = RecompositionMode.Immediate, ) -/** Provides the [DesktopMoleculeScopeFactory] in the kotlin-inject graph. */ +/** Provides the [LinuxComposePresenterScopeFactory] in the kotlin-inject graph. */ @KiContributesTo(KiAppScope::class) -public interface DesktopMoleculeScopeFactoryComponent { - /** Provides the [DesktopMoleculeScopeFactory] in the kotlin-inject graph as a singleton. */ +public interface LinuxComposePresenterScopeFactoryComponent { + /** Provides the [LinuxComposePresenterScopeFactory] in the kotlin-inject graph as a singleton. */ @KiProvides @KiSingleIn(KiAppScope::class) - public fun provideDesktopMoleculeScopeFactory( + public fun provideLinuxComposePresenterScopeFactory( @PresenterCoroutineScope coroutineScopeFactory: () -> CoroutineScope - ): MoleculeScopeFactory = DesktopMoleculeScopeFactory(coroutineScopeFactory) + ): ComposePresenterScopeFactory = LinuxComposePresenterScopeFactory(coroutineScopeFactory) } -/** Provides the [DesktopMoleculeScopeFactory] in the Metro graph. */ +/** Provides the [LinuxComposePresenterScopeFactory] in the Metro graph. */ @MetroContributesTo(MetroAppScope::class) -public interface DesktopMoleculeScopeFactoryGraph { - /** Provides the [DesktopMoleculeScopeFactory] in the Metro graph as a singleton. */ +public interface LinuxComposePresenterScopeFactoryGraph { + /** Provides the [LinuxComposePresenterScopeFactory] in the Metro graph as a singleton. */ @MetroProvides @MetroSingleIn(MetroAppScope::class) - public fun provideDesktopMoleculeScopeFactory( + public fun provideLinuxComposePresenterScopeFactory( @PresenterCoroutineScope coroutineScopeFactory: () -> CoroutineScope - ): MoleculeScopeFactory = DesktopMoleculeScopeFactory { coroutineScopeFactory() } + ): ComposePresenterScopeFactory = LinuxComposePresenterScopeFactory { coroutineScopeFactory() } } diff --git a/presenter-molecule/impl/src/linuxMain/kotlin/software/ralf/app/platform/presenter/molecule/LinuxMoleculeScopeFactory.kt b/presenter-compose/impl/src/wasmJsMain/kotlin/software/ralf/app/platform/presenter/compose/WasmJsComposePresenterScopeFactory.kt similarity index 50% rename from presenter-molecule/impl/src/linuxMain/kotlin/software/ralf/app/platform/presenter/molecule/LinuxMoleculeScopeFactory.kt rename to presenter-compose/impl/src/wasmJsMain/kotlin/software/ralf/app/platform/presenter/compose/WasmJsComposePresenterScopeFactory.kt index 9ac7adf1..c4e9ea0c 100644 --- a/presenter-molecule/impl/src/linuxMain/kotlin/software/ralf/app/platform/presenter/molecule/LinuxMoleculeScopeFactory.kt +++ b/presenter-compose/impl/src/wasmJsMain/kotlin/software/ralf/app/platform/presenter/compose/WasmJsComposePresenterScopeFactory.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import app.cash.molecule.RecompositionMode import dev.zacsweers.metro.AppScope as MetroAppScope @@ -13,33 +13,35 @@ import software.amazon.lastmile.kotlin.inject.anvil.SingleIn as KiSingleIn import software.ralf.app.platform.presenter.PresenterCoroutineScope /** - * Runs `MoleculePresenters` on the main thread provided by [PresenterCoroutineScope] and recomposes + * Runs `ComposePresenters` on the main thread provided by [PresenterCoroutineScope] and recomposes * as fast as possible. */ -public class LinuxMoleculeScopeFactory(coroutineScopeFactory: () -> CoroutineScope) : - MoleculeScopeFactory by DefaultMoleculeScopeFactory( +public class WasmJsComposePresenterScopeFactory(coroutineScopeFactory: () -> CoroutineScope) : + ComposePresenterScopeFactory by DefaultComposePresenterScopeFactory( coroutineScopeFactory = coroutineScopeFactory, recompositionMode = RecompositionMode.Immediate, ) -/** Provides the [LinuxMoleculeScopeFactory] in the kotlin-inject graph. */ +/** Provides the [WasmJsComposePresenterScopeFactory] in the kotlin-inject graph. */ @KiContributesTo(KiAppScope::class) -public interface LinuxMoleculeScopeFactoryComponent { - /** Provides the [LinuxMoleculeScopeFactory] in the kotlin-inject graph as a singleton. */ +public interface WasmJsComposePresenterScopeFactoryComponent { + /** + * Provides the [WasmJsComposePresenterScopeFactory] in the kotlin-inject graph as a singleton. + */ @KiProvides @KiSingleIn(KiAppScope::class) - public fun provideLinuxMoleculeScopeFactory( + public fun provideWasmJsComposePresenterScopeFactory( @PresenterCoroutineScope coroutineScopeFactory: () -> CoroutineScope - ): MoleculeScopeFactory = LinuxMoleculeScopeFactory(coroutineScopeFactory) + ): ComposePresenterScopeFactory = WasmJsComposePresenterScopeFactory(coroutineScopeFactory) } -/** Provides the [LinuxMoleculeScopeFactory] in the Metro graph. */ +/** Provides the [WasmJsComposePresenterScopeFactory] in the Metro graph. */ @MetroContributesTo(MetroAppScope::class) -public interface LinuxMoleculeScopeFactoryGraph { - /** Provides the [LinuxMoleculeScopeFactory] in the Metro graph as a singleton. */ +public interface WasmJsComposePresenterScopeFactoryGraph { + /** Provides the [WasmJsComposePresenterScopeFactory] in the Metro graph as a singleton. */ @MetroProvides @MetroSingleIn(MetroAppScope::class) - public fun provideLinuxMoleculeScopeFactory( + public fun provideWasmJsComposePresenterScopeFactory( @PresenterCoroutineScope coroutineScopeFactory: () -> CoroutineScope - ): MoleculeScopeFactory = LinuxMoleculeScopeFactory { coroutineScopeFactory() } + ): ComposePresenterScopeFactory = WasmJsComposePresenterScopeFactory { coroutineScopeFactory() } } diff --git a/presenter-compose/public/api/android/public.api b/presenter-compose/public/api/android/public.api new file mode 100644 index 00000000..81db7faa --- /dev/null +++ b/presenter-compose/public/api/android/public.api @@ -0,0 +1,80 @@ +public final class software/ralf/app/platform/presenter/compose/LaunchComposePresenterKt { + public static final fun launchComposePresenter (Lkotlinx/coroutines/CoroutineScope;Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/flow/StateFlow;Lapp/cash/molecule/RecompositionMode;)Lsoftware/ralf/app/platform/presenter/Presenter; + public static final fun launchComposePresenter (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope;Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Ljava/lang/Object;)Lsoftware/ralf/app/platform/presenter/Presenter; + public static final fun launchComposePresenter (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope;Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/flow/StateFlow;)Lsoftware/ralf/app/platform/presenter/Presenter; + public static final fun presentDetached (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Ljava/lang/Object;Lapp/cash/molecule/RecompositionMode;Landroidx/compose/runtime/Composer;II)Lsoftware/ralf/app/platform/presenter/BaseModel; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/ComposePresenter { + public abstract fun present (Ljava/lang/Object;Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/BaseModel; +} + +public final class software/ralf/app/platform/presenter/compose/ComposePresenterScope { + public static final field $stable I + public fun (Lkotlinx/coroutines/CoroutineScope;Lapp/cash/molecule/RecompositionMode;)V + public final fun cancel ()V + public final fun getCoroutineScope ()Lkotlinx/coroutines/CoroutineScope; + public final fun getRecompositionMode ()Lapp/cash/molecule/RecompositionMode; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory { + public abstract fun createComposePresenterScope ()Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; + public abstract fun createComposePresenterScopeFromCoroutineScope (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; + public static synthetic fun createComposePresenterScopeFromCoroutineScope$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory;Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; +} + +public final class software/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory$DefaultImpls { + public static synthetic fun createComposePresenterScopeFromCoroutineScope$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory;Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/BackEventPresenter { + public static final field $stable I + public static final field Companion Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackEventPresenter$Companion; + public static final field EDGE_LEFT I + public static final field EDGE_RIGHT I + public fun (FFFI)V + public final fun getProgress ()F + public final fun getSwipeEdge ()I + public final fun getTouchX ()F + public final fun getTouchY ()F +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/BackEventPresenter$Companion { +} + +public abstract interface class software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter { + public static final field Companion Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter$Companion; + public abstract fun PredictiveBackHandlerPresenter (ZLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)V + public abstract fun getListenersCount ()Lkotlinx/coroutines/flow/StateFlow; + public abstract fun onPredictiveBack (Lkotlinx/coroutines/flow/Flow;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter$Companion { + public final fun createNewInstance ()Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenterKt { + public static final fun BackHandlerPresenter (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;ZLkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;II)V + public static final fun PredictiveBackHandlerPresenter (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;ZLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V + public static final fun getLocalBackGestureDispatcherPresenter ()Landroidx/compose/runtime/ProvidableCompositionLocal; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/saveable/ReturningSaveableStateHolder { + public abstract fun SaveableStateProvider (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)Ljava/lang/Object; + public abstract fun removeState (Ljava/lang/Object;)V +} + +public final class software/ralf/app/platform/presenter/compose/saveable/ReturningSaveableStateHolderKt { + public static final fun rememberReturningSaveableStateHolder (Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/compose/saveable/ReturningSaveableStateHolder; +} + +public final class software/ralf/app/platform/presenter/compose/text/PresenterTextFieldState : androidx/compose/runtime/State { + public static final field $stable I + public fun ()V + public fun (Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun clearText ()V + public synthetic fun getValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/String; + public final fun replaceText (Ljava/lang/String;)V +} diff --git a/presenter-compose/public/api/desktop/public.api b/presenter-compose/public/api/desktop/public.api new file mode 100644 index 00000000..dfc7b062 --- /dev/null +++ b/presenter-compose/public/api/desktop/public.api @@ -0,0 +1,85 @@ +public abstract interface class software/ralf/app/platform/presenter/compose/ComposePresenter { + public abstract fun present (Ljava/lang/Object;Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/BaseModel; +} + +public final class software/ralf/app/platform/presenter/compose/ComposePresenterScope { + public static final field $stable I + public fun (Lkotlinx/coroutines/CoroutineScope;Lapp/cash/molecule/RecompositionMode;)V + public final fun cancel ()V + public final fun getCoroutineScope ()Lkotlinx/coroutines/CoroutineScope; + public final fun getRecompositionMode ()Lapp/cash/molecule/RecompositionMode; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory { + public abstract fun createComposePresenterScope ()Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; + public abstract fun createComposePresenterScopeFromCoroutineScope (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; + public static synthetic fun createComposePresenterScopeFromCoroutineScope$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory;Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; +} + +public final class software/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory$DefaultImpls { + public static synthetic fun createComposePresenterScopeFromCoroutineScope$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory;Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; +} + +public final class software/ralf/app/platform/presenter/compose/LaunchComposePresenterKt { + public static final fun launchComposePresenter (Lkotlinx/coroutines/CoroutineScope;Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/flow/StateFlow;Lapp/cash/molecule/RecompositionMode;)Lsoftware/ralf/app/platform/presenter/Presenter; + public static final fun launchComposePresenter (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope;Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Ljava/lang/Object;)Lsoftware/ralf/app/platform/presenter/Presenter; + public static final fun launchComposePresenter (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope;Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/flow/StateFlow;)Lsoftware/ralf/app/platform/presenter/Presenter; + public static final fun presentDetached (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Ljava/lang/Object;Lapp/cash/molecule/RecompositionMode;Landroidx/compose/runtime/Composer;II)Lsoftware/ralf/app/platform/presenter/BaseModel; +} + +public final class software/ralf/app/platform/presenter/compose/WithLocalRetainedValuesStoreKt { + public static final fun withLocalRetainedValuesStore (Landroidx/compose/runtime/retain/RetainedValuesStore;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)Ljava/lang/Object; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/BackEventPresenter { + public static final field $stable I + public static final field Companion Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackEventPresenter$Companion; + public static final field EDGE_LEFT I + public static final field EDGE_RIGHT I + public fun (FFFI)V + public final fun getProgress ()F + public final fun getSwipeEdge ()I + public final fun getTouchX ()F + public final fun getTouchY ()F +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/BackEventPresenter$Companion { +} + +public abstract interface class software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter { + public static final field Companion Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter$Companion; + public abstract fun PredictiveBackHandlerPresenter (ZLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)V + public abstract fun getListenersCount ()Lkotlinx/coroutines/flow/StateFlow; + public abstract fun onPredictiveBack (Lkotlinx/coroutines/flow/Flow;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter$Companion { + public final fun createNewInstance ()Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenterKt { + public static final fun BackHandlerPresenter (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;ZLkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;II)V + public static final fun PredictiveBackHandlerPresenter (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;ZLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V + public static final fun getLocalBackGestureDispatcherPresenter ()Landroidx/compose/runtime/ProvidableCompositionLocal; +} + +public abstract interface class software/ralf/app/platform/presenter/compose/saveable/ReturningSaveableStateHolder { + public abstract fun SaveableStateProvider (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)Ljava/lang/Object; + public abstract fun removeState (Ljava/lang/Object;)V +} + +public final class software/ralf/app/platform/presenter/compose/saveable/ReturningSaveableStateHolderKt { + public static final fun rememberReturningSaveableStateHolder (Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/compose/saveable/ReturningSaveableStateHolder; +} + +public final class software/ralf/app/platform/presenter/compose/text/PresenterTextFieldState : androidx/compose/runtime/State { + public static final field $stable I + public fun ()V + public fun (Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun clearText ()V + public synthetic fun getValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/String; + public final fun replaceText (Ljava/lang/String;)V +} + diff --git a/presenter-molecule/public/build.gradle b/presenter-compose/public/build.gradle similarity index 88% rename from presenter-molecule/public/build.gradle rename to presenter-compose/public/build.gradle index 3b1c491f..da63a33c 100644 --- a/presenter-molecule/public/build.gradle +++ b/presenter-compose/public/build.gradle @@ -15,5 +15,5 @@ dependencies { commonMainImplementation libs.androidx.collection commonMainImplementation libs.androidx.lifecycle.runtime commonTestImplementation project(':internal:testing') - commonTestImplementation project(':presenter-molecule:testing') + commonTestImplementation project(':presenter-compose:testing') } diff --git a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/MoleculePresenter.kt b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenter.kt similarity index 75% rename from presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/MoleculePresenter.kt rename to presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenter.kt index d7250bea..4540cb8b 100644 --- a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/MoleculePresenter.kt +++ b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenter.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import androidx.compose.runtime.Composable import kotlinx.coroutines.flow.StateFlow @@ -6,24 +6,24 @@ import software.ralf.app.platform.presenter.BaseModel import software.ralf.app.platform.presenter.Presenter /** - * `MoleculePresenter` is a presenter that uses Compose core (don't confuse Compose core with - * Compose UI, Compose UI is built on-top of Compose core) to create a [StateFlow] of models. + * `ComposePresenter` is a presenter that uses Compose core (don't confuse Compose core with Compose + * UI, Compose UI is built on-top of Compose core) to create a [StateFlow] of models. * [Molecule](https://github.com/cashapp/molecule) is leveraged to turn the composable function * [present] into a `StateFlow`. By leveraging Compose we can turn reactive code built * on-top of Flow and its operators into imperative code using language statements like * `if-then-else`, `when` or `try-catch`. * - * Note that [MoleculePresenter] itself doesn't extend the [Presenter] interface. Use - * [launchMoleculePresenter] to transform a [MoleculePresenter] to a [Presenter]. To use another - * [Presenter] within a [MoleculePresenter] you can inject the presenter directly and subscribe to + * Note that [ComposePresenter] itself doesn't extend the [Presenter] interface. Use + * [launchComposePresenter] to transform a [ComposePresenter] to a [Presenter]. To use another + * [Presenter] within a [ComposePresenter] you can inject the presenter directly and subscribe to * changes of [Presenter.model]. * - * `MoleculePresenters` typically are stateless, meaning they have no properties and are not marked + * `ComposePresenters` typically are stateless, meaning they have no properties and are not marked * as singletons. If no input is used, then use [Unit] for [InputT]. A typical implementation may * look like: * ``` * @Inject - * class MyPresenter : MoleculePresenter { + * class MyPresenter : ComposePresenter { * * @Composable * override fun present(input: Unit): Model { @@ -40,7 +40,7 @@ import software.ralf.app.platform.presenter.Presenter * [BaseModel] implementation typically has an `onEvent` callback lambda as last parameter: * ``` * @Inject - * class MyPresenter : MoleculePresenter { + * class MyPresenter : ComposePresenter { * * @Composable * override fun present(input: Unit): Model { @@ -70,7 +70,7 @@ import software.ralf.app.platform.presenter.Presenter * } * ``` * - * `MoleculePresenters` can host and embed other child presenters. To invoke them call [present] + * `ComposePresenters` can host and embed other child presenters. To invoke them call [present] * inline. This is also the chance to pass inputs from one presenter to another. To avoid * instantiating presenters eagerly and only when they're actually needed, it's recommended to * inject them lazily: @@ -79,7 +79,7 @@ import software.ralf.app.platform.presenter.Presenter * class MyPresenter( * private val userPresenter: () -> UserPresenter, * private val loginPresenter: () -> LoginPresenter, - * ) : MoleculePresenter { + * ) : ComposePresenter { * * @Composable * override fun present(input: Unit): Model { @@ -101,7 +101,7 @@ import software.ralf.app.platform.presenter.Presenter * } * ``` */ -public fun interface MoleculePresenter { +public fun interface ComposePresenter { /** Called every time state of the composable changes to produce a new model. */ @Composable public fun present(input: InputT): ModelT } diff --git a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/MoleculeScope.kt b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenterScope.kt similarity index 53% rename from presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/MoleculeScope.kt rename to presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenterScope.kt index 943b5e97..edd4d1da 100644 --- a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/MoleculeScope.kt +++ b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenterScope.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import app.cash.molecule.RecompositionMode import kotlinx.coroutines.CoroutineScope @@ -6,16 +6,18 @@ import kotlinx.coroutines.cancel /** * A pair of a [CoroutineScope] and a Compose [RecompositionMode] to make it easier to launch a - * [MoleculePresenter]. Once a [MoleculeScope] is no longer used it must be canceled through + * [ComposePresenter]. Once a [ComposePresenterScope] is no longer used it must be canceled through * [cancel] otherwise [coroutineScope] will leak. */ -public class MoleculeScope( - /** The CoroutineScope which this MoleculeScope should use to run @Composable functions. */ +public class ComposePresenterScope( + /** + * The CoroutineScope which this ComposePresenterScope should use to run @Composable functions. + */ public val coroutineScope: CoroutineScope, /** - * The [RecompositionMode] which this MoleculeScope should use to determine how frequently new - * models are computed. + * The [RecompositionMode] which this ComposePresenterScope should use to determine how frequently + * new models are computed. */ public val recompositionMode: RecompositionMode, ) { diff --git a/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory.kt b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory.kt new file mode 100644 index 00000000..ca7e42af --- /dev/null +++ b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory.kt @@ -0,0 +1,25 @@ +package software.ralf.app.platform.presenter.compose + +import kotlin.coroutines.CoroutineContext +import kotlin.coroutines.EmptyCoroutineContext +import kotlinx.coroutines.CoroutineScope + +/** Creates new [ComposePresenterScope] instances. */ +public interface ComposePresenterScopeFactory { + + /** + * Creates a new [ComposePresenterScope]. Once the returned scope is not needed anymore, you must + * call [ComposePresenterScope.cancel] to avoid memory leaks. + */ + public fun createComposePresenterScope(): ComposePresenterScope + + /** + * Wraps the given [coroutineScope] in a [ComposePresenterScope] and applies platform specific + * defaults in order to run Molecule. [coroutineContext] allows you to add additional elements to + * the used [CoroutineScope] and override the platform defaults if necessary. + */ + public fun createComposePresenterScopeFromCoroutineScope( + coroutineScope: CoroutineScope, + coroutineContext: CoroutineContext = EmptyCoroutineContext, + ): ComposePresenterScope +} diff --git a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/LaunchMoleculePresenter.kt b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/LaunchComposePresenter.kt similarity index 75% rename from presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/LaunchMoleculePresenter.kt rename to presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/LaunchComposePresenter.kt index 86f21e80..19c33c59 100644 --- a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/LaunchMoleculePresenter.kt +++ b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/LaunchComposePresenter.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import androidx.compose.runtime.Composable import androidx.compose.runtime.ProvidableCompositionLocal @@ -28,11 +28,11 @@ internal val LocalRecompositionMode: ProvidableCompositionLocal CoroutineScope.launchMoleculePresenter( - presenter: MoleculePresenter, +public fun CoroutineScope.launchComposePresenter( + presenter: ComposePresenter, input: StateFlow, recompositionMode: RecompositionMode, ): Presenter { @@ -48,60 +48,60 @@ public fun CoroutineScope.launchMoleculePrese } /** - * Launch a coroutine into this [MoleculeScope] which will continually recompose - * [MoleculePresenter.present] to produce a [StateFlow]. The [StateFlow] will be provided by the + * Launch a coroutine into this [ComposePresenterScope] which will continually recompose + * [ComposePresenter.present] to produce a [StateFlow]. The [StateFlow] will be provided by the * returned [Presenter]. */ -public fun MoleculeScope.launchMoleculePresenter( - presenter: MoleculePresenter, +public fun ComposePresenterScope.launchComposePresenter( + presenter: ComposePresenter, input: StateFlow, ): Presenter = - coroutineScope.launchMoleculePresenter( + coroutineScope.launchComposePresenter( presenter = presenter, input = input, recompositionMode = recompositionMode, ) /** - * Launch a coroutine into this [MoleculeScope] which will continually recompose - * [MoleculePresenter.present] to produce a [StateFlow]. The [StateFlow] will be provided by the + * Launch a coroutine into this [ComposePresenterScope] which will continually recompose + * [ComposePresenter.present] to produce a [StateFlow]. The [StateFlow] will be provided by the * returned [Presenter]. */ -public fun MoleculeScope.launchMoleculePresenter( - presenter: MoleculePresenter, +public fun ComposePresenterScope.launchComposePresenter( + presenter: ComposePresenter, input: InputT, ): Presenter = - launchMoleculePresenter(presenter = presenter, input = MutableStateFlow(input)) + launchComposePresenter(presenter = presenter, input = MutableStateFlow(input)) /** - * Presents this [MoleculePresenter] in a detached Molecule composition and returns the latest + * Presents this [ComposePresenter] in a detached Molecule composition and returns the latest * [ModelT]. * - * Calling [MoleculePresenter.present] directly composes a child presenter inline with its parent. + * Calling [ComposePresenter.present] directly composes a child presenter inline with its parent. * That keeps the hierarchy simple, but every parent recomposition also invokes every inline child * presenter below it. [presentDetached] creates a separate presenter hierarchy instead. Parent * recompositions keep collecting the detached model, but the detached presenter only recomposes * when its own [input] or its own state changes. * * Use this for presenter subtrees that are expensive to compute and whose input changes less often - * than the parent presenter. Prefer a direct [MoleculePresenter.present] call for cheap presenters + * than the parent presenter. Prefer a direct [ComposePresenter.present] call for cheap presenters * or presenters that need to participate in the parent's composition locals beyond the App Platform * locals that [presentDetached] explicitly preserves. * * By default, this function uses the [RecompositionMode] from the current presenter hierarchy. Pass * [recompositionMode] explicitly if this is called from a composition that was not created through - * [launchMoleculePresenter]. + * [launchComposePresenter]. * * When [input] changes, the parent presenter can emit one model with the new parent input and the * previous detached child model before the detached hierarchy catches up. Use a direct - * [MoleculePresenter.present] call instead if parent and child model state must be updated + * [ComposePresenter.present] call instead if parent and child model state must be updated * atomically in the same emission. This is not a concern when the detached presenter always * receives the same input, such as [Unit]; in that case, child presenter updates are driven by the * detached hierarchy's own state changes. */ @Composable @ExperimentalAppPlatform -public fun MoleculePresenter.presentDetached( +public fun ComposePresenter.presentDetached( input: InputT, recompositionMode: RecompositionMode = LocalRecompositionMode.current, ): ModelT { @@ -110,7 +110,7 @@ public fun MoleculePresenter. val detachedObserver = remember(presenter, recompositionMode) { val inputFlow = MutableStateFlow(input) - // launchMoleculePresenter() returns a Presenter with a StateFlow, but not the Job running + // launchComposePresenter() returns a Presenter with a StateFlow, but not the Job running // the composition. Use a child scope so this detached hierarchy can be canceled when it // leaves composition, without canceling the parent presenter scope. val detachedCoroutineScope = parentCoroutineScope.createChildScope() @@ -119,7 +119,7 @@ public fun MoleculePresenter. input = inputFlow, model = detachedCoroutineScope - .launchMoleculePresenter( + .launchComposePresenter( presenter = presenter, input = inputFlow, recompositionMode = recompositionMode, diff --git a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/WithLocalRetainedValuesStore.kt b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/WithLocalRetainedValuesStore.kt similarity index 98% rename from presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/WithLocalRetainedValuesStore.kt rename to presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/WithLocalRetainedValuesStore.kt index 6d612629..00fa7474 100644 --- a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/WithLocalRetainedValuesStore.kt +++ b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/WithLocalRetainedValuesStore.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import androidx.compose.runtime.CancellationHandle import androidx.compose.runtime.Composable diff --git a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/BackEventPresenter.kt b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/BackEventPresenter.kt similarity index 95% rename from presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/BackEventPresenter.kt rename to presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/BackEventPresenter.kt index 206ad77f..f59ae80f 100644 --- a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/BackEventPresenter.kt +++ b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/BackEventPresenter.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.backgesture +package software.ralf.app.platform.presenter.compose.backgesture import androidx.annotation.FloatRange import androidx.annotation.IntRange diff --git a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter.kt b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter.kt similarity index 94% rename from presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter.kt rename to presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter.kt index 7cb85484..32bfaae5 100644 --- a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter.kt +++ b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.backgesture +package software.ralf.app.platform.presenter.compose.backgesture import androidx.compose.runtime.Composable import androidx.compose.runtime.ProvidableCompositionLocal @@ -6,7 +6,7 @@ import androidx.compose.runtime.compositionLocalOf import kotlinx.coroutines.CancellationException import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter /** * A dispatcher that forwards back press events from the UI layer to presenters. Internally it @@ -34,7 +34,7 @@ public interface BackGestureDispatcherPresenter { /** * Presenters call this function to register the [onBack] callback for back press gestures. See - * [software.ralf.app.platform.presenter.molecule.backgesture.PredictiveBackHandlerPresenter] for + * [software.ralf.app.platform.presenter.compose.backgesture.PredictiveBackHandlerPresenter] for * more details. */ @Composable @@ -81,7 +81,7 @@ public interface BackGestureDispatcherPresenter { * @Inject * class RootPresenter( * private val backPressDispatcherPresenter: BackPressDispatcherPresenter, - * ) : MoleculePresenter { + * ) : ComposePresenter { * @Composable * override fun present(input: Unit): Model { * return withCompositionLocal( @@ -137,7 +137,7 @@ public val LocalBackGestureDispatcherPresenter: // presenter. This will make sure that a renderer doesn't call this function accidentally. @Suppress("UnusedReceiverParameter") @Composable -public fun MoleculePresenter<*, *>.PredictiveBackHandlerPresenter( +public fun ComposePresenter<*, *>.PredictiveBackHandlerPresenter( enabled: Boolean = true, onBack: suspend (progress: Flow) -> Unit, ) { @@ -171,7 +171,7 @@ public fun MoleculePresenter<*, *>.PredictiveBackHandlerPresenter( // Note that the receiver parameter is used to ensure that this function is only called within a // presenter. This will make sure that a renderer doesn't call this function accidentally. @Composable -public fun MoleculePresenter<*, *>.BackHandlerPresenter( +public fun ComposePresenter<*, *>.BackHandlerPresenter( enabled: Boolean = true, onBack: () -> Unit, ) { diff --git a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/CommonBackGestureDispatcherPresenter.kt b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/CommonBackGestureDispatcherPresenter.kt similarity index 97% rename from presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/CommonBackGestureDispatcherPresenter.kt rename to presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/CommonBackGestureDispatcherPresenter.kt index e93ef366..19c551b1 100644 --- a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/CommonBackGestureDispatcherPresenter.kt +++ b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/CommonBackGestureDispatcherPresenter.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.backgesture +package software.ralf.app.platform.presenter.compose.backgesture import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect diff --git a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/saveable/ReturningSaveableStateHolder.kt b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/saveable/ReturningSaveableStateHolder.kt similarity index 99% rename from presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/saveable/ReturningSaveableStateHolder.kt rename to presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/saveable/ReturningSaveableStateHolder.kt index eceb3595..1ae9d256 100644 --- a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/saveable/ReturningSaveableStateHolder.kt +++ b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/saveable/ReturningSaveableStateHolder.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.saveable +package software.ralf.app.platform.presenter.compose.saveable import androidx.collection.mutableScatterMapOf import androidx.compose.runtime.Composable diff --git a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/text/PresenterTextFieldState.kt b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/text/PresenterTextFieldState.kt similarity index 87% rename from presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/text/PresenterTextFieldState.kt rename to presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/text/PresenterTextFieldState.kt index 2d0070c1..69d46ca3 100644 --- a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/text/PresenterTextFieldState.kt +++ b/presenter-compose/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/text/PresenterTextFieldState.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.text +package software.ralf.app.platform.presenter.compose.text import androidx.compose.runtime.Stable import androidx.compose.runtime.State @@ -15,11 +15,11 @@ import software.ralf.app.platform.ExperimentalAppPlatform * selection, and editing behavior. [PresenterTextFieldState] keeps only the text value, making it * suitable for presenter models without depending on Compose Foundation. * - * In a Molecule presenter, remember one instance for each logical text field and expose it through + * In a Compose presenter, remember one instance for each logical text field and expose it through * the model: * ```kotlin * @OptIn(ExperimentalAppPlatform::class) - * class SearchPresenter : MoleculePresenter { + * class SearchPresenter : ComposePresenter { * @Composable * override fun present(input: Unit): Model { * val query = remember { PresenterTextFieldState() } diff --git a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/MoleculeScopeTest.kt b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenterScopeTest.kt similarity index 61% rename from presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/MoleculeScopeTest.kt rename to presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenterScopeTest.kt index 291597ec..3863f364 100644 --- a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/MoleculeScopeTest.kt +++ b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/ComposePresenterScopeTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import app.cash.molecule.RecompositionMode import assertk.assertThat @@ -9,16 +9,16 @@ import kotlin.test.Test import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.isActive -class MoleculeScopeTest { +class ComposePresenterScopeTest { @Test - fun `canceling a MoleculeScope cancels the CoroutineScope`() { + fun `canceling a ComposePresenterScope cancels the CoroutineScope`() { val coroutineScope = CoroutineScope(EmptyCoroutineContext) - val moleculeScope = MoleculeScope(coroutineScope, RecompositionMode.Immediate) + val composePresenterScope = ComposePresenterScope(coroutineScope, RecompositionMode.Immediate) assertThat(coroutineScope.isActive).isTrue() - moleculeScope.cancel() + composePresenterScope.cancel() assertThat(coroutineScope.isActive).isFalse() } } diff --git a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/LaunchMoleculePresenterTest.kt b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/LaunchComposePresenterTest.kt similarity index 89% rename from presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/LaunchMoleculePresenterTest.kt rename to presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/LaunchComposePresenterTest.kt index 46b1c121..64da57b6 100644 --- a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/LaunchMoleculePresenterTest.kt +++ b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/LaunchComposePresenterTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState @@ -27,7 +27,7 @@ import software.ralf.app.platform.internal.createMarkedDispatcher import software.ralf.app.platform.presenter.BaseModel @OptIn(ExperimentalCoroutinesApi::class, ExperimentalAppPlatform::class) -class LaunchMoleculePresenterTest { +class LaunchComposePresenterTest { @Test @IgnoreNative @@ -54,7 +54,7 @@ class LaunchMoleculePresenterTest { fun `the presenter is called and computes a new model whenever the input changes`() = runTest { data class Model(val value: String) : BaseModel - val presenter = MoleculePresenter { input -> Model(input.toString()) } + val presenter = ComposePresenter { input -> Model(input.toString()) } val inputFlow = MutableStateFlow(1) @@ -74,7 +74,7 @@ class LaunchMoleculePresenterTest { data class Model(val recompositionMode: RecompositionMode) : BaseModel val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { return Model(LocalRecompositionMode.current) @@ -94,7 +94,7 @@ class LaunchMoleculePresenterTest { var childPresentCalls = 0 val childPresenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): ChildModel { childPresentCalls++ @@ -104,7 +104,7 @@ class LaunchMoleculePresenterTest { } val parentPresenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Int): ParentModel { val childModel = childPresenter.presentDetached(Unit) @@ -140,7 +140,7 @@ class LaunchMoleculePresenterTest { var childPresentCalls = 0 val childPresenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Int): Model { childPresentCalls++ @@ -150,7 +150,7 @@ class LaunchMoleculePresenterTest { } val parentPresenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Int): Model { return childPresenter.presentDetached(input) @@ -176,7 +176,7 @@ class LaunchMoleculePresenterTest { data class ParentModel(val input: Int, val childInput: Int) : BaseModel val childPresenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Int): ChildModel { return ChildModel(input) @@ -184,7 +184,7 @@ class LaunchMoleculePresenterTest { } val parentPresenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Int): ParentModel { val childModel = childPresenter.presentDetached(input) @@ -211,23 +211,25 @@ class LaunchMoleculePresenterTest { coroutineScope.cancel() assertThat(coroutineScope.isActive).isFalse() - val moleculeScope = MoleculeScope(coroutineScope, RecompositionMode.Immediate) + val composePresenterScope = ComposePresenterScope(coroutineScope, RecompositionMode.Immediate) data class Model(val value: String) : BaseModel val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Int): Model { return Model(input.toString()) } } - assertFailsWith { moleculeScope.launchMoleculePresenter(presenter, 1) } + assertFailsWith { + composePresenterScope.launchComposePresenter(presenter, 1) + } } private class ThreadPresenter(private val markedDispatcher: MarkedDispatcher) : - MoleculePresenter, ThreadPresenter.Model> { + ComposePresenter, ThreadPresenter.Model> { @Composable override fun present(input: StateFlow): Model { diff --git a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/OnEventMemoizationTest.kt b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/OnEventMemoizationTest.kt similarity index 95% rename from presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/OnEventMemoizationTest.kt rename to presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/OnEventMemoizationTest.kt index 8d3b9421..dc5fc211 100644 --- a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/OnEventMemoizationTest.kt +++ b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/OnEventMemoizationTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import androidx.compose.runtime.Composable import androidx.compose.runtime.DontMemoize @@ -21,7 +21,7 @@ class OnEventMemoizationTest { var presentCalls = 0 val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Int): Model { presentCalls++ @@ -65,7 +65,7 @@ class OnEventMemoizationTest { var state by mutableIntStateOf(0) val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { presentCalls++ @@ -105,7 +105,7 @@ class OnEventMemoizationTest { var presentCalls = 0 val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { presentCalls++ @@ -150,7 +150,7 @@ class OnEventMemoizationTest { var presentCalls = 0 val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { presentCalls++ diff --git a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/WithLocalRetainedValuesStoreTest.kt b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/WithLocalRetainedValuesStoreTest.kt similarity index 93% rename from presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/WithLocalRetainedValuesStoreTest.kt rename to presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/WithLocalRetainedValuesStoreTest.kt index d4438500..66dcabe1 100644 --- a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/WithLocalRetainedValuesStoreTest.kt +++ b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/WithLocalRetainedValuesStoreTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState @@ -51,7 +51,7 @@ class WithLocalRetainedValuesStoreTest { } private class RecompositionParentPresenter(private val count: StateFlow) : - MoleculePresenter { + ComposePresenter { @Composable override fun present(input: Unit): Model { val childRetainedValuesStore = key("child") { retainManagedRetainedValuesStore() } @@ -63,7 +63,7 @@ class WithLocalRetainedValuesStoreTest { } private class ParentPresenter(private val childPresenter: ChildPresenter) : - MoleculePresenter { + ComposePresenter { @Composable override fun present(input: Boolean): Model { val childRetainedValuesStore = key("child") { retainManagedRetainedValuesStore() } @@ -77,7 +77,7 @@ class WithLocalRetainedValuesStoreTest { } } - private class ChildPresenter : MoleculePresenter { + private class ChildPresenter : ComposePresenter { @Composable override fun present(input: Unit): Model.Child { val counter = retain { Counter() } diff --git a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/CommonBackGestureDispatcherPresenterTest.kt b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/backgesture/CommonBackGestureDispatcherPresenterTest.kt similarity index 92% rename from presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/CommonBackGestureDispatcherPresenterTest.kt rename to presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/backgesture/CommonBackGestureDispatcherPresenterTest.kt index fde423d4..77a5113b 100644 --- a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/CommonBackGestureDispatcherPresenterTest.kt +++ b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/backgesture/CommonBackGestureDispatcherPresenterTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.backgesture +package software.ralf.app.platform.presenter.compose.backgesture import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -18,8 +18,8 @@ import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runTest import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter -import software.ralf.app.platform.presenter.molecule.test +import software.ralf.app.platform.presenter.compose.ComposePresenter +import software.ralf.app.platform.presenter.compose.test class CommonBackGestureDispatcherPresenterTest { @Test @@ -29,7 +29,7 @@ class CommonBackGestureDispatcherPresenterTest { data class Model(val backPressCount: Int) : BaseModel val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { var backPressCount by remember { mutableIntStateOf(0) } @@ -57,7 +57,7 @@ class CommonBackGestureDispatcherPresenterTest { data class Model(val lastEvent: BackEventPresenter?) : BaseModel val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { var lastEvent by remember { mutableStateOf(null) } @@ -85,7 +85,7 @@ class CommonBackGestureDispatcherPresenterTest { data class Model(val backPressCount1: Int, val backPressCount2: Int) : BaseModel val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { var backPressCount1 by remember { mutableIntStateOf(0) } @@ -124,7 +124,7 @@ class CommonBackGestureDispatcherPresenterTest { data class Model(val backPressCount: Int) : BaseModel val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { var backPressCount by remember { mutableIntStateOf(0) } @@ -154,7 +154,7 @@ class CommonBackGestureDispatcherPresenterTest { val model = Model() val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { repeat(handlers) { index -> @@ -188,7 +188,7 @@ class CommonBackGestureDispatcherPresenterTest { data class Model(val count: Int) : BaseModel val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { var count by remember { mutableIntStateOf(0) } @@ -218,8 +218,8 @@ class CommonBackGestureDispatcherPresenterTest { private class RootPresenter( private val dispatcher: BackGestureDispatcherPresenter, - private val presenter: MoleculePresenter, - ) : MoleculePresenter { + private val presenter: ComposePresenter, + ) : ComposePresenter { @Composable override fun present(input: Unit): ModelT { return withCompositionLocal(LocalBackGestureDispatcherPresenter provides dispatcher) { diff --git a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/saveable/ReturningSaveableStateHolderTest.kt b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/saveable/ReturningSaveableStateHolderTest.kt similarity index 94% rename from presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/saveable/ReturningSaveableStateHolderTest.kt rename to presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/saveable/ReturningSaveableStateHolderTest.kt index 629e3de5..7f042368 100644 --- a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/saveable/ReturningSaveableStateHolderTest.kt +++ b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/saveable/ReturningSaveableStateHolderTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.saveable +package software.ralf.app.platform.presenter.compose.saveable import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState @@ -19,8 +19,8 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest import software.ralf.app.platform.ExperimentalAppPlatform import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter -import software.ralf.app.platform.presenter.molecule.test +import software.ralf.app.platform.presenter.compose.ComposePresenter +import software.ralf.app.platform.presenter.compose.test @OptIn(ExperimentalAppPlatform::class) class ReturningSaveableStateHolderTest { @@ -125,7 +125,7 @@ class ReturningSaveableStateHolderTest { private class SaveablePresenter( private val key: MutableStateFlow, private val parentRegistry: SaveableStateRegistry? = null, - ) : MoleculePresenter { + ) : ComposePresenter { @Composable override fun present(input: Unit): Model { return if (parentRegistry != null) { @@ -159,7 +159,7 @@ class ReturningSaveableStateHolderTest { } private class NonSaveableKeyPresenter(private val parentRegistry: SaveableStateRegistry) : - MoleculePresenter { + ComposePresenter { @Composable override fun present(input: Unit): Model { return withCompositionLocal(LocalSaveableStateRegistry provides parentRegistry) { @@ -185,7 +185,7 @@ class ReturningSaveableStateHolderTest { val removeState: () -> Unit, ) : BaseModel - private class PlainReturnPresenter : MoleculePresenter { + private class PlainReturnPresenter : ComposePresenter { @Composable override fun present(input: Unit): PlainReturnModel { val stateHolder = rememberReturningSaveableStateHolder() diff --git a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/text/PresenterTextFieldStateTest.kt b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/text/PresenterTextFieldStateTest.kt similarity index 91% rename from presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/text/PresenterTextFieldStateTest.kt rename to presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/text/PresenterTextFieldStateTest.kt index 9b5b9840..d147f477 100644 --- a/presenter-molecule/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/text/PresenterTextFieldStateTest.kt +++ b/presenter-compose/public/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/text/PresenterTextFieldStateTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.text +package software.ralf.app.platform.presenter.compose.text import assertk.assertThat import assertk.assertions.isEqualTo diff --git a/presenter-compose/testing/api/android/testing.api b/presenter-compose/testing/api/android/testing.api new file mode 100644 index 00000000..67d304be --- /dev/null +++ b/presenter-compose/testing/api/android/testing.api @@ -0,0 +1,27 @@ +public final class software/ralf/app/platform/presenter/compose/FakeComposePresenterScopeFactory : software/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory { + public static final field $stable I + public fun (Lkotlinx/coroutines/CoroutineScope;)V + public fun createComposePresenterScope ()Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; + public fun createComposePresenterScopeFromCoroutineScope (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; +} + +public final class software/ralf/app/platform/presenter/compose/TestComposePresenterScopeKt { + public static final fun composePresenterScope (Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; + public static synthetic fun composePresenterScope$default (Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; +} + +public final class software/ralf/app/platform/presenter/compose/TestPresenterKt { + public static final fun test (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlinx/coroutines/flow/StateFlow;Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun test$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlinx/coroutines/flow/StateFlow;Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static final fun test-FHKeTTw (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun test-FHKeTTw$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static final fun test-Zzr-CC0 (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/test/TestScope;Ljava/lang/Object;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun test-Zzr-CC0$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/test/TestScope;Ljava/lang/Object;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/TestBackGestureDispatcherPresenterKt { + public static final fun withBackGestureDispatcher (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/flow/SharedFlow;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter; + public static final fun withBackGestureDispatcherUnit (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/flow/SharedFlow;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter; + public static synthetic fun withBackGestureDispatcherUnit$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/flow/SharedFlow;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter; +} + diff --git a/presenter-compose/testing/api/desktop/testing.api b/presenter-compose/testing/api/desktop/testing.api new file mode 100644 index 00000000..67d304be --- /dev/null +++ b/presenter-compose/testing/api/desktop/testing.api @@ -0,0 +1,27 @@ +public final class software/ralf/app/platform/presenter/compose/FakeComposePresenterScopeFactory : software/ralf/app/platform/presenter/compose/ComposePresenterScopeFactory { + public static final field $stable I + public fun (Lkotlinx/coroutines/CoroutineScope;)V + public fun createComposePresenterScope ()Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; + public fun createComposePresenterScopeFromCoroutineScope (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; +} + +public final class software/ralf/app/platform/presenter/compose/TestComposePresenterScopeKt { + public static final fun composePresenterScope (Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; + public static synthetic fun composePresenterScope$default (Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenterScope; +} + +public final class software/ralf/app/platform/presenter/compose/TestPresenterKt { + public static final fun test (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlinx/coroutines/flow/StateFlow;Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun test$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlinx/coroutines/flow/StateFlow;Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static final fun test-FHKeTTw (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun test-FHKeTTw$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static final fun test-Zzr-CC0 (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/test/TestScope;Ljava/lang/Object;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun test-Zzr-CC0$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/test/TestScope;Ljava/lang/Object;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class software/ralf/app/platform/presenter/compose/backgesture/TestBackGestureDispatcherPresenterKt { + public static final fun withBackGestureDispatcher (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/flow/SharedFlow;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter; + public static final fun withBackGestureDispatcherUnit (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/flow/SharedFlow;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter; + public static synthetic fun withBackGestureDispatcherUnit$default (Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter;Lkotlinx/coroutines/flow/SharedFlow;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/compose/ComposePresenter; +} + diff --git a/presenter-molecule/testing/build.gradle b/presenter-compose/testing/build.gradle similarity index 78% rename from presenter-molecule/testing/build.gradle rename to presenter-compose/testing/build.gradle index 39d8ca0f..ac2cc708 100644 --- a/presenter-molecule/testing/build.gradle +++ b/presenter-compose/testing/build.gradle @@ -10,5 +10,5 @@ appPlatformBuildSrc { dependencies { commonMainApi project(':presenter:public') commonTestImplementation project(':internal:testing') - commonTestImplementation project(':presenter-molecule:testing') + commonTestImplementation project(':presenter-compose:testing') } diff --git a/presenter-compose/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/FakeComposePresenterScopeFactory.kt b/presenter-compose/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/FakeComposePresenterScopeFactory.kt new file mode 100644 index 00000000..535fef64 --- /dev/null +++ b/presenter-compose/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/FakeComposePresenterScopeFactory.kt @@ -0,0 +1,31 @@ +package software.ralf.app.platform.presenter.compose + +import app.cash.molecule.RecompositionMode +import kotlin.coroutines.CoroutineContext +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.plus +import kotlinx.coroutines.test.TestScope + +/** + * Uses the given [coroutineScope] to create new [ComposePresenterScope] instances. In testing + * environments often [TestScope] is used as argument. + */ +public class FakeComposePresenterScopeFactory(private val coroutineScope: CoroutineScope) : + ComposePresenterScopeFactory { + override fun createComposePresenterScope(): ComposePresenterScope = + createComposePresenterScopeFromCoroutineScope(coroutineScope) + + override fun createComposePresenterScopeFromCoroutineScope( + coroutineScope: CoroutineScope, + coroutineContext: CoroutineContext, + ): ComposePresenterScope { + return if (coroutineScope is TestScope) { + coroutineScope.composePresenterScope(coroutineContext) + } else { + ComposePresenterScope( + coroutineScope = coroutineScope + coroutineContext, + recompositionMode = RecompositionMode.Immediate, + ) + } + } +} diff --git a/presenter-molecule/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/TestMoleculeScope.kt b/presenter-compose/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/TestComposePresenterScope.kt similarity index 51% rename from presenter-molecule/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/TestMoleculeScope.kt rename to presenter-compose/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/TestComposePresenterScope.kt index cde1714c..681f73e3 100644 --- a/presenter-molecule/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/TestMoleculeScope.kt +++ b/presenter-compose/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/TestComposePresenterScope.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import app.cash.molecule.RecompositionMode import kotlin.coroutines.CoroutineContext @@ -9,15 +9,15 @@ import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope /** - * Creates and returns a [MoleculeScope] with a recompositionMode of [RecompositionMode.Immediate] - * and with a scope that defaults to using [StandardTestDispatcher]. + * Creates and returns a [ComposePresenterScope] with a recompositionMode of + * [RecompositionMode.Immediate] and with a scope that defaults to using [StandardTestDispatcher]. * * @param coroutineContext a [CoroutineContext] to override any element of coroutine scope. */ -public fun TestScope.moleculeScope( +public fun TestScope.composePresenterScope( coroutineContext: CoroutineContext = EmptyCoroutineContext -): MoleculeScope { - val scope = backgroundScope + CoroutineName("TestMoleculeScope") + coroutineContext +): ComposePresenterScope { + val scope = backgroundScope + CoroutineName("TestComposePresenterScope") + coroutineContext - return MoleculeScope(scope, RecompositionMode.Immediate) + return ComposePresenterScope(scope, RecompositionMode.Immediate) } diff --git a/presenter-molecule/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/TestPresenter.kt b/presenter-compose/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/TestPresenter.kt similarity index 77% rename from presenter-molecule/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/TestPresenter.kt rename to presenter-compose/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/TestPresenter.kt index d3550781..0c497428 100644 --- a/presenter-molecule/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/TestPresenter.kt +++ b/presenter-compose/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/TestPresenter.kt @@ -1,6 +1,6 @@ @file:Suppress("RedundantSuppression", "RedundantSuspendModifier") -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import app.cash.turbine.ReceiveTurbine import app.cash.turbine.test @@ -13,7 +13,7 @@ import kotlinx.coroutines.test.UnconfinedTestDispatcher import software.ralf.app.platform.presenter.BaseModel /** - * Assert the emitted models of the given [MoleculePresenter] in the provided [validate] lambda. + * Assert the emitted models of the given [ComposePresenter] in the provided [validate] lambda. * * The used [CoroutineContext] for the presenter can be changed with [coroutineContext]. By default, * a [UnconfinedTestDispatcher] will be used, which means coroutines aren't confined to any thread @@ -29,7 +29,7 @@ import software.ralf.app.platform.presenter.BaseModel * } * ``` */ -public suspend fun MoleculePresenter.test( +public suspend fun ComposePresenter.test( testScope: TestScope, input: InputT, coroutineContext: CoroutineContext = EmptyCoroutineContext, @@ -37,14 +37,14 @@ public suspend fun MoleculePresenter.() -> Unit, ) { testScope - .moleculeScope(coroutineContext) - .launchMoleculePresenter(this, input) + .composePresenterScope(coroutineContext) + .launchComposePresenter(this, input) .model .test(validate = validate, timeout = timeout) } /** - * Assert the emitted models of the given [MoleculePresenter] in the provided [validate] lambda. + * Assert the emitted models of the given [ComposePresenter] in the provided [validate] lambda. * * The used [CoroutineContext] for the presenter can be changed with [coroutineContext]. By default, * a [UnconfinedTestDispatcher] will be used, which means coroutines aren't confined to any thread @@ -60,21 +60,21 @@ public suspend fun MoleculePresenter MoleculePresenter.test( +public suspend fun ComposePresenter.test( testScope: TestScope, input: StateFlow, coroutineContext: CoroutineContext = EmptyCoroutineContext, validate: suspend ReceiveTurbine.() -> Unit, ) { testScope - .moleculeScope(coroutineContext) - .launchMoleculePresenter(this, input) + .composePresenterScope(coroutineContext) + .launchComposePresenter(this, input) .model .test(validate = validate) } /** - * Assert the emitted models of the given [MoleculePresenter] in the provided [validate] lambda. + * Assert the emitted models of the given [ComposePresenter] in the provided [validate] lambda. * * The used [CoroutineContext] for the presenter can be changed with [coroutineContext]. By default, * a [UnconfinedTestDispatcher] will be used, which means coroutines aren't confined to any thread @@ -90,7 +90,7 @@ public suspend fun MoleculePresenter MoleculePresenter.test( +public suspend fun ComposePresenter.test( testScope: TestScope, coroutineContext: CoroutineContext = EmptyCoroutineContext, timeout: Duration? = null, diff --git a/presenter-molecule/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/TestBackGestureDispatcherPresenter.kt b/presenter-compose/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/TestBackGestureDispatcherPresenter.kt similarity index 78% rename from presenter-molecule/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/TestBackGestureDispatcherPresenter.kt rename to presenter-compose/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/TestBackGestureDispatcherPresenter.kt index b33d31e1..85ed4994 100644 --- a/presenter-molecule/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/TestBackGestureDispatcherPresenter.kt +++ b/presenter-compose/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/TestBackGestureDispatcherPresenter.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.backgesture +package software.ralf.app.platform.presenter.compose.backgesture import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -11,12 +11,12 @@ import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.map import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter private class TestBackGestureDispatcherPresenter( - private val delegate: MoleculePresenter, + private val delegate: ComposePresenter, private val backEvents: Flow>, -) : MoleculePresenter { +) : ComposePresenter { @Composable override fun present(input: InputT): ModelT { val dispatcher = remember { BackGestureDispatcherPresenter.createNewInstance() } @@ -37,10 +37,10 @@ private class TestBackGestureDispatcherPresenter MoleculePresenter +public fun ComposePresenter .withBackGestureDispatcher( backEvents: SharedFlow = MutableSharedFlow() -): MoleculePresenter = +): ComposePresenter = TestBackGestureDispatcherPresenter(this, backEvents.map { emptyFlow() }) /** @@ -50,7 +50,7 @@ public fun MoleculePresenter * * [backEvents] provides predictive back press events. */ -public fun MoleculePresenter +public fun ComposePresenter .withBackGestureDispatcher( backEvents: SharedFlow> -): MoleculePresenter = TestBackGestureDispatcherPresenter(this, backEvents) +): ComposePresenter = TestBackGestureDispatcherPresenter(this, backEvents) diff --git a/presenter-molecule/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/FakeMoleculeScopeFactoryTest.kt b/presenter-compose/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/FakeComposePresenterScopeFactoryTest.kt similarity index 57% rename from presenter-molecule/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/FakeMoleculeScopeFactoryTest.kt rename to presenter-compose/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/FakeComposePresenterScopeFactoryTest.kt index 4b2364e1..37698aa5 100644 --- a/presenter-molecule/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/FakeMoleculeScopeFactoryTest.kt +++ b/presenter-compose/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/FakeComposePresenterScopeFactoryTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import assertk.assertThat import assertk.assertions.isEqualTo @@ -16,11 +16,11 @@ import kotlinx.coroutines.plus import kotlinx.coroutines.test.runTest import software.ralf.app.platform.internal.IgnoreWasm -class FakeMoleculeScopeFactoryTest { +class FakeComposePresenterScopeFactoryTest { @Test - fun `a created MoleculeScope can be canceled`() = runTest { - val scope = FakeMoleculeScopeFactory(this).createMoleculeScope() + fun `a created ComposePresenterScope can be canceled`() = runTest { + val scope = FakeComposePresenterScopeFactory(this).createComposePresenterScope() scope.cancel() var didRun = false @@ -32,11 +32,11 @@ class FakeMoleculeScopeFactoryTest { @Test @IgnoreWasm - fun `a created MoleculeScope does not need to be canceled for the test to complete`() { + fun `a created ComposePresenterScope does not need to be canceled for the test to complete`() { // Basically this test should not hang. var presenterJobStarted = false runTest { - val scope = FakeMoleculeScopeFactory(this).createMoleculeScope() + val scope = FakeComposePresenterScopeFactory(this).createComposePresenterScope() scope.coroutineScope.launch(start = CoroutineStart.UNDISPATCHED) { presenterJobStarted = true awaitCancellation() @@ -49,8 +49,8 @@ class FakeMoleculeScopeFactoryTest { @Test fun `the coroutine context is added to the scope`() = runTest { val scope = - FakeMoleculeScopeFactory(this) - .createMoleculeScopeFromCoroutineScope(this, CoroutineName("test")) + FakeComposePresenterScopeFactory(this) + .createComposePresenterScopeFromCoroutineScope(this, CoroutineName("test")) val name = scope.coroutineScope.coroutineContext[CoroutineName.Key] assertThat(name?.name).isEqualTo("test") @@ -61,34 +61,36 @@ class FakeMoleculeScopeFactoryTest { val testJob = coroutineContext.job val originalChildren = testJob.children.toList() - FakeMoleculeScopeFactory(this) - .createMoleculeScopeFromCoroutineScope(this + CoroutineName("decorated")) + FakeComposePresenterScopeFactory(this) + .createComposePresenterScopeFromCoroutineScope(this + CoroutineName("decorated")) assertThat(testJob.children.toList()).isEqualTo(originalChildren) } @Test - fun `a regular CoroutineScope can be used to create a MoleculeScope`() = runTest { + fun `a regular CoroutineScope can be used to create a ComposePresenterScope`() = runTest { val coroutineScope = CoroutineScope(CoroutineName("test")) - val moleculeScope = - FakeMoleculeScopeFactory(this).createMoleculeScopeFromCoroutineScope(coroutineScope) + val composePresenterScope = + FakeComposePresenterScopeFactory(this) + .createComposePresenterScopeFromCoroutineScope(coroutineScope) - val name = moleculeScope.coroutineScope.coroutineContext[CoroutineName.Key] + val name = composePresenterScope.coroutineScope.coroutineContext[CoroutineName.Key] assertThat(name?.name).isEqualTo("test") - moleculeScope.cancel() + composePresenterScope.cancel() assertThat(coroutineScope.isActive).isFalse() } @Test - fun `a regular CoroutineScope can be used to create a MoleculeScope without a TestScope`() { + fun `a regular CoroutineScope creates a ComposePresenterScope without a TestScope`() { val coroutineScope = CoroutineScope(CoroutineName("test")) - val moleculeScope = FakeMoleculeScopeFactory(coroutineScope).createMoleculeScope() + val composePresenterScope = + FakeComposePresenterScopeFactory(coroutineScope).createComposePresenterScope() - val name = moleculeScope.coroutineScope.coroutineContext[CoroutineName.Key] + val name = composePresenterScope.coroutineScope.coroutineContext[CoroutineName.Key] assertThat(name?.name).isEqualTo("test") - moleculeScope.cancel() + composePresenterScope.cancel() assertThat(coroutineScope.isActive).isFalse() } } diff --git a/presenter-molecule/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/TestMoleculeScopeTest.kt b/presenter-compose/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/TestComposePresenterScopeTest.kt similarity index 58% rename from presenter-molecule/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/TestMoleculeScopeTest.kt rename to presenter-compose/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/TestComposePresenterScopeTest.kt index feb23dcd..6af40ce4 100644 --- a/presenter-molecule/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/TestMoleculeScopeTest.kt +++ b/presenter-compose/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/TestComposePresenterScopeTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import app.cash.molecule.RecompositionMode import assertk.assertFailure @@ -17,21 +17,21 @@ import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import software.ralf.app.platform.internal.IgnoreWasm -class TestMoleculeScopeTest { +class TestComposePresenterScopeTest { @Test - fun `test recompositionMode of moleculeScope is always Immediate`() = runTest { - var moleculeScope = moleculeScope() - assertThat(moleculeScope.recompositionMode).isEqualTo(RecompositionMode.Immediate) + fun `test recompositionMode of composePresenterScope is always Immediate`() = runTest { + var composePresenterScope = composePresenterScope() + assertThat(composePresenterScope.recompositionMode).isEqualTo(RecompositionMode.Immediate) - moleculeScope = moleculeScope(CoroutineName("test")) - assertThat(moleculeScope.recompositionMode).isEqualTo(RecompositionMode.Immediate) + composePresenterScope = composePresenterScope(CoroutineName("test")) + assertThat(composePresenterScope.recompositionMode).isEqualTo(RecompositionMode.Immediate) } @Test fun `a standard test dispatcher is used by default`() = runTest { val job = - moleculeScope().coroutineScope.launch { + composePresenterScope().coroutineScope.launch { // Do nothing } assertThat(job.isCompleted).isFalse() @@ -42,7 +42,7 @@ class TestMoleculeScopeTest { @Test fun `an unconfined test dispatcher can be used`() = runTest { val job = - moleculeScope(UnconfinedTestDispatcher()).coroutineScope.launch { + composePresenterScope(UnconfinedTestDispatcher()).coroutineScope.launch { // Do nothing } assertThat(job.isCompleted).isTrue() @@ -51,7 +51,7 @@ class TestMoleculeScopeTest { @Test fun `the coroutine context can be changed`() = runTest { val name = - moleculeScope(CoroutineName("Test-abc")) + composePresenterScope(CoroutineName("Test-abc")) .coroutineScope .coroutineContext[CoroutineName.Key] ?.name @@ -60,10 +60,10 @@ class TestMoleculeScopeTest { @Test fun `the coroutine context is canceled`() = runTest { - val moleculeScope = moleculeScope() - assertThat(moleculeScope.coroutineScope.isActive).isTrue() - moleculeScope.cancel() - assertThat(moleculeScope.coroutineScope.isActive).isFalse() + val composePresenterScope = composePresenterScope() + assertThat(composePresenterScope.coroutineScope.isActive).isTrue() + composePresenterScope.cancel() + assertThat(composePresenterScope.coroutineScope.isActive).isFalse() } @Test @@ -71,8 +71,8 @@ class TestMoleculeScopeTest { fun `failures in a coroutine are reported`() { assertFailure { runTest { - val moleculeScope = moleculeScope() - moleculeScope.coroutineScope.launch { error("test failure") } + val composePresenterScope = composePresenterScope() + composePresenterScope.coroutineScope.launch { error("test failure") } runCurrent() } diff --git a/presenter-molecule/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/TestPresenterTest.kt b/presenter-compose/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/TestPresenterTest.kt similarity index 93% rename from presenter-molecule/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/TestPresenterTest.kt rename to presenter-compose/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/TestPresenterTest.kt index c4c027e0..2a1b1277 100644 --- a/presenter-molecule/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/TestPresenterTest.kt +++ b/presenter-compose/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/TestPresenterTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule +package software.ralf.app.platform.presenter.compose import androidx.compose.runtime.Composable import androidx.compose.runtime.InternalComposeApi @@ -27,7 +27,7 @@ class TestPresenterTest { fun `values are properly emitted`() = runTest { data class Model(val value: String) : BaseModel - class TestPresenter : MoleculePresenter, Model> { + class TestPresenter : ComposePresenter, Model> { @Composable override fun present(input: StateFlow): Model { return Model(input.collectAsState().value) @@ -47,7 +47,7 @@ class TestPresenterTest { fun `the coroutine context can be changed`() = runTest { data class Model(val name: CoroutineName?) : BaseModel - class TestPresenter : MoleculePresenter { + class TestPresenter : ComposePresenter { @Composable override fun present(input: Unit): Model { @OptIn(InternalComposeApi::class) @@ -65,7 +65,7 @@ class TestPresenterTest { fun `failures in a presenter are reported in the first emission`() { class Model : BaseModel - class TestPresenter : MoleculePresenter { + class TestPresenter : ComposePresenter { @Composable override fun present(input: Unit): Model { fail("test failure") @@ -96,7 +96,7 @@ class TestPresenterTest { val trigger = MutableStateFlow(0) - class TestPresenter : MoleculePresenter { + class TestPresenter : ComposePresenter { @Composable override fun present(input: Unit): Model { val triggerValue by trigger.collectAsState() diff --git a/presenter-molecule/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/TestBackGestureDispatcherPresenterTest.kt b/presenter-compose/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/backgesture/TestBackGestureDispatcherPresenterTest.kt similarity index 91% rename from presenter-molecule/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/TestBackGestureDispatcherPresenterTest.kt rename to presenter-compose/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/backgesture/TestBackGestureDispatcherPresenterTest.kt index 0f3223e1..0400576d 100644 --- a/presenter-molecule/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/TestBackGestureDispatcherPresenterTest.kt +++ b/presenter-compose/testing/src/commonTest/kotlin/software/ralf/app/platform/presenter/compose/backgesture/TestBackGestureDispatcherPresenterTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.backgesture +package software.ralf.app.platform.presenter.compose.backgesture import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -21,14 +21,14 @@ import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runTest import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter -import software.ralf.app.platform.presenter.molecule.test +import software.ralf.app.platform.presenter.compose.ComposePresenter +import software.ralf.app.platform.presenter.compose.test class TestBackGestureDispatcherPresenterTest { @Test fun `a presenter cannot be tested without the dispatcher wrapper`() = runTest { val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): BaseModel { BackHandlerPresenter {} @@ -45,7 +45,7 @@ class TestBackGestureDispatcherPresenterTest { @Test fun `a presenter can be tested with the dispatcher wrapper`() = runTest { val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): BaseModel { BackHandlerPresenter {} @@ -62,7 +62,7 @@ class TestBackGestureDispatcherPresenterTest { data class Model(val count: Int) : BaseModel val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { var backPressCount by remember { mutableIntStateOf(0) } @@ -89,7 +89,7 @@ class TestBackGestureDispatcherPresenterTest { data class Model(val eventCount: Int, val doneCount: Int) : BaseModel val presenter = - object : MoleculePresenter { + object : ComposePresenter { @Composable override fun present(input: Unit): Model { var eventCount by remember { mutableIntStateOf(0) } diff --git a/presenter-molecule/impl/api/android/impl.api b/presenter-molecule/impl/api/android/impl.api deleted file mode 100644 index e8f138e0..00000000 --- a/presenter-molecule/impl/api/android/impl.api +++ /dev/null @@ -1,85 +0,0 @@ -public final class software/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactory : software/ralf/app/platform/presenter/molecule/MoleculeScopeFactory { - public static final field $stable I - public fun (Lkotlin/jvm/functions/Function0;)V - public fun createMoleculeScope ()Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; - public fun createMoleculeScopeFromCoroutineScope (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryComponent { - public fun provideAndroidMoleculeScopeFactory (Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; -} - -public final class software/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryComponent$DefaultImpls { - public static fun provideAndroidMoleculeScopeFactory (Lsoftware/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryComponent;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph { - public fun provideAndroidMoleculeScopeFactory (Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; -} - -public final class software/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph$DefaultImpls { - public static fun provideAndroidMoleculeScopeFactory (Lsoftware/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph$MetroContributionToAppScope : software/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph { -} - -public final class software/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph$MetroContributionToAppScope$DefaultImpls { - public static fun provideAndroidMoleculeScopeFactory (Lsoftware/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph$MetroContributionToAppScope;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; -} - -public final class software/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph$ProvideAndroidMoleculeScopeFactoryMetroFactory : dev/zacsweers/metro/internal/Factory { - public static final field $stable I - public static final field Companion Lsoftware/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph$ProvideAndroidMoleculeScopeFactoryMetroFactory$Companion; - public synthetic fun (Lsoftware/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph;Ldev/zacsweers/metro/Provider;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun create (Lsoftware/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph;Ldev/zacsweers/metro/Provider;)Lsoftware/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph$ProvideAndroidMoleculeScopeFactoryMetroFactory; - public final fun declarationMirror (Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; - public synthetic fun invoke ()Ljava/lang/Object; - public final fun invoke ()Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; - public static final fun provideAndroidMoleculeScopeFactory (Lsoftware/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; -} - -public final class software/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph$ProvideAndroidMoleculeScopeFactoryMetroFactory$Companion { - public final fun create (Lsoftware/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph;Ldev/zacsweers/metro/Provider;)Lsoftware/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph$ProvideAndroidMoleculeScopeFactoryMetroFactory; - public final fun provideAndroidMoleculeScopeFactory (Lsoftware/ralf/app/platform/presenter/molecule/AndroidMoleculeScopeFactoryGraph;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterComponent { - public fun provideDefaultBackGestureDispatcherPresenter ()Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterComponent$DefaultImpls { - public static fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterComponent;)Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph { - public fun provideDefaultBackGestureDispatcherPresenter ()Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$DefaultImpls { - public static fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$MetroContributionToAppScope : software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph { -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$MetroContributionToAppScope$DefaultImpls { - public static fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$MetroContributionToAppScope;)Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory : dev/zacsweers/metro/internal/Factory { - public static final field $stable I - public static final field Companion Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory$Companion; - public synthetic fun (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun create (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory; - public final fun declarationMirror ()Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; - public synthetic fun invoke ()Ljava/lang/Object; - public final fun invoke ()Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; - public static final fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory$Companion { - public final fun create (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory; - public final fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - diff --git a/presenter-molecule/impl/api/desktop/impl.api b/presenter-molecule/impl/api/desktop/impl.api deleted file mode 100644 index da43be51..00000000 --- a/presenter-molecule/impl/api/desktop/impl.api +++ /dev/null @@ -1,73 +0,0 @@ -public final class software/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactory : software/ralf/app/platform/presenter/molecule/MoleculeScopeFactory { - public static final field $stable I - public fun (Lkotlin/jvm/functions/Function0;)V - public fun createMoleculeScope ()Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; - public fun createMoleculeScopeFromCoroutineScope (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryComponent { - public fun provideDesktopMoleculeScopeFactory (Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; -} - -public final class software/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryComponent$DefaultImpls { - public static fun provideDesktopMoleculeScopeFactory (Lsoftware/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryComponent;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryGraph { - public fun provideDesktopMoleculeScopeFactory (Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; -} - -public final class software/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryGraph$DefaultImpls { - public static fun provideDesktopMoleculeScopeFactory (Lsoftware/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryGraph;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; -} - -public final class software/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryGraph$ProvideDesktopMoleculeScopeFactoryMetroFactory : dev/zacsweers/metro/internal/Factory { - public static final field $stable I - public static final field Companion Lsoftware/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryGraph$ProvideDesktopMoleculeScopeFactoryMetroFactory$Companion; - public synthetic fun (Lsoftware/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryGraph;Ldev/zacsweers/metro/Provider;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun create (Lsoftware/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryGraph;Ldev/zacsweers/metro/Provider;)Lsoftware/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryGraph$ProvideDesktopMoleculeScopeFactoryMetroFactory; - public final fun declarationMirror (Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; - public synthetic fun invoke ()Ljava/lang/Object; - public final fun invoke ()Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; - public static final fun provideDesktopMoleculeScopeFactory (Lsoftware/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryGraph;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; -} - -public final class software/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryGraph$ProvideDesktopMoleculeScopeFactoryMetroFactory$Companion { - public fun ()V - public final fun create (Lsoftware/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryGraph;Ldev/zacsweers/metro/Provider;)Lsoftware/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryGraph$ProvideDesktopMoleculeScopeFactoryMetroFactory; - public final fun provideDesktopMoleculeScopeFactory (Lsoftware/ralf/app/platform/presenter/molecule/DesktopMoleculeScopeFactoryGraph;Lkotlin/jvm/functions/Function0;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterComponent { - public fun provideDefaultBackGestureDispatcherPresenter ()Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterComponent$DefaultImpls { - public static fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterComponent;)Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph { - public fun provideDefaultBackGestureDispatcherPresenter ()Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$DefaultImpls { - public static fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory : dev/zacsweers/metro/internal/Factory { - public static final field $stable I - public static final field Companion Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory$Companion; - public synthetic fun (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun create (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory; - public final fun declarationMirror ()Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; - public synthetic fun invoke ()Ljava/lang/Object; - public final fun invoke ()Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; - public static final fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory$Companion { - public fun ()V - public final fun create (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph$ProvideDefaultBackGestureDispatcherPresenterMetroFactory; - public final fun provideDefaultBackGestureDispatcherPresenter (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/DefaultBackGestureDispatcherPresenterGraph;)Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - diff --git a/presenter-molecule/impl/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/DefaultMoleculeScopeFactory.kt b/presenter-molecule/impl/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/DefaultMoleculeScopeFactory.kt deleted file mode 100644 index 1597b8e3..00000000 --- a/presenter-molecule/impl/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/DefaultMoleculeScopeFactory.kt +++ /dev/null @@ -1,32 +0,0 @@ -package software.ralf.app.platform.presenter.molecule - -import app.cash.molecule.RecompositionMode -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.EmptyCoroutineContext -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.plus -import software.ralf.app.platform.presenter.PresenterCoroutineScope - -/** - * Creates new [MoleculeScope]s with the given defaults. When calling [createMoleculeScope], then - * [coroutineScopeFactory] is used as default scope. [coroutineContext] allows you to add additional - * elements to created scopes. [recompositionMode] is used for launching [MoleculePresenter]s. - */ -internal class DefaultMoleculeScopeFactory( - @PresenterCoroutineScope private val coroutineScopeFactory: () -> CoroutineScope, - private val coroutineContext: CoroutineContext = EmptyCoroutineContext, - private val recompositionMode: RecompositionMode, -) : MoleculeScopeFactory { - - override fun createMoleculeScope(): MoleculeScope = - createMoleculeScopeFromCoroutineScope(coroutineScopeFactory()) - - override fun createMoleculeScopeFromCoroutineScope( - coroutineScope: CoroutineScope, - coroutineContext: CoroutineContext, - ): MoleculeScope = - MoleculeScope( - coroutineScope = coroutineScope + this.coroutineContext + coroutineContext, - recompositionMode = recompositionMode, - ) -} diff --git a/presenter-molecule/public/api/android/public.api b/presenter-molecule/public/api/android/public.api deleted file mode 100644 index 0112f2ff..00000000 --- a/presenter-molecule/public/api/android/public.api +++ /dev/null @@ -1,80 +0,0 @@ -public final class software/ralf/app/platform/presenter/molecule/LaunchMoleculePresenterKt { - public static final fun launchMoleculePresenter (Lkotlinx/coroutines/CoroutineScope;Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/flow/StateFlow;Lapp/cash/molecule/RecompositionMode;)Lsoftware/ralf/app/platform/presenter/Presenter; - public static final fun launchMoleculePresenter (Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope;Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Ljava/lang/Object;)Lsoftware/ralf/app/platform/presenter/Presenter; - public static final fun launchMoleculePresenter (Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope;Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/flow/StateFlow;)Lsoftware/ralf/app/platform/presenter/Presenter; - public static final fun presentDetached (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Ljava/lang/Object;Lapp/cash/molecule/RecompositionMode;Landroidx/compose/runtime/Composer;II)Lsoftware/ralf/app/platform/presenter/BaseModel; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/MoleculePresenter { - public abstract fun present (Ljava/lang/Object;Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/BaseModel; -} - -public final class software/ralf/app/platform/presenter/molecule/MoleculeScope { - public static final field $stable I - public fun (Lkotlinx/coroutines/CoroutineScope;Lapp/cash/molecule/RecompositionMode;)V - public final fun cancel ()V - public final fun getCoroutineScope ()Lkotlinx/coroutines/CoroutineScope; - public final fun getRecompositionMode ()Lapp/cash/molecule/RecompositionMode; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/MoleculeScopeFactory { - public abstract fun createMoleculeScope ()Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; - public abstract fun createMoleculeScopeFromCoroutineScope (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; - public static synthetic fun createMoleculeScopeFromCoroutineScope$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory;Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; -} - -public final class software/ralf/app/platform/presenter/molecule/MoleculeScopeFactory$DefaultImpls { - public static synthetic fun createMoleculeScopeFromCoroutineScope$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory;Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/BackEventPresenter { - public static final field $stable I - public static final field Companion Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackEventPresenter$Companion; - public static final field EDGE_LEFT I - public static final field EDGE_RIGHT I - public fun (FFFI)V - public final fun getProgress ()F - public final fun getSwipeEdge ()I - public final fun getTouchX ()F - public final fun getTouchY ()F -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/BackEventPresenter$Companion { -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter { - public static final field Companion Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter$Companion; - public abstract fun PredictiveBackHandlerPresenter (ZLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)V - public abstract fun getListenersCount ()Lkotlinx/coroutines/flow/StateFlow; - public abstract fun onPredictiveBack (Lkotlinx/coroutines/flow/Flow;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter$Companion { - public final fun createNewInstance ()Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenterKt { - public static final fun BackHandlerPresenter (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;ZLkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;II)V - public static final fun PredictiveBackHandlerPresenter (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;ZLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V - public static final fun getLocalBackGestureDispatcherPresenter ()Landroidx/compose/runtime/ProvidableCompositionLocal; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/saveable/ReturningSaveableStateHolder { - public abstract fun SaveableStateProvider (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)Ljava/lang/Object; - public abstract fun removeState (Ljava/lang/Object;)V -} - -public final class software/ralf/app/platform/presenter/molecule/saveable/ReturningSaveableStateHolderKt { - public static final fun rememberReturningSaveableStateHolder (Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/molecule/saveable/ReturningSaveableStateHolder; -} - -public final class software/ralf/app/platform/presenter/molecule/text/PresenterTextFieldState : androidx/compose/runtime/State { - public static final field $stable I - public fun ()V - public fun (Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun clearText ()V - public synthetic fun getValue ()Ljava/lang/Object; - public fun getValue ()Ljava/lang/String; - public final fun replaceText (Ljava/lang/String;)V -} diff --git a/presenter-molecule/public/api/desktop/public.api b/presenter-molecule/public/api/desktop/public.api deleted file mode 100644 index 1de6ddf3..00000000 --- a/presenter-molecule/public/api/desktop/public.api +++ /dev/null @@ -1,85 +0,0 @@ -public final class software/ralf/app/platform/presenter/molecule/LaunchMoleculePresenterKt { - public static final fun launchMoleculePresenter (Lkotlinx/coroutines/CoroutineScope;Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/flow/StateFlow;Lapp/cash/molecule/RecompositionMode;)Lsoftware/ralf/app/platform/presenter/Presenter; - public static final fun launchMoleculePresenter (Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope;Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Ljava/lang/Object;)Lsoftware/ralf/app/platform/presenter/Presenter; - public static final fun launchMoleculePresenter (Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope;Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/flow/StateFlow;)Lsoftware/ralf/app/platform/presenter/Presenter; - public static final fun presentDetached (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Ljava/lang/Object;Lapp/cash/molecule/RecompositionMode;Landroidx/compose/runtime/Composer;II)Lsoftware/ralf/app/platform/presenter/BaseModel; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/MoleculePresenter { - public abstract fun present (Ljava/lang/Object;Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/BaseModel; -} - -public final class software/ralf/app/platform/presenter/molecule/MoleculeScope { - public static final field $stable I - public fun (Lkotlinx/coroutines/CoroutineScope;Lapp/cash/molecule/RecompositionMode;)V - public final fun cancel ()V - public final fun getCoroutineScope ()Lkotlinx/coroutines/CoroutineScope; - public final fun getRecompositionMode ()Lapp/cash/molecule/RecompositionMode; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/MoleculeScopeFactory { - public abstract fun createMoleculeScope ()Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; - public abstract fun createMoleculeScopeFromCoroutineScope (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; - public static synthetic fun createMoleculeScopeFromCoroutineScope$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory;Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; -} - -public final class software/ralf/app/platform/presenter/molecule/MoleculeScopeFactory$DefaultImpls { - public static synthetic fun createMoleculeScopeFromCoroutineScope$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScopeFactory;Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; -} - -public final class software/ralf/app/platform/presenter/molecule/WithLocalRetainedValuesStoreKt { - public static final fun withLocalRetainedValuesStore (Landroidx/compose/runtime/retain/RetainedValuesStore;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)Ljava/lang/Object; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/BackEventPresenter { - public static final field $stable I - public static final field Companion Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackEventPresenter$Companion; - public static final field EDGE_LEFT I - public static final field EDGE_RIGHT I - public fun (FFFI)V - public final fun getProgress ()F - public final fun getSwipeEdge ()I - public final fun getTouchX ()F - public final fun getTouchY ()F -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/BackEventPresenter$Companion { -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter { - public static final field Companion Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter$Companion; - public abstract fun PredictiveBackHandlerPresenter (ZLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)V - public abstract fun getListenersCount ()Lkotlinx/coroutines/flow/StateFlow; - public abstract fun onPredictiveBack (Lkotlinx/coroutines/flow/Flow;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter$Companion { - public final fun createNewInstance ()Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenterKt { - public static final fun BackHandlerPresenter (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;ZLkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;II)V - public static final fun PredictiveBackHandlerPresenter (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;ZLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V - public static final fun getLocalBackGestureDispatcherPresenter ()Landroidx/compose/runtime/ProvidableCompositionLocal; -} - -public abstract interface class software/ralf/app/platform/presenter/molecule/saveable/ReturningSaveableStateHolder { - public abstract fun SaveableStateProvider (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)Ljava/lang/Object; - public abstract fun removeState (Ljava/lang/Object;)V -} - -public final class software/ralf/app/platform/presenter/molecule/saveable/ReturningSaveableStateHolderKt { - public static final fun rememberReturningSaveableStateHolder (Landroidx/compose/runtime/Composer;I)Lsoftware/ralf/app/platform/presenter/molecule/saveable/ReturningSaveableStateHolder; -} - -public final class software/ralf/app/platform/presenter/molecule/text/PresenterTextFieldState : androidx/compose/runtime/State { - public static final field $stable I - public fun ()V - public fun (Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun clearText ()V - public synthetic fun getValue ()Ljava/lang/Object; - public fun getValue ()Ljava/lang/String; - public final fun replaceText (Ljava/lang/String;)V -} - diff --git a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/MoleculeScopeFactory.kt b/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/MoleculeScopeFactory.kt deleted file mode 100644 index 1a5733ac..00000000 --- a/presenter-molecule/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/MoleculeScopeFactory.kt +++ /dev/null @@ -1,25 +0,0 @@ -package software.ralf.app.platform.presenter.molecule - -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.EmptyCoroutineContext -import kotlinx.coroutines.CoroutineScope - -/** Creates new [MoleculeScope] instances. */ -public interface MoleculeScopeFactory { - - /** - * Creates a new [MoleculeScope]. Once the returned scope is not needed anymore, you must call - * [MoleculeScope.cancel] to avoid memory leaks. - */ - public fun createMoleculeScope(): MoleculeScope - - /** - * Wraps the given [coroutineScope] in a [MoleculeScope] and applies platform specific defaults in - * order to run Molecule. [coroutineContext] allows you to add additional elements to the used - * [CoroutineScope] and override the platform defaults if necessary. - */ - public fun createMoleculeScopeFromCoroutineScope( - coroutineScope: CoroutineScope, - coroutineContext: CoroutineContext = EmptyCoroutineContext, - ): MoleculeScope -} diff --git a/presenter-molecule/testing/api/android/testing.api b/presenter-molecule/testing/api/android/testing.api deleted file mode 100644 index 604b828e..00000000 --- a/presenter-molecule/testing/api/android/testing.api +++ /dev/null @@ -1,27 +0,0 @@ -public final class software/ralf/app/platform/presenter/molecule/FakeMoleculeScopeFactory : software/ralf/app/platform/presenter/molecule/MoleculeScopeFactory { - public static final field $stable I - public fun (Lkotlinx/coroutines/CoroutineScope;)V - public fun createMoleculeScope ()Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; - public fun createMoleculeScopeFromCoroutineScope (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; -} - -public final class software/ralf/app/platform/presenter/molecule/TestMoleculeScopeKt { - public static final fun moleculeScope (Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; - public static synthetic fun moleculeScope$default (Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; -} - -public final class software/ralf/app/platform/presenter/molecule/TestPresenterKt { - public static final fun test (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlinx/coroutines/flow/StateFlow;Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static synthetic fun test$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlinx/coroutines/flow/StateFlow;Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; - public static final fun test-FHKeTTw (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static synthetic fun test-FHKeTTw$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; - public static final fun test-Zzr-CC0 (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/test/TestScope;Ljava/lang/Object;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static synthetic fun test-Zzr-CC0$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/test/TestScope;Ljava/lang/Object;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/TestBackGestureDispatcherPresenterKt { - public static final fun withBackGestureDispatcher (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/flow/SharedFlow;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter; - public static final fun withBackGestureDispatcherUnit (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/flow/SharedFlow;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter; - public static synthetic fun withBackGestureDispatcherUnit$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/flow/SharedFlow;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter; -} - diff --git a/presenter-molecule/testing/api/desktop/testing.api b/presenter-molecule/testing/api/desktop/testing.api deleted file mode 100644 index 604b828e..00000000 --- a/presenter-molecule/testing/api/desktop/testing.api +++ /dev/null @@ -1,27 +0,0 @@ -public final class software/ralf/app/platform/presenter/molecule/FakeMoleculeScopeFactory : software/ralf/app/platform/presenter/molecule/MoleculeScopeFactory { - public static final field $stable I - public fun (Lkotlinx/coroutines/CoroutineScope;)V - public fun createMoleculeScope ()Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; - public fun createMoleculeScopeFromCoroutineScope (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; -} - -public final class software/ralf/app/platform/presenter/molecule/TestMoleculeScopeKt { - public static final fun moleculeScope (Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; - public static synthetic fun moleculeScope$default (Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculeScope; -} - -public final class software/ralf/app/platform/presenter/molecule/TestPresenterKt { - public static final fun test (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlinx/coroutines/flow/StateFlow;Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static synthetic fun test$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlinx/coroutines/flow/StateFlow;Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; - public static final fun test-FHKeTTw (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static synthetic fun test-FHKeTTw$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/test/TestScope;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; - public static final fun test-Zzr-CC0 (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/test/TestScope;Ljava/lang/Object;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static synthetic fun test-Zzr-CC0$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/test/TestScope;Ljava/lang/Object;Lkotlin/coroutines/CoroutineContext;Lkotlin/time/Duration;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; -} - -public final class software/ralf/app/platform/presenter/molecule/backgesture/TestBackGestureDispatcherPresenterKt { - public static final fun withBackGestureDispatcher (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/flow/SharedFlow;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter; - public static final fun withBackGestureDispatcherUnit (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/flow/SharedFlow;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter; - public static synthetic fun withBackGestureDispatcherUnit$default (Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter;Lkotlinx/coroutines/flow/SharedFlow;ILjava/lang/Object;)Lsoftware/ralf/app/platform/presenter/molecule/MoleculePresenter; -} - diff --git a/presenter-molecule/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/FakeMoleculeScopeFactory.kt b/presenter-molecule/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/FakeMoleculeScopeFactory.kt deleted file mode 100644 index 5ba9f3f7..00000000 --- a/presenter-molecule/testing/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/FakeMoleculeScopeFactory.kt +++ /dev/null @@ -1,31 +0,0 @@ -package software.ralf.app.platform.presenter.molecule - -import app.cash.molecule.RecompositionMode -import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.plus -import kotlinx.coroutines.test.TestScope - -/** - * Uses the given [coroutineScope] to create new [MoleculeScope] instances. In testing environments - * often [TestScope] is used as argument. - */ -public class FakeMoleculeScopeFactory(private val coroutineScope: CoroutineScope) : - MoleculeScopeFactory { - override fun createMoleculeScope(): MoleculeScope = - createMoleculeScopeFromCoroutineScope(coroutineScope) - - override fun createMoleculeScopeFromCoroutineScope( - coroutineScope: CoroutineScope, - coroutineContext: CoroutineContext, - ): MoleculeScope { - return if (coroutineScope is TestScope) { - coroutineScope.moleculeScope(coroutineContext) - } else { - MoleculeScope( - coroutineScope = coroutineScope + coroutineContext, - recompositionMode = RecompositionMode.Immediate, - ) - } - } -} diff --git a/presenter/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/Presenter.kt b/presenter/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/Presenter.kt index 28c99515..be1394b9 100644 --- a/presenter/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/Presenter.kt +++ b/presenter/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/Presenter.kt @@ -29,8 +29,8 @@ import kotlinx.coroutines.flow.StateFlow * ``` * * Presenters can be implemented with any framework or by hand. Most commonly we use - * `MoleculePresenter`, which can be transformed into a [Presenter] with `launchMoleculePresenter`. - * A direct implementation of this interface could look like this: + * `ComposePresenter`, which can be transformed into a [Presenter] with `launchComposePresenter`. A + * direct implementation of this interface could look like this: * ``` * @Inject * class LoginPresenter( diff --git a/recipes/app-framework/impl/build.gradle b/recipes/app-framework/impl/build.gradle index 58c841f3..6f9e3141 100644 --- a/recipes/app-framework/impl/build.gradle +++ b/recipes/app-framework/impl/build.gradle @@ -14,7 +14,7 @@ appPlatform { enableModuleStructure { enableDependencyCheck false } - enableMoleculePresenters true + enableComposePresenters true addImplModuleDependencies true } diff --git a/recipes/app-framework/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/AppComponent.kt b/recipes/app-framework/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/AppComponent.kt index 9b4c57fb..88865079 100644 --- a/recipes/app-framework/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/AppComponent.kt +++ b/recipes/app-framework/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/AppComponent.kt @@ -6,7 +6,7 @@ import software.amazon.lastmile.kotlin.inject.anvil.AppScope import software.amazon.lastmile.kotlin.inject.anvil.ContributesTo import software.amazon.lastmile.kotlin.inject.anvil.ForScope import software.amazon.lastmile.kotlin.inject.anvil.SingleIn -import software.ralf.app.platform.presenter.molecule.MoleculeScopeFactory +import software.ralf.app.platform.presenter.compose.ComposePresenterScopeFactory import software.ralf.app.platform.recipes.swiftui.SwiftUiHomePresenter import software.ralf.app.platform.scope.Scoped import software.ralf.app.platform.scope.coroutine.CoroutineScopeScoped @@ -35,5 +35,5 @@ interface AppComponent { val swiftUiHomePresenter: SwiftUiHomePresenter /** Factory needed to launch presenters from native. */ - val moleculeScopeFactory: MoleculeScopeFactory + val composePresenterScopeFactory: ComposePresenterScopeFactory } diff --git a/recipes/app-framework/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/TemplateProvider.kt b/recipes/app-framework/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/TemplateProvider.kt index ae0870d4..25c28647 100644 --- a/recipes/app-framework/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/TemplateProvider.kt +++ b/recipes/app-framework/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/TemplateProvider.kt @@ -3,9 +3,9 @@ package software.ralf.app.platform.recipes import kotlinx.coroutines.flow.StateFlow import me.tatarka.inject.annotations.Assisted import me.tatarka.inject.annotations.Inject -import software.ralf.app.platform.presenter.molecule.MoleculeScope -import software.ralf.app.platform.presenter.molecule.MoleculeScopeFactory -import software.ralf.app.platform.presenter.molecule.launchMoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenterScope +import software.ralf.app.platform.presenter.compose.ComposePresenterScopeFactory +import software.ralf.app.platform.presenter.compose.launchComposePresenter import software.ralf.app.platform.recipes.template.RecipesAppTemplate import software.ralf.app.platform.recipes.template.RootPresenter @@ -18,34 +18,34 @@ import software.ralf.app.platform.recipes.template.RootPresenter @Inject class TemplateProvider( presenter: RootPresenter, - @Assisted private val moleculeScope: MoleculeScope, + @Assisted private val composePresenterScope: ComposePresenterScope, ) { /** The templates that should be rendered in the UI. */ val templates: StateFlow by lazy { - moleculeScope.launchMoleculePresenter(presenter = presenter, input = Unit).model + composePresenterScope.launchComposePresenter(presenter = presenter, input = Unit).model } /** Releases all resources and stops [templates] from updating further. */ fun cancel() { - moleculeScope.cancel() + composePresenterScope.cancel() } /** Factory class to create a new instance of [TemplateProvider]. */ // Note that the Factory class technically is not required. But since TemplateProvider - // contains a MoleculeScope that needs to be canceled explicitly, this Factory helps to + // contains a ComposePresenterScope that needs to be canceled explicitly, this Factory helps to // highlight that the created instance contains resources that must be cleaned up. @Inject class Factory( - private val moleculeScopeFactory: MoleculeScopeFactory, - private val templateProvider: (MoleculeScope) -> TemplateProvider, + private val composePresenterScopeFactory: ComposePresenterScopeFactory, + private val templateProvider: (ComposePresenterScope) -> TemplateProvider, ) { /** * Creates a new instance of [TemplateProvider]. Call [TemplateProvider.cancel] when the * instance not needed anymore to avoid leaking resources. */ fun createTemplateProvider(): TemplateProvider { - return templateProvider(moleculeScopeFactory.createMoleculeScope()) + return templateProvider(composePresenterScopeFactory.createComposePresenterScope()) } } } diff --git a/recipes/app/android/build.gradle b/recipes/app/android/build.gradle index bbb08f83..c8138385 100644 --- a/recipes/app/android/build.gradle +++ b/recipes/app/android/build.gradle @@ -9,7 +9,7 @@ appPlatform { enableComposeUi true enableKotlinInject true enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true addImplModuleDependencies true } diff --git a/recipes/app/desktop/build.gradle b/recipes/app/desktop/build.gradle index cb201f4a..c83a0a52 100644 --- a/recipes/app/desktop/build.gradle +++ b/recipes/app/desktop/build.gradle @@ -9,7 +9,7 @@ appPlatform { enableComposeUi true enableKotlinInject true enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true addImplModuleDependencies true } diff --git a/recipes/app/ios/recipesIosApp/PresenterViews/ComposePresenterWrapper.swift b/recipes/app/ios/recipesIosApp/PresenterViews/ComposePresenterWrapper.swift new file mode 100644 index 00000000..addb4fab --- /dev/null +++ b/recipes/app/ios/recipesIosApp/PresenterViews/ComposePresenterWrapper.swift @@ -0,0 +1,31 @@ +// +// ComposePresenterWrapper.swift +// recipesIosApp +// +// Created by Wang, Jessalyn on 11/24/25. +// + +import RecipesApp + +/// Wraps a Compose Presenter that has been converted into a regular Presenter. +/// +/// In order to convert a Compose Presenter to a regular Presenter, we need to create a ComposePresenterScope, +/// and that scope needs to be cancelled when we are done, +/// so we create this class which will automatically cancel the scope upon deinit. +class ComposePresenterWrapper: Presenter { + var model: Kotlinx_coroutines_coreStateFlow { wrapped.model } + + private let wrapped: Presenter + private let scope: ComposePresenterScope + + init(composePresenterScopeFactory: ComposePresenterScopeFactory, composePresenter: ComposePresenter, input: Any) { + let scope = composePresenterScopeFactory.createComposePresenterScope() + self.scope = scope + self.wrapped = scope.launchComposePresenter(presenter: composePresenter, input: input) + } + + deinit { + scope.cancel() + } + +} diff --git a/recipes/app/ios/recipesIosApp/PresenterViews/MoleculePresenterWrapper.swift b/recipes/app/ios/recipesIosApp/PresenterViews/MoleculePresenterWrapper.swift deleted file mode 100644 index cf6467b7..00000000 --- a/recipes/app/ios/recipesIosApp/PresenterViews/MoleculePresenterWrapper.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// MoleculePresenterWrapper.swift -// recipesIosApp -// -// Created by Wang, Jessalyn on 11/24/25. -// - -import RecipesApp - -/// Wraps a Molecule Presenter that has been converted into a regular Presenter. -/// -/// In order to convert a Molecule Presenter to a regular Presenter, we need to create a MoleculeScope, -/// and that scope needs to be cancelled when we are done, -/// so we create this class which will automatically cancel the scope upon deinit. -class MoleculePresenterWrapper: Presenter { - var model: Kotlinx_coroutines_coreStateFlow { wrapped.model } - - private let wrapped: Presenter - private let scope: MoleculeScope - - init(moleculeScopeFactory: MoleculeScopeFactory, moleculePresenter: MoleculePresenter, input: Any) { - let scope = moleculeScopeFactory.createMoleculeScope() - self.scope = scope - self.wrapped = scope.launchMoleculePresenter(presenter: moleculePresenter, input: input) - } - - deinit { - scope.cancel() - } - -} diff --git a/recipes/app/ios/recipesIosApp/SwiftUI/SwiftUiHomePresenterBuilder.swift b/recipes/app/ios/recipesIosApp/SwiftUI/SwiftUiHomePresenterBuilder.swift index 3965205e..a90a3aca 100644 --- a/recipes/app/ios/recipesIosApp/SwiftUI/SwiftUiHomePresenterBuilder.swift +++ b/recipes/app/ios/recipesIosApp/SwiftUI/SwiftUiHomePresenterBuilder.swift @@ -15,9 +15,9 @@ struct SwiftUiHomePresenterBuilder { } func makeHomePresenter() -> Presenter { - MoleculePresenterWrapper( - moleculeScopeFactory: appComponent.moleculeScopeFactory, - moleculePresenter: appComponent.swiftUiHomePresenter, + ComposePresenterWrapper( + composePresenterScopeFactory: appComponent.composePresenterScopeFactory, + composePresenter: appComponent.swiftUiHomePresenter, input: Void() ) } diff --git a/recipes/app/web/build.gradle b/recipes/app/web/build.gradle index cb201f4a..c83a0a52 100644 --- a/recipes/app/web/build.gradle +++ b/recipes/app/web/build.gradle @@ -9,7 +9,7 @@ appPlatform { enableComposeUi true enableKotlinInject true enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true addImplModuleDependencies true } diff --git a/recipes/common/impl/build.gradle b/recipes/common/impl/build.gradle index 11158492..0ed7a374 100644 --- a/recipes/common/impl/build.gradle +++ b/recipes/common/impl/build.gradle @@ -11,8 +11,8 @@ appPlatform { enableComposeUi true enableKotlinInject true enableModuleStructure true - enableMoleculePresenters true - enableMoleculePresenterBackstack true + enableComposePresenters true + enableComposePresenterBackstack true } dependencies { diff --git a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/appbar/menu/MenuPresenter.kt b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/appbar/menu/MenuPresenter.kt index b6a36da1..ba6838c1 100644 --- a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/appbar/menu/MenuPresenter.kt +++ b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/appbar/menu/MenuPresenter.kt @@ -23,14 +23,14 @@ import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.delay import software.ralf.app.platform.inject.ContributesRenderer import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter import software.ralf.app.platform.recipes.appbar.AppBarConfig import software.ralf.app.platform.recipes.appbar.AppBarConfigModel import software.ralf.app.platform.recipes.appbar.menu.MenuPresenter.Model import software.ralf.app.platform.renderer.ComposeRenderer /** This presenter provides a custom menu in the App Bar. */ -class MenuPresenter : MoleculePresenter { +class MenuPresenter : ComposePresenter { @Composable override fun present(input: Unit): Model { var itemCount by remember { mutableIntStateOf(2) } diff --git a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/backstack/CrossSlideBackstackPresenter.kt b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/backstack/CrossSlideBackstackPresenter.kt index 7269d73c..bcb7674a 100644 --- a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/backstack/CrossSlideBackstackPresenter.kt +++ b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/backstack/CrossSlideBackstackPresenter.kt @@ -8,7 +8,7 @@ import software.ralf.app.platform.ExperimentalAppPlatform import software.ralf.app.platform.presenter.BaseModel import software.ralf.app.platform.presenter.backstack.nav3.PresenterBackstackModel import software.ralf.app.platform.presenter.backstack.nav3.presenterBackstack -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter import software.ralf.app.platform.recipes.appbar.AppBarConfig import software.ralf.app.platform.recipes.appbar.AppBarConfigModel import software.ralf.app.platform.recipes.backstack.CrossSlideBackstackPresenter.Model @@ -19,8 +19,8 @@ import software.ralf.app.platform.recipes.backstack.CrossSlideBackstackPresenter * as an element. */ class CrossSlideBackstackPresenter( - private val initialPresenter: MoleculePresenter -) : MoleculePresenter { + private val initialPresenter: ComposePresenter +) : ComposePresenter { @Composable override fun present(input: Unit): Model { return presenterBackstack(initialPresenter) { backstack -> diff --git a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/backstack/presenter/BackstackChildPresenter.kt b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/backstack/presenter/BackstackChildPresenter.kt index 5af198cb..ca051e52 100644 --- a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/backstack/presenter/BackstackChildPresenter.kt +++ b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/backstack/presenter/BackstackChildPresenter.kt @@ -25,7 +25,7 @@ import software.ralf.app.platform.inject.ContributesRenderer import software.ralf.app.platform.presenter.BaseModel import software.ralf.app.platform.presenter.backstack.nav3.LocalBackstackScope import software.ralf.app.platform.presenter.backstack.nav3.requireNotNull -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter import software.ralf.app.platform.recipes.appbar.AppBarConfig import software.ralf.app.platform.recipes.appbar.AppBarConfigModel import software.ralf.app.platform.recipes.backstack.presenter.BackstackChildPresenter.Model @@ -35,7 +35,7 @@ import software.ralf.app.platform.renderer.ComposeRenderer * A presenter that is added to the backstack and has a button to put a new instance on top of the * stack. */ -class BackstackChildPresenter(private val index: Int) : MoleculePresenter { +class BackstackChildPresenter(private val index: Int) : ComposePresenter { @Composable override fun present(input: Unit): Model { val backstack = LocalBackstackScope.requireNotNull() diff --git a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/landing/LandingPresenter.kt b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/landing/LandingPresenter.kt index 4ed00d37..e23afad4 100644 --- a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/landing/LandingPresenter.kt +++ b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/landing/LandingPresenter.kt @@ -8,7 +8,7 @@ import software.ralf.app.platform.ExperimentalAppPlatform import software.ralf.app.platform.presenter.BaseModel import software.ralf.app.platform.presenter.backstack.nav3.LocalBackstackScope import software.ralf.app.platform.presenter.backstack.nav3.requireNotNull -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter import software.ralf.app.platform.recipes.appbar.menu.MenuPresenter import software.ralf.app.platform.recipes.backstack.presenter.BackstackChildPresenter import software.ralf.app.platform.recipes.landing.LandingPresenter.Model @@ -16,7 +16,7 @@ import software.ralf.app.platform.recipes.nav3.Navigation3HomePresenter /** The presenter that is responsible to show the content of the landing page in the Recipes app. */ @Inject -class LandingPresenter : MoleculePresenter { +class LandingPresenter : ComposePresenter { @Composable override fun present(input: Unit): Model { val backstack = LocalBackstackScope.requireNotNull() diff --git a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/nav3/Navigation3ChildPresenter.kt b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/nav3/Navigation3ChildPresenter.kt index ecdd00f5..c3dd650e 100644 --- a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/nav3/Navigation3ChildPresenter.kt +++ b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/nav3/Navigation3ChildPresenter.kt @@ -14,10 +14,10 @@ import software.ralf.app.platform.ExperimentalAppPlatform import software.ralf.app.platform.presenter.BaseModel import software.ralf.app.platform.presenter.backstack.nav3.LocalBackstackScope import software.ralf.app.platform.presenter.backstack.nav3.requireNotNull -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter import software.ralf.app.platform.recipes.nav3.Navigation3ChildPresenter.Model -class Navigation3ChildPresenter(private val index: Int) : MoleculePresenter { +class Navigation3ChildPresenter(private val index: Int) : ComposePresenter { @Composable override fun present(input: Unit): Model { val backstack = LocalBackstackScope.requireNotNull() diff --git a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/nav3/Navigation3HomePresenter.kt b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/nav3/Navigation3HomePresenter.kt index 6a88ff75..f3f1d309 100644 --- a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/nav3/Navigation3HomePresenter.kt +++ b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/nav3/Navigation3HomePresenter.kt @@ -9,14 +9,14 @@ import software.ralf.app.platform.ExperimentalAppPlatform import software.ralf.app.platform.presenter.BaseModel import software.ralf.app.platform.presenter.backstack.nav3.PresenterBackstackModel import software.ralf.app.platform.presenter.backstack.nav3.presenterBackstack -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter import software.ralf.app.platform.recipes.appbar.AppBarConfig import software.ralf.app.platform.recipes.appbar.AppBarConfigModel import software.ralf.app.platform.recipes.nav3.Navigation3HomePresenter.Model /** Presenter that hosts a Navigation 3 presenter backstack. */ @Inject -class Navigation3HomePresenter : MoleculePresenter { +class Navigation3HomePresenter : ComposePresenter { @Composable override fun present(input: Unit): Model { return presenterBackstack(Navigation3ChildPresenter(index = 0)) { backstack -> diff --git a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/swiftui/SwiftUiChildPresenter.kt b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/swiftui/SwiftUiChildPresenter.kt index eee5198e..e9fe414d 100644 --- a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/swiftui/SwiftUiChildPresenter.kt +++ b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/swiftui/SwiftUiChildPresenter.kt @@ -10,13 +10,13 @@ import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter import software.ralf.app.platform.recipes.swiftui.SwiftUiChildPresenter.Model class SwiftUiChildPresenter( private val index: Int, - private val backstack: SnapshotStateList>, -) : MoleculePresenter { + private val backstack: SnapshotStateList>, +) : ComposePresenter { @Composable override fun present(input: Unit): Model { val counter by diff --git a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/swiftui/SwiftUiHomePresenter.kt b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/swiftui/SwiftUiHomePresenter.kt index 6bc739cf..1034e8eb 100644 --- a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/swiftui/SwiftUiHomePresenter.kt +++ b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/swiftui/SwiftUiHomePresenter.kt @@ -7,7 +7,7 @@ import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.remember import me.tatarka.inject.annotations.Inject import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter import software.ralf.app.platform.recipes.swiftui.SwiftUiHomePresenter.Model /** @@ -28,11 +28,11 @@ import software.ralf.app.platform.recipes.swiftui.SwiftUiHomePresenter.Model * class in a hashable `struct`. */ @Inject -class SwiftUiHomePresenter : MoleculePresenter { +class SwiftUiHomePresenter : ComposePresenter { @Composable override fun present(input: Unit): Model { val backstack = remember { - mutableStateListOf>().apply { + mutableStateListOf>().apply { // There must be always one element. add(SwiftUiChildPresenter(index = 0, backstack = this)) } diff --git a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/template/RootPresenter.kt b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/template/RootPresenter.kt index 8d826e63..050d4ca2 100644 --- a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/template/RootPresenter.kt +++ b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/template/RootPresenter.kt @@ -4,9 +4,9 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.runtime.withCompositionLocal import me.tatarka.inject.annotations.Inject -import software.ralf.app.platform.presenter.molecule.MoleculePresenter -import software.ralf.app.platform.presenter.molecule.backgesture.BackGestureDispatcherPresenter -import software.ralf.app.platform.presenter.molecule.backgesture.LocalBackGestureDispatcherPresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter +import software.ralf.app.platform.presenter.compose.backgesture.BackGestureDispatcherPresenter +import software.ralf.app.platform.presenter.compose.backgesture.LocalBackGestureDispatcherPresenter import software.ralf.app.platform.presenter.template.toTemplate import software.ralf.app.platform.recipes.appbar.AppBarConfig import software.ralf.app.platform.recipes.appbar.AppBarConfigModel @@ -21,7 +21,7 @@ import software.ralf.app.platform.recipes.landing.LandingPresenter class RootPresenter( private val landingPresenter: LandingPresenter, private val backGestureDispatcherPresenter: BackGestureDispatcherPresenter, -) : MoleculePresenter { +) : ComposePresenter { @Composable override fun present(input: Unit): RecipesAppTemplate { return withCompositionLocal( diff --git a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/template/RootPresenterRenderer.kt b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/template/RootPresenterRenderer.kt index 76d5c59d..fd06937d 100644 --- a/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/template/RootPresenterRenderer.kt +++ b/recipes/common/impl/src/commonMain/kotlin/software/ralf/app/platform/recipes/template/RootPresenterRenderer.kt @@ -31,8 +31,8 @@ import androidx.compose.ui.unit.dp import me.tatarka.inject.annotations.Inject import software.ralf.app.platform.inject.ContributesRenderer import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.backgesture.BackGestureDispatcherPresenter -import software.ralf.app.platform.presenter.molecule.backgesture.ForwardBackPressEventsToPresenters +import software.ralf.app.platform.presenter.compose.backgesture.BackGestureDispatcherPresenter +import software.ralf.app.platform.presenter.compose.backgesture.ForwardBackPressEventsToPresenters import software.ralf.app.platform.recipes.appbar.AppBarConfig import software.ralf.app.platform.renderer.ComposeRenderer import software.ralf.app.platform.renderer.Renderer diff --git a/renderer-android-view/public/api/public.api b/renderer-android-view/public/api/public.api index d634af9d..1528904f 100644 --- a/renderer-android-view/public/api/public.api +++ b/renderer-android-view/public/api/public.api @@ -1,5 +1,5 @@ -public final class software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenterAndroidKt { - public static final fun forwardBackPressEventsToPresenters (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter;Landroidx/activity/OnBackPressedDispatcherOwner;)V +public final class software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenterAndroidKt { + public static final fun forwardBackPressEventsToPresenters (Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter;Landroidx/activity/OnBackPressedDispatcherOwner;)V } public class software/ralf/app/platform/renderer/AndroidRendererFactory : software/ralf/app/platform/renderer/BaseRendererFactory { diff --git a/renderer-android-view/public/build.gradle b/renderer-android-view/public/build.gradle index e475c14f..607f1a2a 100644 --- a/renderer-android-view/public/build.gradle +++ b/renderer-android-view/public/build.gradle @@ -11,7 +11,7 @@ dependencies { commonMainApi project(':presenter:public') commonMainApi project(':renderer:public') - commonMainImplementation project(':presenter-molecule:public') + commonMainImplementation project(':presenter-compose:public') // Use a lower version to not force a higher version on consumers. androidMainApi libs.androidx.activity diff --git a/renderer-android-view/public/src/androidDeviceTest/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/ForwardBackPressEventsToPresentersAndroidTest.kt b/renderer-android-view/public/src/androidDeviceTest/kotlin/software/ralf/app/platform/presenter/compose/backgesture/ForwardBackPressEventsToPresentersAndroidTest.kt similarity index 95% rename from renderer-android-view/public/src/androidDeviceTest/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/ForwardBackPressEventsToPresentersAndroidTest.kt rename to renderer-android-view/public/src/androidDeviceTest/kotlin/software/ralf/app/platform/presenter/compose/backgesture/ForwardBackPressEventsToPresentersAndroidTest.kt index 77ff9c25..20f006f1 100644 --- a/renderer-android-view/public/src/androidDeviceTest/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/ForwardBackPressEventsToPresentersAndroidTest.kt +++ b/renderer-android-view/public/src/androidDeviceTest/kotlin/software/ralf/app/platform/presenter/compose/backgesture/ForwardBackPressEventsToPresentersAndroidTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.backgesture +package software.ralf.app.platform.presenter.compose.backgesture import androidx.test.espresso.Espresso import androidx.test.ext.junit.rules.ActivityScenarioRule diff --git a/renderer-android-view/public/src/androidMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenterAndroid.kt b/renderer-android-view/public/src/androidMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenterAndroid.kt similarity index 98% rename from renderer-android-view/public/src/androidMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenterAndroid.kt rename to renderer-android-view/public/src/androidMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenterAndroid.kt index f117f130..2948181e 100644 --- a/renderer-android-view/public/src/androidMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenterAndroid.kt +++ b/renderer-android-view/public/src/androidMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenterAndroid.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.backgesture +package software.ralf.app.platform.presenter.compose.backgesture import androidx.activity.BackEventCompat import androidx.activity.OnBackPressedCallback diff --git a/renderer-compose-multiplatform/public/api/android/public.api b/renderer-compose-multiplatform/public/api/android/public.api index ef618b1f..eff06a4d 100644 --- a/renderer-compose-multiplatform/public/api/android/public.api +++ b/renderer-compose-multiplatform/public/api/android/public.api @@ -1,5 +1,5 @@ -public final class software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenterComposeKt { - public static final fun ForwardBackPressEventsToPresenters (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter;Landroidx/compose/runtime/Composer;I)V +public final class software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenterComposeKt { + public static final fun ForwardBackPressEventsToPresenters (Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter;Landroidx/compose/runtime/Composer;I)V } public abstract interface class software/ralf/app/platform/renderer/BaseComposeRenderer { @@ -47,6 +47,6 @@ public final class software/ralf/app/platform/renderer/ComposeRendererFactoryKt } public final class software/ralf/app/platform/renderer/text/PresenterBackedTextFieldStateKt { - public static final fun rememberPresenterBackedTextFieldState (Lsoftware/ralf/app/platform/presenter/molecule/text/PresenterTextFieldState;Landroidx/compose/runtime/Composer;I)Landroidx/compose/foundation/text/input/TextFieldState; + public static final fun rememberPresenterBackedTextFieldState (Lsoftware/ralf/app/platform/presenter/compose/text/PresenterTextFieldState;Landroidx/compose/runtime/Composer;I)Landroidx/compose/foundation/text/input/TextFieldState; } diff --git a/renderer-compose-multiplatform/public/api/desktop/public.api b/renderer-compose-multiplatform/public/api/desktop/public.api index 21418931..0b84b760 100644 --- a/renderer-compose-multiplatform/public/api/desktop/public.api +++ b/renderer-compose-multiplatform/public/api/desktop/public.api @@ -1,5 +1,5 @@ -public final class software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenterComposeKt { - public static final fun ForwardBackPressEventsToPresenters (Lsoftware/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenter;Landroidx/compose/runtime/Composer;I)V +public final class software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenterComposeKt { + public static final fun ForwardBackPressEventsToPresenters (Lsoftware/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenter;Landroidx/compose/runtime/Composer;I)V } public abstract interface class software/ralf/app/platform/renderer/BaseComposeRenderer { @@ -38,6 +38,6 @@ public final class software/ralf/app/platform/renderer/ComposeRendererFactoryKt } public final class software/ralf/app/platform/renderer/text/PresenterBackedTextFieldStateKt { - public static final fun rememberPresenterBackedTextFieldState (Lsoftware/ralf/app/platform/presenter/molecule/text/PresenterTextFieldState;Landroidx/compose/runtime/Composer;I)Landroidx/compose/foundation/text/input/TextFieldState; + public static final fun rememberPresenterBackedTextFieldState (Lsoftware/ralf/app/platform/presenter/compose/text/PresenterTextFieldState;Landroidx/compose/runtime/Composer;I)Landroidx/compose/foundation/text/input/TextFieldState; } diff --git a/renderer-compose-multiplatform/public/build.gradle b/renderer-compose-multiplatform/public/build.gradle index bccd50eb..62cb389a 100644 --- a/renderer-compose-multiplatform/public/build.gradle +++ b/renderer-compose-multiplatform/public/build.gradle @@ -11,7 +11,7 @@ appPlatformBuildSrc { dependencies { commonMainApi project(':presenter:public') - commonMainApi project(':presenter-molecule:public') + commonMainApi project(':presenter-compose:public') commonMainApi project(':renderer:public') commonMainApi project(':scope:public') commonMainApi libs.compose.foundation @@ -25,7 +25,7 @@ dependencies { commonTestImplementation libs.metro.runtime androidDeviceTestImplementation project(':metro:public') - androidDeviceTestImplementation project(':presenter-molecule:impl') + androidDeviceTestImplementation project(':presenter-compose:impl') androidDeviceTestImplementation libs.androidx.activity.compose androidDeviceTestImplementation libs.androidx.test.espresso androidDeviceTestImplementation libs.compose.ui.test.junit4 diff --git a/renderer-compose-multiplatform/public/src/androidDeviceTest/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/ForwardBackPressEventsToPresentersComposeTest.kt b/renderer-compose-multiplatform/public/src/androidDeviceTest/kotlin/software/ralf/app/platform/presenter/compose/backgesture/ForwardBackPressEventsToPresentersComposeTest.kt similarity index 91% rename from renderer-compose-multiplatform/public/src/androidDeviceTest/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/ForwardBackPressEventsToPresentersComposeTest.kt rename to renderer-compose-multiplatform/public/src/androidDeviceTest/kotlin/software/ralf/app/platform/presenter/compose/backgesture/ForwardBackPressEventsToPresentersComposeTest.kt index 43d101e2..f3f2692a 100644 --- a/renderer-compose-multiplatform/public/src/androidDeviceTest/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/ForwardBackPressEventsToPresentersComposeTest.kt +++ b/renderer-compose-multiplatform/public/src/androidDeviceTest/kotlin/software/ralf/app/platform/presenter/compose/backgesture/ForwardBackPressEventsToPresentersComposeTest.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.backgesture +package software.ralf.app.platform.presenter.compose.backgesture import androidx.activity.compose.setContent import androidx.compose.foundation.text.BasicText @@ -18,8 +18,8 @@ import androidx.test.ext.junit.rules.ActivityScenarioRule import org.junit.Rule import org.junit.Test import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter -import software.ralf.app.platform.presenter.molecule.backgesture.ForwardBackPressEventsToPresentersComposeTest.TestPresenter.Model +import software.ralf.app.platform.presenter.compose.ComposePresenter +import software.ralf.app.platform.presenter.compose.backgesture.ForwardBackPressEventsToPresentersComposeTest.TestPresenter.Model import software.ralf.app.platform.renderer.ComposeRenderer import software.ralf.app.platform.renderer.TestActivity import software.ralf.app.platform.renderer.getActivityFromTestRule @@ -70,7 +70,7 @@ class ForwardBackPressEventsToPresentersComposeTest { private class TestPresenter( private val backGestureDispatcherPresenter: BackGestureDispatcherPresenter - ) : MoleculePresenter { + ) : ComposePresenter { @Composable override fun present(input: Unit): Model { return withCompositionLocal( diff --git a/renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenterCompose.kt b/renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenterCompose.kt similarity index 98% rename from renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenterCompose.kt rename to renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenterCompose.kt index 09ca3a13..838f8165 100644 --- a/renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/molecule/backgesture/BackGestureDispatcherPresenterCompose.kt +++ b/renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/presenter/compose/backgesture/BackGestureDispatcherPresenterCompose.kt @@ -1,4 +1,4 @@ -package software.ralf.app.platform.presenter.molecule.backgesture +package software.ralf.app.platform.presenter.compose.backgesture import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect diff --git a/renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/renderer/BaseComposeRenderer.kt b/renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/renderer/BaseComposeRenderer.kt index 1ac29931..551ab386 100644 --- a/renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/renderer/BaseComposeRenderer.kt +++ b/renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/renderer/BaseComposeRenderer.kt @@ -23,7 +23,7 @@ import software.ralf.app.platform.presenter.BaseModel // This separate base interface is needed for several implementations that cannot extend the // abstract ComposeRenderer class. It also helps to distinguish between the normal Renderer API // vs this BaseComposeRenderer API. Note that BaseComposeRenderer is not extending the Renderer -// interface. This distinction is similar to Presenter and MoleculePresenter. +// interface. This distinction is similar to Presenter and ComposePresenter. public interface BaseComposeRenderer { /** Render the given [model] on screen using Compose UI with the provided [modifier]. */ // Android Lint will complain that this function should start with an uppercase letter, but diff --git a/renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/renderer/text/PresenterBackedTextFieldState.kt b/renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/renderer/text/PresenterBackedTextFieldState.kt index 54bd10d5..a300cec0 100644 --- a/renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/renderer/text/PresenterBackedTextFieldState.kt +++ b/renderer-compose-multiplatform/public/src/commonMain/kotlin/software/ralf/app/platform/renderer/text/PresenterBackedTextFieldState.kt @@ -10,7 +10,7 @@ import androidx.compose.runtime.rememberUpdatedState import androidx.compose.runtime.snapshotFlow import kotlinx.coroutines.flow.collectLatest import software.ralf.app.platform.ExperimentalAppPlatform -import software.ralf.app.platform.presenter.molecule.text.PresenterTextFieldState +import software.ralf.app.platform.presenter.compose.text.PresenterTextFieldState /** * Remembers a Compose Foundation [TextFieldState] backed by [presenterState]. diff --git a/renderer-compose-multiplatform/public/src/desktopTest/kotlin/software/ralf/app/platform/renderer/text/PresenterBackedTextFieldStateTest.kt b/renderer-compose-multiplatform/public/src/desktopTest/kotlin/software/ralf/app/platform/renderer/text/PresenterBackedTextFieldStateTest.kt index e07c80b8..64f3c328 100644 --- a/renderer-compose-multiplatform/public/src/desktopTest/kotlin/software/ralf/app/platform/renderer/text/PresenterBackedTextFieldStateTest.kt +++ b/renderer-compose-multiplatform/public/src/desktopTest/kotlin/software/ralf/app/platform/renderer/text/PresenterBackedTextFieldStateTest.kt @@ -8,7 +8,7 @@ import assertk.assertThat import assertk.assertions.isEqualTo import kotlin.test.Test import software.ralf.app.platform.ExperimentalAppPlatform -import software.ralf.app.platform.presenter.molecule.text.PresenterTextFieldState +import software.ralf.app.platform.presenter.compose.text.PresenterTextFieldState @OptIn(ExperimentalAppPlatform::class, ExperimentalTestApi::class) class PresenterBackedTextFieldStateTest { diff --git a/sample/app-framework/impl-ui-test-robots/build.gradle b/sample/app-framework/impl-ui-test-robots/build.gradle index b21049f5..5c7b8d21 100644 --- a/sample/app-framework/impl-ui-test-robots/build.gradle +++ b/sample/app-framework/impl-ui-test-robots/build.gradle @@ -11,7 +11,7 @@ appPlatform { enableComposeUi true enableMetro true enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true } dependencies { diff --git a/sample/app-framework/impl/build.gradle b/sample/app-framework/impl/build.gradle index ba9aa251..95077bfa 100644 --- a/sample/app-framework/impl/build.gradle +++ b/sample/app-framework/impl/build.gradle @@ -14,7 +14,7 @@ appPlatform { enableModuleStructure { enableDependencyCheck false } - enableMoleculePresenters true + enableComposePresenters true addImplModuleDependencies true } diff --git a/sample/app-framework/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/TemplateProvider.kt b/sample/app-framework/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/TemplateProvider.kt index 33e3e47d..a3c04827 100644 --- a/sample/app-framework/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/TemplateProvider.kt +++ b/sample/app-framework/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/TemplateProvider.kt @@ -5,9 +5,9 @@ import dev.zacsweers.metro.AssistedFactory import dev.zacsweers.metro.AssistedInject import dev.zacsweers.metro.Inject import kotlinx.coroutines.flow.StateFlow -import software.ralf.app.platform.presenter.molecule.MoleculeScope -import software.ralf.app.platform.presenter.molecule.MoleculeScopeFactory -import software.ralf.app.platform.presenter.molecule.launchMoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenterScope +import software.ralf.app.platform.presenter.compose.ComposePresenterScopeFactory +import software.ralf.app.platform.presenter.compose.launchComposePresenter import software.ralf.app.platform.sample.navigation.NavigationPresenter import software.ralf.app.platform.sample.template.SampleAppTemplate import software.ralf.app.platform.sample.template.SampleAppTemplatePresenter @@ -24,13 +24,13 @@ import software.ralf.app.platform.sample.template.SampleAppTemplatePresenter class TemplateProvider( presenter: NavigationPresenter, templatePresenterFactory: SampleAppTemplatePresenter.Factory, - @Assisted private val moleculeScope: MoleculeScope, + @Assisted private val composePresenterScope: ComposePresenterScope, ) { /** The templates that should be rendered in the UI. */ val templates: StateFlow by lazy { - moleculeScope - .launchMoleculePresenter( + composePresenterScope + .launchComposePresenter( presenter = templatePresenterFactory.createSampleAppTemplatePresenter(presenter), input = Unit, ) @@ -39,7 +39,7 @@ class TemplateProvider( /** Releases all resources and stops [templates] from updating further. */ fun cancel() { - moleculeScope.cancel() + composePresenterScope.cancel() } /** @@ -48,17 +48,17 @@ class TemplateProvider( */ @AssistedFactory fun interface InternalFactory { - /** Create a new instance of [TemplateProvider] with the given [MoleculeScope]. */ - fun create(moleculeScope: MoleculeScope): TemplateProvider + /** Create a new instance of [TemplateProvider] with the given [ComposePresenterScope]. */ + fun create(composePresenterScope: ComposePresenterScope): TemplateProvider } /** Factory class to create a new instance of [TemplateProvider]. */ // Note that the Factory class technically is not required. But since TemplateProvider - // contains a MoleculeScope that needs to be canceled explicitly, this Factory helps to + // contains a ComposePresenterScope that needs to be canceled explicitly, this Factory helps to // highlight that the created instance contains resources that must be cleaned up. @Inject class Factory( - private val moleculeScopeFactory: MoleculeScopeFactory, + private val composePresenterScopeFactory: ComposePresenterScopeFactory, private val templateProviderFactory: InternalFactory, ) { /** @@ -66,7 +66,9 @@ class TemplateProvider( * instance not needed anymore to avoid leaking resources. */ fun createTemplateProvider(): TemplateProvider { - return templateProviderFactory.create(moleculeScopeFactory.createMoleculeScope()) + return templateProviderFactory.create( + composePresenterScopeFactory.createComposePresenterScope() + ) } } } diff --git a/sample/app/android/build.gradle b/sample/app/android/build.gradle index 01609536..e9153d46 100644 --- a/sample/app/android/build.gradle +++ b/sample/app/android/build.gradle @@ -9,7 +9,7 @@ appPlatform { enableComposeUi true enableMetro true enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true addImplModuleDependencies true } diff --git a/sample/app/desktop/build.gradle b/sample/app/desktop/build.gradle index 14b6fe32..bdbfdbce 100644 --- a/sample/app/desktop/build.gradle +++ b/sample/app/desktop/build.gradle @@ -9,7 +9,7 @@ appPlatform { enableComposeUi true enableMetro true enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true addImplModuleDependencies true } diff --git a/sample/app/web/build.gradle b/sample/app/web/build.gradle index d6912761..4ce901d9 100644 --- a/sample/app/web/build.gradle +++ b/sample/app/web/build.gradle @@ -9,7 +9,7 @@ appPlatform { enableComposeUi true enableMetro true enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true addImplModuleDependencies true } diff --git a/sample/login/impl/build.gradle b/sample/login/impl/build.gradle index 06f4d358..d968441c 100644 --- a/sample/login/impl/build.gradle +++ b/sample/login/impl/build.gradle @@ -11,7 +11,7 @@ appPlatform { enableComposeUi true enableMetro true enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true } dependencies { diff --git a/sample/login/impl/src/commonTest/kotlin/software/ralf/app/platform/sample/login/LoginPresenterImplTest.kt b/sample/login/impl/src/commonTest/kotlin/software/ralf/app/platform/sample/login/LoginPresenterImplTest.kt index 780ab98c..bd7d4f2d 100644 --- a/sample/login/impl/src/commonTest/kotlin/software/ralf/app/platform/sample/login/LoginPresenterImplTest.kt +++ b/sample/login/impl/src/commonTest/kotlin/software/ralf/app/platform/sample/login/LoginPresenterImplTest.kt @@ -10,7 +10,7 @@ import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runTest -import software.ralf.app.platform.presenter.molecule.test +import software.ralf.app.platform.presenter.compose.test import software.ralf.app.platform.sample.user.FakeUserManager class LoginPresenterImplTest { diff --git a/sample/login/public/build.gradle b/sample/login/public/build.gradle index eb2ffa3a..ce9a2763 100644 --- a/sample/login/public/build.gradle +++ b/sample/login/public/build.gradle @@ -9,5 +9,5 @@ plugins { appPlatform { enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true } diff --git a/sample/login/public/src/commonMain/kotlin/software/ralf/app/platform/sample/login/LoginPresenter.kt b/sample/login/public/src/commonMain/kotlin/software/ralf/app/platform/sample/login/LoginPresenter.kt index 3dd8151b..6f8dd62a 100644 --- a/sample/login/public/src/commonMain/kotlin/software/ralf/app/platform/sample/login/LoginPresenter.kt +++ b/sample/login/public/src/commonMain/kotlin/software/ralf/app/platform/sample/login/LoginPresenter.kt @@ -1,10 +1,10 @@ package software.ralf.app.platform.sample.login import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter /** A presenter to render the login screen. */ -interface LoginPresenter : MoleculePresenter { +interface LoginPresenter : ComposePresenter { /** The state of the login screen. */ data class Model( /** Whether login is currently in progress. */ diff --git a/sample/navigation/impl/build.gradle b/sample/navigation/impl/build.gradle index e77ccfaa..80a0891b 100644 --- a/sample/navigation/impl/build.gradle +++ b/sample/navigation/impl/build.gradle @@ -10,7 +10,7 @@ plugins { appPlatform { enableMetro true enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true } dependencies { diff --git a/sample/navigation/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/navigation/NavigationPresenterImpl.kt b/sample/navigation/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/navigation/NavigationPresenterImpl.kt index 12ecef3c..cf8a4a84 100644 --- a/sample/navigation/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/navigation/NavigationPresenterImpl.kt +++ b/sample/navigation/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/navigation/NavigationPresenterImpl.kt @@ -8,7 +8,7 @@ import dev.zacsweers.metro.AppScope import dev.zacsweers.metro.ContributesBinding import dev.zacsweers.metro.ContributesTo import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter import software.ralf.app.platform.sample.login.LoginPresenter import software.ralf.app.platform.sample.user.UserManager import software.ralf.app.platform.sample.user.UserPagePresenter @@ -20,7 +20,7 @@ import software.ralf.app.platform.scope.di.metro.metroDependencyGraph * Production implementation of [NavigationPresenter]. * * [loginPresenter] is injected lazily to delay initialization until it's actually needed. See - * [MoleculePresenter] for more details. + * [ComposePresenter] for more details. */ @ContributesBinding(AppScope::class) class NavigationPresenterImpl( diff --git a/sample/navigation/impl/src/commonTest/kotlin/software/ralf/app/platform/sample/navigation/NavigationPresenterImplTest.kt b/sample/navigation/impl/src/commonTest/kotlin/software/ralf/app/platform/sample/navigation/NavigationPresenterImplTest.kt index b8d3fa5d..47d315e6 100644 --- a/sample/navigation/impl/src/commonTest/kotlin/software/ralf/app/platform/sample/navigation/NavigationPresenterImplTest.kt +++ b/sample/navigation/impl/src/commonTest/kotlin/software/ralf/app/platform/sample/navigation/NavigationPresenterImplTest.kt @@ -6,7 +6,7 @@ import assertk.assertions.isInstanceOf import kotlin.test.Test import kotlinx.coroutines.test.runTest import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.test +import software.ralf.app.platform.presenter.compose.test import software.ralf.app.platform.sample.login.LoginPresenter import software.ralf.app.platform.sample.user.FakeUserManager import software.ralf.app.platform.sample.user.UserPagePresenter diff --git a/sample/navigation/public/build.gradle b/sample/navigation/public/build.gradle index eb2ffa3a..ce9a2763 100644 --- a/sample/navigation/public/build.gradle +++ b/sample/navigation/public/build.gradle @@ -9,5 +9,5 @@ plugins { appPlatform { enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true } diff --git a/sample/navigation/public/src/commonMain/kotlin/software/ralf/app/platform/sample/navigation/NavigationPresenter.kt b/sample/navigation/public/src/commonMain/kotlin/software/ralf/app/platform/sample/navigation/NavigationPresenter.kt index da55c39f..99cb6112 100644 --- a/sample/navigation/public/src/commonMain/kotlin/software/ralf/app/platform/sample/navigation/NavigationPresenter.kt +++ b/sample/navigation/public/src/commonMain/kotlin/software/ralf/app/platform/sample/navigation/NavigationPresenter.kt @@ -1,10 +1,10 @@ package software.ralf.app.platform.sample.navigation import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter /** * A presenter that hosts other presenters and returns their models. For that reason this presenter * doesn't have its own [BaseModel] type and returns [BaseModel]. */ -interface NavigationPresenter : MoleculePresenter +interface NavigationPresenter : ComposePresenter diff --git a/sample/templates/impl/build.gradle b/sample/templates/impl/build.gradle index 14fec8f6..b2874709 100644 --- a/sample/templates/impl/build.gradle +++ b/sample/templates/impl/build.gradle @@ -11,7 +11,7 @@ appPlatform { enableComposeUi true enableMetro true enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true } appPlatformBuildSrc { diff --git a/sample/templates/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/template/ComposeSampleAppTemplateRenderer.kt b/sample/templates/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/template/ComposeSampleAppTemplateRenderer.kt index e4d398c8..67b4a9c2 100644 --- a/sample/templates/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/template/ComposeSampleAppTemplateRenderer.kt +++ b/sample/templates/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/template/ComposeSampleAppTemplateRenderer.kt @@ -14,8 +14,8 @@ import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Modifier import software.ralf.app.platform.inject.ContributesRenderer import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.backgesture.BackGestureDispatcherPresenter -import software.ralf.app.platform.presenter.molecule.backgesture.ForwardBackPressEventsToPresenters +import software.ralf.app.platform.presenter.compose.backgesture.BackGestureDispatcherPresenter +import software.ralf.app.platform.presenter.compose.backgesture.ForwardBackPressEventsToPresenters import software.ralf.app.platform.renderer.ComposeRenderer import software.ralf.app.platform.renderer.Renderer import software.ralf.app.platform.renderer.RendererFactory diff --git a/sample/templates/public/build.gradle b/sample/templates/public/build.gradle index bdc3ac39..4f83b678 100644 --- a/sample/templates/public/build.gradle +++ b/sample/templates/public/build.gradle @@ -11,5 +11,5 @@ appPlatform { enableComposeUi true enableMetro true enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true } diff --git a/sample/templates/public/src/commonMain/kotlin/software/ralf/app/platform/sample/template/SampleAppTemplatePresenter.kt b/sample/templates/public/src/commonMain/kotlin/software/ralf/app/platform/sample/template/SampleAppTemplatePresenter.kt index 40d16a0e..8d41595f 100644 --- a/sample/templates/public/src/commonMain/kotlin/software/ralf/app/platform/sample/template/SampleAppTemplatePresenter.kt +++ b/sample/templates/public/src/commonMain/kotlin/software/ralf/app/platform/sample/template/SampleAppTemplatePresenter.kt @@ -6,9 +6,9 @@ import dev.zacsweers.metro.Assisted import dev.zacsweers.metro.AssistedFactory import dev.zacsweers.metro.AssistedInject import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter -import software.ralf.app.platform.presenter.molecule.backgesture.BackGestureDispatcherPresenter -import software.ralf.app.platform.presenter.molecule.backgesture.LocalBackGestureDispatcherPresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter +import software.ralf.app.platform.presenter.compose.backgesture.BackGestureDispatcherPresenter +import software.ralf.app.platform.presenter.compose.backgesture.LocalBackGestureDispatcherPresenter import software.ralf.app.platform.presenter.template.ModelDelegate import software.ralf.app.platform.presenter.template.toTemplate @@ -21,8 +21,8 @@ import software.ralf.app.platform.presenter.template.toTemplate @AssistedInject class SampleAppTemplatePresenter( private val backGestureDispatcherPresenter: BackGestureDispatcherPresenter, - @Assisted private val rootPresenter: MoleculePresenter, -) : MoleculePresenter { + @Assisted private val rootPresenter: ComposePresenter, +) : ComposePresenter { @Composable override fun present(input: Unit): SampleAppTemplate { return withCompositionLocal( @@ -44,7 +44,7 @@ class SampleAppTemplatePresenter( * [SampleAppTemplate] directly or making its [BaseModel] type implement [ModelDelegate]. */ fun createSampleAppTemplatePresenter( - rootPresenter: MoleculePresenter + rootPresenter: ComposePresenter ): SampleAppTemplatePresenter } } diff --git a/sample/templates/public/src/commonTest/kotlin/software/ralf/app/platform/sample/template/SampleAppTemplatePresenterTest.kt b/sample/templates/public/src/commonTest/kotlin/software/ralf/app/platform/sample/template/SampleAppTemplatePresenterTest.kt index a4b6c3e1..974bbfd0 100644 --- a/sample/templates/public/src/commonTest/kotlin/software/ralf/app/platform/sample/template/SampleAppTemplatePresenterTest.kt +++ b/sample/templates/public/src/commonTest/kotlin/software/ralf/app/platform/sample/template/SampleAppTemplatePresenterTest.kt @@ -10,9 +10,9 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.test.runTest import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter -import software.ralf.app.platform.presenter.molecule.backgesture.BackGestureDispatcherPresenter -import software.ralf.app.platform.presenter.molecule.test +import software.ralf.app.platform.presenter.compose.ComposePresenter +import software.ralf.app.platform.presenter.compose.backgesture.BackGestureDispatcherPresenter +import software.ralf.app.platform.presenter.compose.test import software.ralf.app.platform.presenter.template.ModelDelegate import software.ralf.app.platform.presenter.template.Template import software.ralf.app.platform.sample.template.SampleAppTemplate.FullScreenTemplate @@ -37,7 +37,7 @@ class SampleAppTemplatePresenterTest { } private class TestPresenter(private val trigger: StateFlow) : - MoleculePresenter { + ComposePresenter { @Composable override fun present(input: Unit): Model { return Model(trigger.collectAsState().value) diff --git a/sample/user/impl/build.gradle b/sample/user/impl/build.gradle index c8eca073..63272b8d 100644 --- a/sample/user/impl/build.gradle +++ b/sample/user/impl/build.gradle @@ -11,7 +11,7 @@ appPlatform { enableComposeUi true enableMetro true enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true } appPlatformBuildSrc { diff --git a/sample/user/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPageDetailPresenter.kt b/sample/user/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPageDetailPresenter.kt index cc70f9ff..19b1e111 100644 --- a/sample/user/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPageDetailPresenter.kt +++ b/sample/user/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPageDetailPresenter.kt @@ -11,7 +11,7 @@ import androidx.compose.runtime.setValue import dev.zacsweers.metro.Inject import kotlin.time.Duration import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter import software.ralf.app.platform.sample.template.animation.AnimationContentKey import software.ralf.app.platform.sample.user.UserPageDetailPresenter.Input import software.ralf.app.platform.sample.user.UserPageDetailPresenter.Model @@ -19,7 +19,7 @@ import software.ralf.app.platform.sample.user.UserPageDetailPresenter.Model /** Presenter to manage the detail content of the list-detail layout. */ @Inject class UserPageDetailPresenter(private val sessionTimeout: SessionTimeout) : - MoleculePresenter { + ComposePresenter { @Composable override fun present(input: Input): Model { diff --git a/sample/user/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPageListPresenter.kt b/sample/user/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPageListPresenter.kt index 826e3b84..d99e47df 100644 --- a/sample/user/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPageListPresenter.kt +++ b/sample/user/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPageListPresenter.kt @@ -7,14 +7,14 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import dev.zacsweers.metro.Inject import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter import software.ralf.app.platform.sample.user.UserPageListPresenter.Input import software.ralf.app.platform.sample.user.UserPageListPresenter.Model /** Presenter to manage the list content of the list-detail layout. */ @Inject class UserPageListPresenter(private val sessionTimeout: SessionTimeout) : - MoleculePresenter { + ComposePresenter { @Composable override fun present(input: Input): Model { diff --git a/sample/user/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPagePresenterImpl.kt b/sample/user/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPagePresenterImpl.kt index 8c88ee17..81b3f2dd 100644 --- a/sample/user/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPagePresenterImpl.kt +++ b/sample/user/impl/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPagePresenterImpl.kt @@ -3,7 +3,7 @@ package software.ralf.app.platform.sample.user import androidx.compose.runtime.Composable import dev.zacsweers.metro.ContributesBinding import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.backgesture.BackHandlerPresenter +import software.ralf.app.platform.presenter.compose.backgesture.BackHandlerPresenter import software.ralf.app.platform.presenter.template.ModelDelegate import software.ralf.app.platform.renderer.Renderer import software.ralf.app.platform.sample.template.SampleAppTemplate diff --git a/sample/user/impl/src/commonTest/kotlin/software/ralf/app/platform/sample/user/UserPagePresenterImplTest.kt b/sample/user/impl/src/commonTest/kotlin/software/ralf/app/platform/sample/user/UserPagePresenterImplTest.kt index 29614aba..0cfb0a55 100644 --- a/sample/user/impl/src/commonTest/kotlin/software/ralf/app/platform/sample/user/UserPagePresenterImplTest.kt +++ b/sample/user/impl/src/commonTest/kotlin/software/ralf/app/platform/sample/user/UserPagePresenterImplTest.kt @@ -10,8 +10,8 @@ import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest -import software.ralf.app.platform.presenter.molecule.backgesture.withBackGestureDispatcher -import software.ralf.app.platform.presenter.molecule.test +import software.ralf.app.platform.presenter.compose.backgesture.withBackGestureDispatcher +import software.ralf.app.platform.presenter.compose.test import software.ralf.app.platform.scope.runTestWithScope class UserPagePresenterImplTest { diff --git a/sample/user/public/build.gradle b/sample/user/public/build.gradle index eb2ffa3a..ce9a2763 100644 --- a/sample/user/public/build.gradle +++ b/sample/user/public/build.gradle @@ -9,5 +9,5 @@ plugins { appPlatform { enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true } diff --git a/sample/user/public/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPagePresenter.kt b/sample/user/public/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPagePresenter.kt index a7d0af4a..b1ce8757 100644 --- a/sample/user/public/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPagePresenter.kt +++ b/sample/user/public/src/commonMain/kotlin/software/ralf/app/platform/sample/user/UserPagePresenter.kt @@ -1,12 +1,12 @@ package software.ralf.app.platform.sample.user import software.ralf.app.platform.presenter.BaseModel -import software.ralf.app.platform.presenter.molecule.MoleculePresenter +import software.ralf.app.platform.presenter.compose.ComposePresenter import software.ralf.app.platform.presenter.template.ModelDelegate import software.ralf.app.platform.sample.user.UserPagePresenter.Model /** Presenter to render user details on screen. */ -interface UserPagePresenter : MoleculePresenter { +interface UserPagePresenter : ComposePresenter { /** * The state of the user page. Note that the actual implementation class implements diff --git a/sample/user/testing/build.gradle b/sample/user/testing/build.gradle index c3f773d4..3587cbc1 100644 --- a/sample/user/testing/build.gradle +++ b/sample/user/testing/build.gradle @@ -10,5 +10,5 @@ plugins { appPlatform { enableMetro true enableModuleStructure true - enableMoleculePresenters true + enableComposePresenters true } diff --git a/settings.gradle b/settings.gradle index 6f51fff1..85784cb9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -54,9 +54,9 @@ include ':metro-extensions:contribute:impl-code-generators' include ':presenter:public' include ':presenter-backstack-nav3:public' include ':presenter-backstack-nav3:testing' -include ':presenter-molecule:impl' -include ':presenter-molecule:public' -include ':presenter-molecule:testing' +include ':presenter-compose:impl' +include ':presenter-compose:public' +include ':presenter-compose:testing' include ':recipes:app-framework:impl' include ':recipes:app:android' include ':recipes:app:desktop' diff --git a/skills/app-platform-presenters/SKILL.md b/skills/app-platform-presenters/SKILL.md index 162f8123..890044cc 100644 --- a/skills/app-platform-presenters/SKILL.md +++ b/skills/app-platform-presenters/SKILL.md @@ -1,17 +1,17 @@ --- name: app-platform-presenters -description: Build and test App Platform MoleculePresenters. Use when changing models, state, parent and child presenters, template selection or delegation, tests, or Gradle and host setup. +description: Build and test App Platform ComposePresenters. Use when changing models, state, parent and child presenters, template selection or delegation, tests, or Gradle and host setup. --- -# App Platform Molecule Presenters +# App Platform Compose Presenters -`MoleculePresenter` uses the Compose runtime to turn inputs and injected data into a `BaseModel`. The UI or a parent presenter reads the model and sends events through its callbacks. Compose UI is optional. +`ComposePresenter` uses the Compose runtime to turn inputs and injected data into a `BaseModel`. The UI or a parent presenter reads the model and sends events through its callbacks. Compose UI is optional. Before editing, identify the inputs, model, events, how long state must last, and who starts and stops the root. Follow the project's module, DI, and build choices. Check its App Platform version before using `ExperimentalAppPlatform` APIs. Examples omit imports; resolve unfamiliar APIs from existing code or matching public docs. ## Models -- Implement `MoleculePresenter` with `ModelT : BaseModel`. Include all state and callbacks the consumer needs. +- Implement `ComposePresenter` with `ModelT : BaseModel`. Include all state and callbacks the consumer needs. - Expose immutable model snapshots, preferably data classes or sealed types. Use `val` properties and immutable values, and return a new model when state changes. Keep equality and public types stable to satisfy `BaseModel`. - Prefer presenter interfaces with implementations supplied through DI. Put shared contracts and models in `:public`, implementations in `:impl`, and assemble them in the app. Keep implementations used by generated graphs across modules public. - Nest `Model` under its presenter. Put `present()` first, then helpers, the companion object, and nested types, with `Model` last. @@ -19,7 +19,7 @@ Before editing, identify the inputs, model, events, how long state must last, an ```kotlin // :public - interface SearchPresenter : MoleculePresenter { + interface SearchPresenter : ComposePresenter { interface Model : BaseModel { val query: String } @@ -44,7 +44,7 @@ Before editing, identify the inputs, model, events, how long state must last, an - When consumers only pass a model along, hide its type with a generic interface: ```kotlin - interface CatalogPresenter : MoleculePresenter + interface CatalogPresenter : ComposePresenter ``` Consumers can use `CatalogPresenter<*>`. Parents that return different child models can use `BaseModel`. @@ -62,7 +62,7 @@ Keep mutable state, caches, scopes, and effects inside `present()`. Presenter fi Use `remember` for local state and Compose runtime APIs such as `collectAsState` or `produceState` for changing data: ```kotlin -interface CounterPresenter : MoleculePresenter { +interface CounterPresenter : ComposePresenter { data class Model( val count: Int, val onIncrement: () -> Unit, @@ -101,7 +101,7 @@ Use `presentDetached()` only for costly child presenters. It can briefly pair ne For push and pop navigation, use experimental `presenterBackstack(initialPresenter) { models -> ... }`. Wrap its models in an app-specific `PresenterBackstackModel` with `onBack = { pop() }`. The helper provides `LocalBackstackScope`; children read `LocalBackstackScope.requireNotNull()` and call `push()`, `pop()`, or `replaceTop()` from model callbacks. The stack holds presenter instances, keeps every entry in composition, and ignores a pop at the root. -Use `PresenterBackstackRenderer` for Navigation 3 UI. Set `appPlatform { enableMoleculePresenterBackstack(true) }` to add the module and enable Molecule presenters and Compose UI. See the [backstack guide](https://vrallev.github.io/app-platform/presenter/#presenter-backstack) for rendering and tests with a fake scope. +Use `PresenterBackstackRenderer` for Navigation 3 UI. Set `appPlatform { enableComposePresenterBackstack(true) }` to add the module and enable Compose presenters and Compose UI. See the [backstack guide](https://vrallev.github.io/app-platform/presenter/#presenter-backstack) for rendering and tests with a fake scope. ## Template selection @@ -122,8 +122,8 @@ Wrap the root presenter in a template presenter. `toTemplate` follows `ModelDele ```kotlin class AppTemplatePresenter( - private val rootPresenter: MoleculePresenter, -) : MoleculePresenter { + private val rootPresenter: ComposePresenter, +) : ComposePresenter { @Composable override fun present(input: Unit): AppTemplate { return rootPresenter.present(Unit).toTemplate { @@ -172,21 +172,21 @@ In a Compose host, remember the root and call `present()` directly if the host's ```kotlin class PresenterHost( - moleculeScopeFactory: MoleculeScopeFactory, - rootPresenter: MoleculePresenter, + composePresenterScopeFactory: ComposePresenterScopeFactory, + rootPresenter: ComposePresenter, ) { - private val moleculeScope = moleculeScopeFactory.createMoleculeScope() - val models = moleculeScope.launchMoleculePresenter(rootPresenter, Unit).model + private val composePresenterScope = composePresenterScopeFactory.createComposePresenterScope() + val models = composePresenterScope.launchComposePresenter(rootPresenter, Unit).model fun close() { - moleculeScope.cancel() + composePresenterScope.cancel() } } ``` The factory applies platform defaults. Launching returns `Presenter`, with a `StateFlow` at `.model`. Pass a `StateFlow` input when the host needs to change it. -Call the host's `close()` from its owner's cleanup, such as `ViewModel.onCleared()` or window cleanup. Stopping collection does not stop the presenters. Canceling a `MoleculeScope` also cancels the wrapped coroutine scope, so use a scope the host owns. +Call the host's `close()` from its owner's cleanup, such as `ViewModel.onCleared()` or window cleanup. Stopping collection does not stop the presenters. Canceling a `ComposePresenterScope` also cancels the wrapped coroutine scope, so use a scope the host owns. ## Keep state after a child leaves @@ -263,7 +263,7 @@ plugins { } appPlatform { - enableMoleculePresenters(true) + enableComposePresenters(true) } ``` @@ -271,7 +271,7 @@ This adds the Compose compiler, runtime, Molecule, presenter API, and test helpe Bind presenter interfaces to implementations through the app's existing DI setup. For Metro, use `enableMetro(true)`. -In modules that build the app, `addImplModuleDependencies(true)` supplies defaults such as `MoleculeScopeFactory`. Keep `:impl` dependencies out of feature API modules and check that the app's DI graph builds. +In modules that build the app, `addImplModuleDependencies(true)` supplies defaults such as `ComposePresenterScopeFactory`. Keep `:impl` dependencies out of feature API modules and check that the app's DI graph builds. The presenter option does not set Android's `isReturnDefaultValues`. Configure it in shared test setup if needed for Android stubs. Use Robolectric only for tests of real Android behavior. diff --git a/skills/app-platform-renderers/SKILL.md b/skills/app-platform-renderers/SKILL.md index f7a1db15..d7e3d051 100644 --- a/skills/app-platform-renderers/SKILL.md +++ b/skills/app-platform-renderers/SKILL.md @@ -164,7 +164,7 @@ This supplies Compose compiler/runtime, Foundation, and the Compose renderer API For Android View renderers, `addPublicModuleDependencies(true)` supplies the renderer APIs alongside the app's Android plugin setup. -For Metro-generated contributions, use `enableMetro(true)`. Add implementation dependencies at app assembly points, using `addImplModuleDependencies(true)` when relying on App Platform defaults. Enable `enableMoleculePresenterBackstack(true)` for the Navigation 3 backstack module; it also enables Molecule presenters and Compose UI. +For Metro-generated contributions, use `enableMetro(true)`. Add implementation dependencies at app assembly points, using `addImplModuleDependencies(true)` when relying on App Platform defaults. Enable `enableComposePresenterBackstack(true)` for the Navigation 3 backstack module; it also enables Compose presenters and Compose UI. ## Tests diff --git a/skills/app-platform-testing/SKILL.md b/skills/app-platform-testing/SKILL.md index 5aae96d0..9a226adb 100644 --- a/skills/app-platform-testing/SKILL.md +++ b/skills/app-platform-testing/SKILL.md @@ -63,7 +63,7 @@ fun routeChangesWithLocation() = runTest { } ``` -For `MoleculePresenter`, pass the current `TestScope` to the App Platform `test` helper. Drive changes through model callbacks, input flows, or fakes. For a counter model with `count` and `onIncrement`: +For `ComposePresenter`, pass the current `TestScope` to the App Platform `test` helper. Drive changes through model callbacks, input flows, or fakes. For a counter model with `count` and `onIncrement`: ```kotlin @Test @@ -167,7 +167,7 @@ appPlatform { } ``` -Keep `enableModuleStructure(true)` when the project uses App Platform's `:testing` and robot module rules. Keep the project's existing DI integration enabled so `@ContributesRobot` registrations are generated. `enableComposeUi(true)` supplies Compose Robot support, but the app still chooses its UI test runner and screenshot dependencies. `enableMoleculePresenters(true)` supplies the presenter test helper to test source sets, and the public plugin supplies scope test helpers. +Keep `enableModuleStructure(true)` when the project uses App Platform's `:testing` and robot module rules. Keep the project's existing DI integration enabled so `@ContributesRobot` registrations are generated. `enableComposeUi(true)` supplies Compose Robot support, but the app still chooses its UI test runner and screenshot dependencies. `enableComposePresenters(true)` supplies the presenter test helper to test source sets, and the public plugin supplies scope test helpers. Ordinary production modules add `:testing` only to test configurations and robot modules only to UI or integration-test configurations. Test-only `:testing` and robot modules may use `:testing` from main source sets; robot modules may also depend on other robot modules. Compile the final test graph after changing robot contributions or test bindings; compiling the feature alone does not verify graph assembly.