Skip to content

Conversation

@TheKalpeshPawar
Copy link
Contributor

@TheKalpeshPawar TheKalpeshPawar commented Sep 10, 2025


##Video

Record_2025-09-12-20-19-12_026f621985d6cfa1a169c52d305dc178.mp4


## Goal not achieved yet:
**Show preview for pdf documents.**
I haven't found a kmp library yet for this.
Actually I found one this morning, but it doesn't suppot IOS
Link: [compose-pdf](https://klibs.io/project/zt64/compose-pdf)
But I was busy making the screen work, I haven't properly looked into this issue yet.

---

Important things to note

  • The maximum upload size for a document is restricted to 1MB.
  • The user are restricted to JPG , JPEG, PNG AND PDF format files for uploading.
  • Documents (both image and PDFs) download by user to view are stored in the app cache. Also the PDF files which the user chooses to preview by clicking on View button are also stored in the cache. But this doesn't fill the cache much because each saved file overwrites the existing file. Atmost there will be only two file in the app cache attachment.pdf and attachment.jpeg.

How is the preview for documents implemented?

Image as Documents

  • Image files preview is shown in the app itself.
  • It is shown when uploading, when user wished to preview again once before when uploading,
    in which case they can update the document too.
  • When the user download the Image file from the server it is stored in the app cache and the preview is shown in the app itself.

PDF as Documents

  • PDF file preview is not shown when the user picks them first time for upload,
  • The PDF file will open in an external app if the user wished to preview it once (by clicking on View button)
    before upload. They can replace the file too.
  • When the user downloads the PDF file from the server it is stored in the app cache and the a chooser for opening the file in external PDF viewer apps is shown.

What I have done in this PR ?

My task was to create feature for clients documents upload and preview.

  • This feature is divided into three screens
    -- ClientDocumentList Screen: This screen lists documents of the client.
    -- ClientAddDocument Screen: This screen is for adding and updating client documents.
    -- DocumentPreviewScreen: This is for show preview of document and choosing a new one if needed.

One thing about the DocumentPreview Screen, it is used with other screen too, therefore I wanted it to be a separate screen.
I don't know If I have succeeded in doing so.

Since, these are three different screens they have their own different states and also their own view model.
As they were state dependent on each other, I had to find out some way of sharing states between these three screens.

Navigation arguments were a terrible option.
I tried using shared viewmodel then, which also didn't work, because of too many states and having to host a shared view model in a navgraph, which created issue with navigation.


My solution

I have used a repository and hosted common states in it and injected it in these three screens.

I rewrote this feature many times, and this time it worked properly. I think it can be improved. So, help me improve it.

# Conflicts:
#	core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosActionsListingCardComponent.kt
#	feature/client/src/commonMain/kotlin/com/mifos/feature/client/di/ClientModule.kt
#	feature/client/src/commonMain/kotlin/com/mifos/feature/client/navigation/ClientNavigation.kt
# Conflicts:
#	feature/client/src/commonMain/kotlin/com/mifos/feature/client/di/ClientModule.kt
@TheKalpeshPawar TheKalpeshPawar marked this pull request as ready for review September 10, 2025 16:53
@therajanmaurya therajanmaurya merged commit a1b91e5 into openMF:development Sep 12, 2025
2 checks passed
@TheKalpeshPawar TheKalpeshPawar deleted the clientDocument branch November 10, 2025 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants