Skip to content

Migrate ReflexGame UI to Compose and StateFlow#18

Merged
juandiana merged 1 commit intomainfrom
codex/compose-ui-migration-finalize
Feb 17, 2026
Merged

Migrate ReflexGame UI to Compose and StateFlow#18
juandiana merged 1 commit intomainfrom
codex/compose-ui-migration-finalize

Conversation

@juandiana
Copy link
Copy Markdown
Owner

@juandiana juandiana commented Feb 17, 2026

Summary

This PR migrates the app from XML/View-based UI to Jetpack Compose, moves UI state observation from LiveData to Flow/StateFlow, and aligns theming/state structure with Compose-first practices while preserving the existing look/behavior.

High-level changes

  • Replaced the View/XML screen implementation with Compose UI in MainScreen.kt (grid, HUD, button, and game-over title).
  • Added MainScreenRoute(viewModel) that collects state with collectAsStateWithLifecycle, while keeping MainScreen(...) stateless and previewable.
  • Added @Preview for the main screen.
  • Renamed MainUiState to MainScreenState for naming consistency.
  • Moved SquareState into the new UI state file and removed old ui/model state files.
  • Migrated MainViewModel from LiveData to MutableStateFlow/StateFlow.
  • Replaced nullable/live-data copy patterns with explicit _uiState.value = _uiState.value.copy(...) updates.
  • Renamed the square interaction callback to onSquareTouched across the codebase.
  • Refactored chronometer responsibility to ViewModel:
    • timer start/stop lifecycle is handled in ViewModel
    • elapsed time is formatted in ViewModel via DateUtils.formatElapsedTime(...)
    • UI now only renders the formatted text
  • Extracted Compose theme artifacts into dedicated files:
    • theme/Color.kt
    • theme/Theme.kt
    • theme/Spacing.kt
    • theme/Type.kt
  • Removed no-longer-used View/XML resources:
    • deleted activity_main.xml and item_square.xml
    • deleted colors.xml and dimens.xml
  • Simplified themes.xml for Compose usage (kept app theme + status bar color only).
  • Removed no-longer-used LiveData helper classes (Event, EventObserver) and old adapter (SquaresAdapter).
  • Updated Gradle/dependencies for Compose-first setup:
    • enabled buildFeatures.compose = true
    • added Kotlin Compose plugin alias
    • added kotlin entry to the version catalog and referenced it from the Compose plugin
    • set Kotlin to 2.3.10
    • switched to Compose BOM + Material3 + tooling dependencies
    • removed obsolete view-system dependencies
  • Hardened MainViewModelFactory to validate modelClass before casting.

Validation

  • ./gradlew :app:assembleDebug
  • ./gradlew :app:lintDebug

Both pass locally.

@juandiana juandiana merged commit 9c26def into main Feb 17, 2026
1 check passed
@juandiana juandiana deleted the codex/compose-ui-migration-finalize branch February 17, 2026 16:31
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