diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5833d11..a623bfb 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -53,6 +53,8 @@ dependencies { implementation("com.squareup.okhttp3:okhttp:4.7.2") + implementation("io.insert-koin:koin-compose:4.1.0-Beta5") + implementation("io.insert-koin:koin-compose-viewmodel:4.1.0-Beta5") implementation(libs.androidx.core.ktx) implementation(libs.androidx.lifecycle.runtime.ktx) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f2b85a1..d84f436 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,6 +3,7 @@ xmlns:tools="http://schemas.android.com/tools"> { - RegistrationScreen(authUseCase){ + RegistrationScreen(registrationViewModel){ navController.navigate(route = Profile) } } diff --git a/app/src/main/java/com/example/netwrok_datastore/MainApplication.kt b/app/src/main/java/com/example/netwrok_datastore/MainApplication.kt new file mode 100644 index 0000000..314b785 --- /dev/null +++ b/app/src/main/java/com/example/netwrok_datastore/MainApplication.kt @@ -0,0 +1,16 @@ +package com.example.netwrok_datastore + +import android.app.Application +import com.example.netwrok_datastore.di.appModules +import org.koin.android.ext.koin.androidContext +import org.koin.core.context.startKoin + +class MainApplication: Application() { + override fun onCreate() { + super.onCreate() + startKoin { + androidContext(applicationContext) + modules(appModules) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/netwrok_datastore/di/appModules.kt b/app/src/main/java/com/example/netwrok_datastore/di/appModules.kt new file mode 100644 index 0000000..5bd93ac --- /dev/null +++ b/app/src/main/java/com/example/netwrok_datastore/di/appModules.kt @@ -0,0 +1,18 @@ +package com.example.netwrok_datastore.di + +import com.example.netwrok_datastore.data.AuthRepository +import com.example.netwrok_datastore.data.local.LocalStorage +import com.example.netwrok_datastore.data.remote.RetrofitSettings +import com.example.netwrok_datastore.data.remote.auth.AuthApi +import com.example.netwrok_datastore.domain.usecase.AuthUseCase +import com.example.netwrok_datastore.ui.screen.registration.RegistrationViewModel +import org.koin.core.module.dsl.viewModel +import org.koin.dsl.module + +val appModules = module { + single { LocalStorage(get()) } + single { RetrofitSettings.authApi } + single { AuthRepository(get()) } + single { AuthUseCase(get(), get()) } + viewModel { RegistrationViewModel(get()) } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/netwrok_datastore/ui/screen/registration/RegistrationScreen.kt b/app/src/main/java/com/example/netwrok_datastore/ui/screen/registration/RegistrationScreen.kt index f3012a2..2e7a942 100644 --- a/app/src/main/java/com/example/netwrok_datastore/ui/screen/registration/RegistrationScreen.kt +++ b/app/src/main/java/com/example/netwrok_datastore/ui/screen/registration/RegistrationScreen.kt @@ -31,8 +31,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking @Composable -fun RegistrationScreen(authUseCase: AuthUseCase, onNavigationToProfile: ()-> Unit){ - val viewModel = RegistrationViewModel(authUseCase) +fun RegistrationScreen(viewModel: RegistrationViewModel, onNavigationToProfile: ()-> Unit){ val snackBarHostState = remember { SnackbarHostState() } Scaffold(