Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOT FOR MERGE ( core/common KMP draft) #2289

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 51 additions & 17 deletions core/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
plugins {
alias(libs.plugins.mifos.android.library)
alias(libs.plugins.mifos.kmp.library)
alias(libs.plugins.mifos.android.hilt)
alias(libs.plugins.mifos.android.library.jacoco)
alias(libs.plugins.secrets)
// alias(libs.plugins.mifos.android.library.jacoco)
// alias(libs.plugins.secrets)
id(libs.plugins.kotlin.parcelize.get().pluginId)
}

android {
Expand All @@ -22,19 +23,52 @@ android {
}
}

secrets {
defaultPropertiesFileName = "secrets.defaults.properties"
}

dependencies {
implementation(projects.core.model)
testImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.turbine)

androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.test.espresso.core)
//secrets {
// defaultPropertiesFileName = "secrets.defaults.properties"
//}

implementation(libs.converter.gson)
kotlin {
sourceSets {
commonMain.dependencies {
implementation(libs.kotlinx.coroutines.core)
api(libs.coil.kt)
api(libs.coil.core)
api(libs.coil.svg)
api(libs.coil.network.ktor)
api(libs.kermit.logging)
api(libs.squareup.okio)
api(libs.jb.kotlin.stdlib)
api(libs.kotlinx.datetime)
}

implementation(libs.javax.inject)
}
androidMain.dependencies {
implementation(libs.kotlinx.coroutines.android)
}
commonTest.dependencies {
implementation(libs.kotlinx.coroutines.test)
}
iosMain.dependencies {
api(libs.kermit.simple)
}
desktopMain.dependencies {
implementation(libs.kotlinx.coroutines.swing)
implementation(libs.kotlin.reflect)
}
jsMain.dependencies {
api(libs.jb.kotlin.stdlib.js)
api(libs.jb.kotlin.dom)
}
}
}
//dependencies {
// implementation(projects.core.model)
// testImplementation(libs.kotlinx.coroutines.test)
// testImplementation(libs.turbine)
//
// androidTestImplementation(libs.androidx.junit)
// androidTestImplementation(libs.androidx.test.espresso.core)
//
// implementation(libs.converter.gson)
//
// implementation(libs.javax.inject)
//}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.mifos.core.common.network.di

import org.koin.core.module.Module

actual val ioDispatcherModule: Module
get() = TODO("Not yet implemented")
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.mifos.core.common.utils

actual annotation class Parcelize actual constructor()
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
package com.mifos.core.common.network

import javax.inject.Qualifier
import org.koin.core.annotation.Qualifier
import kotlin.annotation.AnnotationRetention.RUNTIME

@Qualifier
Expand All @@ -20,3 +20,4 @@ enum class MifosDispatchers {
Default,
IO,
}

Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ internal object CoroutineScopesModule {
@Dispatcher(Default) dispatcher: CoroutineDispatcher,
): CoroutineScope = CoroutineScope(SupervisorJob() + dispatcher)
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@
package com.mifos.core.common.network.di

import com.mifos.core.common.network.Dispatcher
import com.mifos.core.common.network.MifosDispatchers
import com.mifos.core.common.network.MifosDispatchers.Default
import com.mifos.core.common.network.MifosDispatchers.IO
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import org.koin.core.module.Module
import org.koin.core.qualifier.named
import org.koin.dsl.module

