Skip to content
Open
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
3 changes: 2 additions & 1 deletion cmp-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/

import org.mifos.MifosBuildType
import org.mifos.dynamicVersion

Expand Down Expand Up @@ -154,4 +155,4 @@ dependencyGuard {
modules = true
tree = true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ private val SCRIM_COLOR: Int = Color.TRANSPARENT
* [here](https://github.com/android/nowinandroid/blob/689ef92e41427ab70f82e2c9fe59755441deae92/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt#L94).
*/
@Suppress("MaxLineLength")
fun ComponentActivity.setupEdgeToEdge(
appThemeFlow: Flow<DarkThemeConfig>,
) {
fun ComponentActivity.setupEdgeToEdge(appThemeFlow: Flow<DarkThemeConfig>) {
lifecycleScope.launch {
lifecycle.repeatOnLifecycle(state = Lifecycle.State.STARTED) {
combine(
Expand All @@ -55,12 +53,13 @@ fun ComponentActivity.setupEdgeToEdge(
// This handles all the settings to go edge-to-edge. We are using a transparent
// scrim for system bars and switching between "light" and "dark" based on the
// system and internal app theme settings.
val style = SystemBarStyle.auto(
darkScrim = SCRIM_COLOR,
lightScrim = SCRIM_COLOR,
// Disabling Dark Mode for this app
detectDarkMode = { false },
)
val style =
SystemBarStyle.auto(
darkScrim = SCRIM_COLOR,
lightScrim = SCRIM_COLOR,
// Disabling Dark Mode for this app
detectDarkMode = { false },
)
enableEdgeToEdge(statusBarStyle = style, navigationBarStyle = style)
}
}
Expand All @@ -75,9 +74,10 @@ fun ComponentActivity.setupEdgeToEdge(
private fun ComponentActivity.isSystemInDarkModeFlow(): Flow<Boolean> =
callbackFlow {
channel.trySend(element = resources.configuration.isSystemInDarkMode)
val listener = Consumer<Configuration> {
channel.trySend(element = it.isSystemInDarkMode)
}
val listener =
Consumer<Configuration> {
channel.trySend(element = it.isSystemInDarkMode)
}
addOnConfigurationChangedListener(listener = listener)
awaitClose { removeOnConfigurationChangedListener(listener = listener) }
}
Expand Down
1 change: 1 addition & 0 deletions cmp-android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@
<string name="feature_groups_no_more_groups_available">No more Groups Available</string>
<string name="no_more_centers_available">No more Centers Available</string>


<string name="numberofrepayments">Number of repayments</string>

<string name="days_in_year">Days in year</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<string name="core_designsystem_enter_tenant">Enter a tenant</string>
<string name="core_designsystem_cancel">Cancel</string>
<string name="core_designsystem_dialog_action_ok">Save</string>
<string name="core_designsystem_dialog_success">Success</string>
<string name="core_designsystem_dialog_failure">Failure</string>
<string name="core_designsystem_dialog_continue">Continue</string>
<string name="core_designsystem_mifosStatusDialog">MifosStatusDialog</string>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Keep dialog test tag string non-translatable.

Line 22 declares core_designsystem_mifosStatusDialog, which feeds directly into a Modifier.testTag. If translators localize this value, every UI test that targets that tag will fail. Please mark it non-translatable (or inline a constant) so the tag stays stable across locales.

-    <string name="core_designsystem_mifosStatusDialog">MifosStatusDialog</string>
+    <string name="core_designsystem_mifosStatusDialog" translatable="false">MifosStatusDialog</string>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<string name="core_designsystem_mifosStatusDialog">MifosStatusDialog</string>
<string name="core_designsystem_mifosStatusDialog" translatable="false">MifosStatusDialog</string>
🤖 Prompt for AI Agents
In core/designsystem/src/commonMain/composeResources/values/strings.xml around
line 22, the string resource core_designsystem_mifosStatusDialog is used as a
testTag and must not be translated; change its declaration to mark it
non-translatable (e.g., add translatable="false" to the <string> tag) or replace
usages with an inline constant so the test tag value remains stable across
locales.


<string name="core_designsystem_app_title">Mifos</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -32,6 +35,16 @@ import com.mifos.core.designsystem.theme.MifosTypography
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.jetbrains.compose.ui.tooling.preview.PreviewParameter
import org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.CheckCircle
import androidx.compose.material.icons.filled.Error
import androidx.compose.ui.graphics.Color
import core.designsystem.generated.resources.Res
import core.designsystem.generated.resources.core_designsystem_dialog_continue
import core.designsystem.generated.resources.core_designsystem_dialog_failure
import core.designsystem.generated.resources.core_designsystem_dialog_success
import core.designsystem.generated.resources.core_designsystem_mifosStatusDialog
import org.jetbrains.compose.resources.stringResource

@Composable
fun MifosBasicDialog(
Expand Down Expand Up @@ -197,6 +210,73 @@ fun MifosBasicDialog(
)
}



enum class MifosDialogStatus { SUCCESS, FAILURE }

@Composable
fun MifosStatusDialog(
status: MifosDialogStatus,
message: String,
onDismissRequest: () -> Unit
) {
data class DialogUI(
val title: String,
val icon: androidx.compose.ui.graphics.vector.ImageVector,
val color: Color
)

val dialogUI: DialogUI = when (status) {
MifosDialogStatus.SUCCESS -> DialogUI(
title = stringResource(Res.string.core_designsystem_dialog_success),
icon = Icons.Filled.CheckCircle,
color = Color(0xFF4CAF50)
)
MifosDialogStatus.FAILURE -> DialogUI(
title = stringResource(Res.string.core_designsystem_dialog_failure),
icon = Icons.Filled.Error,
color = Color(0xFFF44336)
)
}

AlertDialog(
onDismissRequest = onDismissRequest,
icon = {
Icon(
imageVector = dialogUI.icon,
contentDescription = dialogUI.title,
tint = dialogUI.color,
modifier = Modifier
.size(84.dp)
.padding(bottom = 4.dp)
)
},
title = {
Text(
text = dialogUI.title,
style = MaterialTheme.typography.titleLarge
)
},
text = {
Text(
text = message,
style = MaterialTheme.typography.bodyMedium
)
},
confirmButton = {
Button(
onClick = onDismissRequest,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp)
) {
Text(stringResource(Res.string.core_designsystem_dialog_continue))
}
},
modifier = Modifier.testTag(stringResource(Res.string.core_designsystem_mifosStatusDialog))
)
}

@Preview
@Composable
private fun MifosBasicDialog_preview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.navigation.NavController
import com.mifos.core.designsystem.theme.DesignToken
import com.mifos.core.designsystem.theme.MifosTheme
import com.mifos.core.designsystem.theme.MifosTypography
import com.mifos.core.ui.util.PROFILE_SHOULD_REFRESH_KEY
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.ui.tooling.preview.Preview

Expand Down Expand Up @@ -81,6 +82,9 @@ fun MifosBreadcrumbNavBar(
isActive = index == routes.lastIndex,
onClick = {
if (index != routes.lastIndex && route != "...") {
navController.previousBackStackEntry
?.savedStateHandle
?.set(PROFILE_SHOULD_REFRESH_KEY, true)
navController.popBackStack(route, inclusive = false)
}
},
Expand All @@ -93,10 +97,13 @@ fun MifosBreadcrumbNavBar(
}
}

IconButton(
onClick = { navController.popBackStack() },
modifier = Modifier.size(DesignToken.sizes.iconMedium),
) {

IconButton(onClick = {
navController.previousBackStackEntry
?.savedStateHandle
?.set(PROFILE_SHOULD_REFRESH_KEY, true)
navController.popBackStack()
}) {
Icon(
painter = painterResource(Res.drawable.bread_crumb_back_icon),
contentDescription = "Back",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.mifos.core.ui.util

internal const val PROFILE_SHOULD_REFRESH_KEY = "profile_should_refresh"
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Consolidate duplicate constant definition.

The same constant PROFILE_SHOULD_REFRESH_KEY with identical value is defined in both:

  • core/ui/src/commonMain/kotlin/com/mifos/core/ui/util/Constants.kt (this file)
  • feature/client/src/commonMain/kotlin/com/mifos/feature/client/utils/Constants.kt

Since both are marked internal, they cannot be shared across modules. Consider making the core/ui version public and removing the duplicate from feature/client to maintain a single source of truth.

Apply this approach:

  1. Make this constant public (or internal with module export if using Kotlin Multiplatform module structure)
  2. Remove the duplicate from feature/client/utils/Constants.kt
  3. Update imports in feature/client files to use the core/ui constant
🤖 Prompt for AI Agents
In core/ui/src/commonMain/kotlin/com/mifos/core/ui/util/Constants.kt around line
3, the constant PROFILE_SHOULD_REFRESH_KEY is declared internal and duplicated
in feature/client; make this the single source of truth by changing its
visibility to public (or configure module export for KMP if you prefer keeping
it internal across modules), remove the duplicate declaration from
feature/client/src/commonMain/kotlin/com/mifos/feature/client/utils/Constants.kt,
and update all imports/usages in feature/client to reference
com.mifos.core.ui.util.PROFILE_SHOULD_REFRESH_KEY from the core/ui module.

Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@
<string name="confirm_text">I Confirm</string>
<string name="dismiss_text">Cancel</string>
<string name="dialog_continue">Continue</string>
<string name="update_success_message">Your profile image has been updated successfully!</string>
<string name="profile_update_error_message">We couldn’t update your profile image. Please try again.</string>
<string name="profile_should_refresh">should refresh</string>
<string name="success">Success</string>
<string name="failure">Failure</string>

<!-- Assign Staff Screen -->
<string name="label_assign_staff">Assign Staff</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidclient.feature.client.generated.resources.dialog_continue
import androidclient.feature.client.generated.resources.dialog_unassign_message
import androidclient.feature.client.generated.resources.dismiss_text
import androidclient.feature.client.generated.resources.pen_icon
import androidclient.feature.client.generated.resources.profile_should_refresh
import androidclient.feature.client.generated.resources.scroll_for_more_options
import androidclient.feature.client.generated.resources.staff_unassign_failure_title
import androidclient.feature.client.generated.resources.staff_unassign_success_message
Expand All @@ -44,7 +45,9 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -67,6 +70,7 @@ import com.mifos.core.ui.util.TextUtil
import com.mifos.feature.client.clientDetailsProfile.components.ClientDetailsProfile
import com.mifos.feature.client.clientDetailsProfile.components.ClientProfileDetailsActionItem
import com.mifos.feature.client.clientDetailsProfile.components.clientsDetailsActionItems
import com.mifos.feature.client.utils.PROFILE_SHOULD_REFRESH_KEY
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import org.koin.compose.viewmodel.koinViewModel
Expand All @@ -88,6 +92,20 @@ internal fun ClientProfileDetailsScreen(
viewModel: ClientProfileDetailsViewModel = koinViewModel(),
) {
val state by viewModel.stateFlow.collectAsStateWithLifecycle()
val currentBackStackEntry = navController.currentBackStackEntry
val savedStateHandle = currentBackStackEntry?.savedStateHandle

val profileUpdated by savedStateHandle
?.getStateFlow(PROFILE_SHOULD_REFRESH_KEY, false)
?.collectAsStateWithLifecycle(initialValue = false)
?: remember { mutableStateOf(false) }

LaunchedEffect(profileUpdated) {
if (profileUpdated) {
viewModel.trySendAction(ClientProfileDetailsAction.OnRetry)
savedStateHandle?.set(PROFILE_SHOULD_REFRESH_KEY, false)
}
}

EventsEffect(viewModel.eventFlow) { event ->
when (event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ import androidclient.feature.client.generated.resources.choose_from_option
import androidclient.feature.client.generated.resources.delete_dialog_message
import androidclient.feature.client.generated.resources.delete_dialog_title
import androidclient.feature.client.generated.resources.delete_photo
import androidclient.feature.client.generated.resources.dialog_continue
import androidclient.feature.client.generated.resources.edit_profile_title
import androidclient.feature.client.generated.resources.feature_client_Image_Upload_Failed
import androidclient.feature.client.generated.resources.feature_client_Image_Upload_Successful
import androidclient.feature.client.generated.resources.from_camera
import androidclient.feature.client.generated.resources.from_gallery
import androidclient.feature.client.generated.resources.profile_update_error_message
import androidclient.feature.client.generated.resources.remove
import androidclient.feature.client.generated.resources.update_profile_photo_message
import androidclient.feature.client.generated.resources.update_success_message
import androidclient.feature.client.generated.resources.upload_new_photo
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
Expand All @@ -48,8 +53,10 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavController
import com.mifos.core.designsystem.component.BasicDialogState
import com.mifos.core.designsystem.component.MifosBasicDialog
import com.mifos.core.designsystem.component.MifosDialogStatus
import com.mifos.core.designsystem.component.MifosOutlinedButton
import com.mifos.core.designsystem.component.MifosScaffold
import com.mifos.core.designsystem.component.MifosStatusDialog
import com.mifos.core.designsystem.component.MifosTextButton
import com.mifos.core.designsystem.icon.MifosIcons
import com.mifos.core.designsystem.theme.DesignToken
Expand All @@ -76,15 +83,6 @@ internal fun ClientProfileEditScreen(
) {
val state by viewModel.stateFlow.collectAsStateWithLifecycle()

EventsEffect(viewModel.eventFlow) { event ->
when (event) {
ClientProfileEditEvent.NavigateBack -> onNavigateBack()
ClientProfileEditEvent.OnSaveSuccess -> {
onNavigateBack()
}
}
}

ClientProfileEditScaffold(
modifier = modifier,
state = state,
Expand Down Expand Up @@ -198,11 +196,18 @@ private fun ClientProfileEditDialogs(
is ClientProfileEditState.DialogState.Loading -> MifosProgressIndicator()

is ClientProfileEditState.DialogState.Error -> {
MifosErrorComponent(
isNetworkConnected = state.networkConnection,
message = state.dialogState.message,
isRetryEnabled = true,
onRetry = onRetry,
MifosStatusDialog(
status = MifosDialogStatus.FAILURE,
message = stringResource(Res.string.profile_update_error_message),
onDismissRequest = { onAction(ClientProfileEditAction.DismissModalBottomSheet) }
)
}

is ClientProfileEditState.DialogState.Success -> {
MifosStatusDialog(
status = MifosDialogStatus.SUCCESS,
message = stringResource(Res.string.update_success_message),
onDismissRequest = { onAction(ClientProfileEditAction.DismissModalBottomSheet) }
)
}
Comment on lines +199 to 212
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify navigation occurs after successful profile update.

The switch to MifosStatusDialog for error and success states improves UX consistency. However, the previous EventsEffect handling for OnSaveSuccess navigation was removed. Please verify that dismissing the success dialog triggers the appropriate navigation action (e.g., DismissModalBottomSheet should navigate back or trigger the refresh mechanism).


🏁 Script executed:

#!/bin/bash
# Search for the ViewModel implementation to verify success state handling
rg -A 10 "ClientProfileEditAction.DismissModalBottomSheet" --type=kotlin

# Check if DialogState.Success is properly set in the ViewModel
rg -B 5 -A 5 "DialogState.Success" --type=kotlin -g '*ClientProfileEdit*'

Length of output: 8200


I need to verify if the navigation logic is still present after dismissing the success dialog.

I need to verify if there's a LaunchedEffect or similar mechanism that triggers navigation when the dialog state is cleared.


🏁 Script executed:

#!/bin/bash
# Search for LaunchedEffect and navigation logic in the screen
rg -A 20 "LaunchedEffect\|navController\|navigate\(" --type=kotlin -g '*ClientProfileEditScreen*'

# Also check the complete dialog state handling
rg -B 10 "when.*dialogState" --type=kotlin -g '*ClientProfileEditScreen*'

Length of output: 1463


🏁 Script executed:

#!/bin/bash
# Get the full ClientProfileEditScreen composable function signature and context
rg -B 5 "fun ClientProfileEditScreen" --type=kotlin -A 30 -g '*ClientProfileEditScreen*'

# Search for EventsEffect pattern mentioned in review comment
rg -B 3 -A 10 "EventsEffect\|OnSaveSuccess" --type=kotlin -g '*ClientProfileEdit*'

Length of output: 5004


🏁 Script executed:

#!/bin/bash
# Search for navController usage in ClientProfileEditScaffold
rg -A 100 "fun ClientProfileEditScaffold" --type=kotlin -g '*ClientProfileEditScreen*' | head -120

# Check if onNavigateBack is called or if there's any side effect after dialog state change
rg "onNavigateBack\|LaunchedEffect.*dialogState" --type=kotlin -g '*ClientProfileEditScreen*'

Length of output: 15376


Add navigation trigger after successful profile update.

The success dialog now dismisses without navigating. When DismissModalBottomSheet clears the dialog state, there's no mechanism to trigger navigation back. Add a LaunchedEffect in ClientProfileEditScreen to observe state.dialogState and call onNavigateBack() after a successful update completion, or handle navigation in the ViewModel by triggering a navigation action when DismissModalBottomSheet follows a successful profile update.

🤖 Prompt for AI Agents
In
feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientEditProfile/ClientProfileEditScreen.kt
around lines 199-212, the success dialog currently only dismisses without
navigating back; add a LaunchedEffect that observes state.dialogState and when
it transitions to a success dialog then is dismissed, call onNavigateBack() (or
alternatively emit a navigation action from the ViewModel when
DismissModalBottomSheet follows a success) so the UI navigates back after a
successful profile update; ensure the LaunchedEffect only triggers once per
success transition to avoid duplicate navigations.


Expand Down
Loading