Move some code to 'architecture' module
This commit is contained in:
parent
3ffbba954e
commit
eeebb99292
38 changed files with 48 additions and 67 deletions
|
|
@ -1,5 +1,5 @@
|
|||
plugins {
|
||||
id("io.element.android-library")
|
||||
id("io.element.android-compose-library")
|
||||
alias(libs.plugins.molecule)
|
||||
}
|
||||
|
||||
|
|
@ -8,7 +8,9 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":libraries:core"))
|
||||
api(libs.dagger)
|
||||
api(libs.appyx.core)
|
||||
api(libs.androidx.lifecycle.runtime)
|
||||
api(libs.mavericks.compose)
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.element.android.x.core.di
|
||||
package io.element.android.x.architecture
|
||||
|
||||
import com.bumble.appyx.core.modality.BuildContext
|
||||
import com.bumble.appyx.core.node.Node
|
||||
|
|
@ -1,30 +1,12 @@
|
|||
package io.element.android.x.core.di
|
||||
package io.element.android.x.architecture
|
||||
|
||||
import android.content.Context
|
||||
import android.content.ContextWrapper
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.bumble.appyx.core.node.Node
|
||||
|
||||
/**
|
||||
* Use this to get the Dagger "Bindings" for your module. Bindings are used if you need to directly interact with a dagger component such as:
|
||||
* * an inject function: `inject(node: MyNode)`
|
||||
* * an explicit getter: `fun myClass(): MyClass`
|
||||
*
|
||||
* Anvil will make your Dagger component implement these bindings so that you can call any of these functions on an instance of your component.
|
||||
*
|
||||
* [bindings] will walk up the Node/Activity hierarchy and check for [DaggerComponentOwner] to see if any of its components implement the
|
||||
* specified bindings. Most of the time this will "just work" and you don't have to think about it.
|
||||
*
|
||||
* For example, if your class has @Inject properties:
|
||||
* 1) Create an bindings interface such as `YourModuleBindings`
|
||||
* 1) Add an inject function like `fun inject(yourClass: YourClass)`
|
||||
* 2) Contribute your interface to the correct component via `@ContributesTo(AppScope::class)`.
|
||||
* 3) Call bindings<YourModuleBindings>().inject(this).
|
||||
*/
|
||||
|
||||
inline fun <reified T : Any> Context.bindings() = bindings(T::class.java)
|
||||
import io.element.android.x.core.di.DaggerComponentOwner
|
||||
|
||||
inline fun <reified T : Any> Node.bindings() = bindings(T::class.java)
|
||||
inline fun <reified T : Any> Context.bindings() = bindings(T::class.java)
|
||||
|
||||
/** Use no-arg extension function instead: [Context.bindings] */
|
||||
fun <T : Any> Context.bindings(klass: Class<T>): T {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.element.android.x.core.di
|
||||
package io.element.android.x.architecture
|
||||
|
||||
import com.bumble.appyx.core.modality.BuildContext
|
||||
import com.bumble.appyx.core.node.Node
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.x.core.di
|
||||
package io.element.android.x.architecture
|
||||
|
||||
import com.bumble.appyx.core.node.Node
|
||||
import dagger.MapKey
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.element.android.x.presentation
|
||||
package io.element.android.x.architecture
|
||||
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import app.cash.molecule.AndroidUiDispatcher
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.element.android.x.presentation
|
||||
package io.element.android.x.architecture
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.element.android.x.core.di
|
||||
package io.element.android.x.architecture.viewmodel
|
||||
|
||||
import com.airbnb.mvrx.MavericksState
|
||||
import com.airbnb.mvrx.MavericksViewModel
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package io.element.android.x.core.di
|
||||
package io.element.android.x.architecture.viewmodel
|
||||
|
||||
import com.airbnb.mvrx.FragmentViewModelContext
|
||||
import com.airbnb.mvrx.MavericksState
|
||||
import com.airbnb.mvrx.MavericksViewModel
|
||||
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||
import com.airbnb.mvrx.ViewModelContext
|
||||
import io.element.android.x.architecture.bindings
|
||||
|
||||
/**
|
||||
* To connect Mavericks ViewModel creation with Anvil's dependency injection, add the following to your MavericksViewModel.
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.x.core.di
|
||||
package io.element.android.x.architecture.viewmodel
|
||||
|
||||
import com.airbnb.mvrx.MavericksViewModel
|
||||
import dagger.MapKey
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.element.android.x.core.di
|
||||
package io.element.android.x.architecture.viewmodel
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.compose.runtime.Composable
|
||||
|
|
@ -5,9 +5,3 @@ plugins {
|
|||
android {
|
||||
namespace = "io.element.android.x.core"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(libs.mavericks.compose)
|
||||
api(libs.dagger)
|
||||
api(libs.appyx.core)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ anvil {
|
|||
dependencies {
|
||||
api(project(":libraries:rustsdk"))
|
||||
implementation(project(":libraries:di"))
|
||||
implementation(libs.dagger)
|
||||
implementation(project(":libraries:core"))
|
||||
implementation("net.java.dev.jna:jna:5.12.1@aar")
|
||||
implementation(libs.coil.compose)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue