Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion .run/mifospay-ios.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="mifospay-ios" type="KmmRunConfiguration" factoryName="iOS Application" CONFIG_VERSION="1" XCODE_PROJECT="$PROJECT_DIR$/mifospay-ios/iosApp.xcodeproj">
<configuration default="false" name="mifospay-ios" type="KmmRunConfiguration" factoryName="iOS Application" CONFIG_VERSION="1" XCODE_PROJECT="$PROJECT_DIR$/mifospay-ios/iosApp.xcodeproj" XCODE_CONFIGURATION="Debug" XCODE_SCHEME="iosApp">
<method v="2">
<option name="com.jetbrains.kmm.ios.BuildIOSAppTask" enabled="true" />
</method>
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ plugins {
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.wire) apply false
alias(libs.plugins.ktorfit) apply false
alias(libs.plugins.dokka)
}

object DynamicVersion {
Expand Down
20 changes: 20 additions & 0 deletions feature/accounts/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
plugins {
alias(libs.plugins.mifospay.cmp.feature)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.dokka)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these plugins alias(libs.plugins.dokka) and alias(libs.plugins.mifospay.feature.library)

}

android {
Expand All @@ -27,4 +28,23 @@ kotlin {
implementation(libs.kotlinx.serialization.json)
}
}
}
// Configure Dokka
tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be be part of feature and library gradle custom plugin

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move these in feature and library build-logic gradle plugin

// Output format (HTML by default)
outputDirectory.set(layout.buildDirectory.dir("dokka"))

// Module name in documentation
moduleName.set("feature")

