Skip to content

Conversation

@kartikey004
Copy link
Contributor

@kartikey004 kartikey004 commented Dec 28, 2025

Fixes - Jira-#618

Updated logic to conditionally render a TopAppBar when a title is provided. Previously, the topBar parameter was explicitly set to empty, hiding it for all detail screens.

Screenshot_20251227_172730 Screenshot_20251227_172753 Screenshot_20251227_172945 Screenshot_20251227_173032

Summary by CodeRabbit

  • Enhancement
    • Improved detail screen navigation with consistent top bar styling, including back navigation icon and customizable action buttons across the application.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 28, 2025

📝 Walkthrough

Walkthrough

MifosScaffold now conditionally renders a new MifosDetailTopBar component when a title is provided. This top bar includes back navigation, ellipsis-truncated title text, and customizable actions with styling via the design system's TopAppBarDefaults and AppColors.

Changes

Cohort / File(s) Summary
MifosScaffold Top Bar Enhancement
core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosScaffold.kt
Replaces static empty topBar with conditional rendering of new MifosDetailTopBar composable. Adds back navigation icon (MifosIcons.ArrowBack), title text with overflow handling, and action support. Imports: Icon, IconButton, Text, TopAppBar, TopAppBarDefaults, TextOverflow. Colors aligned with design system via AppColors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A topbar now stands tall and bright,
With back arrows pointing left with might,
When titles flow in, the bar takes shape,
Custom actions help users escape,
Mifos scaffolding, refined and tight! ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions 'Navigation Drawer items sections' but the actual change is adding a conditional TopAppBar (toolbar) in the MifosScaffold component for detail screens, not specifically in Navigation Drawer items sections. Update the title to accurately reflect the primary change, such as 'MIFOSAC-618 Add conditional TopAppBar to MifosScaffold for detail screens' to better describe the toolbar implementation in the scaffold component.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fbb8ed0 and 92ef506.

📒 Files selected for processing (1)
  • core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosScaffold.kt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR Checks / Static Analysis Check
🔇 Additional comments (1)
core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosScaffold.kt (1)

23-24: LGTM! Imports are appropriate.

The new imports correctly support the TopAppBar implementation including navigation, text styling, and icon resources.

Also applies to: 30-32, 41-42

Comment on lines +59 to +67
topBar = {
if (title != null) {
MifosDetailTopBar(
title = title,
onBackPressed = onBackPressed,
actions = actions,
)
}
},
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

Default empty onBackPressed creates non-functional back button.

When title is provided but onBackPressed retains its default empty lambda (line 48), the back button appears in the TopAppBar but does nothing when clicked. This violates user expectations and creates a confusing UX.

Consider one of these solutions:

  1. Provide a functional default for onBackPressed (e.g., navigation back stack pop)
  2. Make onBackPressed required when title is non-null
  3. Conditionally hide the navigation icon when onBackPressed is not meaningful

Comment on lines +164 to +169
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun MifosDetailTopBar(
title: String,
onBackPressed: (() -> Unit)?,
actions: @Composable RowScope.() -> Unit,
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

Simplify the nullable parameter type.

The onBackPressed parameter is declared as nullable (() -> Unit)?, but the call site at line 63 always passes a non-nullable () -> Unit (with default value {} from line 48). This type inconsistency creates confusion and makes the safe call at line 181 redundant.

🔎 Proposed fix to use non-nullable parameter type
 private fun MifosDetailTopBar(
     title: String,
-    onBackPressed: (() -> Unit)?,
+    onBackPressed: () -> Unit,
     actions: @Composable RowScope.() -> Unit,
 ) {

Then update line 181 to remove the safe call:

-            IconButton(onClick = { onBackPressed?.invoke() }) {
+            IconButton(onClick = onBackPressed) {

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In
core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosScaffold.kt
around lines 164–169, the onBackPressed parameter is declared nullable (() ->
Unit)? but all callers provide a non-null () -> Unit (default {}), so change the
parameter to a non-nullable () -> Unit, update its default if present, and
remove the redundant safe-call at line 181 (call it directly). Ensure any other
internal references treat it as non-nullable and adjust any call sites that
incorrectly pass null.

Comment on lines +182 to +185
Icon(
imageVector = MifosIcons.ArrowBack,
contentDescription = "Navigate back",
)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Hardcoded contentDescription needs internationalization.

The content description "Navigate back" is hardcoded in English, which prevents proper localization for non-English users and impacts accessibility.

Consider extracting this to a string resource to support i18n/l10n requirements.

🤖 Prompt for AI Agents
In
core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosScaffold.kt
around lines 182 to 185, the Icon contentDescription is hardcoded as "Navigate
back"; extract that text into a string resource and use the compose string
retrieval instead of the literal. Add a localized entry (e.g., navigate_back) in
the appropriate resources (strings.xml / common resource file), import and call
stringResource(R.string.navigate_back) (or the multiplatform/localization helper
your project uses) for the contentDescription, and ensure the new resource key
is used consistently so the description is localizable.

@therajanmaurya therajanmaurya merged commit 6694744 into openMF:development Dec 29, 2025
3 checks passed
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.

4 participants