anytype-kotlin-wild/app/src/main/java/com/anytypeio/anytype/di/feature/CreateObjectDI.kt
Evgenii Kozlov 5886fc1ae5
DROID-1654 App | Feature | Multispaces + Misc. enhancements (#300)
Co-authored-by: Konstantin Ivanov <54908981+konstantiniiv@users.noreply.github.com>
2023-10-24 12:41:32 +02:00

84 lines
2.5 KiB
Kotlin

package com.anytypeio.anytype.di.feature
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
import com.anytypeio.anytype.domain.block.repo.BlockRepository
import com.anytypeio.anytype.domain.config.ConfigStorage
import com.anytypeio.anytype.domain.config.UserSettingsRepository
import com.anytypeio.anytype.domain.launch.GetDefaultPageType
import com.anytypeio.anytype.domain.page.CreateObject
import com.anytypeio.anytype.domain.templates.GetTemplates
import com.anytypeio.anytype.domain.workspace.SpaceManager
import com.anytypeio.anytype.presentation.objects.CreateObjectViewModel
import com.anytypeio.anytype.ui.editor.CreateObjectFragment
import dagger.Module
import dagger.Provides
import dagger.Subcomponent
@Subcomponent(modules = [CreateObjectModule::class])
@PerScreen
interface CreateObjectSubComponent {
@Subcomponent.Builder
interface Builder {
fun module(module: CreateObjectModule): Builder
fun build(): CreateObjectSubComponent
}
fun inject(fragment: CreateObjectFragment)
}
@Module
object CreateObjectModule {
@JvmStatic
@Provides
@PerScreen
fun getCreateObject(
repo: BlockRepository,
getDefaultPageType: GetDefaultPageType,
dispatchers: AppCoroutineDispatchers,
spaceManager: SpaceManager
): CreateObject = CreateObject(
repo = repo,
getDefaultPageType = getDefaultPageType,
dispatchers = dispatchers,
spaceManager = spaceManager
)
@JvmStatic
@PerScreen
@Provides
fun provideGetDefaultPageType(
blockRepository: BlockRepository,
userSettingsRepository: UserSettingsRepository,
dispatchers: AppCoroutineDispatchers,
spaceManager: SpaceManager,
configStorage: ConfigStorage
): GetDefaultPageType = GetDefaultPageType(
userSettingsRepository = userSettingsRepository,
blockRepository = blockRepository,
dispatchers = dispatchers,
spaceManager = spaceManager,
configStorage = configStorage
)
@JvmStatic
@Provides
@PerScreen
fun provideGetTemplates(
repo: BlockRepository,
dispatchers: AppCoroutineDispatchers
): GetTemplates = GetTemplates(
repo = repo,
dispatchers = dispatchers
)
@JvmStatic
@Provides
@PerScreen
fun provideViewModelFactory(
createObject: CreateObject
): CreateObjectViewModel.Factory = CreateObjectViewModel.Factory(createObject = createObject)
}