Skip to content

Commit

Permalink
Merge pull request #19 from Infomaniak/fix-adaptative-navigation
Browse files Browse the repository at this point in the history
Fix adaptative navigation
  • Loading branch information
LunarX authored Aug 15, 2024
2 parents 322851f + b73a041 commit d16272d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.os.Bundle
import androidx.navigation.NavBackStackEntry
import kotlinx.serialization.Serializable
import kotlin.reflect.KClass
import kotlin.reflect.full.primaryConstructor

/**
* Sealed class representing the navigation arguments for the main navigation flow.
Expand Down Expand Up @@ -96,8 +97,7 @@ sealed class NavigationDestination {
}

private fun <T : NavigationDestination> createInstance(kClass: KClass<T>, bundle: Bundle?): T? {
val primaryConstructor = kClass.constructors.firstOrNull()
return primaryConstructor?.let {
return kClass.primaryConstructor?.let {
val args = it.parameters.associateWith { parameter ->
bundle?.get(parameter.name)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ fun AppNavigationSuiteScaffold(
Surface(color = SwissTransferTheme.materialColors.background) {
NavigationSuiteScaffoldLayout(
navigationSuite = {
if (layoutType == NavigationSuiteType.NavigationBar) {
AppNavigationBar(navigationItems, currentDestination, navigateToSelectedItem)
} else {
AppNavigationRail(navigationItems, currentDestination, navigateToSelectedItem)
when (layoutType) {
NavigationSuiteType.None -> Unit
NavigationSuiteType.NavigationBar -> {
AppNavigationBar(navigationItems, currentDestination, navigateToSelectedItem)
}
else -> {
AppNavigationRail(navigationItems, currentDestination, navigateToSelectedItem)
}
}
},
layoutType = layoutType,
Expand Down

0 comments on commit d16272d

Please sign in to comment.