forked from openMF/mobile-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial koin setup for dependency injection (openMF#1749)
* Added koin dependencies * Koin structure setup * Koin initialized for androidMain and IosMain * PreferencesHelper di implemented,required data models added * PreferencesHelper implemented for desktopMain * PreferencesHelper removed for datastore implementation
- Loading branch information
1 parent
dc95c55
commit 99099ff
Showing
19 changed files
with
229 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
shared/src/androidMain/kotlin/org/mifospay/shared/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.mifospay.shared | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.tooling.preview.Preview | ||
|
||
class MainActivity : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
setContent { | ||
App() | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun AppAndroidPreview() { | ||
App() | ||
} |
15 changes: 15 additions & 0 deletions
15
shared/src/androidMain/kotlin/org/mifospay/shared/MyApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.mifospay.shared | ||
|
||
import android.app.Application | ||
import org.koin.android.ext.koin.androidContext | ||
import org.mifospay.shared.di.initKoin | ||
|
||
class MyApplication: Application() { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
initKoin { | ||
androidContext(this@MyApplication) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
shared/src/androidMain/kotlin/org/mifospay/shared/di/Modules.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.mifospay.shared.di | ||
|
||
import org.koin.dsl.module | ||
|
||
actual val platformModule = module { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
shared/src/commonMain/kotlin/org/mifospay/shared/di/Modules.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.mifospay.shared.di | ||
|
||
import org.koin.core.module.Module | ||
import org.koin.dsl.module | ||
|
||
expect val platformModule: Module | ||
|
||
val sharedModule = module { | ||
single { } | ||
} |
11 changes: 11 additions & 0 deletions
11
shared/src/commonMain/kotlin/org/mifospay/shared/di/initKoin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.mifospay.shared.di | ||
|
||
import org.koin.core.context.startKoin | ||
import org.koin.dsl.KoinAppDeclaration | ||
|
||
fun initKoin(config: KoinAppDeclaration? = null) { | ||
startKoin { | ||
config?.invoke(this) | ||
modules(sharedModule, platformModule) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
shared/src/commonMain/kotlin/org/mifospay/shared/modal/domain/Client.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2024 Mifos Initiative | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md | ||
*/ | ||
package org.mifospay.shared.modal.domain | ||
|
||
import org.mifospay.shared.CommonParcelable | ||
import org.mifospay.shared.CommonParcelize | ||
|
||
@CommonParcelize | ||
data class Client( | ||
var name: String? = null, | ||
var image: String, | ||
var externalId: String? = null, | ||
var clientId: Long = 0L, | ||
var displayName: String, | ||
var mobileNo: String, | ||
) : CommonParcelable{ | ||
companion object | ||
} |
23 changes: 23 additions & 0 deletions
23
shared/src/commonMain/kotlin/org/mifospay/shared/modal/domain/Role.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2024 Mifos Initiative | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md | ||
*/ | ||
package org.mifospay.shared.modal.domain | ||
|
||
import org.mifospay.shared.CommonParcelable | ||
import org.mifospay.shared.CommonParcelize | ||
|
||
@CommonParcelize | ||
data class Role( | ||
var id: String? = null, | ||
var name: String? = null, | ||
var description: String? = null, | ||
val disabled: Boolean, | ||
): CommonParcelable { | ||
companion object | ||
} |
30 changes: 30 additions & 0 deletions
30
shared/src/commonMain/kotlin/org/mifospay/shared/modal/domain/User.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2024 Mifos Initiative | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md | ||
*/ | ||
package org.mifospay.shared.modal.domain | ||
|
||
import org.mifospay.shared.CommonParcelable | ||
import org.mifospay.shared.CommonParcelize | ||
|
||
@CommonParcelize | ||
data class User( | ||
val username: String, | ||
val userId: Long = 0, | ||
val base64EncodedAuthenticationKey: String, | ||
val authenticated: Boolean = false, | ||
val officeId: Int, | ||
val officeName: String, | ||
val roles: List<Role>, | ||
val permissions: List<String>, | ||
val clients: List<Long>, | ||
val shouldRenewPassword: Boolean, | ||
val isTwoFactorAuthenticationRequired: Boolean, | ||
): CommonParcelable { | ||
companion object | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
shared/src/desktopMain/kotlin/org/mifospay/shared/di/Modules.desktop.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.mifospay.shared.di | ||
|
||
import org.koin.core.module.Module | ||
|
||
actual val platformModule: Module | ||
get() = TODO("Not yet implemented") |
12 changes: 12 additions & 0 deletions
12
shared/src/iosMain/kotlin/org/mifospay/shared/MainViewController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.mifospay.shared | ||
|
||
import androidx.compose.ui.window.ComposeUIViewController | ||
import org.mifospay.shared.di.initKoin | ||
|
||
fun MainViewController() = ComposeUIViewController( | ||
configure = { | ||
initKoin() | ||
} | ||
) { | ||
App() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
shared/src/iosMain/kotlin/org/mifospay/shared/di/Modules.ios.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.mifospay.shared.di | ||
|
||
import org.koin.core.module.Module | ||
|
||
actual val platformModule: Module | ||
get() = TODO("Not yet implemented") |