DEV Community

Navegação Descomplicada no Android utilizando MVVM-C com NavigationManager

The article proposes a practical approach to organizing navigation logic using the Coordinator pattern in native Android development. The MVVM-C architecture is an extension of the MVVM pattern, where navigation responsibility is delegated to a Coordinator component. This approach is commonly used in iOS development and can be applied to Android native development. The NavigationManager is a simple controller that abstracts navigation using the FragmentManager. It depends on an Activity with a container that acts as the visual stack of navigation. The Coordinator integrates with the NavigationManager to orchestrate the app's flow. The NavigationManager is the link between features, controlled by the Coordinator, which is responsible for initializing each flow and future redirects. To start a navigation flow, an Activity defines a container and its ID, then calls the initial Coordinator. Adopting MVVM-C with a NavigationManager simplifies navigation, organizes feature structure, and facilitates modularization, dependency injection, and unit testing. This approach can be easily migrated to existing projects, as each feature can have a reference Activity to initialize the flow.
favicon
dev.to
dev.to
Image for the article: Navegação Descomplicada no Android utilizando MVVM-C com NavigationManager