Skip to content

Commit d3d2692

Browse files
authored
Merge branch 'development' into feature/navigate-to-loan-list-after-creation
2 parents e9cfb97 + b811bcd commit d3d2692

32 files changed

Lines changed: 679 additions & 267 deletions

File tree

cmp-navigation/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ kotlin {
2929
implementation(projects.core.datastore)
3030
implementation(projects.core.database)
3131
implementation(projects.core.network)
32+
implementation(projects.coreBase.common)
3233

3334
implementation(projects.feature.about)
3435
implementation(projects.feature.activate)

cmp-navigation/src/commonMain/kotlin/cmp/navigation/di/KoinModules.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ import com.mifos.room.di.HelperModule
4343
import com.mifos.room.di.PlatformSpecificDatabaseModule
4444
import org.koin.core.module.dsl.viewModelOf
4545
import org.koin.dsl.module
46+
import template.core.base.common.di.CommonModule
4647

4748
object KoinModules {
4849

4950
private val commonModules = module { includes(DispatchersModule) }
51+
private val coreBaseCommonModules = module { includes(CommonModule) }
5052
private val domainModule = module { includes(UseCaseModule) }
5153
private val dataModules = module { includes(RepositoryModule) }
5254
private val coreDataStoreModules = module { includes(PreferencesModule) }
@@ -104,5 +106,6 @@ object KoinModules {
104106
featureModules,
105107
networkModules,
106108
coreDataStoreModules,
109+
coreBaseCommonModules,
107110
)
108111
}

cmp-shared/cmp_shared.podspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Pod::Spec.new do |spec|
99
spec.vendored_frameworks = 'build/cocoapods/framework/ComposeApp.framework'
1010
spec.libraries = 'c++'
1111
spec.ios.deployment_target = '16.0'
12-
13-
12+
13+
1414
if !Dir.exist?('build/cocoapods/framework/ComposeApp.framework') || Dir.empty?('build/cocoapods/framework/ComposeApp.framework')
1515
raise "
1616
@@ -21,16 +21,16 @@ Pod::Spec.new do |spec|
2121
2222
Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)"
2323
end
24-
24+
2525
spec.xcconfig = {
2626
'ENABLE_USER_SCRIPT_SANDBOXING' => 'NO',
2727
}
28-
28+
2929
spec.pod_target_xcconfig = {
3030
'KOTLIN_PROJECT_PATH' => ':cmp-shared',
3131
'PRODUCT_MODULE_NAME' => 'ComposeApp',
3232
}
33-
33+
3434
spec.script_phases = [
3535
{
3636
:name => 'Build cmp_shared',

core/data/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ kotlin {
3939
api(projects.core.datastore)
4040
api(projects.core.network)
4141
api(projects.core.database)
42+
api(projects.coreBase.common)
43+
4244

4345
implementation(libs.mifos.authenticator.passcode)
4446
implementation(libs.mifos.authenticator.biometrics)

core/data/src/androidMain/kotlin/com/mifos/core/data/util/ConnectivityManagerNetworkMonitor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ internal class ConnectivityManagerNetworkMonitor(
5555
}
5656
}
5757
val request = Builder()
58-
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
58+
.addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
5959
.build()
6060
connectivityManager.registerNetworkCallback(request, callback)
6161
/**
@@ -72,5 +72,5 @@ internal class ConnectivityManagerNetworkMonitor(
7272

7373
private fun ConnectivityManager.isCurrentlyConnected() = activeNetwork
7474
?.let(::getNetworkCapabilities)
75-
?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) ?: false
75+
?.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED) ?: false
7676
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2026 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/mifos-x-field-officer-app/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.core.data.mappers.client.note
11+
12+
import com.mifos.core.model.objects.note.Note
13+
import com.mifos.core.network.dto.note.NoteDto
14+
15+
fun NoteDto.toDomain(): Note = Note(
16+
clientId = clientId,
17+
createdById = createdById,
18+
createdByUsername = createdByUsername,
19+
createdOn = createdOn,
20+
id = id,
21+
note = note,
22+
updatedById = updatedById,
23+
updatedByUsername = updatedByUsername,
24+
updatedOn = updatedOn,
25+
)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2026 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/mifos-x-field-officer-app/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.core.data.mappers.client.note
11+
12+
import com.mifos.core.model.objects.note.Note
13+
import com.mifos.core.network.dto.note.NoteDto
14+
import com.mifos.room.entities.noncore.NoteEntity
15+
16+
fun NoteDto.toEntity(): NoteEntity = NoteEntity(
17+
id = id,
18+
clientId = clientId,
19+
noteContent = note,
20+
createdById = createdById,
21+
createdByUsername = createdByUsername,
22+
createdOn = createdOn,
23+
updatedById = updatedById,
24+
updatedByUsername = updatedByUsername,
25+
updatedOn = updatedOn,
26+
)
27+
28+
fun NoteEntity.toDomain(): Note = Note(
29+
id = id,
30+
clientId = clientId,
31+
note = noteContent,
32+
createdById = createdById,
33+
createdByUsername = createdByUsername,
34+
createdOn = createdOn,
35+
updatedById = updatedById,
36+
updatedByUsername = updatedByUsername,
37+
updatedOn = updatedOn,
38+
)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2026 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/mifos-x-field-officer-app/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.core.data.mappers.client.note
11+
12+
import com.mifos.core.model.objects.note.CreateNoteInput
13+
import com.mifos.core.model.objects.note.UpdateNoteInput
14+
import com.mifos.core.network.dto.note.NoteRequestDto
15+
16+
fun CreateNoteInput.toDto(): NoteRequestDto = NoteRequestDto(
17+
note = note,
18+
)
19+
20+
fun UpdateNoteInput.toDto(): NoteRequestDto = NoteRequestDto(
21+
note = note,
22+
)

core/data/src/commonMain/kotlin/com/mifos/core/data/repository/NoteRepository.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
package com.mifos.core.data.repository
1111

1212
import com.mifos.core.common.utils.DataState
13-
import com.mifos.core.model.objects.notes.Note
14-
import com.mifos.core.model.objects.payloads.NotesPayload
15-
import com.mifos.core.network.GenericResponse
13+
import com.mifos.core.model.objects.note.CreateNoteInput
14+
import com.mifos.core.model.objects.note.Note
15+
import com.mifos.core.model.objects.note.UpdateNoteInput
1616
import kotlinx.coroutines.flow.Flow
1717

1818
/**
@@ -23,14 +23,14 @@ interface NoteRepository {
2323
suspend fun addNewNote(
2424
resourceType: String,
2525
resourceId: Long,
26-
notesPayload: NotesPayload,
27-
): GenericResponse
26+
createNoteInput: CreateNoteInput,
27+
): DataState<Unit>
2828

2929
suspend fun deleteNote(
3030
resourceType: String,
3131
resourceId: Long,
3232
noteId: Long,
33-
): GenericResponse
33+
): DataState<Unit>
3434

3535
fun retrieveNote(
3636
resourceType: String,
@@ -47,6 +47,6 @@ interface NoteRepository {
4747
resourceType: String,
4848
resourceId: Long,
4949
noteId: Long,
50-
notesPayload: NotesPayload,
51-
): GenericResponse
50+
updateNoteInput: UpdateNoteInput,
51+
): DataState<Unit>
5252
}

core/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/NoteRepositoryImp.kt

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,94 @@ package com.mifos.core.data.repositoryImp
1111

1212
import com.mifos.core.common.utils.DataState
1313
import com.mifos.core.common.utils.asDataStateFlow
14+
import com.mifos.core.data.mappers.client.note.toDomain
15+
import com.mifos.core.data.mappers.client.note.toDto
1416
import com.mifos.core.data.repository.NoteRepository
15-
import com.mifos.core.model.objects.notes.Note
16-
import com.mifos.core.model.objects.payloads.NotesPayload
17-
import com.mifos.core.network.GenericResponse
17+
import com.mifos.core.data.util.NetworkMonitor
18+
import com.mifos.core.data.util.runAsDataState
19+
import com.mifos.core.data.util.withNetworkCheck
20+
import com.mifos.core.model.objects.note.CreateNoteInput
21+
import com.mifos.core.model.objects.note.Note
22+
import com.mifos.core.model.objects.note.UpdateNoteInput
1823
import com.mifos.core.network.datamanager.DataManagerNote
1924
import kotlinx.coroutines.flow.Flow
25+
import kotlinx.coroutines.flow.flowOn
26+
import kotlinx.coroutines.flow.map
27+
import template.core.base.common.manager.DispatcherManager
2028

2129
class NoteRepositoryImp(
2230
private val dataManagerNote: DataManagerNote,
31+
private val networkMonitor: NetworkMonitor,
32+
private val dispatcher: DispatcherManager,
2333
) : NoteRepository {
2434

2535
override suspend fun addNewNote(
2636
resourceType: String,
2737
resourceId: Long,
28-
notesPayload: NotesPayload,
29-
): GenericResponse {
30-
return dataManagerNote.addNewNote(resourceType, resourceId, notesPayload)
38+
createNoteInput: CreateNoteInput,
39+
): DataState<Unit> {
40+
return runAsDataState(
41+
networkMonitor,
42+
dispatcher.io,
43+
) {
44+
dataManagerNote.addNewNote(resourceType, resourceId, createNoteInput.toDto())
45+
}
3146
}
3247

3348
override suspend fun deleteNote(
3449
resourceType: String,
3550
resourceId: Long,
3651
noteId: Long,
37-
): GenericResponse {
38-
return dataManagerNote.deleteNote(resourceType, resourceId, noteId)
52+
): DataState<Unit> {
53+
return runAsDataState(
54+
networkMonitor,
55+
dispatcher.io,
56+
) {
57+
dataManagerNote.deleteNote(resourceType, resourceId, noteId)
58+
}
3959
}
4060

4161
override fun retrieveNote(
4262
resourceType: String,
4363
resourceId: Long,
4464
noteId: Long,
45-
): Flow<DataState<Note>> {
46-
return dataManagerNote.retrieveNote(resourceType, resourceId, noteId).asDataStateFlow()
47-
}
65+
): Flow<DataState<Note>> =
66+
networkMonitor.withNetworkCheck(
67+
dataManagerNote.retrieveNote(resourceType, resourceId, noteId).map { it.toDomain() }
68+
.asDataStateFlow(),
69+
).flowOn(dispatcher.io)
4870

4971
override fun retrieveListNotes(
5072
resourceType: String,
5173
resourceId: Long,
52-
): Flow<DataState<List<Note>>> {
53-
return dataManagerNote.retrieveListNotes(resourceType, resourceId).asDataStateFlow()
54-
}
74+
): Flow<DataState<List<Note>>> =
75+
networkMonitor.withNetworkCheck(
76+
dataManagerNote
77+
.retrieveListNotes(resourceType, resourceId)
78+
.map { dtoList ->
79+
dtoList.map { dto ->
80+
dto.toDomain()
81+
}
82+
}
83+
.asDataStateFlow(),
84+
).flowOn(dispatcher.io)
5585

5686
override suspend fun updateNote(
5787
resourceType: String,
5888
resourceId: Long,
5989
noteId: Long,
60-
notesPayload: NotesPayload,
61-
): GenericResponse {
62-
return dataManagerNote.updateNote(resourceType, resourceId, noteId, notesPayload)
90+
updateNoteInput: UpdateNoteInput,
91+
): DataState<Unit> {
92+
return runAsDataState(
93+
networkMonitor,
94+
dispatcher.io,
95+
) {
96+
dataManagerNote.updateNote(
97+
resourceType,
98+
resourceId,
99+
noteId,
100+
updateNoteInput.toDto(),
101+
)
102+
}
63103
}
64104
}

0 commit comments

Comments
 (0)