Skip to content

Feature/manage pocket screen#2057

Open
Kartikey15dem wants to merge 4 commits into
openMF:devfrom
Kartikey15dem:feature/manage-pocket-screen
Open

Feature/manage pocket screen#2057
Kartikey15dem wants to merge 4 commits into
openMF:devfrom
Kartikey15dem:feature/manage-pocket-screen

Conversation

@Kartikey15dem

@Kartikey15dem Kartikey15dem commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Fixes - Jira-#MW-380

Summary

This PR adds the Manage Pocket screen, which allows users to view, add, and remove accounts that they want to keep track of in their "Pocket".

Features Added in Manage Pocket Screen:

Here are the cool things you can do on this screen:

  1. View Linked Accounts:

    • On the main screen, you can see a list of all your currently linked pocket accounts under the "Linked Accounts" section.
    • If you haven't linked any accounts yet, it simply tells you: "No accounts are linked to pocket".
  2. Link More Accounts:

    • There's a "Link More Accounts" card that opens up a bottom sheet.
    • Inside this sheet, you can see all your available accounts that can be linked.
    • To make it easy to find them, they are divided into neat tabs: Savings, Loan, and Share accounts.
  3. Search for Accounts:

    • Inside the bottom sheet, there's a search bar.
    • When you search, it shows the results right there while dimming out the rest of the sheet, just like how it works in professional apps like LinkedIn!
  4. Select & Link:

    • You can select multiple accounts using checkboxes and link them all at once.
  5. Remove (Delink) Accounts:

    • If you don't want an account in your pocket anymore, you can click to remove it.
    • This opens up a warning bottom sheet asking you to confirm if you really want to remove the account (so you don't do it by mistake!).

Summary by CodeRabbit

  • New Features
    • Added a “Manage Pocket” experience to link, search, and remove pocket accounts.
    • Enabled navigation from the Pocket dashboard to account management.
    • Added tabbed account selection (pager + tabs) and alert/confirmation dialogs.
  • Improvements
    • Pocket balances now show currency symbols/codes, including multi-currency totals.
    • Refreshed Pocket dashboard and related UI spacing/typography for a cleaner layout.
  • Bug Fixes
    • Improved linking/delinking accuracy to prevent duplicate or incorrect account matches.
    • Updated manage flow back-navigation and confirmation messaging behavior.

@Kartikey15dem
Kartikey15dem requested review from a team and Copilot July 21, 2026 16:39
@Kartikey15dem
Kartikey15dem marked this pull request as draft July 21, 2026 16:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Manage Pocket account linking and delinking, currency-aware pocket data and dashboard balances, reusable Compose dialog and pager components, updated pocket navigation, and dashboard presentation refinements.

Changes

Pocket management

Layer / File(s) Summary
Account data and dashboard balance handling
core/model/..., core/data/..., feature/pocket/.../PocketDashboardViewModel.kt
Pocket models and mappings now carry currency display symbols; account linking distinguishes account IDs by type; dashboard balances support grouped multi-currency formatting.
Manage Pocket state and repository operations
feature/pocket/.../ManagePocketViewModel.kt
Adds state, actions, account mappings, and repository-backed linking and delinking flows.
Manage Pocket Compose surfaces
core/designsystem/..., feature/pocket/.../ManagePocketScreen.kt, feature/pocket/.../strings.xml
Adds the management screen, searchable tabbed linking sheet, account rows, confirmation dialogs, previews, localized strings, and pager support.
Manage Pocket navigation and dependency wiring
feature/pocket/.../PocketModule.kt, feature/pocket/.../ManagePocketRoute.kt, cmp-shared/.../MifosNavHost.kt
Registers the ViewModel and connects dashboard navigation, destination registration, and back navigation.
Pocket dashboard and account card presentation
feature/pocket/.../PocketDashboardScreen.kt, core/designsystem/.../MifosAccountCard.kt
Updates spacing, typography, card sizing, and preview balance values.
Shared tab and dialog component updates
core/designsystem/..., core/ui/.../ScrollableTabRow.kt
Adds reusable alert and pager components and simplifies tab styling and parameters.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ManagePocketScreen
  participant ManagePocketViewModel
  participant PocketRepository
  User->>ManagePocketScreen: Select accounts or request delink
  ManagePocketScreen->>ManagePocketViewModel: Dispatch ManagePocketAction
  ManagePocketViewModel->>PocketRepository: Link or delink accounts
  PocketRepository-->>ManagePocketViewModel: Return DataState
  ManagePocketViewModel-->>ManagePocketScreen: Update account and dialog state
Loading

Possibly related PRs

Suggested reviewers: revanthkumarj

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding the Manage Pocket screen and related flow.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

feat(feature/pocket):implement pocket dashboard screen

feat(feature/pocket):implement pocket dashboard screen

feat(feature/pocket):implement pocket dashboard screen

# Conflicts:
#	feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/viewmodels/PocketDashboardViewModel.kt
fix(feature/pocket):fix static checks
@Kartikey15dem
Kartikey15dem force-pushed the feature/manage-pocket-screen branch from e398d63 to 11e49ae Compare July 22, 2026 07:13
feat(feature/pocket):implement manage pocket screen

feat(feature/pocket):implement manage pocket screen

feat(feature/pocket):implement manage pocket screen

feat(feature/pocket):implement manage pocket screen
@Kartikey15dem
Kartikey15dem force-pushed the feature/manage-pocket-screen branch from 11e49ae to 73b7fa0 Compare July 25, 2026 11:10
@Kartikey15dem
Kartikey15dem marked this pull request as ready for review July 25, 2026 12:01

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (5)
feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/screens/ManagePocketScreen.kt (2)

769-773: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use the non-clickable Card overload.

onClick = {} with enabled = false only to get a static container also applies disabled content colors. Prefer Card(modifier, shape, colors) without onClick.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/screens/ManagePocketScreen.kt`
around lines 769 - 773, Update the Card invocation in ManagePocketScreen to use
the non-clickable overload by removing the empty onClick and enabled arguments,
while preserving the existing modifier and any shape or color configuration.

540-588: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated account list.

The search overlay repeats the LazyColumn + SelectablePocketAccountCard + AccountSelectionChanged block from Lines 513-535 verbatim, including the identifier string built in three places ("${accountId}_${accountType.name}", also in the ViewModel). Extract a private AvailableAccountsList(accounts, selectedIds, onSelectedChange) composable and a shared identifier helper.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/screens/ManagePocketScreen.kt`
around lines 540 - 588, Extract the repeated account-list UI into a private
AvailableAccountsList composable accepting accounts, selectedIds, and an
onSelectedChange callback, then reuse it in both the main list and search
overlay instead of duplicating LazyColumn and SelectablePocketAccountCard logic.
Add and use a shared account identifier helper for the
"${accountId}_${accountType.name}" value in the composable and ViewModel,
preserving selection behavior and item keys.
feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/viewmodels/ManagePocketViewModel.kt (1)

337-342: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Drop the unused ErrorString variant and import StringResource.

ManagePocketUiState.ErrorString is never produced by the ViewModel, so the screen carries a dead branch. Also prefer an import over the fully-qualified org.jetbrains.compose.resources.StringResource in both sealed interfaces.

Also applies to: 364-369

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/viewmodels/ManagePocketViewModel.kt`
around lines 337 - 342, Remove the unused ManagePocketUiState.ErrorString
variant, add an import for StringResource, and replace the fully qualified type
in ManagePocketUiState.Error; apply the same import/type cleanup to the other
sealed interface referenced by the comment.
core/data/src/commonMain/kotlin/org/mifospay/core/data/repositoryImpl/PocketRepositoryImp.kt (1)

226-227: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Use a Set for the already-linked lookup.

alreadyLinkedAccounts is a List<Pair<Long, AccountType>> queried with !in once per loan/savings/share account, giving O(n·m) scans. A Set makes each check O(1) and expresses intent better.

♻️ Proposed change
-                val alreadyLinkedAccounts = (detailedPocketCache.value as? DataState.Success)
-                    ?.data?.map { Pair(it.pocket.accountId, it.pocket.accountType) } ?: emptyList()
+                val alreadyLinkedAccounts = (detailedPocketCache.value as? DataState.Success)
+                    ?.data?.mapTo(mutableSetOf()) { Pair(it.pocket.accountId, it.pocket.accountType) }
+                    ?: emptySet()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@core/data/src/commonMain/kotlin/org/mifospay/core/data/repositoryImpl/PocketRepositoryImp.kt`
around lines 226 - 227, Update alreadyLinkedAccounts in the detailedPocketCache
lookup to collect the accountId/accountType pairs into a Set instead of a List,
preserving the existing empty fallback and Pair values so subsequent !in checks
use constant-time membership lookup.
feature/pocket/src/commonMain/composeResources/values/strings.xml (1)

35-35: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use or remove the unused delink title string.

feature_pocket_delink_account_title is defined in feature/pocket/src/commonMain/composeResources/values/strings.xml, but no code references it. If it is intended for the delink confirmation sheet, wire it in; otherwise remove the resource.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@feature/pocket/src/commonMain/composeResources/values/strings.xml` at line
35, Resolve the unused feature_pocket_delink_account_title resource by either
wiring it into the delink confirmation sheet’s title or removing the string
resource if that sheet does not use it. Keep the resource and its usage
consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@core/designsystem/src/commonMain/kotlin/org/mifospay/core/designsystem/component/MifosTabPager.kt`:
- Around line 45-52: Update the indicator lambda in MifosTabPager to retrieve
the current tab position with getOrNull(currentPage), and render
SecondaryIndicator only when a position exists; preserve the existing modifier,
padding, and color for valid indices while safely skipping the indicator for
empty or out-of-range tabPositions.
- Around line 69-74: Update MifosTabPager so TabRow selection and setCurrentPage
use the same pagerState.currentPage that HorizontalPager updates during swipes,
rather than the stale currentPage parameter. Keep tab taps and pager swipes
synchronized through this single source of truth.

In
`@feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/screens/ManagePocketScreen.kt`:
- Around line 464-467: Update the search hint construction in ManagePocketScreen
around feature_pocket_search_accounts_hint so it interpolates a localized string
resource mapped from the selected AccountType, rather than
tabs[selectedTabIndex].name.lowercase(). Apply the same mapping to the
additional occurrence, preserving the existing tab-selection behavior and using
the appropriate SAVINGS, LOAN, and SHARE resources from strings.xml.
- Around line 709-718: Update the clear-search Icon in the trailingIcon block of
ManagePocketScreen to use a localized string resource for contentDescription
instead of the hardcoded “Close Icon” literal. Add the resource to the
appropriate strings.xml with wording that describes clearing the search, such as
“Clear search.”

In
`@feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/viewmodels/ManagePocketViewModel.kt`:
- Around line 12-20: Remove the duplicated license header after the package
declaration in ManagePocketViewModel.kt and ManagePocketScreen.kt; retain only
each file’s header at the top and remove the incorrect openMF/mobile-mobile URL
block.

In
`@feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/viewmodels/PocketDashboardViewModel.kt`:
- Around line 157-169: Update the empty-account fallback in the formattedTotal
calculation to avoid the hardcoded "$0.00" USD value. Use CurrencyFormatter to
format zero without assuming a currency symbol, or reuse an existing
empty/placeholder string resource consistent with
PocketDashboardState.totalBalance.
- Around line 91-93: Remove the per-emission coroutine launches in
PocketDashboardViewModel.handleReceivedAccounts and
ManagePocketViewModel.handleLinkedAccounts/handleAvailableAccounts by resolving
getString fallback values once in the collector coroutine or mapping within the
single loadJob collector, so each DataState is handled synchronously and
emissions cannot complete out of order. Apply the corresponding change in
feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/viewmodels/PocketDashboardViewModel.kt
lines 91-93 and
feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/viewmodels/ManagePocketViewModel.kt
lines 223-228; both sites require the same update.

---

Nitpick comments:
In
`@core/data/src/commonMain/kotlin/org/mifospay/core/data/repositoryImpl/PocketRepositoryImp.kt`:
- Around line 226-227: Update alreadyLinkedAccounts in the detailedPocketCache
lookup to collect the accountId/accountType pairs into a Set instead of a List,
preserving the existing empty fallback and Pair values so subsequent !in checks
use constant-time membership lookup.

In `@feature/pocket/src/commonMain/composeResources/values/strings.xml`:
- Line 35: Resolve the unused feature_pocket_delink_account_title resource by
either wiring it into the delink confirmation sheet’s title or removing the
string resource if that sheet does not use it. Keep the resource and its usage
consistent.

In
`@feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/screens/ManagePocketScreen.kt`:
- Around line 769-773: Update the Card invocation in ManagePocketScreen to use
the non-clickable overload by removing the empty onClick and enabled arguments,
while preserving the existing modifier and any shape or color configuration.
- Around line 540-588: Extract the repeated account-list UI into a private
AvailableAccountsList composable accepting accounts, selectedIds, and an
onSelectedChange callback, then reuse it in both the main list and search
overlay instead of duplicating LazyColumn and SelectablePocketAccountCard logic.
Add and use a shared account identifier helper for the
"${accountId}_${accountType.name}" value in the composable and ViewModel,
preserving selection behavior and item keys.

In
`@feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/viewmodels/ManagePocketViewModel.kt`:
- Around line 337-342: Remove the unused ManagePocketUiState.ErrorString
variant, add an import for StringResource, and replace the fully qualified type
in ManagePocketUiState.Error; apply the same import/type cleanup to the other
sealed interface referenced by the comment.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5007abe0-2aeb-4871-891f-689c382b9aa9

📥 Commits

Reviewing files that changed from the base of the PR and between bbe0ea9 and 73b7fa0.

📒 Files selected for processing (13)
  • cmp-shared/src/commonMain/kotlin/org/mifospay/shared/navigation/MifosNavHost.kt
  • core/data/src/commonMain/kotlin/org/mifospay/core/data/repositoryImpl/PocketRepositoryImp.kt
  • core/designsystem/src/commonMain/kotlin/org/mifospay/core/designsystem/component/MifosAccountCard.kt
  • core/designsystem/src/commonMain/kotlin/org/mifospay/core/designsystem/component/MifosAlertDialog.kt
  • core/designsystem/src/commonMain/kotlin/org/mifospay/core/designsystem/component/MifosTabPager.kt
  • core/model/src/commonMain/kotlin/org/mifospay/core/model/pocket/PocketAccount.kt
  • feature/pocket/src/commonMain/composeResources/values/strings.xml
  • feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/di/PocketModule.kt
  • feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/navigation/ManagePocketRoute.kt
  • feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/screens/ManagePocketScreen.kt
  • feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/screens/PocketDashboardScreen.kt
  • feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/viewmodels/ManagePocketViewModel.kt
  • feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/viewmodels/PocketDashboardViewModel.kt

fix(feature/pocket):fix MifosTabPager
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.

3 participants