Skip to content

Commit

Permalink
Allow overriding default selected element directly
Browse files Browse the repository at this point in the history
  • Loading branch information
zsoltk committed Oct 6, 2023
1 parent c8cae30 commit db1d906
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class MainActivity : NodeActivity() {
AppyxMaterial3NavNode(
buildContext = it,
navTargets = MainNavItem.values().toList(),
navTargetResolver = MainNavItem.resolver
navTargetResolver = MainNavItem.resolver,
initialActiveElement = MainNavItem.CARDS
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ class MainNavNode(
) : AppyxMaterial3NavNode<MainNavItem>(
buildContext = buildContext,
navTargets = MainNavItem.values().toList(),
navTargetResolver = MainNavItem.resolver
navTargetResolver = MainNavItem.resolver,
initialActiveElement = MainNavItem.SPOTLIGHT
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ open class AppyxMaterial3NavNode<NavTarget : Any>(
buildContext: BuildContext,
private val navTargets: List<NavTarget>,
private val navTargetResolver: (NavTarget) -> AppyxNavItem,
private val initialActiveElement: NavTarget,
private val animationSpec: SpringSpec<Float> = spring(
stiffness = Spring.StiffnessHigh
),
Expand All @@ -56,7 +57,7 @@ open class AppyxMaterial3NavNode<NavTarget : Any>(
private val spotlight: Spotlight<NavTarget> = Spotlight(
model = SpotlightModel(
items = navTargets,
initialActiveIndex = 0f,
initialActiveIndex = navTargets.indexOf(initialActiveElement).toFloat(),
savedStateMap = buildContext.savedStateMap
),
visualisation = visualisation
Expand Down

0 comments on commit db1d906

Please sign in to comment.