handleDeepNavigationFromRoot method

NavigationResult handleDeepNavigationFromRoot(
  1. Iterable<T> subNavigations
)

Will create a new DeepNavigationNode to assign to currentMainNavigation that starts from the base layer.

Implementation

NavigationResult handleDeepNavigationFromRoot(Iterable<T> subNavigations) {
  final deepNavigationStrategy =
      getDeepNavigationStrategy(currentMainNavigation);

  DeepNavigationNode<T>? node;

  for (final subNavigation in subNavigations) {
    if (!deepNavigationStrategy.shouldAcceptNavigation(subNavigation, node)) {
      return NavigationResult.failed;
    }

    node = node?.setLeaf(DeepNavigationNode(subNavigation)) ??
        DeepNavigationNode(subNavigation);
  }
  logSuccessfulNavigation();

  if (deepNavigationMap[currentMainNavigation] == node) {
    return NavigationResult.same;
  }

  deepNavigationMap[currentMainNavigation] = node;

  return NavigationResult.success;
}