// Documentation format
dokkaSourceSets {
configureEach {
sourceLink {
localDirectory.set(file("src"))
remoteUrl.set(uri("https://github.com/openMF/mobile-wallet.git").toURL())
remoteLineSuffix.set("#L")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import org.mifospay.feature.accounts.AccountAction.Internal.DeleteBeneficiary
import org.mifospay.feature.accounts.AccountEvent.OnAddEditSavingsAccount
import org.mifospay.feature.accounts.beneficiary.BeneficiaryAddEditType
import org.mifospay.feature.accounts.savingsaccount.SavingsAddEditType

@OptIn(ExperimentalCoroutinesApi::class)
class AccountViewModel(
private val userRepository: UserPreferencesRepository,
Expand All @@ -51,6 +50,9 @@ class AccountViewModel(
)
},
) {
/**
* Exposes the account and beneficiary list as a [StateFlow] of [AccountState.ViewState].
*/
val accountState = repository.getAccountAndBeneficiaryList(state.clientId)
.mapLatest {
when (it) {
Expand All @@ -67,6 +69,9 @@ class AccountViewModel(
initialValue = AccountState.ViewState.Loading,
)

/**
* Handles [AccountAction] and triggers corresponding [AccountEvent] or state updates.
*/
override fun handleAction(action: AccountAction) {
when (action) {
is AccountAction.CreateSavingsAccount -> {
Expand Down Expand Up @@ -124,6 +129,9 @@ class AccountViewModel(
}
}

/**
* Handles updating the default account in [userRepository].
*/
private fun handleSetDefaultAccount(action: AccountAction.SetDefaultAccount) {
viewModelScope.launch {
userRepository.updateDefaultAccount(
Expand All @@ -138,6 +146,9 @@ class AccountViewModel(
sendEvent(AccountEvent.ShowToast("Default account updated"))
}

/**
* Sends a delete request for the given beneficiary ID and shows a loading dialog.
*/
private fun handleDeleteBeneficiary(action: DeleteBeneficiary) {
mutableStateFlow.update { it.copy(dialogState = AccountState.DialogState.Loading) }

Expand All @@ -148,6 +159,9 @@ class AccountViewModel(
}
}

/**
* Handles the result of deleting a beneficiary and updates dialog state accordingly.
*/
private fun handleBeneficiaryDeleteResult(action: BeneficiaryDeleteResultReceived) {
when (action.result) {
is DataState.Success -> {
Expand Down Expand Up @@ -175,36 +189,52 @@ class AccountViewModel(
}
}

/**
* Represents the state of the account screen.
*/
data class AccountState(
val clientId: Long,
val defaultAccountId: Long? = null,
val dialogState: DialogState? = null,
) {
/**
* Defines various dialog UI states.
*/
sealed interface DialogState {
/** Represents a loading dialog. */
data object Loading : DialogState

/** Represents an error dialog with a message. */
data class Error(val message: String) : DialogState

/** Dialog shown before deleting a beneficiary. */
data class DeleteBeneficiary(
val title: StringResource,
val message: StringResource,
val onConfirm: () -> Unit,
) : DialogState
}

/**
* UI state representing the screen's visual content.
*/
sealed interface ViewState {
val hasFab: Boolean

val isPullToRefreshEnabled: Boolean

/** Loading view state. */
data object Loading : ViewState {
override val hasFab: Boolean get() = false
override val isPullToRefreshEnabled: Boolean get() = false
}

/** Error view state with a message. */
data class Error(val message: String) : ViewState {
override val hasFab: Boolean get() = false
override val isPullToRefreshEnabled: Boolean get() = false
}

/** Content view state with account and beneficiary info. */
data class Content(
val accounts: List<Account>,
val beneficiaries: List<Beneficiary>,
Expand All @@ -215,26 +245,32 @@ data class AccountState(
}
}

/**
* Events that can be sent by [AccountViewModel] to update the UI.
*/
sealed interface AccountEvent {
data class OnAddEditSavingsAccount(val type: SavingsAddEditType) : AccountEvent
data class OnNavigateToAccountDetail(val accountId: Long) : AccountEvent
data class OnAddOrEditTPTBeneficiary(val type: BeneficiaryAddEditType) : AccountEvent

data class ShowToast(val message: String) : AccountEvent
}

/**
* Actions that can be triggered from the UI to be handled by [AccountViewModel].
*/
sealed interface AccountAction {
data object AddTPTBeneficiary : AccountAction
data class EditBeneficiary(val beneficiary: Beneficiary) : AccountAction
data class DeleteBeneficiary(val beneficiaryId: Long) : AccountAction

data object CreateSavingsAccount : AccountAction
data class EditSavingsAccount(val accountId: Long) : AccountAction
data class ViewAccountDetails(val accountId: Long) : AccountAction
data class SetDefaultAccount(val accountId: Long, val accountNo: String) : AccountAction

data object DismissDialog : AccountAction

/**
* Internal-only actions used within the view model.
*/
sealed interface Internal : AccountAction {
data class DeleteBeneficiary(val beneficiaryId: Long) : Internal
data class BeneficiaryDeleteResultReceived(val result: DataState<String>) : Internal
Expand Down
20 changes: 20 additions & 0 deletions feature/auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ plugins {
alias(libs.plugins.mifospay.cmp.feature)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.dokka)
}

android {
Expand Down Expand Up @@ -44,4 +45,23 @@ kotlin {
implementation(libs.play.services.auth)
}
}
}

tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, it should be moved in feature and library gradle plugin

Copy link
Collaborator

@niyajali niyajali Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the Dokka configurations into the root build.gradle.kts file and include the Dokka plugin into the existing KMP Library and CMP Feature Convention plugin. and It will be applied to all the core and feature modules and no need to add the plugin on every module and it will works as expected.

// Output format (HTML by default)
outputDirectory.set(layout.buildDirectory.dir("dokka"))

// Module name in documentation
moduleName.set("feature")

// Documentation format
dokkaSourceSets {
configureEach {
sourceLink {
localDirectory.set(file("src"))
remoteUrl.set(uri("https://github.com/openMF/mobile-wallet.git").toURL())
remoteLineSuffix.set("#L")
}
}
}
}
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ org.gradle.configureondemand=false
org.gradle.caching=true

# Enable configuration caching between builds.
org.gradle.configuration-cache=true
org.gradle.configuration-cache=false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert it back

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's enable configuration caching to improve build performance. While it may occasionally fail due to cache mismatches, running clean and rebuilding typically resolves the issue. Disabling it would significantly slow down our builds, so the trade-off is worth it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

# This option is set because of https://github.com/google/play-services-plugins/issues/246
# to generate the Configuration Cache regardless of incompatible tasks.
# See https://github.com/android/nowinandroid/issues/1022 before using it.
Expand Down Expand Up @@ -53,4 +53,5 @@ RblClientIdProp=a
RblClientSecretProp=b

kotlin.native.ignoreDisabledTargets=true
kotlin.mpp.androidGradlePluginCompatibility.nowarn=true
kotlin.mpp.androidGradlePluginCompatibility.nowarn=true

1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,4 @@ ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotlessVersion" }
version-catalog-linter = { id = "io.github.pemistahl.version-catalog-linter", version.ref = "versionCatalogLinterVersion" }

dokka = { id = "org.jetbrains.dokka", version = "2.0.0" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a variable for version number of this library like above libraries instead of hardcoding

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the variable dokkaGradlePlugin for version number like version.ref="dokkaGradlePlugin"

Please don't resolve the conversion even though you fixed it.

Loading