[Draft] Replace tasks fragment with pure compose screens within DataCollection fragment #3635
Draft
shobhitagarwal1612 wants to merge 10 commits intomasterfrom
Draft
[Draft] Replace tasks fragment with pure compose screens within DataCollection fragment #3635shobhitagarwal1612 wants to merge 10 commits intomasterfrom
shobhitagarwal1612 wants to merge 10 commits intomasterfrom
Conversation
- Remove `DataCollectionViewPagerAdapter` and its associated factory. - Introduce `TaskPager` Composable using `HorizontalPager` to manage task transitions. - Implement `TaskFragmentProvider` to encapsulate fragment creation logic previously held in the adapter. - Update `DataCollectionFragment` to use `ComposeView` for the main task display, integrating with `TaskPager`. - Use `AndroidView` and `FragmentContainerView` within the pager to host existing task fragments. - Add logic to `DataCollectionFragment.onCreate` to clean up child fragments on configuration changes, preventing view attachment errors. - Simplify progress bar updates by removing the `shouldAnimate` flag and always using animated transitions.
- Replace `TaskFragmentProvider` and individual task fragments (`Text`, `Date`, `Number`, `Photo`, `MultipleChoice`, `Time`, `Instruction`, `DrawArea`, `DropPin`, `CaptureLocation`) with Compose-based screen functions. - Introduce `TaskContainer` as a unified Compose component to handle task layout, headers, footers, and common dialog logic (LOI naming and instructions). - Migrate task-specific logic, such as photo capture, location permissions, and dialog handling, into their respective Composable screens. - Update `TaskPager` to switch between tasks by rendering the new Composable screens instead of inflating fragments. - Update `DataCollectionFragment` to provide necessary dependencies (permissions, popups, and map fragment providers) to the new Compose hierarchy. - Standardize header and instruction handling across all task types within the Compose architecture.
- Rename various `*TaskFragment.kt` files to `*TaskScreen.kt` for Consistency (Number, MultipleChoice, CaptureLocation, Text, DrawArea, DropPin, Instruction). - Refactor `PhotoTaskFragment.kt` and `PhotoTaskScreen.kt` into a unified `PhotoTaskScreen.kt` and move the UI content to `PhotoTaskContent.kt`. - Refactor `TimeTaskFragment.kt` and `TimeTaskScreen.kt` into a unified `TimeTaskScreen.kt` and move the input field to `TimeTaskField.kt`. - Rename `DateTaskScreen` to `DateTaskField` and update `DateTaskFragment` to use the new component name. - Update `PhotoTaskScreenTest` to reflect the renaming of `PhotoTaskScreen` to `PhotoTaskContent`.
- Split `TaskContainer` into a stateful parent and a stateless `TaskContainerUi` Composable to improve testability and separation of concerns. - Move event handling logic (e.g., `handleNext`, `handleButtonClick`, `handleLoiNameConfirm`) into the parent `TaskContainer`. - Pass simplified state values and callbacks (e.g., `initialNameValue`, `onButtonClicked`) as parameters to `TaskContainerUi`. - Optimize conditional rendering of `InstructionsDialog` and `LoiNameDialog` using standard Kotlin idioms like `takeIf`. - Refactor footer position tracking to use a callback provided by the parent.
- Update `TaskPager` to use `animateScrollToPage` instead of `scrollToPage` for smoother task transitions. - Refactor task screen selection logic in `TaskPager` to use `when` expressions on `taskViewModel` types instead of `task.type`, eliminating redundant type casting. - Reorder parameters in `DataCollectionFragment` and `TaskPager` for better consistency. - Add an explicit error message for unhandled task ViewModel types.
…d CompositionLocals - Introduce `TaskScreenEnvironment` data class to encapsulate common dependencies like view models, fragment managers, and map fragment providers. - Update all task screens (Photo, Number, MultipleChoice, Location, Text, Date, Time, Instruction) to accept `TaskScreenEnvironment` instead of individual dependency parameters. - Introduce `LocalPermissionsManager` and `LocalEphemeralPopups` using `CompositionLocalProvider` to provide global utilities to the Composable hierarchy. - Simplify `TaskPager` and `DataCollectionFragment` by passing the new environment object and using `CompositionLocalProvider` for UI-related dependencies. - Relocate `DateTaskScreen` from `DateTaskFragment.kt` (logic remains the same).
…mpose - Create a new `@Composable` component `FragmentContainer` to handle the boilerplate of embedding Android `Fragment`s within a Compose UI using `AndroidView` and `FragmentContainerView`. - Refactor `CaptureLocationTaskScreen`, `DrawAreaTaskScreen`, and `DropPinTaskScreen` to use the new `FragmentContainer` for displaying map-based task fragments. - Simplify fragment transaction logic by centralizing argument passing and fragment manager interactions within `FragmentContainer`. - Remove unused imports and legacy view-binding code from the refactored task screens.
- Centralize action handling logic in `DataCollectionViewModel#onAction`, moving it out of `TaskContainer`. - Relocate LOI name dialog confirmation and dismissal logic to `DataCollectionViewModel`. - Move instruction dialog state management into `AbstractTaskViewModel`, providing `showInstructionsDialog()` and `dismissInstructionsDialog()` methods. - Introduce an `instructionsDialogShown` property in `AbstractTaskViewModel` to track and persist the shown state, implemented in `DropPinTaskViewModel` and `DrawAreaTaskViewModel`. - Simplify `TaskContainer` and task screens (`DrawAreaTaskScreen`, `DropPinTaskScreen`) by delegating dialog state and actions to their respective ViewModels. - Remove redundant instruction dialog handling from `AbstractTaskFragment`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #
@... PTAL?