support custom theming in ui module#37
Conversation
📝 WalkthroughWalkthroughChangesThe PR adds translate-specific Compose color and typography tokens, provides them through composition locals, and updates Translate theme tokens
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant MainActivity
participant TranslateTheme
participant TranslationScreen
participant TranslateThemeTokens
MainActivity->>TranslateTheme: invoke themed content
TranslateTheme->>TranslateThemeTokens: provide colors and typography
TranslationScreen->>TranslateThemeTokens: read theme tokens
TranslateThemeTokens-->>TranslationScreen: return colors and text styles
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
🧹 Nitpick comments (1)
translate-ui/src/main/java/com/kanake10/translate_ui/ui/theme/TranslateTypography.kt (1)
29-33: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
titlefontSize matchesbodyandletterSpacingunit may be incorrect.The
titlestyle hasfontSize = 16.sp, identical tobody. If this is intentional (both are section labels, not page titles), consider renaming for clarity. Iftitleshould be visually distinct, increase the font size.Additionally,
letterSpacing = 0.15.spis very tight for a 16sp font. Material3'stitleMediumuses0.15.em(≈ 2.4sp at 16sp). If you intended to match that, use0.15.eminstead of0.15.sp.♻️ Suggested adjustment if matching Material3 titleMedium
fun defaultTranslateTypography() = TranslateTypography( body = TextStyle(fontSize = 16.sp, lineHeight = 24.sp, letterSpacing = 0.5.sp), - title = TextStyle(fontSize = 16.sp, lineHeight = 24.sp, letterSpacing = 0.15.sp), + title = TextStyle(fontSize = 16.sp, lineHeight = 24.sp, letterSpacing = 0.15.em), label = TextStyle(fontSize = 11.sp, lineHeight = 16.sp, letterSpacing = 0.5.sp), )🤖 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 `@translate-ui/src/main/java/com/kanake10/translate_ui/ui/theme/TranslateTypography.kt` around lines 29 - 33, Update the title TextStyle in defaultTranslateTypography to match the intended Material3 titleMedium typography: use 0.15.em for letterSpacing and increase fontSize from the body’s 16.sp to the appropriate distinct title size; leave body and label unchanged.
🤖 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.
Nitpick comments:
In
`@translate-ui/src/main/java/com/kanake10/translate_ui/ui/theme/TranslateTypography.kt`:
- Around line 29-33: Update the title TextStyle in defaultTranslateTypography to
match the intended Material3 titleMedium typography: use 0.15.em for
letterSpacing and increase fontSize from the body’s 16.sp to the appropriate
distinct title size; leave body and label unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 4051cd8b-9396-4630-894b-7c6a407bac61
⛔ Files ignored due to path filters (11)
translate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translateButtonLoading.pngis excluded by!**/*.pngtranslate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translateErrorContent.pngis excluded by!**/*.pngtranslate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translateInputField.pngis excluded by!**/*.pngtranslate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translateLanguageSelector.pngis excluded by!**/*.pngtranslate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationContent.pngis excluded by!**/*.pngtranslate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationScreen.pngis excluded by!**/*.pngtranslate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationScreenLoading.pngis excluded by!**/*.pngtranslate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationScreenWithError.pngis excluded by!**/*.pngtranslate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationScreenWithHeader.pngis excluded by!**/*.pngtranslate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationScreenWithoutContentCopyIcon.pngis excluded by!**/*.pngtranslate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationScreenWithoutTranslation.pngis excluded by!**/*.png
📒 Files selected for processing (6)
translate-app/src/main/java/com/kanake10/translate_app/MainActivity.kttranslate-ui/src/main/java/com/kanake10/translate_ui/screen/TranslationScreen.kttranslate-ui/src/main/java/com/kanake10/translate_ui/ui/theme/Theme.kttranslate-ui/src/main/java/com/kanake10/translate_ui/ui/theme/TranslateColors.kttranslate-ui/src/main/java/com/kanake10/translate_ui/ui/theme/TranslateThemeLocals.kttranslate-ui/src/main/java/com/kanake10/translate_ui/ui/theme/TranslateTypography.kt
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@translate-ui/api/translate-ui-api.txt`:
- Around line 14-15: Update the TranslateTheme API around the existing
4-argument TranslateTheme method to restore the prior Boolean-and-content
overload for binary compatibility. Implement that overload as a delegating
wrapper that applies the new default colors and typography while preserving the
existing content behavior.
🪄 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: 505391d0-8948-48fd-bf14-5a1459d31e9d
📒 Files selected for processing (2)
translate-ui/api/translate-ui-api.txttranslate-ui/src/test/java/com/kanake10/translate_ui/screen/TranslationScreenPaparazziTest.kt
✅ Files skipped from review due to trivial changes (1)
- translate-ui/src/test/java/com/kanake10/translate_ui/screen/TranslationScreenPaparazziTest.kt
| method @KotlinOnly @androidx.compose.runtime.Composable public static void TranslateTheme(optional boolean darkTheme, optional com.kanake10.translate_ui.ui.theme.TranslateColors colors, optional com.kanake10.translate_ui.ui.theme.TranslateTypography typography, kotlin.jvm.functions.Function0<kotlin.Unit> content); | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the API file around the referenced lines.
sed -n '1,120p' translate-ui/api/translate-ui-api.txt
printf '\n---- Theme.kt references ----\n'
# Locate the theme implementation and any overloads.
rg -n "TranslateTheme|TranslateColors|TranslateTypography" -S translate-ui -g '!**/build/**' -g '!**/dist/**'
printf '\n---- File list for theme sources ----\n'
git ls-files translate-ui | rg 'Theme|theme|Translate'Repository: kanake10/translate-android
Length of output: 22840
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,120p' translate-ui/api/translate-ui-api.txt
printf '\n---- Theme.kt references ----\n'
rg -n "TranslateTheme|TranslateColors|TranslateTypography" -S translate-ui -g '!**/build/**' -g '!**/dist/**'
printf '\n---- File list for theme sources ----\n'
git ls-files translate-ui | rg 'Theme|theme|Translate'Repository: kanake10/translate-android
Length of output: 22840
Preserve the TranslateTheme(Boolean, content) overload. The published API now exposes only the 4-arg signature, so callers compiled against the previous release will hit NoSuchMethodError. Add a compatibility overload and keep the new defaults behind it.
🤖 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 `@translate-ui/api/translate-ui-api.txt` around lines 14 - 15, Update the
TranslateTheme API around the existing 4-argument TranslateTheme method to
restore the prior Boolean-and-content overload for binary compatibility.
Implement that overload as a delegating wrapper that applies the new default
colors and typography while preserving the existing content behavior.
Summary by CodeRabbit
New Features
Refactor
Tests