Skip to content

feat: Compose setup for project#21147

Open
criticalAY wants to merge 3 commits into
ankidroid:mainfrom
criticalAY:compose/setup
Open

feat: Compose setup for project#21147
criticalAY wants to merge 3 commits into
ankidroid:mainfrom
criticalAY:compose/setup

Conversation

@criticalAY
Copy link
Copy Markdown
Contributor

@criticalAY criticalAY commented May 26, 2026

Purpose / Description

Enable Jetpack Compose on the :AnkiDroid module so future screens can be built or migrated incrementally. This follows Google's I/O 2026 "Compose-First" direction. This PR is foundational it does not convert any existing user-facing screen.

Fixes

Approach

See commit 1 and then:
Added com.ichi2.compose.theme.Theme that reads colors from the host Activity's XML theme via R.styleable.ComposeTheme and bridges each of the four AnkiDroid themes (Light, Plain, Dark, Black) into a Material 3 ColorScheme. Slots not declared by the XML fall back to Material 3 defaults; isLightTheme (inherited from Theme.Material3.{Light,Dark}) decides the base scheme.

  • Add ktlint config: ktlint_function_naming_ignore_when_annotated_with = Composable so @composable fun MySomeScreen() isn't flagged.

How Has This Been Tested?

Local build passed

Learning (optional, can help others)

Themes and Preview is a mess to handle for custom themes and it took me whole night to enable compose for Shared Deck screen

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@criticalAY criticalAY marked this pull request as draft May 26, 2026 03:07
Copy link
Copy Markdown
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

LooksGreatToMe!!

Comment thread gradle/libs.versions.toml Outdated
Comment thread gradle/libs.versions.toml
Comment thread .editorconfig
Comment thread AnkiDroid/src/main/java/com/ichi2/compose/theme/Theme.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/compose/ui/preview/ThemePreviews.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/compose/theme/Dimensions.kt
@criticalAY criticalAY marked this pull request as ready for review May 26, 2026 15:05
@criticalAY criticalAY added the Needs Second Approval Has one approval, one more approval to merge label May 27, 2026
@criticalAY criticalAY requested a review from david-allison May 27, 2026 06:32
Comment thread AnkiDroid/build.gradle
Adds the Kotlin Compose Compiler plugin to :AnkiDroid, pulls in Compose
BOM 2026.04.01 with material3, ui-tooling, activity-compose and the
lifecycle-compose pair, and opts in to ExperimentalMaterial3Api at the
module level so screens don't need @OptIn annotations. The Compose
Compiler attaches to every Kotlin compilation in the module, so
testFixtures (which has no @composable code) needs the runtime on its
compileOnly classpath to satisfy the plugin's version check.

Also relaxes ktlint's function-naming rule for @composable functions
so PascalCase composables don't trip the linter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Second Approval Has one approval, one more approval to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants