refactor: split SearchBar into stateless and stateful components (#86)#87
refactor: split SearchBar into stateless and stateful components (#86)#87
Conversation
- Create MetaSearchSearchBar as a reusable stateless component - Implement state hoisting for NLSearchTextField to improve encapsulation - Optimize rendering performance by isolating recomposition scope
📝 WalkthroughWalkthroughThis PR introduces a new reusable MetaSearchSearchBar Compose component and refactors the NLSearchTextField to use it. The event handling flow is consolidated from separate input-change and search callbacks into a single search action that emits both events sequentially. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@core/ui/src/main/java/com/metasearch/android/core/ui/component/MetaSearchSearchBar.kt`:
- Around line 75-89: The Icon in MetaSearchSearchBar.kt uses a hardcoded
contentDescription ("Search Icon"); extract this to a string resource and
reference it via stringResource in the composable. Add a string entry (e.g.
name="search_icon_content_description" value="Search") to your module's
strings.xml and replace the hardcoded contentDescription in the Icon call with
stringResource(R.string.search_icon_content_description) (keep the Icon,
onSearchClick, and Modifier usage unchanged).
| Icon( | ||
| painter = painterResource(R.drawable.ic_search_line), | ||
| contentDescription = "Search Icon", | ||
| modifier = Modifier | ||
| .size( | ||
| MetaSearchTheme.spacing.spacing6, | ||
| ) | ||
| .clickable( | ||
| indication = null, | ||
| interactionSource = remember { MutableInteractionSource() }, | ||
| ) { | ||
| onSearchClick() | ||
| }, | ||
| tint = Neutral500, | ||
| ) |
There was a problem hiding this comment.
Hardcoded content description should be a string resource.
The contentDescription = "Search Icon" on line 77 should be extracted to a string resource for proper internationalization support.
Suggested fix
Icon(
painter = painterResource(R.drawable.ic_search_line),
- contentDescription = "Search Icon",
+ contentDescription = stringResource(R.string.search_icon_content_description),
modifier = ModifierAdd the corresponding string resource in core/ui/src/main/res/values/strings.xml:
<string name="search_icon_content_description">Search</string>🤖 Prompt for AI Agents
In
`@core/ui/src/main/java/com/metasearch/android/core/ui/component/MetaSearchSearchBar.kt`
around lines 75 - 89, The Icon in MetaSearchSearchBar.kt uses a hardcoded
contentDescription ("Search Icon"); extract this to a string resource and
reference it via stringResource in the composable. Add a string entry (e.g.
name="search_icon_content_description" value="Search") to your module's
strings.xml and replace the hardcoded contentDescription in the Icon call with
stringResource(R.string.search_icon_content_description) (keep the Icon,
onSearchClick, and Modifier usage unchanged).
Summary by CodeRabbit
New Features
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.
Verification