feat(search): Add SearchViewModel and Logic
What does this MR do?
This MR builds the complete "brain" for the movie search feature by implementing the SearchViewModel. It acts as the bridge between the future search UI and the existing MovieRepository.
Key Contributions:
-
SearchViewModel: Contains the core logic for executing a movie search. It includes a 500ms debounce to provide a better user experience and conserve API resources. -
SearchUiState: A sealed class that models the screen's state, making the UI easier to manage and update predictably. -
ViewModelFactoryRefactor: The factory is now more robust and scalable. It uses the applicationContextto create dependencies (like theUserDao), simplifying the logic within the Fragments. - Unit Tests: The ViewModel is fully unit-tested to ensure its state management and interaction with the repository are correct.
Why was this change needed?
This is the final piece of the logic layer for the search feature. With this ViewModel merged, the UI developer can now simply connect the SearchFragment to it to create a fully functional end-to-end movie search experience. This completes the MVVM loop for this feature.