@Module
@InstallIn(SingletonComponent::class)
object DispatchersModule {
object DispatchersModule_s {
@Provides
@Dispatcher(IO)
fun providesIODispatcher(): CoroutineDispatcher = Dispatchers.IO
Expand All @@ -30,3 +36,15 @@ object DispatchersModule {
@Dispatcher(Default)
fun providesDefaultDispatcher(): CoroutineDispatcher = Dispatchers.Default
}

// TODO recheck
val DispatchersModule = module {
includes(ioDispatcherModule)
single<CoroutineDispatcher>(named(MifosDispatchers.Default.name )) { Dispatchers.Default }
single<CoroutineDispatcher>(named(MifosDispatchers.IO.name)) { Dispatchers.Unconfined }
// single<CoroutineScope>(named("ApplicationScope")) {
// CoroutineScope(SupervisorJob() + Dispatchers.Default)
// }
}

expect val ioDispatcherModule: Module
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.mifos.core.common.utils

expect annotation class Parcelize()

expect interface Parcelable

expect annotation class IgnoredOnParcel()

expect interface Parceler<P> {
fun create(parcel: Parcel): P

fun P.write(parcel: Parcel, flags: Int)
}

expect annotation class TypeParceler<T, P : Parceler<in T>>()

expect class Parcel {
fun readByte(): Byte
fun readInt(): Int

fun readFloat(): Float
fun readDouble(): Double
fun readString(): String?

fun writeByte(value: Byte)
fun writeInt(value: Int)

fun writeFloat(value: Float)

fun writeDouble(value: Double)
fun writeString(value: String?)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.mifos.core.common.network.di

import org.koin.core.module.Module

actual val ioDispatcherModule: Module
get() = TODO("Not yet implemented")
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.mifos.core.common.utils

actual annotation class Parcelize actual constructor()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.mifos.core.common.network.di

import org.koin.core.module.Module

actual val ioDispatcherModule: Module
get() = TODO("Not yet implemented")
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.mifos.core.common.utils

actual annotation class Parcelize actual constructor()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.mifos.core.common.network.di

import org.koin.core.module.Module

actual val ioDispatcherModule: Module
get() = TODO("Not yet implemented")
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.mifos.core.common.utils

actual annotation class Parcelize actual constructor()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.mifos.core.common.network.di

import org.koin.core.module.Module

actual val ioDispatcherModule: Module
get() = TODO("Not yet implemented")
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.mifos.core.common.utils

actual annotation class Parcelize actual constructor()
33 changes: 33 additions & 0 deletions core/database/src/main/java/com/mifos/room/dao/GroupInterface.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2025 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/android-client/blob/master/LICENSE.md
*/
package com.mifos.room.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Update
import com.mifos.core.entity.group.Group

/**
* Created by Pronay Sarker on 17/01/2025 (6:18 PM)
*/
@Dao
interface GroupInterface {

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(group: Group)

@Update
suspend fun update(group: Group)

@Delete
suspend fun delete(group: Group)
}
15 changes: 15 additions & 0 deletions core/database/src/main/java/com/mifos/room/dao/SurveyInterface.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright 2025 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/android-client/blob/master/LICENSE.md
*/
package com.mifos.room.dao

/**
* Created by Pronay Sarker on 17/01/2025 (7:10 PM)
*/
interface SurveyInterface
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import androidx.core.net.toFile
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import coil.compose.rememberAsyncImagePainter
import com.mifos.core.common.utils.Network
import com.mifos.core.designsystem.component.MifosCircularProgress
import com.mifos.core.designsystem.component.MifosDatePickerTextField
import com.mifos.core.designsystem.component.MifosOutlinedTextField
Expand Down Expand Up @@ -644,7 +645,7 @@ private fun handleSubmitClick(
return
}

if (!com.mifos.core.common.utils.Network.isOnline(context)) {
if (!Network.isOnline(context)) {
Toast.makeText(
context,
context.resources.getString(R.string.feature_client_error_not_connected_internet),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.mifos.core.common.utils.DateHelper
import com.mifos.core.common.utils.Network
import com.mifos.core.designsystem.component.MifosCircularProgress
import com.mifos.core.designsystem.component.MifosDatePickerTextField
import com.mifos.core.designsystem.component.MifosOutlinedTextField
Expand Down Expand Up @@ -318,7 +319,7 @@ private fun LoanAccountApprovalContent(
if (isFieldValid(amount = approvedAmount, context = context) &&
isFieldValid(amount = transactionAmount, context = context)
) {
if (com.mifos.core.common.utils.Network.isOnline(context)) {
if (Network.isOnline(context)) {
val approvedOnDate = SimpleDateFormat(
"dd MMMM yyyy",
Locale.getDefault(),
Expand Down
Loading