diff --git a/navigation-fragments/src/main/java/dev/hotwire/navigation/navigator/NavigatorHost.kt b/navigation-fragments/src/main/java/dev/hotwire/navigation/navigator/NavigatorHost.kt index 56de95f..350bf23 100644 --- a/navigation-fragments/src/main/java/dev/hotwire/navigation/navigator/NavigatorHost.kt +++ b/navigation-fragments/src/main/java/dev/hotwire/navigation/navigator/NavigatorHost.kt @@ -5,6 +5,7 @@ import android.view.View import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentOnAttachListener +import androidx.lifecycle.Lifecycle import androidx.navigation.fragment.NavHostFragment import androidx.navigation.fragment.findNavController import dev.hotwire.core.config.Hotwire @@ -50,6 +51,18 @@ open class NavigatorHost : NavHostFragment(), FragmentOnAttachListener { return isAdded && !isDetached && childFragmentManager.primaryNavigationFragment != null } + /** + * + */ + fun setMaxLifecycle(state: Lifecycle.State) { + val currentFragment = childFragmentManager.primaryNavigationFragment ?: return + + childFragmentManager + .beginTransaction() + .setMaxLifecycle(currentFragment, state) + .commit() + } + internal fun initControllerGraph() { navController.apply { graph = NavigatorGraphBuilder(