-
Notifications
You must be signed in to change notification settings - Fork 1
IPC 746 implement MainScreen composable and refactor MainAc… #846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
IPC 746 implement MainScreen composable and refactor MainAc… #846
Conversation
…tivity to use it IPC-746
… dependencies IPC-746
…e handling IPC-746
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the MainActivity from XML layouts to Jetpack Compose by creating a new MainScreen composable. The refactoring modernizes the UI to use declarative Compose patterns while maintaining the same functionality as the original imperative View-based implementation.
Key changes:
- Complete migration from XML ViewBinding to Compose UI with MainScreen composable
- Replacement of ViewPager2/TabLayoutMediator with HorizontalPager and custom DotsIndicator
- Integration of activity result launchers directly in Compose using rememberLauncherForActivityResult
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| MainViewModel.kt | Adds contentPages StateFlow and Page data class to support Compose state management |
| MainScreen.kt | New Compose UI implementation replacing XML layouts with declarative UI components |
| MainActivity.kt | Simplified to use setContent with MainScreen composable, removing ViewBinding and listeners |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
health-sdk/example-app/src/main/java/net/gini/android/health/sdk/exampleapp/MainScreen.kt
Outdated
Show resolved
Hide resolved
health-sdk/example-app/src/main/java/net/gini/android/health/sdk/exampleapp/MainScreen.kt
Outdated
Show resolved
Hide resolved
health-sdk/example-app/src/main/java/net/gini/android/health/sdk/exampleapp/MainActivity.kt
Show resolved
Hide resolved
…n MainScreen IPC-746
|




I re-implemented the
MainActivityof the Health SDK using Jetpack Compose. This was part of applying the new concepts and techniques I learned during my Compose course.Instead of relying on XML layouts and ViewBinding, I moved the entire UI into a
MainScreen()composable. This allowed me to:ConstraintLayoutandViewPager2with Compose layouts and the new HorizontalPager API.rememberLauncherForActivityResultto handle camera capture and document import in a declarative way.Flowstate directly in Compose usingcollectAsState, so the UI automatically updates when the ViewModel state changes.TabLayoutMediator.Through this exercise, I could demonstrate what I learned in the course: writing modern, declarative UI, managing lifecycle safely with Compose, and reducing boilerplate compared to XML + imperative View setup.
It was also a chance to share with the team how our existing SDK examples can be updated to Compose-first architecture, which makes the codebase cleaner, more maintainable, and aligned with current Android best practices.