Replace ViewPager2 with Compose-based TaskScreenContainer for Data Collection#3735
Replace ViewPager2 with Compose-based TaskScreenContainer for Data Collection#3735shobhitagarwal1612 wants to merge 11 commits into
Conversation
…creen and TaskScreenContainer
…onViewModel UI effects
andreia-ferreira
left a comment
There was a problem hiding this comment.
The only issue I found was when restoring a draft where the current task was conditional. Clicking on any of the previous/next buttons makes the app crash. Tested this behavior on master to confirm it's not an existing issue and couldn't reproduce
Screen_recording_20260513_175154.webm
tested on API 24 and 36 and happens on both
| * @param onAllowLocationClicked Callback when the allow location button is clicked in the dialog. | ||
| * @param onOpenSettings Callback to open app settings. | ||
| * @param onButtonClicked Callback when a button is clicked. | ||
| * @param mapContent Composable for rendering the map. |
There was a problem hiding this comment.
nit: this parameter is still in the arguments so it should be part of the kdoc
| * routing. | ||
| * | ||
| * @param viewModel The view model for this task. | ||
| * @param mapContent Composable for rendering the map. |
There was a problem hiding this comment.
nit: same comment as above. The params here in general don't match the ones in the composable
| * @param onLoiNameAction Callback when user interacts with the LOI name dialog. | ||
| * @param onInstructionsDismiss Callback when user dismisses the instructions dialog. | ||
| * @param onDismissSelfIntersectionDialog Callback when the self-intersection dialog is dismissed. | ||
| * @param mapContent Composable for rendering the map. |
There was a problem hiding this comment.
nit: same comment as above
| DataCollectionEvent.OpenSettings -> | ||
| viewModelScope.launch { _uiEffects.send(DataCollectionUiEffect.OpenSettings) } | ||
| is DataCollectionEvent.SetAwaitingPhotoCapture -> | ||
| viewModelScope.launch { | ||
| _uiEffects.send(DataCollectionUiEffect.SetAwaitingPhotoCapture(event.awaiting)) | ||
| } |
There was a problem hiding this comment.
suggestion: the logic for each of these events could be extracted to a separate method like the events above
Fixes #3709
This PR overhauls the data collection flow by migrating it to a Compose-based architecture. It removes the legacy
ViewPager2and fragment-based approach (DataCollectionTaskFragment,DataCollectionViewPagerAdapter) in favor of a newTaskScreenContainer. It also refactors event handling to be more deeply integrated with ViewModels.Key Changes:
ViewPager2and task fragments with Compose-basedTaskScreenContainer.TaskMapFragmentContainerwith the official ComposeAndroidFragment.DataCollectionViewModelby removingMutableSharedFlowand using UI effects.onButtonClickedparameter from task screens and handle clicks via individual ViewModels.OpenSettingsandSetAwaitingPhotoCaptureto useDataCollectionViewModelUI effects.Steps to verify:
@andreia-ferreira PTAL?