Skip to content

Conversation

Nagarjuna0033
Copy link
Contributor

This commit introduces a robust, cross-platform ShareUtils implementation for handling text and file sharing across Android, iOS, Desktop (JVM), JS, and WASM.

Key changes include:

  • Common ShareUtils expect/actual structure:
    • Defines shareText(text: String) and shareFile(file: ShareFileModel) in the common module.
    • Implements these functions for each target platform.
  • ShareFileModel and MimeType:
    • Introduces ShareFileModel to encapsulate file details (name, bytes, MIME type).
    • Adds MimeType enum (PDF, TEXT, IMAGE) for better type safety.
  • Platform-specific implementations:
    • Android: Uses Intent.ACTION_SEND with FileProvider for sharing files. Includes image compression via FileKit. setActivityProvider is required for context.
    • iOS: Leverages UIActivityViewController for native sharing. Handles file saving to cache and uses FileKit for image compression.
    • Desktop (JVM): Uses FileKit.openFileSaver to prompt the user to save the file locally, as direct sharing is not typical.
    • JS/WASM: Uses FileKit.download to trigger a browser download for files and text content.
  • Dependency updates:
    • Replaces libs.filekit.compose with libs.filekit.dialog.compose in core/ui/build.gradle.kts for better dialog handling.
  • Helper functions:
    • Android: saveFile, MimeType.toAndroidMimeType, compressImage.
    • iOS: saveFile, compressImage.

This unified approach simplifies sharing logic across the application and leverages platform-specific capabilities where available.

Fixes - Jira-#426

This commit introduces a robust, cross-platform `ShareUtils` implementation for handling text and file sharing across Android, iOS, Desktop (JVM), JS, and WASM.

Key changes include:

- **Common `ShareUtils` expect/actual structure:**
    - Defines `shareText(text: String)` and `shareFile(file: ShareFileModel)` in the common module.
    - Implements these functions for each target platform.
- **`ShareFileModel` and `MimeType`:**
    - Introduces `ShareFileModel` to encapsulate file details (name, bytes, MIME type).
    - Adds `MimeType` enum (PDF, TEXT, IMAGE) for better type safety.
- **Platform-specific implementations:**
    - **Android:** Uses `Intent.ACTION_SEND` with `FileProvider` for sharing files. Includes image compression via `FileKit`. `setActivityProvider` is required for context.
    - **iOS:** Leverages `UIActivityViewController` for native sharing. Handles file saving to cache and uses `FileKit` for image compression.
    - **Desktop (JVM):** Uses `FileKit.openFileSaver` to prompt the user to save the file locally, as direct sharing is not typical.
    - **JS/WASM:** Uses `FileKit.download` to trigger a browser download for files and text content.
- **Dependency updates:**
    - Replaces `libs.filekit.compose` with `libs.filekit.dialog.compose` in `core/ui/build.gradle.kts` for better dialog handling.
- **Helper functions:**
    - Android: `saveFile`, `MimeType.toAndroidMimeType`, `compressImage`.
    - iOS: `saveFile`, `compressImage`.

This unified approach simplifies sharing logic across the application and leverages platform-specific capabilities where available.
- Excluded `core-base/designsystem/**` from Detekt analysis.
- Removed unnecessary `printStackTrace()` calls in `ShareUtils.android.kt` and `ShareUtils.native.kt`.
- Applied `modifier` parameter to `MifosAccountApplyDashboard`.
- Removed redundant `it ->` in `BottomSheetContent.kt`.
@Nagarjuna0033
Copy link
Contributor Author

I just copy pasted the logic from mifos pay. @HekmatullahAmin If you think it can be mergeable. please go ahead and merge it

@HekmatullahAmin HekmatullahAmin enabled auto-merge (squash) September 24, 2025 09:06
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.

2 participants