Skip to content

support custom theming in ui module#37

Merged
kanake10 merged 2 commits into
mainfrom
decouple-SDK-theming
Jul 13, 2026
Merged

support custom theming in ui module#37
kanake10 merged 2 commits into
mainfrom
decouple-SDK-theming

Conversation

@kanake10

@kanake10 kanake10 commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added a dedicated theming system with light/dark palettes and reusable theme tokens.
    • Introduced consistent typography styles (body, title, label) shared across the UI.
    • Updated the translation screen to use the new themed colors/typography for inputs, errors, results, dropdowns, and buttons.
  • Refactor

    • Simplified theme setup syntax in the app’s main activity.
  • Tests

    • Updated the build command comment for generating API signatures.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

The PR adds translate-specific Compose color and typography tokens, provides them through composition locals, and updates TranslationScreen styling to consume those tokens for fields, content, errors, results, and buttons.

Translate theme tokens

Layer / File(s) Summary
Theme token contracts
translate-ui/.../ui/theme/TranslateColors.kt, translate-ui/.../ui/theme/TranslateTypography.kt, translate-ui/.../ui/theme/TranslateThemeLocals.kt, translate-ui/api/translate-ui-api.txt
Defines immutable color and typography models, light/dark factories, composition locals, composable token accessors, and their public API declarations.
Theme provisioning
translate-ui/.../ui/theme/Theme.kt, translate-app/.../MainActivity.kt
Provides selected theme colors and typography through TranslateTheme and updates its invocation syntax.
Translation screen styling
translate-ui/.../screen/TranslationScreen.kt, translate-ui/.../screen/TranslationScreenPaparazziTest.kt
Uses TranslateThemeTokens for screen colors, typography, text fields, translation results, error states, buttons, loading indicators, and updates the metalava command comment.

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
Loading

Possibly related PRs

  • kanake10/translate-android#33: Updates shared TranslateTheme and translation error rendering, overlapping with this PR’s theme and error styling changes.
🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding custom theming support to the UI module.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch decouple-SDK-theming

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.

@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.

🧹 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

title fontSize matches body and letterSpacing unit may be incorrect.

The title style has fontSize = 16.sp, identical to body. If this is intentional (both are section labels, not page titles), consider renaming for clarity. If title should be visually distinct, increase the font size.

Additionally, letterSpacing = 0.15.sp is very tight for a 16sp font. Material3's titleMedium uses 0.15.em (≈ 2.4sp at 16sp). If you intended to match that, use 0.15.em instead of 0.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

📥 Commits

Reviewing files that changed from the base of the PR and between 86eec96 and c7f806a.

⛔ Files ignored due to path filters (11)
  • translate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translateButtonLoading.png is excluded by !**/*.png
  • translate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translateErrorContent.png is excluded by !**/*.png
  • translate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translateInputField.png is excluded by !**/*.png
  • translate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translateLanguageSelector.png is excluded by !**/*.png
  • translate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationContent.png is excluded by !**/*.png
  • translate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationScreen.png is excluded by !**/*.png
  • translate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationScreenLoading.png is excluded by !**/*.png
  • translate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationScreenWithError.png is excluded by !**/*.png
  • translate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationScreenWithHeader.png is excluded by !**/*.png
  • translate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationScreenWithoutContentCopyIcon.png is excluded by !**/*.png
  • translate-ui/src/test/snapshots/images/com.kanake10.translate_ui.screen_TranslationScreenPaparazziTest_translationScreenWithoutTranslation.png is excluded by !**/*.png
📒 Files selected for processing (6)
  • translate-app/src/main/java/com/kanake10/translate_app/MainActivity.kt
  • translate-ui/src/main/java/com/kanake10/translate_ui/screen/TranslationScreen.kt
  • translate-ui/src/main/java/com/kanake10/translate_ui/ui/theme/Theme.kt
  • translate-ui/src/main/java/com/kanake10/translate_ui/ui/theme/TranslateColors.kt
  • translate-ui/src/main/java/com/kanake10/translate_ui/ui/theme/TranslateThemeLocals.kt
  • translate-ui/src/main/java/com/kanake10/translate_ui/ui/theme/TranslateTypography.kt

@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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between c7f806a and cf136c9.

📒 Files selected for processing (2)
  • translate-ui/api/translate-ui-api.txt
  • translate-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

Comment on lines +14 to +15
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);
}

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.

🗄️ 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.

@kanake10 kanake10 merged commit ead9e71 into main Jul 13, 2026
7 checks passed
@kanake10 kanake10 deleted the decouple-SDK-theming branch July 13, 2026 10:58
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.

1 participant