From 2a942d57a5d6ff310c85d998ab146d56f7617c50 Mon Sep 17 00:00:00 2001 From: Arin Yadav Date: Mon, 1 Sep 2025 17:44:50 +0530 Subject: [PATCH 1/7] fix notes screen issue --- .../note/addEditNotes/AddEditNoteScreen.kt | 8 +++++--- .../note/addEditNotes/AddEditNoteViewModel.kt | 18 +++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt index 0df203047b7..cccc234f493 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt @@ -112,7 +112,12 @@ fun AddEditNoteScreenDialog( ) } + AddEditNoteState.DialogState.Success -> { + onAction(AddEditNoteAction.NavigateBack) + } + null -> Unit + } } @@ -221,9 +226,6 @@ private fun AddEditNote( } else { onAction(AddEditNoteAction.AddNote(state.textFieldNotesPayload)) } - if (state.isError) { - onAction(AddEditNoteAction.NavigateBack) - } }, colors = ButtonDefaults.outlinedButtonColors( contentColor = MaterialTheme.colorScheme.onPrimary, diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt index cb4015b7b79..358d7001386 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt @@ -125,20 +125,20 @@ class AddEditNoteViewModel( mutableStateFlow.update { it.copy( dialogState = AddEditNoteState.DialogState.Error(Res.string.feature_note_Unexpected_error), - isError = false, ) } } DataState.Loading -> { - // no need to show loading for this + mutableStateFlow.update { + it.copy(dialogState = AddEditNoteState.DialogState.Loading) + } } is DataState.Success -> { mutableStateFlow.update { it.copy( - isError = true, - dialogState = null, + dialogState = AddEditNoteState.DialogState.Success, successMessage = Res.string.feature_note_add_success, notesPayloadInitialData = state.textFieldNotesPayload.note, ) @@ -159,18 +159,18 @@ class AddEditNoteViewModel( mutableStateFlow.update { it.copy( dialogState = AddEditNoteState.DialogState.Error(Res.string.feature_note_Unexpected_error), - isError = false, ) } } DataState.Loading -> { - // no need to show loading for this + mutableStateFlow.update { + it.copy(dialogState = AddEditNoteState.DialogState.Loading) + } } is DataState.Success -> { mutableStateFlow.update { it.copy( - isError = true, - dialogState = null, + dialogState = AddEditNoteState.DialogState.Success, successMessage = Res.string.feature_note_edit_success, notesPayloadInitialData = state.textFieldNotesPayload.note, ) @@ -257,7 +257,6 @@ data class AddEditNoteState( val textFieldNotesPayload: NotesPayload = NotesPayload(null), val notesPayloadInitialData: String? = null, val showDialog: Boolean = false, - val isError: Boolean = true, val dialogState: DialogState? = null, val networkConnection: Boolean = false, ) { @@ -265,6 +264,7 @@ data class AddEditNoteState( data class Error(val message: StringResource) : DialogState data object Loading : DialogState data object MisTouchBack : DialogState + data object Success : DialogState } } From d357a0df07ff6c83112bfc625ae9d326214c1884 Mon Sep 17 00:00:00 2001 From: Arin Yadav Date: Mon, 1 Sep 2025 18:53:13 +0530 Subject: [PATCH 2/7] update --- .../kotlin/com/mifos/feature/note/notes/NoteScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt index 77d147ead36..8f9f4ad4f86 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt @@ -89,7 +89,7 @@ internal fun NoteScreenScaffold( } } - if (!state.isError && state.notes.isNotEmpty()) { + if (!state.isError) { NoteScreenScaffold( state = state, onAction = remember(viewModel) { { viewModel.trySendAction(it) } }, From 98e4bf0c2ba101729a804bc0d5ef907da39523bc Mon Sep 17 00:00:00 2001 From: Arin Yadav Date: Mon, 1 Sep 2025 21:04:59 +0530 Subject: [PATCH 3/7] update --- .../note/addEditNotes/AddEditNoteScreen.kt | 16 ++++-- .../note/addEditNotes/AddEditNoteViewModel.kt | 7 +++ .../mifos/feature/note/notes/NoteScreen.kt | 56 +++++++++++-------- 3 files changed, 52 insertions(+), 27 deletions(-) diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt index cccc234f493..07ae2650125 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt @@ -29,6 +29,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextFieldDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -44,6 +45,7 @@ import com.mifos.core.designsystem.theme.MifosTypography import com.mifos.core.ui.components.MifosAlertDialog import com.mifos.core.ui.components.MifosErrorComponent import com.mifos.core.ui.util.EventsEffect +import kotlinx.coroutines.delay import org.jetbrains.compose.resources.stringResource import org.koin.compose.viewmodel.koinViewModel @@ -113,7 +115,7 @@ fun AddEditNoteScreenDialog( } AddEditNoteState.DialogState.Success -> { - onAction(AddEditNoteAction.NavigateBack) + onAction(AddEditNoteAction.NavigateBackWithUpdateList) } null -> Unit @@ -136,10 +138,14 @@ internal fun AddEditNoteScreenScaffold( .fillMaxSize() .padding(paddingValues), ) { - AddEditNote( - state = state, - onAction = onAction, - ) + + if(state.dialogState !is AddEditNoteState.DialogState.Loading){ + AddEditNote( + state = state, + onAction = onAction, + ) + } + } } } diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt index 358d7001386..8fc7b6038ed 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt @@ -185,6 +185,10 @@ class AddEditNoteViewModel( override fun handleAction(action: AddEditNoteAction) { when (action) { AddEditNoteAction.NavigateBack -> { + sendEvent(AddEditNoteEvent.NavigateBack) + } + + AddEditNoteAction.NavigateBackWithUpdateList -> { sendEvent(AddEditNoteEvent.NavigateBackWithUpdateList) } @@ -242,6 +246,8 @@ class AddEditNoteViewModel( sendEvent(AddEditNoteEvent.NavigateBack) } } + + } } } @@ -275,6 +281,7 @@ sealed interface AddEditNoteEvent { sealed interface AddEditNoteAction { data object NavigateBack : AddEditNoteAction + data object NavigateBackWithUpdateList : AddEditNoteAction data object OnRetry : AddEditNoteAction data class AddNote(val notesPayload: NotesPayload) : AddEditNoteAction data class EditNote(val notesPayload: NotesPayload) : AddEditNoteAction diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt index 8f9f4ad4f86..b8434cfbb60 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt @@ -84,17 +84,25 @@ internal fun NoteScreenScaffold( EventsEffect(viewModel.eventFlow) { event -> when (event) { NoteEvent.NavigateBack -> onNavigateBack() - NoteEvent.NavigateAddNote -> onNavigateAddEditNote(state.resourceId, state.resourceType, null) - NoteEvent.NavigateEditNote -> onNavigateAddEditNote(state.resourceId, state.resourceType, state.expandedNoteId) + NoteEvent.NavigateAddNote -> onNavigateAddEditNote( + state.resourceId, + state.resourceType, + null, + ) + + NoteEvent.NavigateEditNote -> onNavigateAddEditNote( + state.resourceId, + state.resourceType, + state.expandedNoteId, + ) } } - if (!state.isError) { - NoteScreenScaffold( - state = state, - onAction = remember(viewModel) { { viewModel.trySendAction(it) } }, - ) - } + + NoteScreenScaffold( + state = state, + onAction = remember(viewModel) { { viewModel.trySendAction(it) } }, + ) NoteScreenDialog( state = state, @@ -152,10 +160,12 @@ internal fun NoteScreenScaffold( isRefreshing = state.isRefreshing, onRefresh = { onAction(NoteAction.OnRefresh) }, ) { - NoteContent( - state = state, - onAction = onAction, - ) + if (state.dialogState != NoteState.DialogState.Loading && !state.isError) { + NoteContent( + state = state, + onAction = onAction, + ) + } } } } @@ -271,7 +281,9 @@ private fun NoteItem( width = 1.dp, color = MaterialTheme.colorScheme.secondaryContainer, shape = shape, - ), + ).clickable { + id?.let { onAction(NoteAction.OnToggleExpanded(id)) } + }, shape = shape, elevation = DesignToken.spacing.none, ) { @@ -292,9 +304,7 @@ private fun NoteItem( Icon( imageVector = MifosIcons.MoreHoriz, contentDescription = null, - modifier = Modifier.clickable { - id?.let { onAction(NoteAction.OnToggleExpanded(id)) } - }.size(DesignToken.sizes.iconAverage), + modifier = Modifier.size(DesignToken.sizes.iconAverage), ) } @@ -368,9 +378,10 @@ private fun ContextualActions( verticalArrangement = Arrangement.spacedBy(DesignToken.spacing.medium), ) { Row( - modifier = Modifier.clickable { - onAction(NoteAction.OnClickEditScreen) - }, + modifier = Modifier.fillMaxWidth() + .clickable { + onAction(NoteAction.OnClickEditScreen) + }, horizontalArrangement = Arrangement.spacedBy( DesignToken.spacing.medium, ), @@ -389,9 +400,10 @@ private fun ContextualActions( } Row( - modifier = Modifier.clickable { - onAction(NoteAction.ShowDialog) - }, + modifier = Modifier.fillMaxWidth() + .clickable { + onAction(NoteAction.ShowDialog) + }, horizontalArrangement = Arrangement.spacedBy( DesignToken.spacing.medium, ), From 95d18e7b16b4b1a3a960630db02cda86d70ee02c Mon Sep 17 00:00:00 2001 From: Arin Yadav Date: Tue, 2 Sep 2025 10:14:42 +0530 Subject: [PATCH 4/7] update --- .../feature/note/addEditNotes/AddEditNoteScreen.kt | 11 +---------- .../note/addEditNotes/AddEditNoteViewModel.kt | 12 +++++++----- .../com/mifos/feature/note/notes/NoteScreen.kt | 1 - 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt index 07ae2650125..28b91a0a56c 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt @@ -29,7 +29,6 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextFieldDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -45,7 +44,6 @@ import com.mifos.core.designsystem.theme.MifosTypography import com.mifos.core.ui.components.MifosAlertDialog import com.mifos.core.ui.components.MifosErrorComponent import com.mifos.core.ui.util.EventsEffect -import kotlinx.coroutines.delay import org.jetbrains.compose.resources.stringResource import org.koin.compose.viewmodel.koinViewModel @@ -114,12 +112,7 @@ fun AddEditNoteScreenDialog( ) } - AddEditNoteState.DialogState.Success -> { - onAction(AddEditNoteAction.NavigateBackWithUpdateList) - } - null -> Unit - } } @@ -138,14 +131,12 @@ internal fun AddEditNoteScreenScaffold( .fillMaxSize() .padding(paddingValues), ) { - - if(state.dialogState !is AddEditNoteState.DialogState.Loading){ + if (state.dialogState !is AddEditNoteState.DialogState.Loading) { AddEditNote( state = state, onAction = onAction, ) } - } } } diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt index 8fc7b6038ed..5ee5fe90686 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt @@ -138,11 +138,12 @@ class AddEditNoteViewModel( is DataState.Success -> { mutableStateFlow.update { it.copy( - dialogState = AddEditNoteState.DialogState.Success, + dialogState = null, successMessage = Res.string.feature_note_add_success, notesPayloadInitialData = state.textFieldNotesPayload.note, ) } + sendEvent(AddEditNoteEvent.NavigateBackWithUpdateList) } } } @@ -162,19 +163,23 @@ class AddEditNoteViewModel( ) } } + DataState.Loading -> { mutableStateFlow.update { it.copy(dialogState = AddEditNoteState.DialogState.Loading) } } + is DataState.Success -> { mutableStateFlow.update { it.copy( - dialogState = AddEditNoteState.DialogState.Success, + dialogState = null, successMessage = Res.string.feature_note_edit_success, notesPayloadInitialData = state.textFieldNotesPayload.note, ) } + + sendEvent(AddEditNoteEvent.NavigateBackWithUpdateList) } } } @@ -246,8 +251,6 @@ class AddEditNoteViewModel( sendEvent(AddEditNoteEvent.NavigateBack) } } - - } } } @@ -270,7 +273,6 @@ data class AddEditNoteState( data class Error(val message: StringResource) : DialogState data object Loading : DialogState data object MisTouchBack : DialogState - data object Success : DialogState } } diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt index b8434cfbb60..43976f40245 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt @@ -98,7 +98,6 @@ internal fun NoteScreenScaffold( } } - NoteScreenScaffold( state = state, onAction = remember(viewModel) { { viewModel.trySendAction(it) } }, From 391bb6ed0322d29ccd5b8f51a83408ba470da3d5 Mon Sep 17 00:00:00 2001 From: Arin Yadav Date: Tue, 2 Sep 2025 20:57:00 +0530 Subject: [PATCH 5/7] update --- .../composeResources/values/strings.xml | 17 ++ .../MifosActionsListingCardComponent.kt | 160 +++++++++- .../ui/components/MifosListingComponent.kt | 42 +++ .../composeResources/values/res.xml | 5 - .../note/addEditNotes/AddEditNoteScreen.kt | 4 +- .../note/addEditNotes/AddEditNoteViewModel.kt | 8 - .../com/mifos/feature/note/notes/NoteRoute.kt | 2 +- .../mifos/feature/note/notes/NoteScreen.kt | 287 ++++-------------- .../mifos/feature/note/notes/NoteViewModel.kt | 34 +-- 9 files changed, 275 insertions(+), 284 deletions(-) diff --git a/core/ui/src/commonMain/composeResources/values/strings.xml b/core/ui/src/commonMain/composeResources/values/strings.xml index 786297c617b..600574b0052 100644 --- a/core/ui/src/commonMain/composeResources/values/strings.xml +++ b/core/ui/src/commonMain/composeResources/values/strings.xml @@ -73,4 +73,21 @@ Click Here To View Filled State. No Item Found + + View Account + Edit Note + Delete Note + Approve Account + Make Repayment + View Document + Upload Again + Delete Document + + + Created By: + Date + Note + + + \ No newline at end of file diff --git a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosActionsListingCardComponent.kt b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosActionsListingCardComponent.kt index 2ee2e1ab3aa..db6b1842bb2 100644 --- a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosActionsListingCardComponent.kt +++ b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosActionsListingCardComponent.kt @@ -12,17 +12,25 @@ package com.mifos.core.ui.components import androidclient.core.ui.generated.resources.Res import androidclient.core.ui.generated.resources.core_ui_account_no import androidclient.core.ui.generated.resources.core_ui_amount_paid +import androidclient.core.ui.generated.resources.core_ui_approve_account import androidclient.core.ui.generated.resources.core_ui_balance +import androidclient.core.ui.generated.resources.core_ui_delete_document +import androidclient.core.ui.generated.resources.core_ui_delete_note import androidclient.core.ui.generated.resources.core_ui_description import androidclient.core.ui.generated.resources.core_ui_document_id import androidclient.core.ui.generated.resources.core_ui_document_key import androidclient.core.ui.generated.resources.core_ui_due import androidclient.core.ui.generated.resources.core_ui_due_as_of +import androidclient.core.ui.generated.resources.core_ui_edit_note import androidclient.core.ui.generated.resources.core_ui_identify_documents import androidclient.core.ui.generated.resources.core_ui_last_active import androidclient.core.ui.generated.resources.core_ui_loan_balance import androidclient.core.ui.generated.resources.core_ui_loan_product +import androidclient.core.ui.generated.resources.core_ui_make_repayment import androidclient.core.ui.generated.resources.core_ui_name +import androidclient.core.ui.generated.resources.core_ui_note_createdBy +import androidclient.core.ui.generated.resources.core_ui_note_date +import androidclient.core.ui.generated.resources.core_ui_note_note import androidclient.core.ui.generated.resources.core_ui_original_loan import androidclient.core.ui.generated.resources.core_ui_outstanding import androidclient.core.ui.generated.resources.core_ui_paid @@ -31,6 +39,9 @@ import androidclient.core.ui.generated.resources.core_ui_status import androidclient.core.ui.generated.resources.core_ui_total_collateral_value import androidclient.core.ui.generated.resources.core_ui_total_value import androidclient.core.ui.generated.resources.core_ui_type +import androidclient.core.ui.generated.resources.core_ui_upload_again +import androidclient.core.ui.generated.resources.core_ui_view_account +import androidclient.core.ui.generated.resources.core_ui_view_document import androidclient.core.ui.generated.resources.core_ui_waived import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.expandVertically @@ -49,6 +60,7 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -61,6 +73,7 @@ import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.platform.LocalDensity @@ -70,22 +83,31 @@ import com.mifos.core.designsystem.theme.AppColors import com.mifos.core.designsystem.theme.DesignToken import com.mifos.core.designsystem.theme.MifosTypography import com.mifos.core.designsystem.utils.onClick +import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview @Composable fun MifosActionsListingComponentOutline( + bottomRounded: Boolean = false, + topRounded: Boolean = false, modifier: Modifier = Modifier, content: @Composable () -> Unit, ) { + val shape = if (bottomRounded) { + DesignToken.shapes.bottomMedium + } else if (topRounded) { + DesignToken.shapes.topMedium + } else { + DesignToken.shapes.medium + } + Box( - modifier = modifier - .fillMaxWidth() - .border( - width = 1.dp, - shape = DesignToken.shapes.medium, - color = MaterialTheme.colorScheme.secondaryContainer, - ), + modifier = modifier.fillMaxWidth().border( + width = 1.dp, + shape = shape, + color = MaterialTheme.colorScheme.secondaryContainer, + ), ) { content() } @@ -579,13 +601,123 @@ fun MifosActionsClientFeeListingComponent( } } -enum class Actions(val icon: ImageVector) { - ViewAccount(MifosIcons.ViewAccount), - ApproveAccount(MifosIcons.ApproveAccount), - MakeRepayment(MifosIcons.MakeRepayment), - ViewDocument(MifosIcons.ViewDocument), - UploadAgain(MifosIcons.UploadAgain), - DeleteDocument(MifosIcons.DeleteDocument), +@Composable +fun MifosActionsNoteListingComponent( + createdBy: String, + date: String, + notes: String, + menuList: List, + onExpand: () -> Unit, + isExpanded: Boolean, + onActionClicked: (Actions) -> Unit, +) { + Column { + MifosActionsListingComponentOutline( + topRounded = isExpanded, + modifier = Modifier + .clip(if (isExpanded) DesignToken.shapes.topMedium else DesignToken.shapes.medium) + .clickable { + onExpand() + }, + ) { + Column( + modifier = Modifier.padding(DesignToken.padding.large), + ) { + MifosListingRowItemHeader( + text = stringResource(Res.string.core_ui_note_createdBy) + " " + createdBy, + keyStyle = MifosTypography.titleSmallEmphasized, + ) + + Spacer(Modifier.height(DesignToken.padding.large)) + + MifosListingColumnItem( + key = stringResource(Res.string.core_ui_note_date), + value = date, + ) + + Spacer(Modifier.height(DesignToken.padding.medium)) + + MifosListingColumnItem( + key = stringResource(Res.string.core_ui_note_note), + value = notes, + ) + } + } + + AnimatedVisibility(isExpanded) { + Surface( + modifier = Modifier.fillMaxWidth(), + shape = DesignToken.shapes.bottomMedium, + color = MaterialTheme.colorScheme.surfaceContainer, + ) { + Column( + modifier = Modifier.padding(vertical = DesignToken.spacing.large), + verticalArrangement = Arrangement.spacedBy(DesignToken.spacing.medium), + ) { + menuList.map { menuItem -> + Row( + modifier = Modifier.fillMaxWidth().padding( + horizontal = DesignToken.padding.large, + ).clickable { + onActionClicked(menuItem) + }, + horizontalArrangement = Arrangement.spacedBy( + DesignToken.spacing.medium, + ), + verticalAlignment = Alignment.CenterVertically, + ) { + Icon( + imageVector = menuItem.icon, + contentDescription = null, + modifier = Modifier.size(DesignToken.sizes.iconMedium), + ) + Text( + text = stringResource(menuItem.iconName), + style = MaterialTheme.typography.bodyLarge, + color = MaterialTheme.colorScheme.onSurface, + ) + } + } + } + } + } + } +} + +enum class Actions(val icon: ImageVector, val iconName: StringResource) { + ViewAccount(MifosIcons.ViewAccount, Res.string.core_ui_view_account), + ApproveAccount(MifosIcons.ApproveAccount, Res.string.core_ui_approve_account), + MakeRepayment(MifosIcons.MakeRepayment, Res.string.core_ui_make_repayment), + ViewDocument(MifosIcons.ViewDocument, Res.string.core_ui_view_document), + UploadAgain(MifosIcons.UploadAgain, Res.string.core_ui_upload_again), + DeleteDocument(MifosIcons.DeleteDocument, Res.string.core_ui_delete_document), + Edit(MifosIcons.Edit, Res.string.core_ui_edit_note), + Delete(MifosIcons.Delete, Res.string.core_ui_delete_note), +} + +@Preview +@Composable +private fun PreviewMifosActionsNoteListingComponent() { + MaterialTheme { + MifosActionsNoteListingComponent( + createdBy = "John Doe", + date = "02 September 2025", + notes = "This is a note", + menuList = listOf( + Actions.Edit, + Actions.Delete, + ), + onExpand = {}, + isExpanded = true, + onActionClicked = { action -> + when (action) { + Actions.Edit -> println(Actions.ViewAccount.name) + Actions.Delete -> println(Actions.ApproveAccount.name) + else -> println("Action not Handled") + } + }, + ) + } } @Preview diff --git a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosListingComponent.kt b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosListingComponent.kt index 377fca3ee39..9e956ff497b 100644 --- a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosListingComponent.kt +++ b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosListingComponent.kt @@ -108,6 +108,48 @@ fun MifosListingRowItem( } } +@Composable +fun MifosListingColumnItem( + keyContent: @Composable () -> Unit, + valueContent: @Composable () -> Unit, +) { + Column( + modifier = Modifier.fillMaxWidth(), + ) { + keyContent() + valueContent() + } +} + +@Composable +fun MifosListingColumnItem( + key: String, + value: String, + keyStyle: TextStyle = MifosTypography.labelSmall, + keyColor: Color = MaterialTheme.colorScheme.secondary, + valueStyle: TextStyle = MifosTypography.bodySmall, + valueColor: Color = MaterialTheme.colorScheme.onSurface, +) { + MifosListingColumnItem( + keyContent = { + Text( + text = key, + style = keyStyle.copy(color = keyColor), + maxLines = 1, + overflow = TextOverflow.Clip, + ) + }, + valueContent = { + Text( + text = value, + style = valueStyle.copy(color = valueColor), + overflow = TextOverflow.Clip, + maxLines = 1, + ) + }, + ) +} + @Composable fun MifosListingRowItem( key: String, diff --git a/feature/note/src/commonMain/composeResources/values/res.xml b/feature/note/src/commonMain/composeResources/values/res.xml index 1d3c9cd5ffb..c02b4a4126c 100644 --- a/feature/note/src/commonMain/composeResources/values/res.xml +++ b/feature/note/src/commonMain/composeResources/values/res.xml @@ -14,9 +14,6 @@ Click on "+" Button to add an Item Failed to fetch notes No Internet - Created By: - Date - Note Edit Note Delete Note Delete @@ -31,8 +28,6 @@ Add Update Back - Note Updated Successfully - Note Added Successfully Confirm Warning Discard changes? Unsaved data will be lost. diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt index 28b91a0a56c..1b165c5cfe7 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt @@ -131,7 +131,9 @@ internal fun AddEditNoteScreenScaffold( .fillMaxSize() .padding(paddingValues), ) { - if (state.dialogState !is AddEditNoteState.DialogState.Loading) { + if (state.dialogState !is AddEditNoteState.DialogState.Loading && + state.dialogState !is AddEditNoteState.DialogState.Error + ) { AddEditNote( state = state, onAction = onAction, diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt index 5ee5fe90686..96563f9471d 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteViewModel.kt @@ -12,11 +12,9 @@ package com.mifos.feature.note.addEditNotes import androidclient.feature.note.generated.resources.Res import androidclient.feature.note.generated.resources.feature_note_Unexpected_error import androidclient.feature.note.generated.resources.feature_note_add_note -import androidclient.feature.note.generated.resources.feature_note_add_success import androidclient.feature.note.generated.resources.feature_note_button_add import androidclient.feature.note.generated.resources.feature_note_button_update import androidclient.feature.note.generated.resources.feature_note_edit_note_label -import androidclient.feature.note.generated.resources.feature_note_edit_success import androidclient.feature.note.generated.resources.feature_note_update_note import androidclient.feature.note.generated.resources.feature_note_write_note_label import androidx.lifecycle.SavedStateHandle @@ -139,7 +137,6 @@ class AddEditNoteViewModel( mutableStateFlow.update { it.copy( dialogState = null, - successMessage = Res.string.feature_note_add_success, notesPayloadInitialData = state.textFieldNotesPayload.note, ) } @@ -174,7 +171,6 @@ class AddEditNoteViewModel( mutableStateFlow.update { it.copy( dialogState = null, - successMessage = Res.string.feature_note_edit_success, notesPayloadInitialData = state.textFieldNotesPayload.note, ) } @@ -234,7 +230,6 @@ class AddEditNoteViewModel( mutableStateFlow.update { it.copy( dialogState = null, - showDialog = false, ) } } @@ -244,7 +239,6 @@ class AddEditNoteViewModel( mutableStateFlow.update { it.copy( dialogState = AddEditNoteState.DialogState.MisTouchBack, - showDialog = true, ) } } else { @@ -259,13 +253,11 @@ data class AddEditNoteState( val resourceId: Int = -1, val resourceType: String? = null, val editEnabled: Boolean = false, - val successMessage: StringResource? = null, val addUpdateButton: StringResource = Res.string.feature_note_button_add, val label: StringResource = Res.string.feature_note_write_note_label, val title: StringResource = Res.string.feature_note_add_note, val textFieldNotesPayload: NotesPayload = NotesPayload(null), val notesPayloadInitialData: String? = null, - val showDialog: Boolean = false, val dialogState: DialogState? = null, val networkConnection: Boolean = false, ) { diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteRoute.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteRoute.kt index c88ccedfad9..a16647c81dd 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteRoute.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteRoute.kt @@ -25,7 +25,7 @@ fun NavGraphBuilder.noteRoute( onNavigateAddEditNote: (Int, String?, Long?) -> Unit, ) { composable { - NoteScreenScaffold( + NoteScreen( onNavigateBack = onNavigateBack, onNavigateAddEditNote = onNavigateAddEditNote, ) diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt index 43976f40245..d103e3a4c27 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt @@ -11,23 +11,15 @@ package com.mifos.feature.note.notes import androidclient.feature.note.generated.resources.Res import androidclient.feature.note.generated.resources.feature_note_add_item -import androidclient.feature.note.generated.resources.feature_note_createdBy -import androidclient.feature.note.generated.resources.feature_note_date import androidclient.feature.note.generated.resources.feature_note_delete import androidclient.feature.note.generated.resources.feature_note_delete_note import androidclient.feature.note.generated.resources.feature_note_delete_note_confirmation -import androidclient.feature.note.generated.resources.feature_note_edit_note import androidclient.feature.note.generated.resources.feature_note_item -import androidclient.feature.note.generated.resources.feature_note_no_item_found -import androidclient.feature.note.generated.resources.feature_note_note import androidclient.feature.note.generated.resources.feature_note_notes -import androidx.compose.animation.AnimatedVisibility -import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -37,8 +29,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.CardDefaults import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -48,22 +38,22 @@ import androidx.compose.material3.pulltorefresh.PullToRefreshBox import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.mifos.core.common.utils.DateHelper -import com.mifos.core.designsystem.component.MifosCard import com.mifos.core.designsystem.component.MifosCircularProgress import com.mifos.core.designsystem.component.MifosScaffold import com.mifos.core.designsystem.icon.MifosIcons import com.mifos.core.designsystem.theme.DesignToken import com.mifos.core.designsystem.theme.MifosTypography import com.mifos.core.model.objects.notes.Note +import com.mifos.core.ui.components.Actions +import com.mifos.core.ui.components.MifosActionsNoteListingComponent import com.mifos.core.ui.components.MifosAlertDialog +import com.mifos.core.ui.components.MifosEmptyCard import com.mifos.core.ui.components.MifosErrorComponent import com.mifos.core.ui.util.DevicePreview import com.mifos.core.ui.util.EventsEffect @@ -74,7 +64,7 @@ import org.jetbrains.compose.resources.stringResource import org.koin.compose.viewmodel.koinViewModel @Composable -internal fun NoteScreenScaffold( +internal fun NoteScreen( onNavigateBack: () -> Unit, onNavigateAddEditNote: (Int, String?, Long?) -> Unit, viewModel: NoteViewModel = koinViewModel(), @@ -128,6 +118,19 @@ private fun NoteScreenDialog( MifosCircularProgress() } + NoteState.DialogState.ShowDialog -> { + MifosAlertDialog( + onDismissRequest = { + onAction(NoteAction.DismissDialog) + }, + onConfirmation = { + onAction(NoteAction.DeleteNote) + }, + confirmationText = stringResource(Res.string.feature_note_delete), + dialogTitle = stringResource(Res.string.feature_note_delete_note), + dialogText = stringResource(Res.string.feature_note_delete_note_confirmation), + ) + } null -> Unit } } @@ -159,7 +162,9 @@ internal fun NoteScreenScaffold( isRefreshing = state.isRefreshing, onRefresh = { onAction(NoteAction.OnRefresh) }, ) { - if (state.dialogState != NoteState.DialogState.Loading && !state.isError) { + if (state.dialogState !is NoteState.DialogState.Loading && + state.dialogState !is NoteState.DialogState.Error + ) { NoteContent( state = state, onAction = onAction, @@ -207,237 +212,49 @@ private fun NoteContent( ) } - LazyColumn( - modifier = modifier, - verticalArrangement = Arrangement.spacedBy(DesignToken.spacing.small), - horizontalAlignment = Alignment.CenterHorizontally, - contentPadding = PaddingValues(vertical = DesignToken.spacing.largeIncreased), - ) { - if (state.notes.isEmpty()) { - item { - MifosCard( - modifier = Modifier.fillMaxWidth().border( - width = 1.dp, - color = MaterialTheme.colorScheme.secondaryContainer, - shape = DesignToken.shapes.medium, - ), - elevation = DesignToken.spacing.none, - shape = DesignToken.shapes.medium, - ) { - Column( - modifier = Modifier.padding(DesignToken.spacing.large), - verticalArrangement = Arrangement.spacedBy(DesignToken.spacing.medium), - ) { - Text( - text = stringResource(Res.string.feature_note_no_item_found), - style = MifosTypography.titleSmallEmphasized, - color = MaterialTheme.colorScheme.onSurface, - ) - Text( - text = stringResource(Res.string.feature_note_add_item), - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onSurface, - ) - } - } - } - } else { - items(state.notes.reversed()) { note -> - NoteItem( - id = note.id, - note = note.note, - createdByUsername = note.createdByUsername, - createdOn = note.createdOn, - onAction = onAction, - state = state, - ) - } - } - } - } -} + Spacer(modifier = Modifier.height(DesignToken.spacing.large)) -@Composable -private fun NoteItem( - id: Long?, - note: String?, - onAction: (NoteAction) -> Unit, - createdByUsername: String?, - createdOn: String?, - state: NoteState, -) { - var shape by remember { mutableStateOf(RoundedCornerShape(0.dp)) } - - shape = if (state.expandedNoteId == id) { - DesignToken.shapes.topMedium as RoundedCornerShape - } else { - DesignToken.shapes.medium as RoundedCornerShape - } - - Column { - MifosCard( - modifier = Modifier.fillMaxWidth().border( - width = 1.dp, - color = MaterialTheme.colorScheme.secondaryContainer, - shape = shape, - ).clickable { - id?.let { onAction(NoteAction.OnToggleExpanded(id)) } - }, - shape = shape, - elevation = DesignToken.spacing.none, - ) { - Column( - modifier = Modifier.padding(DesignToken.spacing.large), + if (state.notes.isEmpty()) { + MifosEmptyCard( + msg = stringResource(Res.string.feature_note_add_item), + ) + } else { + LazyColumn( + verticalArrangement = Arrangement.spacedBy(DesignToken.spacing.small), ) { - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - ) { - Text( - text = stringResource(Res.string.feature_note_createdBy) + " " + createdByUsername, - style = MifosTypography.titleSmallEmphasized, - color = MaterialTheme.colorScheme.onSurface, - ) - - Icon( - imageVector = MifosIcons.MoreHoriz, - contentDescription = null, - modifier = Modifier.size(DesignToken.sizes.iconAverage), - ) - } - - Spacer( - modifier = Modifier.height(DesignToken.spacing.large), - ) - - Column { - Text( - text = stringResource(Res.string.feature_note_date), - style = MifosTypography.labelSmall, - color = MaterialTheme.colorScheme.secondary, - ) + items(state.notes.reversed()) { note -> - Text( - text = DateHelper.formatIsoDateToDdMmYyyy(createdOn ?: "Not found"), - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onSurface, - ) - } + MifosActionsNoteListingComponent( + notes = note.note ?: "Empty", + createdBy = note.createdByUsername ?: "Empty", + date = DateHelper.formatIsoDateToDdMmYyyy(note.createdOn ?: "Not found"), + isExpanded = state.expandedNoteId == note.id, + onExpand = { + onAction(NoteAction.OnToggleExpanded(note.id)) + }, + menuList = listOf( + Actions.Edit, + Actions.Delete, + ), + onActionClicked = { actions -> + when (actions) { + Actions.Edit -> { + onAction(NoteAction.OnClickEditScreen) + } - Spacer( - modifier = Modifier.height(DesignToken.spacing.medium), - ) + Actions.Delete -> { + onAction(NoteAction.ShowDialog) + } - Column { - Text( - text = stringResource(Res.string.feature_note_note), - style = MifosTypography.labelSmall, - color = MaterialTheme.colorScheme.secondary, + else -> null + } + }, ) - - if (note != null) { - Text( - text = note, - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onSurface, - ) - } } } } - AnimatedVisibility( - visible = state.expandedNoteId == id, - ) { - ContextualActions( - id = id, - onAction = onAction, - state = state, - ) - } } } - -@Composable -private fun ContextualActions( - state: NoteState, - id: Long?, - onAction: (NoteAction) -> Unit, -) { - MifosCard( - modifier = Modifier.fillMaxWidth(), - shape = DesignToken.shapes.bottomMedium, - colors = CardDefaults.cardColors( - MaterialTheme.colorScheme.surfaceContainer, - ), - elevation = DesignToken.spacing.none, - ) { - Column( - modifier = Modifier.padding(DesignToken.spacing.large), - verticalArrangement = Arrangement.spacedBy(DesignToken.spacing.medium), - ) { - Row( - modifier = Modifier.fillMaxWidth() - .clickable { - onAction(NoteAction.OnClickEditScreen) - }, - horizontalArrangement = Arrangement.spacedBy( - DesignToken.spacing.medium, - ), - verticalAlignment = Alignment.CenterVertically, - ) { - Icon( - imageVector = MifosIcons.Edit, - contentDescription = null, - modifier = Modifier.size(DesignToken.sizes.iconMedium), - ) - Text( - text = stringResource(Res.string.feature_note_edit_note), - style = MaterialTheme.typography.bodyLarge, - color = MaterialTheme.colorScheme.onSurface, - ) - } - - Row( - modifier = Modifier.fillMaxWidth() - .clickable { - onAction(NoteAction.ShowDialog) - }, - horizontalArrangement = Arrangement.spacedBy( - DesignToken.spacing.medium, - ), - verticalAlignment = Alignment.CenterVertically, - ) { - Icon( - imageVector = MifosIcons.Delete, - contentDescription = null, - modifier = Modifier.size(DesignToken.sizes.iconMedium), - ) - - Text( - text = stringResource(Res.string.feature_note_delete_note), - style = MaterialTheme.typography.bodyLarge, - color = MaterialTheme.colorScheme.onSurface, - ) - } - } - } - - if (state.showDialog) { - MifosAlertDialog( - onDismissRequest = { - onAction(NoteAction.DismissDialog) - }, - onConfirmation = { - onAction(NoteAction.DeleteNote(id)) - }, - confirmationText = stringResource(Res.string.feature_note_delete), - dialogTitle = stringResource(Res.string.feature_note_delete_note), - dialogText = stringResource(Res.string.feature_note_delete_note_confirmation), - ) - } -} - internal val demoNotes = listOf( Note( id = 1, diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteViewModel.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteViewModel.kt index 363e7907397..5ede765333d 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteViewModel.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteViewModel.kt @@ -65,7 +65,6 @@ class NoteViewModel( is DataState.Error -> mutableStateFlow.update { it.copy( dialogState = NoteState.DialogState.Error(dataState.message), - isError = true, isRefreshing = false, ) } @@ -86,7 +85,6 @@ class NoteViewModel( it.copy( dialogState = null, notes = dataState.data, - isError = false, expandedNoteId = null, isRefreshing = false, ) @@ -106,7 +104,6 @@ class NoteViewModel( mutableStateFlow.update { it.copy( dialogState = NoteState.DialogState.Error(dataState.message), - isError = true, ) } } @@ -149,14 +146,8 @@ class NoteViewModel( NoteAction.OnClickEditScreen -> sendEvent(NoteEvent.NavigateEditNote) NoteAction.OnClickAddScreen -> sendEvent(NoteEvent.NavigateAddNote) is NoteAction.DeleteNote -> { - mutableStateFlow.update { - it.copy( - showDialog = false, - isError = false, - ) - } viewModelScope.launch { - deleteNote(action.id) + deleteNote(state.expandedNoteId) } } @@ -167,15 +158,11 @@ class NoteViewModel( getNoteOptionsAndObserveNetwork() } - NoteAction.ShowDialog -> { - mutableStateFlow.update { - it.copy(showDialog = true) - } - } - NoteAction.DismissDialog -> { mutableStateFlow.update { - it.copy(showDialog = false) + it.copy( + dialogState = null, + ) } } @@ -186,6 +173,14 @@ class NoteViewModel( ) } } + + is NoteAction.ShowDialog -> { + mutableStateFlow.update { + it.copy( + dialogState = NoteState.DialogState.ShowDialog, + ) + } + } } } } @@ -195,15 +190,14 @@ data class NoteState( val resourceType: String? = null, val isRefreshing: Boolean = false, val notes: List = emptyList(), - val showDialog: Boolean = false, val dialogState: DialogState? = null, val expandedNoteId: Long? = null, - val isError: Boolean = false, val networkConnection: Boolean = false, ) { sealed interface DialogState { data class Error(val message: String) : DialogState data object Loading : DialogState + data object ShowDialog : DialogState } } @@ -222,5 +216,5 @@ sealed interface NoteAction { data object ShowDialog : NoteAction data object DismissDialog : NoteAction data class OnToggleExpanded(val id: Long?) : NoteAction - data class DeleteNote(val id: Long?) : NoteAction + data object DeleteNote : NoteAction } From 571ae515f52d336edb225eea39b252d0213ba080 Mon Sep 17 00:00:00 2001 From: Arin Yadav Date: Wed, 3 Sep 2025 10:19:17 +0530 Subject: [PATCH 6/7] update --- .../feature/note/addEditNotes/AddEditNoteRoute.kt | 2 ++ .../feature/note/addEditNotes/AddEditNoteScreen.kt | 9 ++++++++- .../mifos/feature/note/navigation/NoteNavigation.kt | 2 ++ .../kotlin/com/mifos/feature/note/notes/NoteRoute.kt | 2 ++ .../com/mifos/feature/note/notes/NoteScreen.kt | 12 ++++++++++-- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteRoute.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteRoute.kt index 88f7de6ae55..31d64a052e4 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteRoute.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteRoute.kt @@ -24,11 +24,13 @@ data class AddEditNoteRoute( fun NavGraphBuilder.addEditNoteRoute( onBackPressed: () -> Unit, onNavigateWithUpdatedList: (Int, String?) -> Unit, + navController: NavController, ) { composable { AddEditNoteScreen( onBackPressed = onBackPressed, onNavigateWithUpdatedList = onNavigateWithUpdatedList, + navController = navController ) } } diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt index 1b165c5cfe7..456102b7e28 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt @@ -35,6 +35,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.navigation.NavController import com.mifos.core.designsystem.component.MifosCircularProgress import com.mifos.core.designsystem.component.MifosOutlinedButton import com.mifos.core.designsystem.component.MifosOutlinedTextField @@ -42,6 +43,7 @@ import com.mifos.core.designsystem.component.MifosScaffold import com.mifos.core.designsystem.theme.DesignToken import com.mifos.core.designsystem.theme.MifosTypography import com.mifos.core.ui.components.MifosAlertDialog +import com.mifos.core.ui.components.MifosBreadcrumbNavBar import com.mifos.core.ui.components.MifosErrorComponent import com.mifos.core.ui.util.EventsEffect import org.jetbrains.compose.resources.stringResource @@ -51,6 +53,7 @@ import org.koin.compose.viewmodel.koinViewModel internal fun AddEditNoteScreen( onBackPressed: () -> Unit, onNavigateWithUpdatedList: (Int, String?) -> Unit, + navController: NavController, viewModel: AddEditNoteViewModel = koinViewModel(), ) { val state by viewModel.stateFlow.collectAsStateWithLifecycle() @@ -68,6 +71,7 @@ internal fun AddEditNoteScreen( AddEditNoteScreenScaffold( state = state, onAction = remember(viewModel) { { viewModel.trySendAction(it) } }, + navController = navController, ) AddEditNoteScreenDialog( @@ -120,13 +124,14 @@ fun AddEditNoteScreenDialog( internal fun AddEditNoteScreenScaffold( onAction: (AddEditNoteAction) -> Unit, state: AddEditNoteState, + navController: NavController, ) { MifosScaffold( title = "", onBackPressed = { onAction(AddEditNoteAction.MisTouchBackDialog) }, ) { paddingValues -> - Box( + Column( modifier = Modifier .fillMaxSize() .padding(paddingValues), @@ -134,6 +139,8 @@ internal fun AddEditNoteScreenScaffold( if (state.dialogState !is AddEditNoteState.DialogState.Loading && state.dialogState !is AddEditNoteState.DialogState.Error ) { + MifosBreadcrumbNavBar(navController) + AddEditNote( state = state, onAction = onAction, diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/navigation/NoteNavigation.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/navigation/NoteNavigation.kt index 5697ac5a0ef..bb2b43b0603 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/navigation/NoteNavigation.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/navigation/NoteNavigation.kt @@ -32,6 +32,7 @@ fun NavGraphBuilder.noteNavGraph( noteRoute( onNavigateBack = onBackPressed, onNavigateAddEditNote = navController::navigateToAddEditNoteScreen, + navController = navController ) addEditNoteRoute( @@ -39,6 +40,7 @@ fun NavGraphBuilder.noteNavGraph( navController.popBackStack() }, onNavigateWithUpdatedList = navController::navigateToNoteScreenWithUpdatedList, + navController = navController ) } } diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteRoute.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteRoute.kt index a16647c81dd..7aab24f518d 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteRoute.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteRoute.kt @@ -23,11 +23,13 @@ data class NoteRoute( fun NavGraphBuilder.noteRoute( onNavigateBack: () -> Unit, onNavigateAddEditNote: (Int, String?, Long?) -> Unit, + navController: NavController, ) { composable { NoteScreen( onNavigateBack = onNavigateBack, onNavigateAddEditNote = onNavigateAddEditNote, + navController = navController ) } } diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt index d103e3a4c27..2210d399b5d 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt @@ -43,6 +43,8 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.navigation.NavController +import androidx.navigation.compose.rememberNavController import com.mifos.core.common.utils.DateHelper import com.mifos.core.designsystem.component.MifosCircularProgress import com.mifos.core.designsystem.component.MifosScaffold @@ -53,6 +55,7 @@ import com.mifos.core.model.objects.notes.Note import com.mifos.core.ui.components.Actions import com.mifos.core.ui.components.MifosActionsNoteListingComponent import com.mifos.core.ui.components.MifosAlertDialog +import com.mifos.core.ui.components.MifosBreadcrumbNavBar import com.mifos.core.ui.components.MifosEmptyCard import com.mifos.core.ui.components.MifosErrorComponent import com.mifos.core.ui.util.DevicePreview @@ -67,6 +70,7 @@ import org.koin.compose.viewmodel.koinViewModel internal fun NoteScreen( onNavigateBack: () -> Unit, onNavigateAddEditNote: (Int, String?, Long?) -> Unit, + navController: NavController, viewModel: NoteViewModel = koinViewModel(), ) { val state by viewModel.stateFlow.collectAsStateWithLifecycle() @@ -91,6 +95,7 @@ internal fun NoteScreen( NoteScreenScaffold( state = state, onAction = remember(viewModel) { { viewModel.trySendAction(it) } }, + navController = navController, ) NoteScreenDialog( @@ -138,9 +143,10 @@ private fun NoteScreenDialog( @OptIn(ExperimentalMaterial3Api::class) @Composable internal fun NoteScreenScaffold( - onAction: (NoteAction) -> Unit, state: NoteState, + navController: NavController, modifier: Modifier = Modifier, + onAction: (NoteAction) -> Unit, ) { val snackBarHostState = remember { SnackbarHostState() } val pullRefreshState = rememberPullToRefreshState() @@ -153,9 +159,10 @@ internal fun NoteScreenScaffold( snackbarHostState = snackBarHostState, modifier = modifier, ) { paddingValues -> - Box( + Column( modifier = Modifier.fillMaxSize().padding(paddingValues), ) { + MifosBreadcrumbNavBar(navController) PullToRefreshBox( state = pullRefreshState, modifier = Modifier.fillMaxSize(), @@ -297,5 +304,6 @@ fun PreviewSuccessNoteScreen() { NoteScreenScaffold( onAction = {}, state = NoteState(notes = demoNotes), + navController = rememberNavController() ) } From cc53b3b2f1fa5bdec587f404851114047f0389a2 Mon Sep 17 00:00:00 2001 From: Arin Yadav Date: Wed, 3 Sep 2025 11:22:18 +0530 Subject: [PATCH 7/7] update --- .../com/mifos/feature/note/addEditNotes/AddEditNoteRoute.kt | 2 +- .../com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt | 1 - .../com/mifos/feature/note/navigation/NoteNavigation.kt | 4 ++-- .../kotlin/com/mifos/feature/note/notes/NoteRoute.kt | 2 +- .../kotlin/com/mifos/feature/note/notes/NoteScreen.kt | 3 +-- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteRoute.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteRoute.kt index 31d64a052e4..79b921f3753 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteRoute.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteRoute.kt @@ -30,7 +30,7 @@ fun NavGraphBuilder.addEditNoteRoute( AddEditNoteScreen( onBackPressed = onBackPressed, onNavigateWithUpdatedList = onNavigateWithUpdatedList, - navController = navController + navController = navController, ) } } diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt index 456102b7e28..209069dda36 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/addEditNotes/AddEditNoteScreen.kt @@ -15,7 +15,6 @@ import androidclient.feature.note.generated.resources.feature_note_button_confir import androidclient.feature.note.generated.resources.feature_note_dialog_warning import androidclient.feature.note.generated.resources.feature_note_dialog_warning_message import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/navigation/NoteNavigation.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/navigation/NoteNavigation.kt index bb2b43b0603..99127a9f7f8 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/navigation/NoteNavigation.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/navigation/NoteNavigation.kt @@ -32,7 +32,7 @@ fun NavGraphBuilder.noteNavGraph( noteRoute( onNavigateBack = onBackPressed, onNavigateAddEditNote = navController::navigateToAddEditNoteScreen, - navController = navController + navController = navController, ) addEditNoteRoute( @@ -40,7 +40,7 @@ fun NavGraphBuilder.noteNavGraph( navController.popBackStack() }, onNavigateWithUpdatedList = navController::navigateToNoteScreenWithUpdatedList, - navController = navController + navController = navController, ) } } diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteRoute.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteRoute.kt index 7aab24f518d..048e22e15b6 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteRoute.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteRoute.kt @@ -29,7 +29,7 @@ fun NavGraphBuilder.noteRoute( NoteScreen( onNavigateBack = onNavigateBack, onNavigateAddEditNote = onNavigateAddEditNote, - navController = navController + navController = navController, ) } } diff --git a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt index 2210d399b5d..484f44425c5 100644 --- a/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt +++ b/feature/note/src/commonMain/kotlin/com/mifos/feature/note/notes/NoteScreen.kt @@ -18,7 +18,6 @@ import androidclient.feature.note.generated.resources.feature_note_item import androidclient.feature.note.generated.resources.feature_note_notes import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -304,6 +303,6 @@ fun PreviewSuccessNoteScreen() { NoteScreenScaffold( onAction = {}, state = NoteState(notes = demoNotes), - navController = rememberNavController() + navController = rememberNavController(), ) }